New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@morgan-stanley/desktopjs-electron

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@morgan-stanley/desktopjs-electron - npm Package Compare versions

Comparing version 3.12.0 to 3.13.0

dist/electron.d.ts

251

dist/desktopjs-electron.js

@@ -5,17 +5,17 @@ (function (global, factory) {

(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.desktopJS = global.desktopJS || {}, global.desktopJS.Electron = {}), global.desktopJS));
}(this, (function (exports, desktopjs) { 'use strict';
})(this, (function (exports, desktopjs) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
/******************************************************************************
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -27,3 +27,3 @@ /* global Reflect, Promise */

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -33,2 +33,4 @@ };

function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -40,6 +42,7 @@ function __() { this.constructor = d; }

function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -55,3 +58,3 @@ });

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -78,3 +81,2 @@ if (y = 0, t) op = [op[0] & 2, t.value];

/* eslint-disable @typescript-eslint/no-var-requires */
desktopjs.registerContainer("Electron", {

@@ -91,3 +93,3 @@ condition: function () {

});
var InternalMessageType = /** @class */ (function () {
var InternalMessageType = (function () {
function InternalMessageType() {

@@ -103,6 +105,3 @@ }

var windowEventMap = {};
/**
* @augments ContainerWindow
*/
var ElectronContainerWindow = /** @class */ (function (_super) {
var ElectronContainerWindow = (function (_super) {
__extends(ElectronContainerWindow, _super);

@@ -145,3 +144,3 @@ function ElectronContainerWindow(wrap, container, win) {

}
return [2 /*return*/];
return [2];
});

@@ -154,3 +153,3 @@ });

this.innerWindow.focus();
return [2 /*return*/];
return [2];
});

@@ -163,3 +162,3 @@ });

this.innerWindow.show();
return [2 /*return*/];
return [2];
});

@@ -172,3 +171,3 @@ });

this.innerWindow.hide();
return [2 /*return*/];
return [2];
});

@@ -181,3 +180,3 @@ });

this.innerWindow.close();
return [2 /*return*/];
return [2];
});

@@ -190,3 +189,3 @@ });

this.innerWindow.maximize();
return [2 /*return*/];
return [2];
});

@@ -199,3 +198,3 @@ });

this.innerWindow.minimize();
return [2 /*return*/];
return [2];
});

@@ -208,3 +207,3 @@ });

this.innerWindow.restore();
return [2 /*return*/];
return [2];
});

@@ -216,3 +215,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.innerWindow.isVisible()];
return [2, this.innerWindow.isVisible()];
});

@@ -225,3 +224,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
return [2, new Promise(function (resolve, reject) {
_this.innerWindow.capturePage(function (snapshot) {

@@ -238,3 +237,3 @@ resolve("data:image/png;base64," + snapshot.toPNG().toString("base64"));

this.innerWindow.flashFrame(enable);
return [2 /*return*/];
return [2];
});

@@ -244,5 +243,5 @@ });

ElectronContainerWindow.prototype.getParent = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.innerWindow.getParentWindow()];
return [2, this.innerWindow.getParentWindow()];
});

@@ -255,3 +254,3 @@ });

this.innerWindow.setParentWindow(parent.innerWindow);
return [2 /*return*/];
return [2];
});

@@ -265,3 +264,3 @@ });

_a = this.innerWindow.getBounds(), x = _a.x, y = _a.y, width = _a.width, height = _a.height;
return [2 /*return*/, new desktopjs.Rectangle(x, y, width, height)];
return [2, new desktopjs.Rectangle(x, y, width, height)];
});

@@ -274,3 +273,3 @@ });

this.innerWindow.setBounds(bounds);
return [2 /*return*/];
return [2];
});

@@ -287,3 +286,3 @@ });

ElectronContainerWindow.prototype.getGroup = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var ids;

@@ -295,3 +294,3 @@ var _this = this;

: this.container.windowManager.getGroup(this.innerWindow);
return [2 /*return*/, ids.map(function (id) { return (id === _this.id) ? _this : _this.container.wrapWindow(_this.container.browserWindow.fromId(id)); })];
return [2, ids.map(function (id) { return (id === _this.id) ? _this : _this.container.wrapWindow(_this.container.browserWindow.fromId(id)); })];
});

@@ -304,3 +303,3 @@ });

if (!target || target.id === this.id) {
return [2 /*return*/];
return [2];
}

@@ -313,3 +312,3 @@ if (this.isRemote) {

}
return [2 /*return*/];
return [2];
});

@@ -327,3 +326,3 @@ });

}
return [2 /*return*/];
return [2];
});

@@ -336,3 +335,3 @@ });

this.innerWindow.moveTop();
return [2 /*return*/];
return [2];
});

@@ -348,3 +347,3 @@ });

: this.innerWindow[desktopjs.Container.windowOptionsPropertyKey];
return [2 /*return*/, options];
return [2, options];
});

@@ -357,5 +356,5 @@ });

if (this.innerWindow && this.innerWindow.webContents) {
return [2 /*return*/, this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")];
return [2, this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")];
}
return [2 /*return*/];
return [2];
});

@@ -369,3 +368,3 @@ });

switch (_c.label) {
case 0: return [4 /*yield*/, ((_b = (_a = this.innerWindow) === null || _a === void 0 ? void 0 : _a.webContents) === null || _b === void 0 ? void 0 : _b.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`" + JSON.stringify(state) + "`)); }"))];
case 0: return [4, ((_b = (_a = this.innerWindow) === null || _a === void 0 ? void 0 : _a.webContents) === null || _b === void 0 ? void 0 : _b.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`".concat(JSON.stringify(state), "`)); }")))];
case 1:

@@ -375,3 +374,3 @@ _c.sent();

desktopjs.ContainerWindow.emit("state-changed", { name: "state-changed", windowId: this.id, state: state });
return [2 /*return*/];
return [2];
}

@@ -400,3 +399,2 @@ });

get: function () {
// For Electron we can only return in and for current renderer
return this.window || window;

@@ -409,6 +407,3 @@ },

}(desktopjs.ContainerWindow));
/**
* @augments MessageBus
*/
var ElectronMessageBus = /** @class */ (function () {
var ElectronMessageBus = (function () {
function ElectronMessageBus(ipc, browserWindow) {

@@ -426,3 +421,3 @@ this.ipc = ipc;

this.ipc.on(topic, subscription.listener);
return [2 /*return*/, subscription];
return [2, subscription];
});

@@ -435,4 +430,4 @@ });

return __generator(this, function (_a) {
topic = subscription.topic, listener = subscription.listener;
return [2 /*return*/, this.ipc.removeListener(topic, listener)];
topic = subscription.topic, listener = subscription.listener, subscription.options;
return [2, this.ipc.removeListener(topic, listener)];
});

@@ -444,25 +439,21 @@ });

return __awaiter(this, void 0, void 0, function () {
var _i, _b, window;
var _i, _b, window_1;
return __generator(this, function (_c) {
// If publisher is targeting a window, do not send to main
if (!(options === null || options === void 0 ? void 0 : options.name)) {
if (this.ipc.send !== undefined) {
// Publish to main from renderer (send is not available on ipcMain)
this.ipc.send(topic, message);
}
else {
// we are in main so invoke listener directly
this.ipc.listeners(topic).forEach(function (cb) { return cb({ topic: topic }, message); });
}
}
// Broadcast to all windows or to the individual targeted window
if ((_a = this.browserWindow) === null || _a === void 0 ? void 0 : _a.getAllWindows) {
for (_i = 0, _b = this.browserWindow.getAllWindows(); _i < _b.length; _i++) {
window = _b[_i];
if (!(options === null || options === void 0 ? void 0 : options.name) || options.name === window.name) {
window.webContents.send(topic, message);
window_1 = _b[_i];
if (!(options === null || options === void 0 ? void 0 : options.name) || options.name === window_1.name) {
window_1.webContents.send(topic, message);
}
}
}
return [2 /*return*/];
return [2];
});

@@ -473,6 +464,3 @@ });

}());
/**
* @extends ContainerBase
*/
var ElectronContainer = /** @class */ (function (_super) {
var ElectronContainer = (function (_super) {
__extends(ElectronContainer, _super);

@@ -489,3 +477,2 @@ function ElectronContainer(electron, ipc, win, options) {

else {
// Check if we are in renderer or main by first accessing remote, if undefined switch to main
_this.electron = require("electron").remote;

@@ -507,3 +494,2 @@ if (typeof _this.electron === "undefined") {

catch (e) {
// eslint-disable-next-line no-console
console.error(e);

@@ -543,3 +529,2 @@ }

catch (e) {
// eslint-disable-next-line no-console
console.error(e);

@@ -549,3 +534,3 @@ }

ElectronContainer.prototype.getOptions = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var error_1;

@@ -558,8 +543,8 @@ var _a;

_a = {};
return [4 /*yield*/, this.isAutoStartEnabledAtLogin()];
case 1: return [2 /*return*/, (_a.autoStartOnLogin = _b.sent(), _a)];
return [4, this.isAutoStartEnabledAtLogin()];
case 1: return [2, (_a.autoStartOnLogin = _b.sent(), _a)];
case 2:
error_1 = _b.sent();
throw new Error("Error getting Container options. " + error_1);
case 3: return [2 /*return*/];
case 3: return [2];
}

@@ -570,7 +555,7 @@ });

ElectronContainer.prototype.isAutoStartEnabledAtLogin = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var config;
return __generator(this, function (_a) {
config = this.app.getLoginItemSettings();
return [2 /*return*/, config.openAtLogin];
return [2, config.openAtLogin];
});

@@ -584,6 +569,4 @@ });

if (typeof this.globalWindow !== "undefined" && this.globalWindow) {
// Define owningContainer for closure to inner class
// eslint-disable-next-line @typescript-eslint/no-this-alias
var owningContainer_1 = this;
this.globalWindow["Notification"] = /** @class */ (function (_super) {
this.globalWindow["Notification"] = (function (_super) {
__extends(ElectronNotification, _super);

@@ -601,5 +584,5 @@ function ElectronNotification(title, options) {

ElectronContainer.prototype.getInfo = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, "Electron/" + this.electron.process.versions.electron + " Chrome/" + this.electron.process.versions.chrome];
return [2, "Electron/".concat(this.electron.process.versions.electron, " Chrome/").concat(this.electron.process.versions.chrome)];
});

@@ -610,8 +593,7 @@ });

for (var _i = 0, _a = this.browserWindow.getAllWindows(); _i < _a.length; _i++) {
var window = _a[_i];
if (window[desktopjs.Container.windowOptionsPropertyKey] && window[desktopjs.Container.windowOptionsPropertyKey].main) {
return this.wrapWindow(window);
var window_2 = _a[_i];
if (window_2[desktopjs.Container.windowOptionsPropertyKey] && window_2[desktopjs.Container.windowOptionsPropertyKey].main) {
return this.wrapWindow(window_2);
}
}
// No windows were marked as main so fallback to the first window created as being main
var win = this.browserWindow.fromId(1);

@@ -624,3 +606,2 @@ return win ? this.wrapWindow(win) : undefined;

ElectronContainer.prototype.getWindowOptions = function (options) {
// If we have any container level node default, apply it here if no preference is specified in the options
if (this.nodeIntegration != null && !("node" in options)) {

@@ -635,3 +616,3 @@ options.node = this.nodeIntegration;

ElectronContainer.prototype.createWindow = function (url, options) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var newOptions, electronWindow, windowName, newWindow;

@@ -642,12 +623,2 @@ return __generator(this, function (_a) {

windowName = newOptions.name || desktopjs.Guid.newGuid();
/*
If we are in the renderer process, we need to ipc to the main process
to set the window name. Otherwise it can not be seen from other renderer
processes.
This requires the main process to have desktopJS container listening
either via desktopJS.resolveContainer() or new desktopJS.Electron.ElectronContainer();
If it is not listening, this ipc call will hang indefinitely. If we are in the
main process we can just directly set the name.
*/
if (this.isRemote) {

@@ -663,3 +634,3 @@ electronWindow["name"] = this.internalIpc.sendSync(InternalMessageType.initialize, { id: electronWindow.id, name: windowName, options: newOptions });

this.emit("window-created", { sender: this, name: "window-created", window: newWindow, windowId: electronWindow.id, windowName: windowName });
return [2 /*return*/, newWindow];
return [2, newWindow];
});

@@ -693,11 +664,11 @@ });

return __awaiter(this, void 0, void 0, function () {
var _i, _a, window;
var _i, _a, window_3;
return __generator(this, function (_b) {
for (_i = 0, _a = this.browserWindow.getAllWindows(); _i < _a.length; _i++) {
window = _a[_i];
if (!excludeSelf || window !== this.electron.getCurrentWindow()) {
window.close();
window_3 = _a[_i];
if (!excludeSelf || window_3 !== this.electron.getCurrentWindow()) {
window_3.close();
}
}
return [2 /*return*/];
return [2];
});

@@ -707,6 +678,6 @@ });

ElectronContainer.prototype.getAllWindows = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, this.browserWindow.getAllWindows().map(function (window) { return _this.wrapWindow(window); })];
return [2, this.browserWindow.getAllWindows().map(function (window) { return _this.wrapWindow(window); })];
});

@@ -716,7 +687,7 @@ });

ElectronContainer.prototype.getWindowById = function (id) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var win;
return __generator(this, function (_a) {
win = this.browserWindow.fromId(id);
return [2 /*return*/, win ? this.wrapWindow(win) : null];
return [2, win ? this.wrapWindow(win) : null];
});

@@ -726,7 +697,7 @@ });

ElectronContainer.prototype.getWindowByName = function (name) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var win;
return __generator(this, function (_a) {
win = this.browserWindow.getAllWindows().find(function (window) { return window.name === name; });
return [2 /*return*/, win ? this.wrapWindow(win) : null];
return [2, win ? this.wrapWindow(win) : null];
});

@@ -745,3 +716,3 @@ });

promises = [];
return [4 /*yield*/, this.getAllWindows()];
return [4, this.getAllWindows()];
case 1:

@@ -767,3 +738,3 @@ windows = _a.sent();

};
return [4 /*yield*/, window.getState()];
return [4, window.getState()];
case 1:

@@ -773,7 +744,7 @@ _c.state = _d.sent(),

_c.bounds = window.innerWindow.getBounds();
return [4 /*yield*/, window.getGroup()];
return [4, window.getGroup()];
case 2:
_b.apply(_a, [(_c.group = (_d.sent()).map(function (win) { return win.id; }),
_c)]);
return [2 /*return*/];
return [2];
}

@@ -783,6 +754,6 @@ });

});
return [4 /*yield*/, Promise.all(promises)];
return [4, Promise.all(promises)];
case 2:
_a.sent();
return [2 /*return*/, layout];
return [2, layout];
}

@@ -792,7 +763,2 @@ });

};
/**
* Gets or sets whether to replace the native web Notification API with a wrapper around showNotification.
* @type {boolean}
* @default true
*/
ElectronContainer.replaceNotificationApi = true;

@@ -802,4 +768,3 @@ ElectronContainer.windowOptionsMap = {

node: {
target: "webPreferences",
convert: function (value, from, to) {
target: "webPreferences", convert: function (value, from, to) {
return Object.assign(to.webPreferences || {}, { nodeIntegration: value });

@@ -811,7 +776,7 @@ }

}(desktopjs.WebContainerBase));
var ElectronWindowManager = /** @class */ (function () {
var ElectronWindowManager = (function () {
function ElectronWindowManager(app, ipc, browserWindow) {
var _this = this;
this.lastBounds = new Map(); // BrowserWindow.id -> Rectangle
this.ignoredWindows = []; // Array of BrowserWindow.id
this.lastBounds = new Map();
this.ignoredWindows = [];
this.app = app || require("electron").app;

@@ -894,3 +859,2 @@ this.ipc = ipc || require("electron").ipcMain;

}
// Unhook and clear group of all provided windows
for (var _a = 0, windows_2 = windows; _a < windows_2.length; _a++) {

@@ -902,3 +866,2 @@ var win = windows_2[_a];

}
// Group all windows by group and for any group consisting of one window unhook and clear the group
this.groupBy(this.browserWindow.getAllWindows(), "group").filter(function (group) { return group.key && group.values && group.values.length === 1; }).forEach(function (group) {

@@ -914,11 +877,8 @@ for (var _i = 0, _a = group.values; _i < _a.length; _i++) {

var _this = this;
// Grab the last bounds we had and the current and then store the current
var oldBounds = this.lastBounds.get(win.id);
var newBounds = win.getBounds();
this.lastBounds.set(win.id, newBounds);
// If the height or width change this is a resize and we should just exit out
if (oldBounds.width !== newBounds.width || oldBounds.height !== newBounds.height) {
return;
}
// Prevent cycles
if (this.ignoredWindows.indexOf(win.id) >= 0) {

@@ -928,3 +888,2 @@ return;

if (win.group) {
// Get all windows other windows in same group
var groupedWindows = this.browserWindow.getAllWindows().filter(function (window) { return (window.group === win.group && window.id !== win.id); });

@@ -957,4 +916,3 @@ if (groupedWindows && groupedWindows.length > 0) {

}());
/** @private */
var ElectronDisplayManager = /** @class */ (function () {
var ElectronDisplayManager = (function () {
function ElectronDisplayManager(electron) {

@@ -974,3 +932,3 @@ this.electron = electron;

return __generator(this, function (_a) {
return [2 /*return*/, this.createDisplay(this.electron.screen.getPrimaryDisplay())];
return [2, this.createDisplay(this.electron.screen.getPrimaryDisplay())];
});

@@ -982,3 +940,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))];
return [2, this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))];
});

@@ -988,5 +946,5 @@ });

ElectronDisplayManager.prototype.getMousePosition = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.electron.screen.getCursorScreenPoint()];
return [2, this.electron.screen.getCursorScreenPoint()];
});

@@ -997,4 +955,3 @@ });

}());
/** @private */
var ElectronGlobalShortcutManager = /** @class */ (function (_super) {
var ElectronGlobalShortcutManager = (function (_super) {
__extends(ElectronGlobalShortcutManager, _super);

@@ -1010,3 +967,3 @@ function ElectronGlobalShortcutManager(electron) {

this.electron.globalShortcut.register(shortcut, callback);
return [2 /*return*/];
return [2];
});

@@ -1016,5 +973,5 @@ });

ElectronGlobalShortcutManager.prototype.isRegistered = function (shortcut) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.electron.globalShortcut.isRegistered(shortcut)];
return [2, this.electron.globalShortcut.isRegistered(shortcut)];
});

@@ -1027,3 +984,3 @@ });

this.electron.globalShortcut.unregister(shortcut);
return [2 /*return*/];
return [2];
});

@@ -1036,3 +993,3 @@ });

this.electron.globalShortcut.unregisterAll();
return [2 /*return*/];
return [2];
});

@@ -1051,3 +1008,3 @@ });

})));
}));
//# sourceMappingURL=desktopjs-electron.js.map

@@ -1,2 +0,2 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],t):t(((n="undefined"!=typeof globalThis?globalThis:n||self).desktopJS=n.desktopJS||{},n.desktopJS.Electron={}),n.desktopJS)}(this,function(n,c){"use strict";var i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)t.hasOwnProperty(e)&&(n[e]=t[e])})(n,t)};function t(n,t){function e(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}function d(r,s,u,c){return new(u||(u=Promise))(function(n,t){function e(n){try{o(c.next(n))}catch(n){t(n)}}function i(n){try{o(c.throw(n))}catch(n){t(n)}}function o(t){t.done?n(t.value):new u(function(n){n(t.value)}).then(e,i)}o((c=c.apply(r,s||[])).next())})}function a(e,i){var o,r,s,n,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function t(t){return function(n){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,r&&(s=2&t[0]?r.return:t[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,t[1])).done)return s;switch(r=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return u.label++,{value:t[1],done:!1};case 5:u.label++,r=t[1],t=[0];continue;case 7:t=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){u=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){u.label=t[1];break}if(6===t[0]&&u.label<s[1]){u.label=s[1],s=t;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(t);break}s[2]&&u.ops.pop(),u.trys.pop();continue}t=i.call(e,u)}catch(n){t=[6,n],r=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,n])}}}c.registerContainer("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(n){return new s(null,null,null,n)}});var u=function(){function n(){}return n.initialize="desktopJS.window-initialize",n.getGroup="desktopJS.window-getGroup",n.joinGroup="desktopJS.window-joinGroup",n.leaveGroup="desktopJS.window-leaveGroup",n.getOptions="desktopJS.window-getOptions",n}(),r={},e=function(o){function n(n,t,e){var i=o.call(this,n)||this;return i.container=t,i.window=e,i}return t(n,o),Object.defineProperty(n.prototype,"isRemote",{get:function(){return!!this.container.internalIpc.send},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow.id||this.innerWindow.guestId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,configurable:!0}),n.prototype.load=function(t,e){return d(this,void 0,void 0,function(){return a(this,function(n){return e?this.innerWindow.loadURL(t,e):this.innerWindow.loadURL(t),[2]})})},n.prototype.focus=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.focus(),[2]})})},n.prototype.show=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.show(),[2]})})},n.prototype.hide=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.hide(),[2]})})},n.prototype.close=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.close(),[2]})})},n.prototype.maximize=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.maximize(),[2]})})},n.prototype.minimize=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.minimize(),[2]})})},n.prototype.restore=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.restore(),[2]})})},n.prototype.isShowing=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.innerWindow.isVisible()]})})},n.prototype.getSnapshot=function(){return d(this,void 0,void 0,function(){var e=this;return a(this,function(n){return[2,new Promise(function(t,n){e.innerWindow.capturePage(function(n){t("data:image/png;base64,"+n.toPNG().toString("base64"))})})]})})},n.prototype.flash=function(t,n){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.flashFrame(t),[2]})})},n.prototype.getParent=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.innerWindow.getParentWindow()]})})},n.prototype.setParent=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setParentWindow(t.innerWindow),[2]})})},n.prototype.getBounds=function(){return d(this,void 0,void 0,function(){var t,e,i,o,r;return a(this,function(n){return t=this.innerWindow.getBounds(),e=t.x,i=t.y,o=t.width,r=t.height,[2,new c.Rectangle(e,i,o,r)]})})},n.prototype.setBounds=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setBounds(t),[2]})})},Object.defineProperty(n.prototype,"allowGrouping",{get:function(){return!0},enumerable:!1,configurable:!0}),n.prototype.getGroup=function(){return d(this,void 0,Promise,function(){var t=this;return a(this,function(n){return[2,(this.isRemote?this.container.internalIpc.sendSync(u.getGroup,{source:this.id}):this.container.windowManager.getGroup(this.innerWindow)).map(function(n){return n===t.id?t:t.container.wrapWindow(t.container.browserWindow.fromId(n))})]})})},n.prototype.joinGroup=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return t&&t.id!==this.id&&(this.isRemote?this.container.internalIpc.send(u.joinGroup,{source:this.id,target:t.id}):this.container.windowManager.groupWindows(t.innerWindow,this.innerWindow)),[2]})})},n.prototype.leaveGroup=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.isRemote?this.container.internalIpc.send(u.leaveGroup,{source:this.id}):this.container.windowManager.ungroupWindows(this.innerWindow),[2]})})},n.prototype.bringToFront=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.moveTop(),[2]})})},n.prototype.getOptions=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.isRemote?this.container.internalIpc.sendSync(u.getOptions,{source:this.id}):this.innerWindow[c.Container.windowOptionsPropertyKey]]})})},n.prototype.getState=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow&&this.innerWindow.webContents?[2,this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")]:[2]})})},n.prototype.setState=function(t){var e,i;return d(this,void 0,void 0,function(){return a(this,function(n){switch(n.label){case 0:return[4,null===(i=null===(e=this.innerWindow)||void 0===e?void 0:e.webContents)||void 0===i?void 0:i.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`"+JSON.stringify(t)+"`)); }")];case 1:return n.sent(),this.emit("state-changed",{name:"state-changed",sender:this,state:t}),c.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:this.id,state:t}),[2]}})})},n.prototype.attachListener=function(n,t){if("beforeunload"===n){var e=this.window||window;if(!e||this.id!==this.container.getCurrentWindow().id)throw new Error("Event handler for 'beforeunload' can only be added on current window");e.addEventListener("beforeunload",t)}else this.innerWindow.addListener(r[n]||n,t)},n.prototype.detachListener=function(n,t){this.innerWindow.removeListener(r[n]||n,t)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.window||window},enumerable:!1,configurable:!0}),n}(c.ContainerWindow),o=function(){function n(n,t){this.ipc=n,this.browserWindow=t}return n.prototype.subscribe=function(e,i,n){return d(this,void 0,void 0,function(){var t;return a(this,function(n){return t=new c.MessageBusSubscription(e,function(n,t){i({topic:e},t)}),this.ipc.on(e,t.listener),[2,t]})})},n.prototype.unsubscribe=function(i){return d(this,void 0,void 0,function(){var t,e;return a(this,function(n){return t=i.topic,e=i.listener,[2,this.ipc.removeListener(t,e)]})})},n.prototype.publish=function(o,r,s){var u;return d(this,void 0,void 0,function(){var t,e,i;return a(this,function(n){if((null==s?void 0:s.name)||(void 0!==this.ipc.send?this.ipc.send(o,r):this.ipc.listeners(o).forEach(function(n){return n({topic:o},r)})),null===(u=this.browserWindow)||void 0===u?void 0:u.getAllWindows)for(t=0,e=this.browserWindow.getAllWindows();t<e.length;t++)i=e[t],(null==s?void 0:s.name)&&s.name!==i.name||i.webContents.send(o,r);return[2]})})},n}(),s=function(r){function s(n,t,e,i){var o=r.call(this,e)||this;o.isRemote=!0,o.windowOptionsMap=s.windowOptionsMap,o.hostType="Electron";try{n?o.electron=n:(o.electron=require("electron").remote,void 0===o.electron&&(o.electron=require("electron"),o.isRemote=!1)),o.app=o.electron.app,o.browserWindow=o.electron.BrowserWindow,o.tray=o.electron.Tray,o.menu=o.electron.Menu,o.internalIpc=t||(o.isRemote?require("electron").ipcRenderer:o.electron.ipcMain),o.ipc=o.createMessageBus(),o.nodeIntegration=null,o.setOptions(i)}catch(n){console.error(n)}return o.screen=new h(o.electron),o.globalShortcut=new w(o.electron),o}return t(s,r),s.prototype.setOptions=function(n){try{this.isRemote&&(!n||void 0===n.isRemote||n.isRemote)||this.windowManager||(this.windowManager=new p(this.app,this.internalIpc,this.browserWindow),this.app.on("browser-window-created",function(n,t){setImmediate(function(){c.Container.emit("window-created",{name:"window-created",windowId:t.webContents.id}),c.ContainerWindow.emit("window-created",{name:"window-created",windowId:t.webContents.id})})})),n&&n.autoStartOnLogin&&this.app.setLoginItemSettings({openAtLogin:n.autoStartOnLogin});var t=s.replaceNotificationApi;n&&void 0!==n.replaceNotificationApi&&(t=n.replaceNotificationApi),t&&this.registerNotificationsApi(),n&&n.node&&(this.nodeIntegration=n.node)}catch(n){console.error(n)}},s.prototype.getOptions=function(){return d(this,void 0,Promise,function(){var t,e;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(e.autoStartOnLogin=n.sent(),e)];case 2:throw t=n.sent(),new Error("Error getting Container options. "+t);case 3:return[2]}})})},s.prototype.isAutoStartEnabledAtLogin=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.app.getLoginItemSettings().openAtLogin]})})},s.prototype.createMessageBus=function(){return new o(this.internalIpc,this.browserWindow)},s.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var o=this;this.globalWindow.Notification=function(i){function n(n,t){var e=i.call(this,n,t)||this;return t.notification=e,o.showNotification(e.title,e.options),e}return t(n,i),n}(c.ContainerNotification)}},s.prototype.getInfo=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,"Electron/"+this.electron.process.versions.electron+" Chrome/"+this.electron.process.versions.chrome]})})},s.prototype.getMainWindow=function(){for(var n=0,t=this.browserWindow.getAllWindows();n<t.length;n++){var e=t[n];if(e[c.Container.windowOptionsPropertyKey]&&e[c.Container.windowOptionsPropertyKey].main)return this.wrapWindow(e)}var i=this.browserWindow.fromId(1);return i?this.wrapWindow(i):void 0},s.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},s.prototype.getWindowOptions=function(n){return null==this.nodeIntegration||"node"in n||(n.node=this.nodeIntegration),c.ObjectTransform.transformProperties(n,this.windowOptionsMap)},s.prototype.wrapWindow=function(n){return new e(n,this)},s.prototype.createWindow=function(r,s){return d(this,void 0,Promise,function(){var t,e,i,o;return a(this,function(n){return t=this.getWindowOptions(s),e=new this.browserWindow(t),i=t.name||c.Guid.newGuid(),this.isRemote?(e.name=this.internalIpc.sendSync(u.initialize,{id:e.id,name:i,options:t}),e[c.Container.windowOptionsPropertyKey]=s):this.windowManager.initializeWindow(e,i,t),e.loadURL(this.ensureAbsoluteUrl(r)),o=this.wrapWindow(e),this.emit("window-created",{sender:this,name:"window-created",window:o,windowId:e.id,windowName:i}),[2,o]})})},s.prototype.showNotification=function(n,t){var e=new this.electron.Notification(Object.assign(t||{},{title:n}));t.onClick&&e.addListener("click",t.onClick),t.notification&&e.once("show",function(){return e.addListener("click",t.notification.onclick)}),e.show()},s.prototype.addTrayIcon=function(n,t,e){var i=new this.tray(n.icon);n.text&&i.setToolTip(n.text),e&&i.setContextMenu(this.menu.buildFromTemplate(e)),t&&i.on("click",t)},s.prototype.closeAllWindows=function(o){return d(this,void 0,void 0,function(){var t,e,i;return a(this,function(n){for(t=0,e=this.browserWindow.getAllWindows();t<e.length;t++)i=e[t],o&&i===this.electron.getCurrentWindow()||i.close();return[2]})})},s.prototype.getAllWindows=function(){return d(this,void 0,Promise,function(){var t=this;return a(this,function(n){return[2,this.browserWindow.getAllWindows().map(function(n){return t.wrapWindow(n)})]})})},s.prototype.getWindowById=function(e){return d(this,void 0,Promise,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.fromId(e))?this.wrapWindow(t):null]})})},s.prototype.getWindowByName=function(e){return d(this,void 0,Promise,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.getAllWindows().find(function(n){return n.name===e}))?this.wrapWindow(t):null]})})},s.prototype.buildLayout=function(){return d(this,void 0,void 0,function(){var s,u,t,e=this;return a(this,function(n){switch(n.label){case 0:return s=new c.PersistedWindowLayout,u=this.getMainWindow().innerWindow,t=[],[4,this.getAllWindows()];case 1:return n.sent().forEach(function(o){var r=o.innerWindow[c.Container.windowOptionsPropertyKey];r&&"persist"in r&&!r.persist||t.push(d(e,void 0,void 0,function(){var t,e,i;return a(this,function(n){switch(n.label){case 0:return e=(t=s.windows).push,i={id:o.id,name:o.name,url:o.innerWindow.webContents.getURL(),main:u===o.innerWindow},[4,o.getState()];case 1:return i.state=n.sent(),i.options=r,i.bounds=o.innerWindow.getBounds(),[4,o.getGroup()];case 2:return e.apply(t,[(i.group=n.sent().map(function(n){return n.id}),i)]),[2]}})}))}),[4,Promise.all(t)];case 2:return n.sent(),[2,s]}})})},s.replaceNotificationApi=!0,s.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,t,e){return!n}},node:{target:"webPreferences",convert:function(n,t,e){return Object.assign(e.webPreferences||{},{nodeIntegration:n})}}},s}(c.WebContainerBase),p=function(){function n(n,t,e){var s=this;this.lastBounds=new Map,this.ignoredWindows=[],this.app=n||require("electron").app,this.ipc=t||require("electron").ipcMain,this.browserWindow=e||require("electron").BrowserWindow,this.ipc.on(u.initialize,function(n,t){var e=t.id,i=t.name,o=t.options,r=s.browserWindow.fromId(e);s.initializeWindow(r,i,o),n.returnValue=i}),this.ipc.on(u.joinGroup,function(n,t){var e=t.source,i=t.target,o=s.browserWindow.fromId(e),r=s.browserWindow.fromId(i);s.groupWindows(r,o)}),this.ipc.on(u.leaveGroup,function(n,t){var e=t.source;s.ungroupWindows(s.browserWindow.fromId(e))}),this.ipc.on(u.getGroup,function(n,t){var e=t.source;n.returnValue=s.getGroup(s.browserWindow.fromId(e))}),this.ipc.on(u.getOptions,function(n,t){var e=t.source;n.returnValue=s.browserWindow.fromId(e)[c.Container.windowOptionsPropertyKey]})}return n.prototype.initializeWindow=function(n,t,e){var i=this;n.name=t,!(n[c.Container.windowOptionsPropertyKey]=e)||!e.main||"quitOnClose"in e&&!e.quitOnClose||n.on("closed",function(){i.app.quit()})},n.prototype.registerWindowEvents=function(t){var e=this;t&&!t.moveHandler&&(this.lastBounds.set(t.id,t.getBounds()),t.moveHandler=function(n){return e.handleMove(t)},t.on("move",t.moveHandler))},n.prototype.unregisterWindowEvents=function(n){n&&n.moveHandler&&(this.lastBounds.delete(n.id),n.removeListener("move",n.moveHandler),delete n.moveHandler)},n.prototype.getGroup=function(t){return t.group?this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group}).map(function(n){return n.id}):[]},n.prototype.groupWindows=function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];for(var i=0,o=t;i<o.length;i++){var r=o[i];r.group=n.group||(n.group=c.Guid.newGuid()),this.registerWindowEvents(r),c.ContainerWindow.emit("window-joinGroup",{name:"window-joinGroup",windowId:r.id,targetWindowId:n.id})}this.registerWindowEvents(n)},n.prototype.ungroupWindows=function(){for(var o=this,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var e=0,i=n;e<i.length;e++){var r=i[e];this.unregisterWindowEvents(r),r.group=null,c.ContainerWindow.emit("window-leaveGroup",{name:"window-leaveGroup",windowId:r.id})}this.groupBy(this.browserWindow.getAllWindows(),"group").filter(function(n){return n.key&&n.values&&1===n.values.length}).forEach(function(n){for(var t=0,e=n.values;t<e.length;t++){var i=e[t];o.unregisterWindowEvents(i),i.group=null}})},n.prototype.handleMove=function(t){var e=this,n=this.lastBounds.get(t.id),i=t.getBounds();if(this.lastBounds.set(t.id,i),n.width===i.width&&n.height===i.height&&!(0<=this.ignoredWindows.indexOf(t.id))&&t.group){var o=this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group&&n.id!==t.id});if(o&&0<o.length){var r=n.x-i.x,s=n.y-i.y;o.forEach(function(n){var t=n.getBounds();e.ignoredWindows.push(n.id),n.setBounds({x:t.x-r,y:t.y-s,width:t.width,height:t.height},!0),e.ignoredWindows.splice(e.ignoredWindows.indexOf(n.id),1)})}}},n.prototype.groupBy=function(n,o){return n.reduce(function(n,t){var e=o instanceof Function?o(t):t[o],i=n.find(function(n){return n&&n.key===e});return i?i.values.push(t):n.push({key:e,values:[t]}),n},[])},n}(),h=function(){function n(n){this.electron=n}return n.prototype.createDisplay=function(n){var t=new c.Display;return t.id=n.id,t.scaleFactor=n.scaleFactor,t.bounds=new c.Rectangle(n.bounds.x,n.bounds.y,n.bounds.width,n.bounds.height),t.workArea=new c.Rectangle(n.workArea.x,n.workArea.y,n.workArea.width,n.workArea.height),t},n.prototype.getPrimaryDisplay=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.createDisplay(this.electron.screen.getPrimaryDisplay())]})})},n.prototype.getAllDisplays=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))]})})},n.prototype.getMousePosition=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.electron.screen.getCursorScreenPoint()]})})},n}(),w=function(e){function n(n){var t=e.call(this)||this;return t.electron=n,t}return t(n,e),n.prototype.register=function(t,e){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.register(t,e),[2]})})},n.prototype.isRegistered=function(t){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.electron.globalShortcut.isRegistered(t)]})})},n.prototype.unregister=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregister(t),[2]})})},n.prototype.unregisterAll=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregisterAll(),[2]})})},n}(c.GlobalShortcutManager);n.ElectronContainer=s,n.ElectronContainerWindow=e,n.ElectronMessageBus=o,n.ElectronWindowManager=p,Object.defineProperty(n,"__esModule",{value:!0})});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],t):t(((n="undefined"!=typeof globalThis?globalThis:n||self).desktopJS=n.desktopJS||{},n.desktopJS.Electron={}),n.desktopJS)}(this,function(n,d){"use strict";var i=function(n,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])})(n,t)};function t(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function e(){this.constructor=n}i(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}function c(n,s,u,d){return new(u=u||Promise)(function(e,t){function i(n){try{r(d.next(n))}catch(n){t(n)}}function o(n){try{r(d.throw(n))}catch(n){t(n)}}function r(n){var t;n.done?e(n.value):((t=n.value)instanceof u?t:new u(function(n){n(t)})).then(i,o)}r((d=d.apply(n,s||[])).next())})}function a(i,o){var r,s,u,d={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},c={next:n(0),throw:n(1),return:n(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function n(e){return function(n){var t=[e,n];if(r)throw new TypeError("Generator is already executing.");for(;d=c&&t[c=0]?0:d;)try{if(r=1,s&&(u=2&t[0]?s.return:t[0]?s.throw||((u=s.return)&&u.call(s),0):s.next)&&!(u=u.call(s,t[1])).done)return u;switch(s=0,(t=u?[2&t[0],u.value]:t)[0]){case 0:case 1:u=t;break;case 4:return d.label++,{value:t[1],done:!1};case 5:d.label++,s=t[1],t=[0];continue;case 7:t=d.ops.pop(),d.trys.pop();continue;default:if(!(u=0<(u=d.trys).length&&u[u.length-1])&&(6===t[0]||2===t[0])){d=0;continue}if(3===t[0]&&(!u||t[1]>u[0]&&t[1]<u[3])){d.label=t[1];break}if(6===t[0]&&d.label<u[1]){d.label=u[1],u=t;break}if(u&&d.label<u[2]){d.label=u[2],d.ops.push(t);break}u[2]&&d.ops.pop(),d.trys.pop();continue}t=o.call(i,d)}catch(n){t=[6,n],s=0}finally{r=u=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}d.registerContainer("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(n){return new f(null,null,null,n)}});e.initialize="desktopJS.window-initialize",e.getGroup="desktopJS.window-getGroup",e.joinGroup="desktopJS.window-joinGroup",e.leaveGroup="desktopJS.window-leaveGroup",e.getOptions="desktopJS.window-getOptions";var s=e;function e(){}var o,r={},u=(t(p,o=d.ContainerWindow),Object.defineProperty(p.prototype,"isRemote",{get:function(){return!!this.container.internalIpc.send},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"id",{get:function(){return this.innerWindow.id||this.innerWindow.guestId},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,configurable:!0}),p.prototype.load=function(t,e){return c(this,void 0,void 0,function(){return a(this,function(n){return e?this.innerWindow.loadURL(t,e):this.innerWindow.loadURL(t),[2]})})},p.prototype.focus=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.focus(),[2]})})},p.prototype.show=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.show(),[2]})})},p.prototype.hide=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.hide(),[2]})})},p.prototype.close=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.close(),[2]})})},p.prototype.maximize=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.maximize(),[2]})})},p.prototype.minimize=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.minimize(),[2]})})},p.prototype.restore=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.restore(),[2]})})},p.prototype.isShowing=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.innerWindow.isVisible()]})})},p.prototype.getSnapshot=function(){return c(this,void 0,void 0,function(){var e=this;return a(this,function(n){return[2,new Promise(function(t,n){e.innerWindow.capturePage(function(n){t("data:image/png;base64,"+n.toPNG().toString("base64"))})})]})})},p.prototype.flash=function(t,n){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.flashFrame(t),[2]})})},p.prototype.getParent=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.innerWindow.getParentWindow()]})})},p.prototype.setParent=function(t){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setParentWindow(t.innerWindow),[2]})})},p.prototype.getBounds=function(){return c(this,void 0,void 0,function(){var t,e,i,o;return a(this,function(n){return o=this.innerWindow.getBounds(),t=o.x,e=o.y,i=o.width,o=o.height,[2,new d.Rectangle(t,e,i,o)]})})},p.prototype.setBounds=function(t){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setBounds(t),[2]})})},Object.defineProperty(p.prototype,"allowGrouping",{get:function(){return!0},enumerable:!1,configurable:!0}),p.prototype.getGroup=function(){return c(this,void 0,void 0,function(){var t=this;return a(this,function(n){return[2,(this.isRemote?this.container.internalIpc.sendSync(s.getGroup,{source:this.id}):this.container.windowManager.getGroup(this.innerWindow)).map(function(n){return n===t.id?t:t.container.wrapWindow(t.container.browserWindow.fromId(n))})]})})},p.prototype.joinGroup=function(t){return c(this,void 0,void 0,function(){return a(this,function(n){return t&&t.id!==this.id&&(this.isRemote?this.container.internalIpc.send(s.joinGroup,{source:this.id,target:t.id}):this.container.windowManager.groupWindows(t.innerWindow,this.innerWindow)),[2]})})},p.prototype.leaveGroup=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.isRemote?this.container.internalIpc.send(s.leaveGroup,{source:this.id}):this.container.windowManager.ungroupWindows(this.innerWindow),[2]})})},p.prototype.bringToFront=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.moveTop(),[2]})})},p.prototype.getOptions=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.isRemote?this.container.internalIpc.sendSync(s.getOptions,{source:this.id}):this.innerWindow[d.Container.windowOptionsPropertyKey]]})})},p.prototype.getState=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow&&this.innerWindow.webContents?[2,this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")]:[2]})})},p.prototype.setState=function(t){var e;return c(this,void 0,void 0,function(){return a(this,function(n){switch(n.label){case 0:return[4,null==(e=null==(e=this.innerWindow)?void 0:e.webContents)?void 0:e.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`".concat(JSON.stringify(t),"`)); }"))];case 1:return n.sent(),this.emit("state-changed",{name:"state-changed",sender:this,state:t}),d.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:this.id,state:t}),[2]}})})},p.prototype.attachListener=function(n,t){if("beforeunload"===n){var e=this.window||window;if(!e||this.id!==this.container.getCurrentWindow().id)throw new Error("Event handler for 'beforeunload' can only be added on current window");e.addEventListener("beforeunload",t)}else this.innerWindow.addListener(r[n]||n,t)},p.prototype.detachListener=function(n,t){this.innerWindow.removeListener(r[n]||n,t)},Object.defineProperty(p.prototype,"nativeWindow",{get:function(){return this.window||window},enumerable:!1,configurable:!0}),p);function p(n,t,e){n=o.call(this,n)||this;return n.container=t,n.window=e,n}w.prototype.subscribe=function(e,i,n){return c(this,void 0,void 0,function(){var t;return a(this,function(n){return t=new d.MessageBusSubscription(e,function(n,t){i({topic:e},t)}),this.ipc.on(e,t.listener),[2,t]})})},w.prototype.unsubscribe=function(i){return c(this,void 0,void 0,function(){var t,e;return a(this,function(n){return t=i.topic,e=i.listener,i.options,[2,this.ipc.removeListener(t,e)]})})},w.prototype.publish=function(o,r,s){var u;return c(this,void 0,void 0,function(){var t,e,i;return a(this,function(n){if(null!=s&&s.name||(void 0!==this.ipc.send?this.ipc.send(o,r):this.ipc.listeners(o).forEach(function(n){return n({topic:o},r)})),null!=(u=this.browserWindow)&&u.getAllWindows)for(t=0,e=this.browserWindow.getAllWindows();t<e.length;t++)i=e[t],null!=s&&s.name&&s.name!==i.name||i.webContents.send(o,r);return[2]})})};var h=w;function w(n,t){this.ipc=n,this.browserWindow=t}t(g,l=d.WebContainerBase),g.prototype.setOptions=function(n){try{this.isRemote&&(!n||void 0===n.isRemote||n.isRemote)||this.windowManager||(this.windowManager=new v(this.app,this.internalIpc,this.browserWindow),this.app.on("browser-window-created",function(n,t){setImmediate(function(){d.Container.emit("window-created",{name:"window-created",windowId:t.webContents.id}),d.ContainerWindow.emit("window-created",{name:"window-created",windowId:t.webContents.id})})})),n&&n.autoStartOnLogin&&this.app.setLoginItemSettings({openAtLogin:n.autoStartOnLogin});var t=g.replaceNotificationApi;(t=n&&void 0!==n.replaceNotificationApi?n.replaceNotificationApi:t)&&this.registerNotificationsApi(),n&&n.node&&(this.nodeIntegration=n.node)}catch(n){console.error(n)}},g.prototype.getOptions=function(){return c(this,void 0,void 0,function(){var t,e;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(e.autoStartOnLogin=n.sent(),e)];case 2:throw t=n.sent(),new Error("Error getting Container options. "+t);case 3:return[2]}})})},g.prototype.isAutoStartEnabledAtLogin=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.app.getLoginItemSettings().openAtLogin]})})},g.prototype.createMessageBus=function(){return new h(this.internalIpc,this.browserWindow)},g.prototype.registerNotificationsApi=function(){var e,i;function n(n,t){n=i.call(this,n,t)||this;return t.notification=n,e.showNotification(n.title,n.options),n}void 0!==this.globalWindow&&this.globalWindow&&((e=this).globalWindow.Notification=(t(n,i=d.ContainerNotification),n))},g.prototype.getInfo=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,"Electron/".concat(this.electron.process.versions.electron," Chrome/").concat(this.electron.process.versions.chrome)]})})},g.prototype.getMainWindow=function(){for(var n=0,t=this.browserWindow.getAllWindows();n<t.length;n++){var e=t[n];if(e[d.Container.windowOptionsPropertyKey]&&e[d.Container.windowOptionsPropertyKey].main)return this.wrapWindow(e)}var i=this.browserWindow.fromId(1);return i?this.wrapWindow(i):void 0},g.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},g.prototype.getWindowOptions=function(n){return null==this.nodeIntegration||"node"in n||(n.node=this.nodeIntegration),d.ObjectTransform.transformProperties(n,this.windowOptionsMap)},g.prototype.wrapWindow=function(n){return new u(n,this)},g.prototype.createWindow=function(o,r){return c(this,void 0,void 0,function(){var t,e,i;return a(this,function(n){return i=this.getWindowOptions(r),t=new this.browserWindow(i),e=i.name||d.Guid.newGuid(),this.isRemote?(t.name=this.internalIpc.sendSync(s.initialize,{id:t.id,name:e,options:i}),t[d.Container.windowOptionsPropertyKey]=r):this.windowManager.initializeWindow(t,e,i),t.loadURL(this.ensureAbsoluteUrl(o)),i=this.wrapWindow(t),this.emit("window-created",{sender:this,name:"window-created",window:i,windowId:t.id,windowName:e}),[2,i]})})},g.prototype.showNotification=function(n,t){var e=new this.electron.Notification(Object.assign(t||{},{title:n}));t.onClick&&e.addListener("click",t.onClick),t.notification&&e.once("show",function(){return e.addListener("click",t.notification.onclick)}),e.show()},g.prototype.addTrayIcon=function(n,t,e){var i=new this.tray(n.icon);n.text&&i.setToolTip(n.text),e&&i.setContextMenu(this.menu.buildFromTemplate(e)),t&&i.on("click",t)},g.prototype.closeAllWindows=function(o){return c(this,void 0,void 0,function(){var t,e,i;return a(this,function(n){for(t=0,e=this.browserWindow.getAllWindows();t<e.length;t++)i=e[t],o&&i===this.electron.getCurrentWindow()||i.close();return[2]})})},g.prototype.getAllWindows=function(){return c(this,void 0,void 0,function(){var t=this;return a(this,function(n){return[2,this.browserWindow.getAllWindows().map(function(n){return t.wrapWindow(n)})]})})},g.prototype.getWindowById=function(e){return c(this,void 0,void 0,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.fromId(e))?this.wrapWindow(t):null]})})},g.prototype.getWindowByName=function(e){return c(this,void 0,void 0,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.getAllWindows().find(function(n){return n.name===e}))?this.wrapWindow(t):null]})})},g.prototype.buildLayout=function(){return c(this,void 0,void 0,function(){var s,u,t,e=this;return a(this,function(n){switch(n.label){case 0:return s=new d.PersistedWindowLayout,u=this.getMainWindow().innerWindow,t=[],[4,this.getAllWindows()];case 1:return n.sent().forEach(function(o){var r=o.innerWindow[d.Container.windowOptionsPropertyKey];r&&"persist"in r&&!r.persist||t.push(c(e,void 0,void 0,function(){var t,e,i;return a(this,function(n){switch(n.label){case 0:return e=(t=s.windows).push,i={id:o.id,name:o.name,url:o.innerWindow.webContents.getURL(),main:u===o.innerWindow},[4,o.getState()];case 1:return i.state=n.sent(),i.options=r,i.bounds=o.innerWindow.getBounds(),[4,o.getGroup()];case 2:return e.apply(t,[(i.group=n.sent().map(function(n){return n.id}),i)]),[2]}})}))}),[4,Promise.all(t)];case 2:return n.sent(),[2,s]}})})},g.replaceNotificationApi=!0,g.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,t,e){return!n}},node:{target:"webPreferences",convert:function(n,t,e){return Object.assign(e.webPreferences||{},{nodeIntegration:n})}}};var l,f=g;function g(n,t,e,i){e=l.call(this,e)||this;e.isRemote=!0,e.windowOptionsMap=g.windowOptionsMap,e.hostType="Electron";try{n?e.electron=n:(e.electron=require("electron").remote,void 0===e.electron&&(e.electron=require("electron"),e.isRemote=!1)),e.app=e.electron.app,e.browserWindow=e.electron.BrowserWindow,e.tray=e.electron.Tray,e.menu=e.electron.Menu,e.internalIpc=t||(e.isRemote?require("electron").ipcRenderer:e.electron.ipcMain),e.ipc=e.createMessageBus(),e.nodeIntegration=null,e.setOptions(i)}catch(n){console.error(n)}return e.screen=new W(e.electron),e.globalShortcut=new O(e.electron),e}y.prototype.initializeWindow=function(n,t,e){var i=this;n.name=t,!(n[d.Container.windowOptionsPropertyKey]=e)||!e.main||"quitOnClose"in e&&!e.quitOnClose||n.on("closed",function(){i.app.quit()})},y.prototype.registerWindowEvents=function(t){var e=this;t&&!t.moveHandler&&(this.lastBounds.set(t.id,t.getBounds()),t.moveHandler=function(n){return e.handleMove(t)},t.on("move",t.moveHandler))},y.prototype.unregisterWindowEvents=function(n){n&&n.moveHandler&&(this.lastBounds.delete(n.id),n.removeListener("move",n.moveHandler),delete n.moveHandler)},y.prototype.getGroup=function(t){return t.group?this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group}).map(function(n){return n.id}):[]},y.prototype.groupWindows=function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];for(var i=0,o=t;i<o.length;i++){var r=o[i];r.group=n.group||(n.group=d.Guid.newGuid()),this.registerWindowEvents(r),d.ContainerWindow.emit("window-joinGroup",{name:"window-joinGroup",windowId:r.id,targetWindowId:n.id})}this.registerWindowEvents(n)},y.prototype.ungroupWindows=function(){for(var o=this,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var e=0,i=n;e<i.length;e++){var r=i[e];this.unregisterWindowEvents(r),r.group=null,d.ContainerWindow.emit("window-leaveGroup",{name:"window-leaveGroup",windowId:r.id})}this.groupBy(this.browserWindow.getAllWindows(),"group").filter(function(n){return n.key&&n.values&&1===n.values.length}).forEach(function(n){for(var t=0,e=n.values;t<e.length;t++){var i=e[t];o.unregisterWindowEvents(i),i.group=null}})},y.prototype.handleMove=function(t){var n,e,i,o=this,r=this.lastBounds.get(t.id),s=t.getBounds();this.lastBounds.set(t.id,s),r.width!==s.width||r.height!==s.height||0<=this.ignoredWindows.indexOf(t.id)||!t.group||(n=this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group&&n.id!==t.id}))&&0<n.length&&(e=r.x-s.x,i=r.y-s.y,n.forEach(function(n){var t=n.getBounds();o.ignoredWindows.push(n.id),n.setBounds({x:t.x-e,y:t.y-i,width:t.width,height:t.height},!0),o.ignoredWindows.splice(o.ignoredWindows.indexOf(n.id),1)}))},y.prototype.groupBy=function(n,o){return n.reduce(function(n,t){var e=o instanceof Function?o(t):t[o],i=n.find(function(n){return n&&n.key===e});return i?i.values.push(t):n.push({key:e,values:[t]}),n},[])};var v=y;function y(n,t,e){var o=this;this.lastBounds=new Map,this.ignoredWindows=[],this.app=n||require("electron").app,this.ipc=t||require("electron").ipcMain,this.browserWindow=e||require("electron").BrowserWindow,this.ipc.on(s.initialize,function(n,t){var e=t.id,i=t.name,t=t.options,e=o.browserWindow.fromId(e);o.initializeWindow(e,i,t),n.returnValue=i}),this.ipc.on(s.joinGroup,function(n,t){var e=t.source,t=t.target,e=o.browserWindow.fromId(e),t=o.browserWindow.fromId(t);o.groupWindows(t,e)}),this.ipc.on(s.leaveGroup,function(n,t){t=t.source;o.ungroupWindows(o.browserWindow.fromId(t))}),this.ipc.on(s.getGroup,function(n,t){t=t.source;n.returnValue=o.getGroup(o.browserWindow.fromId(t))}),this.ipc.on(s.getOptions,function(n,t){t=t.source;n.returnValue=o.browserWindow.fromId(t)[d.Container.windowOptionsPropertyKey]})}b.prototype.createDisplay=function(n){var t=new d.Display;return t.id=n.id,t.scaleFactor=n.scaleFactor,t.bounds=new d.Rectangle(n.bounds.x,n.bounds.y,n.bounds.width,n.bounds.height),t.workArea=new d.Rectangle(n.workArea.x,n.workArea.y,n.workArea.width,n.workArea.height),t},b.prototype.getPrimaryDisplay=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.createDisplay(this.electron.screen.getPrimaryDisplay())]})})},b.prototype.getAllDisplays=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))]})})},b.prototype.getMousePosition=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.screen.getCursorScreenPoint()]})})};var W=b;function b(n){this.electron=n}t(S,m=d.GlobalShortcutManager),S.prototype.register=function(t,e){return c(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.register(t,e),[2]})})},S.prototype.isRegistered=function(t){return c(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.globalShortcut.isRegistered(t)]})})},S.prototype.unregister=function(t){return c(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregister(t),[2]})})},S.prototype.unregisterAll=function(){return c(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregisterAll(),[2]})})};var m,O=S;function S(n){var t=m.call(this)||this;return t.electron=n,t}n.ElectronContainer=f,n.ElectronContainerWindow=u,n.ElectronMessageBus=h,n.ElectronWindowManager=v,Object.defineProperty(n,"__esModule",{value:!0})});
//# sourceMappingURL=desktopjs-electron.min.js.map

@@ -5,15 +5,15 @@ this.desktopJS = this.desktopJS || {};

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
/******************************************************************************
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -25,3 +25,3 @@ /* global Reflect, Promise */

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -31,2 +31,4 @@ };

function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -38,6 +40,7 @@ function __() { this.constructor = d; }

function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -53,3 +56,3 @@ });

if (f) throw new TypeError("Generator is already executing.");
while (_) try {
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;

@@ -76,3 +79,2 @@ if (y = 0, t) op = [op[0] & 2, t.value];

/* eslint-disable @typescript-eslint/no-var-requires */
desktopjs.registerContainer("Electron", {

@@ -89,3 +91,3 @@ condition: function () {

});
var InternalMessageType = /** @class */ (function () {
var InternalMessageType = (function () {
function InternalMessageType() {

@@ -101,6 +103,3 @@ }

var windowEventMap = {};
/**
* @augments ContainerWindow
*/
var ElectronContainerWindow = /** @class */ (function (_super) {
var ElectronContainerWindow = (function (_super) {
__extends(ElectronContainerWindow, _super);

@@ -143,3 +142,3 @@ function ElectronContainerWindow(wrap, container, win) {

}
return [2 /*return*/];
return [2];
});

@@ -152,3 +151,3 @@ });

this.innerWindow.focus();
return [2 /*return*/];
return [2];
});

@@ -161,3 +160,3 @@ });

this.innerWindow.show();
return [2 /*return*/];
return [2];
});

@@ -170,3 +169,3 @@ });

this.innerWindow.hide();
return [2 /*return*/];
return [2];
});

@@ -179,3 +178,3 @@ });

this.innerWindow.close();
return [2 /*return*/];
return [2];
});

@@ -188,3 +187,3 @@ });

this.innerWindow.maximize();
return [2 /*return*/];
return [2];
});

@@ -197,3 +196,3 @@ });

this.innerWindow.minimize();
return [2 /*return*/];
return [2];
});

@@ -206,3 +205,3 @@ });

this.innerWindow.restore();
return [2 /*return*/];
return [2];
});

@@ -214,3 +213,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.innerWindow.isVisible()];
return [2, this.innerWindow.isVisible()];
});

@@ -223,3 +222,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve, reject) {
return [2, new Promise(function (resolve, reject) {
_this.innerWindow.capturePage(function (snapshot) {

@@ -236,3 +235,3 @@ resolve("data:image/png;base64," + snapshot.toPNG().toString("base64"));

this.innerWindow.flashFrame(enable);
return [2 /*return*/];
return [2];
});

@@ -242,5 +241,5 @@ });

ElectronContainerWindow.prototype.getParent = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.innerWindow.getParentWindow()];
return [2, this.innerWindow.getParentWindow()];
});

@@ -253,3 +252,3 @@ });

this.innerWindow.setParentWindow(parent.innerWindow);
return [2 /*return*/];
return [2];
});

@@ -263,3 +262,3 @@ });

_a = this.innerWindow.getBounds(), x = _a.x, y = _a.y, width = _a.width, height = _a.height;
return [2 /*return*/, new desktopjs.Rectangle(x, y, width, height)];
return [2, new desktopjs.Rectangle(x, y, width, height)];
});

@@ -272,3 +271,3 @@ });

this.innerWindow.setBounds(bounds);
return [2 /*return*/];
return [2];
});

@@ -285,3 +284,3 @@ });

ElectronContainerWindow.prototype.getGroup = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var ids;

@@ -293,3 +292,3 @@ var _this = this;

: this.container.windowManager.getGroup(this.innerWindow);
return [2 /*return*/, ids.map(function (id) { return (id === _this.id) ? _this : _this.container.wrapWindow(_this.container.browserWindow.fromId(id)); })];
return [2, ids.map(function (id) { return (id === _this.id) ? _this : _this.container.wrapWindow(_this.container.browserWindow.fromId(id)); })];
});

@@ -302,3 +301,3 @@ });

if (!target || target.id === this.id) {
return [2 /*return*/];
return [2];
}

@@ -311,3 +310,3 @@ if (this.isRemote) {

}
return [2 /*return*/];
return [2];
});

@@ -325,3 +324,3 @@ });

}
return [2 /*return*/];
return [2];
});

@@ -334,3 +333,3 @@ });

this.innerWindow.moveTop();
return [2 /*return*/];
return [2];
});

@@ -346,3 +345,3 @@ });

: this.innerWindow[desktopjs.Container.windowOptionsPropertyKey];
return [2 /*return*/, options];
return [2, options];
});

@@ -355,5 +354,5 @@ });

if (this.innerWindow && this.innerWindow.webContents) {
return [2 /*return*/, this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")];
return [2, this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")];
}
return [2 /*return*/];
return [2];
});

@@ -367,3 +366,3 @@ });

switch (_c.label) {
case 0: return [4 /*yield*/, ((_b = (_a = this.innerWindow) === null || _a === void 0 ? void 0 : _a.webContents) === null || _b === void 0 ? void 0 : _b.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`" + JSON.stringify(state) + "`)); }"))];
case 0: return [4, ((_b = (_a = this.innerWindow) === null || _a === void 0 ? void 0 : _a.webContents) === null || _b === void 0 ? void 0 : _b.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`".concat(JSON.stringify(state), "`)); }")))];
case 1:

@@ -373,3 +372,3 @@ _c.sent();

desktopjs.ContainerWindow.emit("state-changed", { name: "state-changed", windowId: this.id, state: state });
return [2 /*return*/];
return [2];
}

@@ -398,3 +397,2 @@ });

get: function () {
// For Electron we can only return in and for current renderer
return this.window || window;

@@ -407,6 +405,3 @@ },

}(desktopjs.ContainerWindow));
/**
* @augments MessageBus
*/
var ElectronMessageBus = /** @class */ (function () {
var ElectronMessageBus = (function () {
function ElectronMessageBus(ipc, browserWindow) {

@@ -424,3 +419,3 @@ this.ipc = ipc;

this.ipc.on(topic, subscription.listener);
return [2 /*return*/, subscription];
return [2, subscription];
});

@@ -433,4 +428,4 @@ });

return __generator(this, function (_a) {
topic = subscription.topic, listener = subscription.listener;
return [2 /*return*/, this.ipc.removeListener(topic, listener)];
topic = subscription.topic, listener = subscription.listener, subscription.options;
return [2, this.ipc.removeListener(topic, listener)];
});

@@ -442,25 +437,21 @@ });

return __awaiter(this, void 0, void 0, function () {
var _i, _b, window;
var _i, _b, window_1;
return __generator(this, function (_c) {
// If publisher is targeting a window, do not send to main
if (!(options === null || options === void 0 ? void 0 : options.name)) {
if (this.ipc.send !== undefined) {
// Publish to main from renderer (send is not available on ipcMain)
this.ipc.send(topic, message);
}
else {
// we are in main so invoke listener directly
this.ipc.listeners(topic).forEach(function (cb) { return cb({ topic: topic }, message); });
}
}
// Broadcast to all windows or to the individual targeted window
if ((_a = this.browserWindow) === null || _a === void 0 ? void 0 : _a.getAllWindows) {
for (_i = 0, _b = this.browserWindow.getAllWindows(); _i < _b.length; _i++) {
window = _b[_i];
if (!(options === null || options === void 0 ? void 0 : options.name) || options.name === window.name) {
window.webContents.send(topic, message);
window_1 = _b[_i];
if (!(options === null || options === void 0 ? void 0 : options.name) || options.name === window_1.name) {
window_1.webContents.send(topic, message);
}
}
}
return [2 /*return*/];
return [2];
});

@@ -471,6 +462,3 @@ });

}());
/**
* @extends ContainerBase
*/
var ElectronContainer = /** @class */ (function (_super) {
var ElectronContainer = (function (_super) {
__extends(ElectronContainer, _super);

@@ -487,3 +475,2 @@ function ElectronContainer(electron, ipc, win, options) {

else {
// Check if we are in renderer or main by first accessing remote, if undefined switch to main
_this.electron = require("electron").remote;

@@ -505,3 +492,2 @@ if (typeof _this.electron === "undefined") {

catch (e) {
// eslint-disable-next-line no-console
console.error(e);

@@ -541,3 +527,2 @@ }

catch (e) {
// eslint-disable-next-line no-console
console.error(e);

@@ -547,3 +532,3 @@ }

ElectronContainer.prototype.getOptions = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var error_1;

@@ -556,8 +541,8 @@ var _a;

_a = {};
return [4 /*yield*/, this.isAutoStartEnabledAtLogin()];
case 1: return [2 /*return*/, (_a.autoStartOnLogin = _b.sent(), _a)];
return [4, this.isAutoStartEnabledAtLogin()];
case 1: return [2, (_a.autoStartOnLogin = _b.sent(), _a)];
case 2:
error_1 = _b.sent();
throw new Error("Error getting Container options. " + error_1);
case 3: return [2 /*return*/];
case 3: return [2];
}

@@ -568,7 +553,7 @@ });

ElectronContainer.prototype.isAutoStartEnabledAtLogin = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var config;
return __generator(this, function (_a) {
config = this.app.getLoginItemSettings();
return [2 /*return*/, config.openAtLogin];
return [2, config.openAtLogin];
});

@@ -582,6 +567,4 @@ });

if (typeof this.globalWindow !== "undefined" && this.globalWindow) {
// Define owningContainer for closure to inner class
// eslint-disable-next-line @typescript-eslint/no-this-alias
var owningContainer_1 = this;
this.globalWindow["Notification"] = /** @class */ (function (_super) {
this.globalWindow["Notification"] = (function (_super) {
__extends(ElectronNotification, _super);

@@ -599,5 +582,5 @@ function ElectronNotification(title, options) {

ElectronContainer.prototype.getInfo = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, "Electron/" + this.electron.process.versions.electron + " Chrome/" + this.electron.process.versions.chrome];
return [2, "Electron/".concat(this.electron.process.versions.electron, " Chrome/").concat(this.electron.process.versions.chrome)];
});

@@ -608,8 +591,7 @@ });

for (var _i = 0, _a = this.browserWindow.getAllWindows(); _i < _a.length; _i++) {
var window = _a[_i];
if (window[desktopjs.Container.windowOptionsPropertyKey] && window[desktopjs.Container.windowOptionsPropertyKey].main) {
return this.wrapWindow(window);
var window_2 = _a[_i];
if (window_2[desktopjs.Container.windowOptionsPropertyKey] && window_2[desktopjs.Container.windowOptionsPropertyKey].main) {
return this.wrapWindow(window_2);
}
}
// No windows were marked as main so fallback to the first window created as being main
var win = this.browserWindow.fromId(1);

@@ -622,3 +604,2 @@ return win ? this.wrapWindow(win) : undefined;

ElectronContainer.prototype.getWindowOptions = function (options) {
// If we have any container level node default, apply it here if no preference is specified in the options
if (this.nodeIntegration != null && !("node" in options)) {

@@ -633,3 +614,3 @@ options.node = this.nodeIntegration;

ElectronContainer.prototype.createWindow = function (url, options) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var newOptions, electronWindow, windowName, newWindow;

@@ -640,12 +621,2 @@ return __generator(this, function (_a) {

windowName = newOptions.name || desktopjs.Guid.newGuid();
/*
If we are in the renderer process, we need to ipc to the main process
to set the window name. Otherwise it can not be seen from other renderer
processes.
This requires the main process to have desktopJS container listening
either via desktopJS.resolveContainer() or new desktopJS.Electron.ElectronContainer();
If it is not listening, this ipc call will hang indefinitely. If we are in the
main process we can just directly set the name.
*/
if (this.isRemote) {

@@ -661,3 +632,3 @@ electronWindow["name"] = this.internalIpc.sendSync(InternalMessageType.initialize, { id: electronWindow.id, name: windowName, options: newOptions });

this.emit("window-created", { sender: this, name: "window-created", window: newWindow, windowId: electronWindow.id, windowName: windowName });
return [2 /*return*/, newWindow];
return [2, newWindow];
});

@@ -691,11 +662,11 @@ });

return __awaiter(this, void 0, void 0, function () {
var _i, _a, window;
var _i, _a, window_3;
return __generator(this, function (_b) {
for (_i = 0, _a = this.browserWindow.getAllWindows(); _i < _a.length; _i++) {
window = _a[_i];
if (!excludeSelf || window !== this.electron.getCurrentWindow()) {
window.close();
window_3 = _a[_i];
if (!excludeSelf || window_3 !== this.electron.getCurrentWindow()) {
window_3.close();
}
}
return [2 /*return*/];
return [2];
});

@@ -705,6 +676,6 @@ });

ElectronContainer.prototype.getAllWindows = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2 /*return*/, this.browserWindow.getAllWindows().map(function (window) { return _this.wrapWindow(window); })];
return [2, this.browserWindow.getAllWindows().map(function (window) { return _this.wrapWindow(window); })];
});

@@ -714,7 +685,7 @@ });

ElectronContainer.prototype.getWindowById = function (id) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var win;
return __generator(this, function (_a) {
win = this.browserWindow.fromId(id);
return [2 /*return*/, win ? this.wrapWindow(win) : null];
return [2, win ? this.wrapWindow(win) : null];
});

@@ -724,7 +695,7 @@ });

ElectronContainer.prototype.getWindowByName = function (name) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
var win;
return __generator(this, function (_a) {
win = this.browserWindow.getAllWindows().find(function (window) { return window.name === name; });
return [2 /*return*/, win ? this.wrapWindow(win) : null];
return [2, win ? this.wrapWindow(win) : null];
});

@@ -743,3 +714,3 @@ });

promises = [];
return [4 /*yield*/, this.getAllWindows()];
return [4, this.getAllWindows()];
case 1:

@@ -765,3 +736,3 @@ windows = _a.sent();

};
return [4 /*yield*/, window.getState()];
return [4, window.getState()];
case 1:

@@ -771,7 +742,7 @@ _c.state = _d.sent(),

_c.bounds = window.innerWindow.getBounds();
return [4 /*yield*/, window.getGroup()];
return [4, window.getGroup()];
case 2:
_b.apply(_a, [(_c.group = (_d.sent()).map(function (win) { return win.id; }),
_c)]);
return [2 /*return*/];
return [2];
}

@@ -781,6 +752,6 @@ });

});
return [4 /*yield*/, Promise.all(promises)];
return [4, Promise.all(promises)];
case 2:
_a.sent();
return [2 /*return*/, layout];
return [2, layout];
}

@@ -790,7 +761,2 @@ });

};
/**
* Gets or sets whether to replace the native web Notification API with a wrapper around showNotification.
* @type {boolean}
* @default true
*/
ElectronContainer.replaceNotificationApi = true;

@@ -800,4 +766,3 @@ ElectronContainer.windowOptionsMap = {

node: {
target: "webPreferences",
convert: function (value, from, to) {
target: "webPreferences", convert: function (value, from, to) {
return Object.assign(to.webPreferences || {}, { nodeIntegration: value });

@@ -809,7 +774,7 @@ }

}(desktopjs.WebContainerBase));
var ElectronWindowManager = /** @class */ (function () {
var ElectronWindowManager = (function () {
function ElectronWindowManager(app, ipc, browserWindow) {
var _this = this;
this.lastBounds = new Map(); // BrowserWindow.id -> Rectangle
this.ignoredWindows = []; // Array of BrowserWindow.id
this.lastBounds = new Map();
this.ignoredWindows = [];
this.app = app || require("electron").app;

@@ -892,3 +857,2 @@ this.ipc = ipc || require("electron").ipcMain;

}
// Unhook and clear group of all provided windows
for (var _a = 0, windows_2 = windows; _a < windows_2.length; _a++) {

@@ -900,3 +864,2 @@ var win = windows_2[_a];

}
// Group all windows by group and for any group consisting of one window unhook and clear the group
this.groupBy(this.browserWindow.getAllWindows(), "group").filter(function (group) { return group.key && group.values && group.values.length === 1; }).forEach(function (group) {

@@ -912,11 +875,8 @@ for (var _i = 0, _a = group.values; _i < _a.length; _i++) {

var _this = this;
// Grab the last bounds we had and the current and then store the current
var oldBounds = this.lastBounds.get(win.id);
var newBounds = win.getBounds();
this.lastBounds.set(win.id, newBounds);
// If the height or width change this is a resize and we should just exit out
if (oldBounds.width !== newBounds.width || oldBounds.height !== newBounds.height) {
return;
}
// Prevent cycles
if (this.ignoredWindows.indexOf(win.id) >= 0) {

@@ -926,3 +886,2 @@ return;

if (win.group) {
// Get all windows other windows in same group
var groupedWindows = this.browserWindow.getAllWindows().filter(function (window) { return (window.group === win.group && window.id !== win.id); });

@@ -955,4 +914,3 @@ if (groupedWindows && groupedWindows.length > 0) {

}());
/** @private */
var ElectronDisplayManager = /** @class */ (function () {
var ElectronDisplayManager = (function () {
function ElectronDisplayManager(electron) {

@@ -972,3 +930,3 @@ this.electron = electron;

return __generator(this, function (_a) {
return [2 /*return*/, this.createDisplay(this.electron.screen.getPrimaryDisplay())];
return [2, this.createDisplay(this.electron.screen.getPrimaryDisplay())];
});

@@ -980,3 +938,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))];
return [2, this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))];
});

@@ -986,5 +944,5 @@ });

ElectronDisplayManager.prototype.getMousePosition = function () {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.electron.screen.getCursorScreenPoint()];
return [2, this.electron.screen.getCursorScreenPoint()];
});

@@ -995,4 +953,3 @@ });

}());
/** @private */
var ElectronGlobalShortcutManager = /** @class */ (function (_super) {
var ElectronGlobalShortcutManager = (function (_super) {
__extends(ElectronGlobalShortcutManager, _super);

@@ -1008,3 +965,3 @@ function ElectronGlobalShortcutManager(electron) {

this.electron.globalShortcut.register(shortcut, callback);
return [2 /*return*/];
return [2];
});

@@ -1014,5 +971,5 @@ });

ElectronGlobalShortcutManager.prototype.isRegistered = function (shortcut) {
return __awaiter(this, void 0, Promise, function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.electron.globalShortcut.isRegistered(shortcut)];
return [2, this.electron.globalShortcut.isRegistered(shortcut)];
});

@@ -1025,3 +982,3 @@ });

this.electron.globalShortcut.unregister(shortcut);
return [2 /*return*/];
return [2];
});

@@ -1034,3 +991,3 @@ });

this.electron.globalShortcut.unregisterAll();
return [2 /*return*/];
return [2];
});

@@ -1051,3 +1008,3 @@ });

}({}, desktopJS));
})({}, desktopJS);
//# sourceMappingURL=desktopjs-electron.js.map

@@ -1,2 +0,2 @@

this.desktopJS=this.desktopJS||{},this.desktopJS.Electron=function(n,c){"use strict";var e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])})(n,t)};function t(n,t){function i(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function d(r,s,u,c){return new(u||(u=Promise))(function(n,t){function i(n){try{o(c.next(n))}catch(n){t(n)}}function e(n){try{o(c.throw(n))}catch(n){t(n)}}function o(t){t.done?n(t.value):new u(function(n){n(t.value)}).then(i,e)}o((c=c.apply(r,s||[])).next())})}function a(i,e){var o,r,s,n,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function t(t){return function(n){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;u;)try{if(o=1,r&&(s=2&t[0]?r.return:t[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,t[1])).done)return s;switch(r=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return u.label++,{value:t[1],done:!1};case 5:u.label++,r=t[1],t=[0];continue;case 7:t=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){u=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){u.label=t[1];break}if(6===t[0]&&u.label<s[1]){u.label=s[1],s=t;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(t);break}s[2]&&u.ops.pop(),u.trys.pop();continue}t=e.call(i,u)}catch(n){t=[6,n],r=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,n])}}}c.registerContainer("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(n){return new s(null,null,null,n)}});var u=function(){function n(){}return n.initialize="desktopJS.window-initialize",n.getGroup="desktopJS.window-getGroup",n.joinGroup="desktopJS.window-joinGroup",n.leaveGroup="desktopJS.window-leaveGroup",n.getOptions="desktopJS.window-getOptions",n}(),r={},i=function(o){function n(n,t,i){var e=o.call(this,n)||this;return e.container=t,e.window=i,e}return t(n,o),Object.defineProperty(n.prototype,"isRemote",{get:function(){return!!this.container.internalIpc.send},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow.id||this.innerWindow.guestId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,configurable:!0}),n.prototype.load=function(t,i){return d(this,void 0,void 0,function(){return a(this,function(n){return i?this.innerWindow.loadURL(t,i):this.innerWindow.loadURL(t),[2]})})},n.prototype.focus=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.focus(),[2]})})},n.prototype.show=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.show(),[2]})})},n.prototype.hide=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.hide(),[2]})})},n.prototype.close=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.close(),[2]})})},n.prototype.maximize=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.maximize(),[2]})})},n.prototype.minimize=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.minimize(),[2]})})},n.prototype.restore=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.restore(),[2]})})},n.prototype.isShowing=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.innerWindow.isVisible()]})})},n.prototype.getSnapshot=function(){return d(this,void 0,void 0,function(){var i=this;return a(this,function(n){return[2,new Promise(function(t,n){i.innerWindow.capturePage(function(n){t("data:image/png;base64,"+n.toPNG().toString("base64"))})})]})})},n.prototype.flash=function(t,n){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.flashFrame(t),[2]})})},n.prototype.getParent=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.innerWindow.getParentWindow()]})})},n.prototype.setParent=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setParentWindow(t.innerWindow),[2]})})},n.prototype.getBounds=function(){return d(this,void 0,void 0,function(){var t,i,e,o,r;return a(this,function(n){return t=this.innerWindow.getBounds(),i=t.x,e=t.y,o=t.width,r=t.height,[2,new c.Rectangle(i,e,o,r)]})})},n.prototype.setBounds=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setBounds(t),[2]})})},Object.defineProperty(n.prototype,"allowGrouping",{get:function(){return!0},enumerable:!1,configurable:!0}),n.prototype.getGroup=function(){return d(this,void 0,Promise,function(){var t=this;return a(this,function(n){return[2,(this.isRemote?this.container.internalIpc.sendSync(u.getGroup,{source:this.id}):this.container.windowManager.getGroup(this.innerWindow)).map(function(n){return n===t.id?t:t.container.wrapWindow(t.container.browserWindow.fromId(n))})]})})},n.prototype.joinGroup=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return t&&t.id!==this.id&&(this.isRemote?this.container.internalIpc.send(u.joinGroup,{source:this.id,target:t.id}):this.container.windowManager.groupWindows(t.innerWindow,this.innerWindow)),[2]})})},n.prototype.leaveGroup=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.isRemote?this.container.internalIpc.send(u.leaveGroup,{source:this.id}):this.container.windowManager.ungroupWindows(this.innerWindow),[2]})})},n.prototype.bringToFront=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.moveTop(),[2]})})},n.prototype.getOptions=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.isRemote?this.container.internalIpc.sendSync(u.getOptions,{source:this.id}):this.innerWindow[c.Container.windowOptionsPropertyKey]]})})},n.prototype.getState=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow&&this.innerWindow.webContents?[2,this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")]:[2]})})},n.prototype.setState=function(t){var i,e;return d(this,void 0,void 0,function(){return a(this,function(n){switch(n.label){case 0:return[4,null===(e=null===(i=this.innerWindow)||void 0===i?void 0:i.webContents)||void 0===e?void 0:e.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`"+JSON.stringify(t)+"`)); }")];case 1:return n.sent(),this.emit("state-changed",{name:"state-changed",sender:this,state:t}),c.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:this.id,state:t}),[2]}})})},n.prototype.attachListener=function(n,t){if("beforeunload"===n){var i=this.window||window;if(!i||this.id!==this.container.getCurrentWindow().id)throw new Error("Event handler for 'beforeunload' can only be added on current window");i.addEventListener("beforeunload",t)}else this.innerWindow.addListener(r[n]||n,t)},n.prototype.detachListener=function(n,t){this.innerWindow.removeListener(r[n]||n,t)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.window||window},enumerable:!1,configurable:!0}),n}(c.ContainerWindow),o=function(){function n(n,t){this.ipc=n,this.browserWindow=t}return n.prototype.subscribe=function(i,e,n){return d(this,void 0,void 0,function(){var t;return a(this,function(n){return t=new c.MessageBusSubscription(i,function(n,t){e({topic:i},t)}),this.ipc.on(i,t.listener),[2,t]})})},n.prototype.unsubscribe=function(e){return d(this,void 0,void 0,function(){var t,i;return a(this,function(n){return t=e.topic,i=e.listener,[2,this.ipc.removeListener(t,i)]})})},n.prototype.publish=function(o,r,s){var u;return d(this,void 0,void 0,function(){var t,i,e;return a(this,function(n){if((null==s?void 0:s.name)||(void 0!==this.ipc.send?this.ipc.send(o,r):this.ipc.listeners(o).forEach(function(n){return n({topic:o},r)})),null===(u=this.browserWindow)||void 0===u?void 0:u.getAllWindows)for(t=0,i=this.browserWindow.getAllWindows();t<i.length;t++)e=i[t],(null==s?void 0:s.name)&&s.name!==e.name||e.webContents.send(o,r);return[2]})})},n}(),s=function(r){function s(n,t,i,e){var o=r.call(this,i)||this;o.isRemote=!0,o.windowOptionsMap=s.windowOptionsMap,o.hostType="Electron";try{n?o.electron=n:(o.electron=require("electron").remote,void 0===o.electron&&(o.electron=require("electron"),o.isRemote=!1)),o.app=o.electron.app,o.browserWindow=o.electron.BrowserWindow,o.tray=o.electron.Tray,o.menu=o.electron.Menu,o.internalIpc=t||(o.isRemote?require("electron").ipcRenderer:o.electron.ipcMain),o.ipc=o.createMessageBus(),o.nodeIntegration=null,o.setOptions(e)}catch(n){console.error(n)}return o.screen=new h(o.electron),o.globalShortcut=new w(o.electron),o}return t(s,r),s.prototype.setOptions=function(n){try{this.isRemote&&(!n||void 0===n.isRemote||n.isRemote)||this.windowManager||(this.windowManager=new p(this.app,this.internalIpc,this.browserWindow),this.app.on("browser-window-created",function(n,t){setImmediate(function(){c.Container.emit("window-created",{name:"window-created",windowId:t.webContents.id}),c.ContainerWindow.emit("window-created",{name:"window-created",windowId:t.webContents.id})})})),n&&n.autoStartOnLogin&&this.app.setLoginItemSettings({openAtLogin:n.autoStartOnLogin});var t=s.replaceNotificationApi;n&&void 0!==n.replaceNotificationApi&&(t=n.replaceNotificationApi),t&&this.registerNotificationsApi(),n&&n.node&&(this.nodeIntegration=n.node)}catch(n){console.error(n)}},s.prototype.getOptions=function(){return d(this,void 0,Promise,function(){var t,i;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),i={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(i.autoStartOnLogin=n.sent(),i)];case 2:throw t=n.sent(),new Error("Error getting Container options. "+t);case 3:return[2]}})})},s.prototype.isAutoStartEnabledAtLogin=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.app.getLoginItemSettings().openAtLogin]})})},s.prototype.createMessageBus=function(){return new o(this.internalIpc,this.browserWindow)},s.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var o=this;this.globalWindow.Notification=function(e){function n(n,t){var i=e.call(this,n,t)||this;return t.notification=i,o.showNotification(i.title,i.options),i}return t(n,e),n}(c.ContainerNotification)}},s.prototype.getInfo=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,"Electron/"+this.electron.process.versions.electron+" Chrome/"+this.electron.process.versions.chrome]})})},s.prototype.getMainWindow=function(){for(var n=0,t=this.browserWindow.getAllWindows();n<t.length;n++){var i=t[n];if(i[c.Container.windowOptionsPropertyKey]&&i[c.Container.windowOptionsPropertyKey].main)return this.wrapWindow(i)}var e=this.browserWindow.fromId(1);return e?this.wrapWindow(e):void 0},s.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},s.prototype.getWindowOptions=function(n){return null==this.nodeIntegration||"node"in n||(n.node=this.nodeIntegration),c.ObjectTransform.transformProperties(n,this.windowOptionsMap)},s.prototype.wrapWindow=function(n){return new i(n,this)},s.prototype.createWindow=function(r,s){return d(this,void 0,Promise,function(){var t,i,e,o;return a(this,function(n){return t=this.getWindowOptions(s),i=new this.browserWindow(t),e=t.name||c.Guid.newGuid(),this.isRemote?(i.name=this.internalIpc.sendSync(u.initialize,{id:i.id,name:e,options:t}),i[c.Container.windowOptionsPropertyKey]=s):this.windowManager.initializeWindow(i,e,t),i.loadURL(this.ensureAbsoluteUrl(r)),o=this.wrapWindow(i),this.emit("window-created",{sender:this,name:"window-created",window:o,windowId:i.id,windowName:e}),[2,o]})})},s.prototype.showNotification=function(n,t){var i=new this.electron.Notification(Object.assign(t||{},{title:n}));t.onClick&&i.addListener("click",t.onClick),t.notification&&i.once("show",function(){return i.addListener("click",t.notification.onclick)}),i.show()},s.prototype.addTrayIcon=function(n,t,i){var e=new this.tray(n.icon);n.text&&e.setToolTip(n.text),i&&e.setContextMenu(this.menu.buildFromTemplate(i)),t&&e.on("click",t)},s.prototype.closeAllWindows=function(o){return d(this,void 0,void 0,function(){var t,i,e;return a(this,function(n){for(t=0,i=this.browserWindow.getAllWindows();t<i.length;t++)e=i[t],o&&e===this.electron.getCurrentWindow()||e.close();return[2]})})},s.prototype.getAllWindows=function(){return d(this,void 0,Promise,function(){var t=this;return a(this,function(n){return[2,this.browserWindow.getAllWindows().map(function(n){return t.wrapWindow(n)})]})})},s.prototype.getWindowById=function(i){return d(this,void 0,Promise,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.fromId(i))?this.wrapWindow(t):null]})})},s.prototype.getWindowByName=function(i){return d(this,void 0,Promise,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.getAllWindows().find(function(n){return n.name===i}))?this.wrapWindow(t):null]})})},s.prototype.buildLayout=function(){return d(this,void 0,void 0,function(){var s,u,t,i=this;return a(this,function(n){switch(n.label){case 0:return s=new c.PersistedWindowLayout,u=this.getMainWindow().innerWindow,t=[],[4,this.getAllWindows()];case 1:return n.sent().forEach(function(o){var r=o.innerWindow[c.Container.windowOptionsPropertyKey];r&&"persist"in r&&!r.persist||t.push(d(i,void 0,void 0,function(){var t,i,e;return a(this,function(n){switch(n.label){case 0:return i=(t=s.windows).push,e={id:o.id,name:o.name,url:o.innerWindow.webContents.getURL(),main:u===o.innerWindow},[4,o.getState()];case 1:return e.state=n.sent(),e.options=r,e.bounds=o.innerWindow.getBounds(),[4,o.getGroup()];case 2:return i.apply(t,[(e.group=n.sent().map(function(n){return n.id}),e)]),[2]}})}))}),[4,Promise.all(t)];case 2:return n.sent(),[2,s]}})})},s.replaceNotificationApi=!0,s.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,t,i){return!n}},node:{target:"webPreferences",convert:function(n,t,i){return Object.assign(i.webPreferences||{},{nodeIntegration:n})}}},s}(c.WebContainerBase),p=function(){function n(n,t,i){var s=this;this.lastBounds=new Map,this.ignoredWindows=[],this.app=n||require("electron").app,this.ipc=t||require("electron").ipcMain,this.browserWindow=i||require("electron").BrowserWindow,this.ipc.on(u.initialize,function(n,t){var i=t.id,e=t.name,o=t.options,r=s.browserWindow.fromId(i);s.initializeWindow(r,e,o),n.returnValue=e}),this.ipc.on(u.joinGroup,function(n,t){var i=t.source,e=t.target,o=s.browserWindow.fromId(i),r=s.browserWindow.fromId(e);s.groupWindows(r,o)}),this.ipc.on(u.leaveGroup,function(n,t){var i=t.source;s.ungroupWindows(s.browserWindow.fromId(i))}),this.ipc.on(u.getGroup,function(n,t){var i=t.source;n.returnValue=s.getGroup(s.browserWindow.fromId(i))}),this.ipc.on(u.getOptions,function(n,t){var i=t.source;n.returnValue=s.browserWindow.fromId(i)[c.Container.windowOptionsPropertyKey]})}return n.prototype.initializeWindow=function(n,t,i){var e=this;n.name=t,!(n[c.Container.windowOptionsPropertyKey]=i)||!i.main||"quitOnClose"in i&&!i.quitOnClose||n.on("closed",function(){e.app.quit()})},n.prototype.registerWindowEvents=function(t){var i=this;t&&!t.moveHandler&&(this.lastBounds.set(t.id,t.getBounds()),t.moveHandler=function(n){return i.handleMove(t)},t.on("move",t.moveHandler))},n.prototype.unregisterWindowEvents=function(n){n&&n.moveHandler&&(this.lastBounds.delete(n.id),n.removeListener("move",n.moveHandler),delete n.moveHandler)},n.prototype.getGroup=function(t){return t.group?this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group}).map(function(n){return n.id}):[]},n.prototype.groupWindows=function(n){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var e=0,o=t;e<o.length;e++){var r=o[e];r.group=n.group||(n.group=c.Guid.newGuid()),this.registerWindowEvents(r),c.ContainerWindow.emit("window-joinGroup",{name:"window-joinGroup",windowId:r.id,targetWindowId:n.id})}this.registerWindowEvents(n)},n.prototype.ungroupWindows=function(){for(var o=this,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var i=0,e=n;i<e.length;i++){var r=e[i];this.unregisterWindowEvents(r),r.group=null,c.ContainerWindow.emit("window-leaveGroup",{name:"window-leaveGroup",windowId:r.id})}this.groupBy(this.browserWindow.getAllWindows(),"group").filter(function(n){return n.key&&n.values&&1===n.values.length}).forEach(function(n){for(var t=0,i=n.values;t<i.length;t++){var e=i[t];o.unregisterWindowEvents(e),e.group=null}})},n.prototype.handleMove=function(t){var i=this,n=this.lastBounds.get(t.id),e=t.getBounds();if(this.lastBounds.set(t.id,e),n.width===e.width&&n.height===e.height&&!(0<=this.ignoredWindows.indexOf(t.id))&&t.group){var o=this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group&&n.id!==t.id});if(o&&0<o.length){var r=n.x-e.x,s=n.y-e.y;o.forEach(function(n){var t=n.getBounds();i.ignoredWindows.push(n.id),n.setBounds({x:t.x-r,y:t.y-s,width:t.width,height:t.height},!0),i.ignoredWindows.splice(i.ignoredWindows.indexOf(n.id),1)})}}},n.prototype.groupBy=function(n,o){return n.reduce(function(n,t){var i=o instanceof Function?o(t):t[o],e=n.find(function(n){return n&&n.key===i});return e?e.values.push(t):n.push({key:i,values:[t]}),n},[])},n}(),h=function(){function n(n){this.electron=n}return n.prototype.createDisplay=function(n){var t=new c.Display;return t.id=n.id,t.scaleFactor=n.scaleFactor,t.bounds=new c.Rectangle(n.bounds.x,n.bounds.y,n.bounds.width,n.bounds.height),t.workArea=new c.Rectangle(n.workArea.x,n.workArea.y,n.workArea.width,n.workArea.height),t},n.prototype.getPrimaryDisplay=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.createDisplay(this.electron.screen.getPrimaryDisplay())]})})},n.prototype.getAllDisplays=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))]})})},n.prototype.getMousePosition=function(){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.electron.screen.getCursorScreenPoint()]})})},n}(),w=function(i){function n(n){var t=i.call(this)||this;return t.electron=n,t}return t(n,i),n.prototype.register=function(t,i){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.register(t,i),[2]})})},n.prototype.isRegistered=function(t){return d(this,void 0,Promise,function(){return a(this,function(n){return[2,this.electron.globalShortcut.isRegistered(t)]})})},n.prototype.unregister=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregister(t),[2]})})},n.prototype.unregisterAll=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregisterAll(),[2]})})},n}(c.GlobalShortcutManager);return n.ElectronContainer=s,n.ElectronContainerWindow=i,n.ElectronMessageBus=o,n.ElectronWindowManager=p,Object.defineProperty(n,"__esModule",{value:!0}),n}({},desktopJS);
this.desktopJS=this.desktopJS||{},this.desktopJS.Electron=function(n,c){"use strict";var e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])})(n,t)};function t(n,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function d(n,s,u,c){return new(u=u||Promise)(function(i,t){function e(n){try{r(c.next(n))}catch(n){t(n)}}function o(n){try{r(c.throw(n))}catch(n){t(n)}}function r(n){var t;n.done?i(n.value):((t=n.value)instanceof u?t:new u(function(n){n(t)})).then(e,o)}r((c=c.apply(n,s||[])).next())})}function a(e,o){var r,s,u,c={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},d={next:n(0),throw:n(1),return:n(2)};return"function"==typeof Symbol&&(d[Symbol.iterator]=function(){return this}),d;function n(i){return function(n){var t=[i,n];if(r)throw new TypeError("Generator is already executing.");for(;c=d&&t[d=0]?0:c;)try{if(r=1,s&&(u=2&t[0]?s.return:t[0]?s.throw||((u=s.return)&&u.call(s),0):s.next)&&!(u=u.call(s,t[1])).done)return u;switch(s=0,(t=u?[2&t[0],u.value]:t)[0]){case 0:case 1:u=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,s=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(u=0<(u=c.trys).length&&u[u.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!u||t[1]>u[0]&&t[1]<u[3])){c.label=t[1];break}if(6===t[0]&&c.label<u[1]){c.label=u[1],u=t;break}if(u&&c.label<u[2]){c.label=u[2],c.ops.push(t);break}u[2]&&c.ops.pop(),c.trys.pop();continue}t=o.call(e,c)}catch(n){t=[6,n],s=0}finally{r=u=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}c.registerContainer("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(n){return new f(null,null,null,n)}});i.initialize="desktopJS.window-initialize",i.getGroup="desktopJS.window-getGroup",i.joinGroup="desktopJS.window-joinGroup",i.leaveGroup="desktopJS.window-leaveGroup",i.getOptions="desktopJS.window-getOptions";var s=i;function i(){}var o,r={},u=(t(p,o=c.ContainerWindow),Object.defineProperty(p.prototype,"isRemote",{get:function(){return!!this.container.internalIpc.send},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"id",{get:function(){return this.innerWindow.id||this.innerWindow.guestId},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,configurable:!0}),p.prototype.load=function(t,i){return d(this,void 0,void 0,function(){return a(this,function(n){return i?this.innerWindow.loadURL(t,i):this.innerWindow.loadURL(t),[2]})})},p.prototype.focus=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.focus(),[2]})})},p.prototype.show=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.show(),[2]})})},p.prototype.hide=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.hide(),[2]})})},p.prototype.close=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.close(),[2]})})},p.prototype.maximize=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.maximize(),[2]})})},p.prototype.minimize=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.minimize(),[2]})})},p.prototype.restore=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.restore(),[2]})})},p.prototype.isShowing=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.innerWindow.isVisible()]})})},p.prototype.getSnapshot=function(){return d(this,void 0,void 0,function(){var i=this;return a(this,function(n){return[2,new Promise(function(t,n){i.innerWindow.capturePage(function(n){t("data:image/png;base64,"+n.toPNG().toString("base64"))})})]})})},p.prototype.flash=function(t,n){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.flashFrame(t),[2]})})},p.prototype.getParent=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.innerWindow.getParentWindow()]})})},p.prototype.setParent=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setParentWindow(t.innerWindow),[2]})})},p.prototype.getBounds=function(){return d(this,void 0,void 0,function(){var t,i,e,o;return a(this,function(n){return o=this.innerWindow.getBounds(),t=o.x,i=o.y,e=o.width,o=o.height,[2,new c.Rectangle(t,i,e,o)]})})},p.prototype.setBounds=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.setBounds(t),[2]})})},Object.defineProperty(p.prototype,"allowGrouping",{get:function(){return!0},enumerable:!1,configurable:!0}),p.prototype.getGroup=function(){return d(this,void 0,void 0,function(){var t=this;return a(this,function(n){return[2,(this.isRemote?this.container.internalIpc.sendSync(s.getGroup,{source:this.id}):this.container.windowManager.getGroup(this.innerWindow)).map(function(n){return n===t.id?t:t.container.wrapWindow(t.container.browserWindow.fromId(n))})]})})},p.prototype.joinGroup=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return t&&t.id!==this.id&&(this.isRemote?this.container.internalIpc.send(s.joinGroup,{source:this.id,target:t.id}):this.container.windowManager.groupWindows(t.innerWindow,this.innerWindow)),[2]})})},p.prototype.leaveGroup=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.isRemote?this.container.internalIpc.send(s.leaveGroup,{source:this.id}):this.container.windowManager.ungroupWindows(this.innerWindow),[2]})})},p.prototype.bringToFront=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow.moveTop(),[2]})})},p.prototype.getOptions=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.isRemote?this.container.internalIpc.sendSync(s.getOptions,{source:this.id}):this.innerWindow[c.Container.windowOptionsPropertyKey]]})})},p.prototype.getState=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.innerWindow&&this.innerWindow.webContents?[2,this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined")]:[2]})})},p.prototype.setState=function(t){var i;return d(this,void 0,void 0,function(){return a(this,function(n){switch(n.label){case 0:return[4,null==(i=null==(i=this.innerWindow)?void 0:i.webContents)?void 0:i.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`".concat(JSON.stringify(t),"`)); }"))];case 1:return n.sent(),this.emit("state-changed",{name:"state-changed",sender:this,state:t}),c.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:this.id,state:t}),[2]}})})},p.prototype.attachListener=function(n,t){if("beforeunload"===n){var i=this.window||window;if(!i||this.id!==this.container.getCurrentWindow().id)throw new Error("Event handler for 'beforeunload' can only be added on current window");i.addEventListener("beforeunload",t)}else this.innerWindow.addListener(r[n]||n,t)},p.prototype.detachListener=function(n,t){this.innerWindow.removeListener(r[n]||n,t)},Object.defineProperty(p.prototype,"nativeWindow",{get:function(){return this.window||window},enumerable:!1,configurable:!0}),p);function p(n,t,i){n=o.call(this,n)||this;return n.container=t,n.window=i,n}w.prototype.subscribe=function(i,e,n){return d(this,void 0,void 0,function(){var t;return a(this,function(n){return t=new c.MessageBusSubscription(i,function(n,t){e({topic:i},t)}),this.ipc.on(i,t.listener),[2,t]})})},w.prototype.unsubscribe=function(e){return d(this,void 0,void 0,function(){var t,i;return a(this,function(n){return t=e.topic,i=e.listener,e.options,[2,this.ipc.removeListener(t,i)]})})},w.prototype.publish=function(o,r,s){var u;return d(this,void 0,void 0,function(){var t,i,e;return a(this,function(n){if(null!=s&&s.name||(void 0!==this.ipc.send?this.ipc.send(o,r):this.ipc.listeners(o).forEach(function(n){return n({topic:o},r)})),null!=(u=this.browserWindow)&&u.getAllWindows)for(t=0,i=this.browserWindow.getAllWindows();t<i.length;t++)e=i[t],null!=s&&s.name&&s.name!==e.name||e.webContents.send(o,r);return[2]})})};var h=w;function w(n,t){this.ipc=n,this.browserWindow=t}t(v,l=c.WebContainerBase),v.prototype.setOptions=function(n){try{this.isRemote&&(!n||void 0===n.isRemote||n.isRemote)||this.windowManager||(this.windowManager=new g(this.app,this.internalIpc,this.browserWindow),this.app.on("browser-window-created",function(n,t){setImmediate(function(){c.Container.emit("window-created",{name:"window-created",windowId:t.webContents.id}),c.ContainerWindow.emit("window-created",{name:"window-created",windowId:t.webContents.id})})})),n&&n.autoStartOnLogin&&this.app.setLoginItemSettings({openAtLogin:n.autoStartOnLogin});var t=v.replaceNotificationApi;(t=n&&void 0!==n.replaceNotificationApi?n.replaceNotificationApi:t)&&this.registerNotificationsApi(),n&&n.node&&(this.nodeIntegration=n.node)}catch(n){console.error(n)}},v.prototype.getOptions=function(){return d(this,void 0,void 0,function(){var t,i;return a(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),i={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(i.autoStartOnLogin=n.sent(),i)];case 2:throw t=n.sent(),new Error("Error getting Container options. "+t);case 3:return[2]}})})},v.prototype.isAutoStartEnabledAtLogin=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.app.getLoginItemSettings().openAtLogin]})})},v.prototype.createMessageBus=function(){return new h(this.internalIpc,this.browserWindow)},v.prototype.registerNotificationsApi=function(){var i,e;function n(n,t){n=e.call(this,n,t)||this;return t.notification=n,i.showNotification(n.title,n.options),n}void 0!==this.globalWindow&&this.globalWindow&&((i=this).globalWindow.Notification=(t(n,e=c.ContainerNotification),n))},v.prototype.getInfo=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,"Electron/".concat(this.electron.process.versions.electron," Chrome/").concat(this.electron.process.versions.chrome)]})})},v.prototype.getMainWindow=function(){for(var n=0,t=this.browserWindow.getAllWindows();n<t.length;n++){var i=t[n];if(i[c.Container.windowOptionsPropertyKey]&&i[c.Container.windowOptionsPropertyKey].main)return this.wrapWindow(i)}var e=this.browserWindow.fromId(1);return e?this.wrapWindow(e):void 0},v.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},v.prototype.getWindowOptions=function(n){return null==this.nodeIntegration||"node"in n||(n.node=this.nodeIntegration),c.ObjectTransform.transformProperties(n,this.windowOptionsMap)},v.prototype.wrapWindow=function(n){return new u(n,this)},v.prototype.createWindow=function(o,r){return d(this,void 0,void 0,function(){var t,i,e;return a(this,function(n){return e=this.getWindowOptions(r),t=new this.browserWindow(e),i=e.name||c.Guid.newGuid(),this.isRemote?(t.name=this.internalIpc.sendSync(s.initialize,{id:t.id,name:i,options:e}),t[c.Container.windowOptionsPropertyKey]=r):this.windowManager.initializeWindow(t,i,e),t.loadURL(this.ensureAbsoluteUrl(o)),e=this.wrapWindow(t),this.emit("window-created",{sender:this,name:"window-created",window:e,windowId:t.id,windowName:i}),[2,e]})})},v.prototype.showNotification=function(n,t){var i=new this.electron.Notification(Object.assign(t||{},{title:n}));t.onClick&&i.addListener("click",t.onClick),t.notification&&i.once("show",function(){return i.addListener("click",t.notification.onclick)}),i.show()},v.prototype.addTrayIcon=function(n,t,i){var e=new this.tray(n.icon);n.text&&e.setToolTip(n.text),i&&e.setContextMenu(this.menu.buildFromTemplate(i)),t&&e.on("click",t)},v.prototype.closeAllWindows=function(o){return d(this,void 0,void 0,function(){var t,i,e;return a(this,function(n){for(t=0,i=this.browserWindow.getAllWindows();t<i.length;t++)e=i[t],o&&e===this.electron.getCurrentWindow()||e.close();return[2]})})},v.prototype.getAllWindows=function(){return d(this,void 0,void 0,function(){var t=this;return a(this,function(n){return[2,this.browserWindow.getAllWindows().map(function(n){return t.wrapWindow(n)})]})})},v.prototype.getWindowById=function(i){return d(this,void 0,void 0,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.fromId(i))?this.wrapWindow(t):null]})})},v.prototype.getWindowByName=function(i){return d(this,void 0,void 0,function(){var t;return a(this,function(n){return[2,(t=this.browserWindow.getAllWindows().find(function(n){return n.name===i}))?this.wrapWindow(t):null]})})},v.prototype.buildLayout=function(){return d(this,void 0,void 0,function(){var s,u,t,i=this;return a(this,function(n){switch(n.label){case 0:return s=new c.PersistedWindowLayout,u=this.getMainWindow().innerWindow,t=[],[4,this.getAllWindows()];case 1:return n.sent().forEach(function(o){var r=o.innerWindow[c.Container.windowOptionsPropertyKey];r&&"persist"in r&&!r.persist||t.push(d(i,void 0,void 0,function(){var t,i,e;return a(this,function(n){switch(n.label){case 0:return i=(t=s.windows).push,e={id:o.id,name:o.name,url:o.innerWindow.webContents.getURL(),main:u===o.innerWindow},[4,o.getState()];case 1:return e.state=n.sent(),e.options=r,e.bounds=o.innerWindow.getBounds(),[4,o.getGroup()];case 2:return i.apply(t,[(e.group=n.sent().map(function(n){return n.id}),e)]),[2]}})}))}),[4,Promise.all(t)];case 2:return n.sent(),[2,s]}})})},v.replaceNotificationApi=!0,v.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,t,i){return!n}},node:{target:"webPreferences",convert:function(n,t,i){return Object.assign(i.webPreferences||{},{nodeIntegration:n})}}};var l,f=v;function v(n,t,i,e){i=l.call(this,i)||this;i.isRemote=!0,i.windowOptionsMap=v.windowOptionsMap,i.hostType="Electron";try{n?i.electron=n:(i.electron=require("electron").remote,void 0===i.electron&&(i.electron=require("electron"),i.isRemote=!1)),i.app=i.electron.app,i.browserWindow=i.electron.BrowserWindow,i.tray=i.electron.Tray,i.menu=i.electron.Menu,i.internalIpc=t||(i.isRemote?require("electron").ipcRenderer:i.electron.ipcMain),i.ipc=i.createMessageBus(),i.nodeIntegration=null,i.setOptions(e)}catch(n){console.error(n)}return i.screen=new W(i.electron),i.globalShortcut=new O(i.electron),i}y.prototype.initializeWindow=function(n,t,i){var e=this;n.name=t,!(n[c.Container.windowOptionsPropertyKey]=i)||!i.main||"quitOnClose"in i&&!i.quitOnClose||n.on("closed",function(){e.app.quit()})},y.prototype.registerWindowEvents=function(t){var i=this;t&&!t.moveHandler&&(this.lastBounds.set(t.id,t.getBounds()),t.moveHandler=function(n){return i.handleMove(t)},t.on("move",t.moveHandler))},y.prototype.unregisterWindowEvents=function(n){n&&n.moveHandler&&(this.lastBounds.delete(n.id),n.removeListener("move",n.moveHandler),delete n.moveHandler)},y.prototype.getGroup=function(t){return t.group?this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group}).map(function(n){return n.id}):[]},y.prototype.groupWindows=function(n){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var e=0,o=t;e<o.length;e++){var r=o[e];r.group=n.group||(n.group=c.Guid.newGuid()),this.registerWindowEvents(r),c.ContainerWindow.emit("window-joinGroup",{name:"window-joinGroup",windowId:r.id,targetWindowId:n.id})}this.registerWindowEvents(n)},y.prototype.ungroupWindows=function(){for(var o=this,n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];for(var i=0,e=n;i<e.length;i++){var r=e[i];this.unregisterWindowEvents(r),r.group=null,c.ContainerWindow.emit("window-leaveGroup",{name:"window-leaveGroup",windowId:r.id})}this.groupBy(this.browserWindow.getAllWindows(),"group").filter(function(n){return n.key&&n.values&&1===n.values.length}).forEach(function(n){for(var t=0,i=n.values;t<i.length;t++){var e=i[t];o.unregisterWindowEvents(e),e.group=null}})},y.prototype.handleMove=function(t){var n,i,e,o=this,r=this.lastBounds.get(t.id),s=t.getBounds();this.lastBounds.set(t.id,s),r.width!==s.width||r.height!==s.height||0<=this.ignoredWindows.indexOf(t.id)||!t.group||(n=this.browserWindow.getAllWindows().filter(function(n){return n.group===t.group&&n.id!==t.id}))&&0<n.length&&(i=r.x-s.x,e=r.y-s.y,n.forEach(function(n){var t=n.getBounds();o.ignoredWindows.push(n.id),n.setBounds({x:t.x-i,y:t.y-e,width:t.width,height:t.height},!0),o.ignoredWindows.splice(o.ignoredWindows.indexOf(n.id),1)}))},y.prototype.groupBy=function(n,o){return n.reduce(function(n,t){var i=o instanceof Function?o(t):t[o],e=n.find(function(n){return n&&n.key===i});return e?e.values.push(t):n.push({key:i,values:[t]}),n},[])};var g=y;function y(n,t,i){var o=this;this.lastBounds=new Map,this.ignoredWindows=[],this.app=n||require("electron").app,this.ipc=t||require("electron").ipcMain,this.browserWindow=i||require("electron").BrowserWindow,this.ipc.on(s.initialize,function(n,t){var i=t.id,e=t.name,t=t.options,i=o.browserWindow.fromId(i);o.initializeWindow(i,e,t),n.returnValue=e}),this.ipc.on(s.joinGroup,function(n,t){var i=t.source,t=t.target,i=o.browserWindow.fromId(i),t=o.browserWindow.fromId(t);o.groupWindows(t,i)}),this.ipc.on(s.leaveGroup,function(n,t){t=t.source;o.ungroupWindows(o.browserWindow.fromId(t))}),this.ipc.on(s.getGroup,function(n,t){t=t.source;n.returnValue=o.getGroup(o.browserWindow.fromId(t))}),this.ipc.on(s.getOptions,function(n,t){t=t.source;n.returnValue=o.browserWindow.fromId(t)[c.Container.windowOptionsPropertyKey]})}b.prototype.createDisplay=function(n){var t=new c.Display;return t.id=n.id,t.scaleFactor=n.scaleFactor,t.bounds=new c.Rectangle(n.bounds.x,n.bounds.y,n.bounds.width,n.bounds.height),t.workArea=new c.Rectangle(n.workArea.x,n.workArea.y,n.workArea.width,n.workArea.height),t},b.prototype.getPrimaryDisplay=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.createDisplay(this.electron.screen.getPrimaryDisplay())]})})},b.prototype.getAllDisplays=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.screen.getAllDisplays().map(this.createDisplay.bind(this))]})})},b.prototype.getMousePosition=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.screen.getCursorScreenPoint()]})})};var W=b;function b(n){this.electron=n}t(S,m=c.GlobalShortcutManager),S.prototype.register=function(t,i){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.register(t,i),[2]})})},S.prototype.isRegistered=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return[2,this.electron.globalShortcut.isRegistered(t)]})})},S.prototype.unregister=function(t){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregister(t),[2]})})},S.prototype.unregisterAll=function(){return d(this,void 0,void 0,function(){return a(this,function(n){return this.electron.globalShortcut.unregisterAll(),[2]})})};var m,O=S;function S(n){var t=m.call(this)||this;return t.electron=n,t}return n.ElectronContainer=f,n.ElectronContainerWindow=u,n.ElectronMessageBus=h,n.ElectronWindowManager=g,Object.defineProperty(n,"__esModule",{value:!0}),n}({},desktopJS);
//# sourceMappingURL=desktopjs-electron.min.js.map

@@ -5,3 +5,3 @@ {

"description": "desktopJS container implementation for Electron",
"version": "3.12.0",
"version": "3.13.0",
"publishConfig": {

@@ -14,3 +14,6 @@ "access": "public"

"author": "Morgan Stanley",
"repository": "https://github.com/MorganStanley/desktopJS/tree/main/packages/desktopjs-electron",
"repository": {
"type": "git",
"url": "git+https://github.com/MorganStanley/desktopJS.git#main"
},
"bugs": {

@@ -30,13 +33,11 @@ "url": "https://github.com/MorganStanley/desktopJS/issues"

"clean": "gulp clean",
"build:lerna": "gulp build:lerna",
"build:workspaces": "gulp build:workspaces",
"build": "gulp build",
"test": "gulp test",
"watch": "gulp watch",
"deploy": "npm publish"
},
"homepage": "https://github.com/MorganStanley/desktopJS/tree/main#readme",
"devDependencies": {
"@morgan-stanley/desktopjs": "^3.12.0",
"@types/jasmine": "^3.5.11",
"gulp": "^4.0.2"
"@morgan-stanley/desktopjs": "file:packages/desktopjs"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc