Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@morgan-stanley/desktopjs

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@morgan-stanley/desktopjs - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

README.md

45

dist/desktop.js
if (typeof desktopJS === "undefined") {(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.desktopJS = {})));
}(this, (function (exports) { 'use strict';
(global = global || self, factory(global.desktopJS = {}));
}(this, function (exports) { 'use strict';

@@ -484,3 +484,2 @@ /*! *****************************************************************************

var fin = (typeof window !== "undefined") ? window.fin : undefined;
var Rectangle = (function () {

@@ -522,2 +521,9 @@ function Rectangle(x, y, width, height) {

}(EventArgs));
var WindowGroupEventArgs = (function (_super) {
__extends(WindowGroupEventArgs, _super);
function WindowGroupEventArgs() {
return _super !== null && _super.apply(this, arguments) || this;
}
return WindowGroupEventArgs;
}(WindowEventArgs));
var ContainerWindow = (function (_super) {

@@ -546,2 +552,5 @@ __extends(ContainerWindow, _super);

};
ContainerWindow.prototype.bringToFront = function () {
return this.focus();
};
ContainerWindow.prototype.getState = function () {

@@ -602,2 +611,5 @@ return Promise.resolve(undefined);

})(exports.WindowStateTracking || (exports.WindowStateTracking = {}));
function isOpenFin() {
return (typeof window !== "undefined" && window.fin);
}
var GroupWindowManager = (function () {

@@ -617,3 +629,3 @@ function GroupWindowManager(container, options) {

if (win) {
win.addListener((typeof fin !== "undefined") ? "minimized" : "minimize", function (e) {
win.addListener(isOpenFin() ? "minimized" : "minimize", function (e) {
if ((_this.windowStateTracking & exports.WindowStateTracking.Main) && _this.container.getMainWindow().id === e.sender.id) {

@@ -630,3 +642,3 @@ _this.container.getAllWindows().then(function (windows) {

});
win.addListener((typeof fin !== "undefined") ? "restored" : "restore", function (e) {
win.addListener(isOpenFin() ? "restored" : "restore", function (e) {
if ((_this.windowStateTracking & exports.WindowStateTracking.Main) && _this.container.getMainWindow().id === e.sender.id) {

@@ -687,4 +699,5 @@ _this.container.getAllWindows().then(function (windows) {

}
if (typeof fin !== "undefined") {
if (isOpenFin()) {
win.addListener("disabled-frame-bounds-changed", function () { return _this.onMoved(win); });
win.addListener("frame-enabled", function () { return win.innerWindow.disableFrame(); });
}

@@ -706,3 +719,3 @@ else {

_this.onAttached(win);
win.addListener((typeof fin !== "undefined") ? "disabled-frame-bounds-changing" : "move", function (e) { return _this.onMoving(e); });
win.addListener(isOpenFin() ? "disabled-frame-bounds-changing" : "move", function (e) { return _this.onMoving(e); });
});

@@ -722,3 +735,3 @@ }

e.sender.getGroup().then(function (groupedWindows) {
var getBounds = (typeof fin !== "undefined")
var getBounds = (isOpenFin())
? Promise.resolve(new Rectangle(e.innerEvent.left, e.innerEvent.top, e.innerEvent.width, e.innerEvent.height))

@@ -728,3 +741,3 @@ : e.sender.getBounds();

if (groupedWindows.length > 0) {
if (typeof fin !== "undefined") {
if (isOpenFin()) {
_this.moveWindow(e.sender, bounds);

@@ -758,3 +771,3 @@ }

}
if (!isSnapped && typeof fin !== "undefined") {
if (!isSnapped && isOpenFin()) {
_this.moveWindow(e.sender, bounds);

@@ -1302,4 +1315,10 @@ }

var version = "3.0.0";
var GlobalShortcutManager = (function () {
function GlobalShortcutManager() {
}
return GlobalShortcutManager;
}());
var version = "3.1.0";
exports.version = version;

@@ -1328,2 +1347,3 @@ exports.LayoutEventArgs = LayoutEventArgs;

exports.WindowEventArgs = WindowEventArgs;
exports.WindowGroupEventArgs = WindowGroupEventArgs;
exports.ContainerWindow = ContainerWindow;

@@ -1334,6 +1354,7 @@ exports.PersistedWindow = PersistedWindow;

exports.SnapAssistWindowManager = SnapAssistWindowManager;
exports.GlobalShortcutManager = GlobalShortcutManager;
Object.defineProperty(exports, '__esModule', { value: true });
})));}
}));}
//# sourceMappingURL=desktop.js.map

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

"undefined"==typeof desktopJS&&function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.desktopJS={})}(this,function(r){"use strict";var o=function(n,t){return(o=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 s(n,t){function e(){this.constructor=n}o(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}function l(e,o){var i,r,a,n,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(a=2&t[0]?r.return:t[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,t[1])).done)return a;switch(r=0,a&&(t=[2&t[0],a.value]),t[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,r=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){s.label=t[1];break}if(6===t[0]&&s.label<a[1]){s.label=a[1],a=t;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(t);break}a[2]&&s.ops.pop(),s.trys.pop();continue}t=o.call(e,s)}catch(n){t=[6,n],r=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,n])}}}var a=function(n,t,e){this.sender=n,this.name=t,this.innerEvent=e},i=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(n,t){return(this.eventListeners[n]=this.eventListeners[n]||[]).push(t),this},r.prototype.registerAndWrapListener=function(n,t){var e=this.wrapListener(n,t);return this.wrappedListeners.set(t,e),e},r.prototype.wrapListener=function(o,i){var r=this;return function(n){var t=new a(r,o,n);r.preProcessArgs(t);var e=i(t);return r.postProcessArgs(t),e}},r.prototype.preProcessArgs=function(n){},r.prototype.postProcessArgs=function(n){n&&void 0!==n.returnValue&&(n.innerEvent.returnValue=n.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(n){var t=this.wrappedListeners.get(n);return t&&this.wrappedListeners.delete(n),t},r.prototype.removeListener=function(n,t){var e=this.listeners(n);if(e){var o=e.indexOf(t);0<=o&&e.splice(o,1)}return this},r.prototype.listeners=function(n){return this.eventListeners[n]||[]},r.prototype.emit=function(n,t){for(var e=0,o=this.listeners(n);e<o.length;e++){(0,o[e])(t)}},Object.defineProperty(r,"ipc",{set:function(n){n&&n.subscribe(r.staticEventName,function(n,t){r.emit(t.eventName,t.eventArgs)})},enumerable:!0,configurable:!0}),r.addListener=function(n,t){(this.staticEventListeners[n]=this.staticEventListeners[n]||[]).push(t)},r.removeListener=function(n,t){var e=r.listeners(n);if(e){var o=e.indexOf(t);0<=o&&e.splice(o,1)}},r.listeners=function(n){return this.staticEventListeners[n]||[]},r.emit=function(n,t,e){if(e&&e.publish)e.publish(r.staticEventName,{eventName:n,eventArgs:t});else for(var o=0,i=r.listeners(n);o<i.length;o++){(0,i[o])(t)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),c=function(){function n(){}return n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var t=16*Math.random()|0;return("x"==n?t:3&t|8).toString(16)})},n}(),n=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return s(t,n),t}(a),w=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return s(o,e),Object.defineProperty(o,"ipc",{get:function(){return o._ipc},set:function(n){i.ipc=o._ipc=n},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"ipc",{get:function(){return o.ipc},set:function(n){o.ipc=n},enumerable:!0,configurable:!0}),o.prototype.addListener=function(n,t){return e.prototype.addListener.call(this,n,t)},o.prototype.removeListener=function(n,t){return e.prototype.removeListener.call(this,n,t)},o.prototype.emit=function(n,t){e.prototype.emit.call(this,n,t)},o.addListener=function(n,t){i.addListener(o.staticEventScopePrefix+n,t)},o.removeListener=function(n,t){i.removeListener(o.staticEventScopePrefix+n,t)},o.emit=function(n,t){i.emit(o.staticEventScopePrefix+n,t,o.ipc)},o.listeners=function(n){return i.listeners(o.staticEventScopePrefix+n)},o.staticEventScopePrefix="container-",o.windowOptionsPropertyKey="desktopJS-options",o}(i),t=function(t){function r(){var n=null!==t&&t.apply(this,arguments)||this;return n.uuid=c.newGuid(),n.storage="undefined"!=typeof window&&window?window.localStorage:void 0,n}return s(r,t),r.prototype.showNotification=function(n,t){throw new TypeError("Notifications not supported by this container")},r.prototype.addTrayIcon=function(n,t,e){throw new TypeError("Tray icons are not supported by this container.")},r.prototype.getLayoutFromStorage=function(n){return JSON.parse(this.storage.getItem(r.layoutsPropertyKey))[n]},r.prototype.saveLayoutToStorage=function(n,t){var e=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{};t.name||(t.name=n),e[n]=t,this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(e)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:t,layoutName:t.name}),w.emit("layout-saved",{name:"layout-saved",layout:t,layoutName:t.name})},r.prototype.loadLayout=function(u){var c=this;return new Promise(function(a,s){c.closeAllWindows(!0).then(function(){var r=c.getLayoutFromStorage(u);if(r&&r.windows){for(var n=[],t=0,e=r.windows;t<e.length;t++){var o=e[t],i=Object.assign(o.options||{},o.bounds);i.name=o.name,o.main?(c.getMainWindow().setBounds(o.bounds),n.push(Promise.resolve(c.getMainWindow()))):n.push(c.createWindow(o.url,i))}Promise.all(n).then(function(n){var i=new Map;n.forEach(function(e){var n=r.windows.find(function(n){return n.name===e.name});n&&n.state&&e.setState&&e.setState(n.state).catch(function(n){return c.log("error","Error invoking setState: "+n)});var o=!1;if(i.forEach(function(n,t){!o&&0<=n.indexOf(e.id)&&(o=!0)}),!o){var t=n?n.group:void 0;t&&0<t.length&&i.set(e,t.filter(function(n){return n!==e.id}))}}),i.forEach(function(n,e){n.forEach(function(t){c.getWindowByName(r.windows.find(function(n){return n.id===t}).name).then(function(n){n.joinGroup(e)})})})}),c.emit("layout-loaded",{sender:c,name:"layout-loaded",layout:r,layoutName:r.name}),w.emit("layout-loaded",{name:"layout-loaded",layout:r,layoutName:r.name}),a(r)}else s("Layout does not exist")})})},r.prototype.getLayouts=function(){var i=this;return new Promise(function(n,t){var e=i.storage.getItem(r.layoutsPropertyKey);if(e){var o=JSON.parse(e);n(Object.getOwnPropertyNames(o).map(function(n){return o[n]}))}n(void 0)})},r.prototype.log=function(e,o){return new Promise(function(n){var t;switch(e){case"debug":t=console.debug;break;case"warn":t=console.warn;break;case"error":t=console.error;break;default:t=console.log}t&&t(o),n()})},r.layoutsPropertyKey="desktopJS-layouts",r}(w),u=function(t){function n(n){var e=t.call(this)||this;e.globalWindow=n||"undefined"!=typeof window&&window||null,e.linkHelper={href:"unknown"};try{e.linkHelper=e.globalWindow.top.document.createElement("a")}catch(n){}if(e.globalWindow){var o=e.globalWindow.open;e.globalWindow.open=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e.onOpen.apply(e,[o].concat(n))}}return e}return s(n,t),n.prototype.onOpen=function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return n.apply(this.globalWindow,t)},n.prototype.ensureAbsoluteUrl=function(n){return this.linkHelper?(this.linkHelper.href=n,this.linkHelper.href):n},n}(t),p=function(n,t,e){this.topic=n,this.listener=t,this.options=e},e=function(){},d=function(){},f=function(){},h=function(){function t(n,t){}return t.requestPermission=function(n){return n&&n(t.permission),Promise.resolve(t.permission)},t.permission="granted",t}(),y=function(){};(r.ObjectTransform||(r.ObjectTransform={})).transformProperties=function(n,t){var e={};if(n)for(var o in n)try{o in t?e[t[o].target]=t[o].convert?t[o].convert(n[o],n,e):n[o]:e[o]=n[o]}catch(n){console.error("Error transforming property '"+o+"'")}return e};var g,v="undefined"!=typeof window?window.fin:void 0,m=function(){function n(n,t,e,o){this.x=n,this.y=t,this.width=e,this.height=o}return Object.defineProperty(n.prototype,"right",{get:function(){return n.getRight(this)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return n.getBottom(this)},enumerable:!0,configurable:!0}),n.getRight=function(n){return n.x+n.width},n.getBottom=function(n){return n.y+n.height},n}(),b=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return s(t,n),t}(a),W=function(o){function e(n){var t=o.call(this)||this;return t.innerWindow=n,t}return s(e,o),Object.defineProperty(e.prototype,"allowGrouping",{get:function(){return!1},enumerable:!0,configurable:!0}),e.prototype.getGroup=function(){return Promise.resolve([])},e.prototype.joinGroup=function(n){return Promise.reject("Not supported")},e.prototype.leaveGroup=function(){return Promise.resolve()},e.prototype.getState=function(){return Promise.resolve(void 0)},e.prototype.setState=function(n){return Promise.resolve()},Object.defineProperty(e.prototype,"nativeWindow",{get:function(){},enumerable:!0,configurable:!0}),e.prototype.addListener=function(n,t){var e=this.registerAndWrapListener(n,t);return this.attachListener(n,e),o.prototype.addListener.call(this,n,e)},e.prototype.removeListener=function(n,t){var e=this.unwrapAndUnRegisterListener(t)||t;return this.detachListener(n,e),o.prototype.removeListener.call(this,n,e)},e.addListener=function(n,t){i.addListener(e.staticEventScopePrefix+n,t)},e.removeListener=function(n,t){i.removeListener(e.staticEventScopePrefix+n,t)},e.emit=function(n,t){i.emit(e.staticEventScopePrefix+n,t,w.ipc)},e.listeners=function(n){return i.listeners(e.staticEventScopePrefix+n)},e.staticEventScopePrefix="containerwindow-",e}(i),P=function(){},x=function(n){this.windows=[],this.name=n};(g=r.WindowStateTracking||(r.WindowStateTracking={}))[g.None=0]="None",g[g.Main=1]="Main",g[g.Group=2]="Group";var S=function(){function n(n,t){this.windowStateTracking=r.WindowStateTracking.None,this.container=n,t&&"windowStateTracking"in t&&(this.windowStateTracking=t.windowStateTracking),this.attach()}return n.prototype.attach=function(n){var t=this;n?(n.addListener(void 0!==v?"minimized":"minimize",function(n){t.windowStateTracking&r.WindowStateTracking.Main&&t.container.getMainWindow().id===n.sender.id&&t.container.getAllWindows().then(function(n){n.forEach(function(n){return n.minimize()})}),t.windowStateTracking&r.WindowStateTracking.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.minimize()})})}),n.addListener(void 0!==v?"restored":"restore",function(n){t.windowStateTracking&r.WindowStateTracking.Main&&t.container.getMainWindow().id===n.sender.id&&t.container.getAllWindows().then(function(n){n.forEach(function(n){return n.restore()})}),t.windowStateTracking&r.WindowStateTracking.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.restore()})})})):(W.addListener("window-created",function(n){t.container&&t.container.getWindowById&&t.container.getWindowById(n.windowId).then(function(n){t.attach(n)})}),this.container&&this.container.getAllWindows().then(function(n){n.forEach(function(n){return t.attach(n)})}))},n}(),L=function(o){function n(n,t){var e=o.call(this,n,t)||this;return e.autoGrouping=!0,e.snapThreshold=15,e.snapOffset=15,e.targetGroup=new Map,t&&("snapThreshold"in t&&(e.snapThreshold=t.snapThreshold),"snapOffset"in t&&(e.snapOffset=t.snapOffset),"autoGrouping"in t&&(e.autoGrouping=t.autoGrouping)),e}return s(n,o),n.prototype.onAttached=function(n){var t=this;n.innerWindow&&n.innerWindow.disableFrame&&n.innerWindow.disableFrame(),void 0!==v?n.addListener("disabled-frame-bounds-changed",function(){return t.onMoved(n)}):n.innerWindow&&n.innerWindow.hookWindowMessage&&n.innerWindow.hookWindowMessage(562,function(){return t.onMoved(n)})},n.prototype.attach=function(t){var e=this;o.prototype.attach.call(this,t),t&&t.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||(e.onAttached(t),t.addListener(void 0!==v?"disabled-frame-bounds-changing":"move",function(n){return e.onMoving(n)}))})},n.prototype.onMoving=function(s){var u=this,e=s.sender.id;this.snappingWindow!==e&&s.sender.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||s.sender.getGroup().then(function(n){(void 0!==v?Promise.resolve(new m(s.innerEvent.left,s.innerEvent.top,s.innerEvent.width,s.innerEvent.height)):s.sender.getBounds()).then(function(a){if(0<n.length)void 0!==v&&u.moveWindow(s.sender,a);else{var t=[];u.container.getAllWindows().then(function(n){n.filter(function(n){return e!==n.id}).forEach(function(o){t.push(new Promise(function(e){o.getOptions().then(function(t){o.getBounds().then(function(n){return e({window:o,bounds:n,options:t})})})}))}),Promise.all(t).then(function(n){for(var t,e=!1,o=0,i=n.filter(function(n){return!(n.options&&void 0!==n.options.snap&&!1===n.options.snap)});o<i.length;o++){var r=i[o];(t=u.getSnapBounds(t||a,r.bounds))?(e=!0,u.showGroupingHint(r.window),u.moveWindow(s.sender,t)):u.hideGroupingHint(r.window)}e||void 0===v||u.moveWindow(s.sender,a)})})}})})})},n.prototype.moveWindow=function(n,t){var e=this;this.snappingWindow=n.id,n.setBounds(t).then(function(){return e.snappingWindow=void 0},function(){return e.snappingWindow=void 0})},n.prototype.onMoved=function(e){var t=this;if(this.autoGrouping){var n=[];this.targetGroup.forEach(function(e){return n.push(new Promise(function(t){e.getGroup().then(function(n){return t({window:e,isGrouped:0<n.length})})}))}),Promise.all(n).then(function(n){0<n.length&&e.joinGroup(n[0].window);for(var t=1;t<n.length;t++)n[t].isGrouped||n[t].window.joinGroup(e)})}this.targetGroup.forEach(function(n){return t.hideGroupingHint(n)}),this.targetGroup.clear()},n.prototype.showGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:.75}),this.targetGroup.set(n.id,n)},n.prototype.hideGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:1}),this.targetGroup.delete(n.id)},n.prototype.isHorizontallyAligned=function(n,t){return n.y>=t.y&&n.y<=t.bottom||n.bottom>=t.y&&n.bottom<=t.bottom||n.y<=t.y&&n.bottom>=t.bottom},n.prototype.isVerticallyAligned=function(n,t){return n.x>=t.x&&n.x<=t.right||n.right>=t.x&&n.right<=t.right||n.x<=t.x&&n.right>=t.right},n.prototype.getSnapBounds=function(n,t){var e,o,i,r,a,s,u,c;if(this.isHorizontallyAligned(n,t)&&(e=Math.abs(n.x-(t.right-this.snapOffset))<this.snapThreshold,o=Math.abs(n.x-t.x)<this.snapThreshold,i=Math.abs(n.right-this.snapOffset-t.x)<this.snapThreshold,r=Math.abs(n.right-t.right)<this.snapThreshold),this.isVerticallyAligned(n,t)&&(a=Math.abs(n.y-(t.bottom-this.snapOffset))<this.snapThreshold,s=Math.abs(n.y-t.y)<this.snapThreshold,u=Math.abs(n.bottom-this.snapOffset-t.y)<this.snapThreshold,c=Math.abs(n.bottom-t.bottom)<this.snapThreshold),e||i||a||u){var p=n.x,d=n.y;return e?p=t.x+t.width-this.snapOffset:o&&(p=t.x),i?p=t.x-n.width+this.snapOffset:r&&(p=t.x+t.width-n.width),a?d=t.y+t.height-Math.floor(this.snapOffset/2):s&&(d=t.y),u?d=t.y-n.height+Math.floor(this.snapOffset/2):c&&(d=t.y+t.height-n.height),new m(p,d,n.width,n.height)}},n}(S),O=function(){},E=function(){};!function(n){var e={close:"unload"},t=function(t){function n(n){return t.call(this,n)||this}return s(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow[a.windowUuidPropertyKey]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow[a.windowNamePropertyKey]},enumerable:!0,configurable:!0}),n.prototype.load=function(t,n){var e=this;return new Promise(function(n){e.innerWindow.location.replace(t),n()})},n.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},n.prototype.show=function(){return Promise.resolve()},n.prototype.hide=function(){return Promise.resolve()},n.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},n.prototype.minimize=function(){var t=this;return new Promise(function(n){t.innerWindow.minimize(),n()})},n.prototype.maximize=function(){var t=this;return new Promise(function(n){t.innerWindow.maximize(),n()})},n.prototype.restore=function(){var t=this;return new Promise(function(n){t.innerWindow.restore(),n()})},n.prototype.isShowing=function(){return Promise.resolve(!0)},n.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},n.prototype.flash=function(n,t){return Promise.reject("Not supported")},n.prototype.getBounds=function(){var t=this;return new Promise(function(n){n(new m(t.innerWindow.screenX,t.innerWindow.screenY,t.innerWindow.outerWidth,t.innerWindow.outerHeight))})},n.prototype.setBounds=function(t){var e=this;return new Promise(function(n){e.innerWindow.moveTo(t.x,t.y),e.innerWindow.resizeTo(t.width,t.height),n()})},n.prototype.getOptions=function(){var e=this;return new Promise(function(n,t){n(e.innerWindow[w.windowOptionsPropertyKey])})},n.prototype.getState=function(){var t=this;return new Promise(function(n){t.nativeWindow&&t.nativeWindow.getState?n(t.nativeWindow.getState()):n(void 0)})},n.prototype.setState=function(t){var e=this;return new Promise(function(n){e.nativeWindow&&e.nativeWindow.setState&&e.nativeWindow.setState(t),n()})},n.prototype.attachListener=function(n,t){this.innerWindow.addEventListener(e[n]||n,t)},n.prototype.detachListener=function(n,t){this.innerWindow.removeEventListener(e[n]||n,t)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!0,configurable:!0}),n}(W);n.DefaultContainerWindow=t;var o=function(){function u(n){this.container=n}return u.prototype.subscribe=function(r,a,n){var s=this;return new Promise(function(n,t){var e=new p(r,function(n){if(n.origin===s.container.globalWindow.location.origin){var t=n.data,e=t.source,o=t.topic,i=t.message;e===u.messageSource&&r===o&&a({topic:r},i)}});s.container.globalWindow&&s.container.globalWindow.addEventListener&&s.container.globalWindow.addEventListener("message",e.listener),n(e)})},u.prototype.unsubscribe=function(n){return Promise.resolve(this.container.globalWindow.removeEventListener("message",n.listener))},u.prototype.publish=function(n,t,e){var o=this.container.globalWindow?this.container.globalWindow[a.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[a.windowsPropertyKey]:[];if(o)for(var i in o){var r=o[i];e&&e.name&&e.name!==r[a.windowNamePropertyKey]||r.location.origin===this.container.globalWindow.location.origin&&r.postMessage({source:u.messageSource,topic:n,message:t},this.container.globalWindow.location.origin)}return Promise.resolve()},u.messageSource="desktopJS",u}();n.DefaultMessageBus=o;var a=function(e){function u(n){var t=e.call(this,n)||this;return t.windowOptionsMap=u.defaultWindowOptionsMap,t.hostType="Default",t.ipc=t.createMessageBus(),!t.globalWindow||u.windowsPropertyKey in t.globalWindow||(t.globalWindow[u.windowsPropertyKey]={root:t.globalWindow}),t.screen=new i(t.globalWindow),t}return s(u,e),u.prototype.createMessageBus=function(){return new o(this)},u.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=new t(this.globalWindow)),this.mainWindow},u.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},u.prototype.getWindowOptions=function(n){return r.ObjectTransform.transformProperties(n,this.windowOptionsMap)},u.prototype.wrapWindow=function(n){return new t(n)},u.prototype.onOpen=function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];var o=n.apply(this.globalWindow,t),i=this.globalWindow[u.windowsPropertyKey],r=o[u.windowUuidPropertyKey]=c.newGuid();return(i[r]=o).addEventListener("beforeunload",function(){o.addEventListener("unload",function(){delete i[r]})}),o[u.windowsPropertyKey]=i,w.emit("window-created",{name:"window-created",windowId:r}),W.emit("window-created",{name:"window-created",windowId:r}),o},u.prototype.createWindow=function(n,t){var e,o="_blank",i=this.getWindowOptions(t);if(i){for(var r in i)e=(e||"")+r+"="+i[r]+",";i&&"target"in i&&(o=i.target)}var a=this.globalWindow.open(n,o,e);a[w.windowOptionsPropertyKey]=t,a[u.windowNamePropertyKey]=i.name;var s=this.wrapWindow(a);return this.emit("window-created",{sender:this,name:"window-created",window:s,windowId:s.id,windowName:i.name}),Promise.resolve(s)},u.prototype.showNotification=function(t,e){var o=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(n){"denied"===n?console.warn("Notifications not permitted"):"granted"===n&&new o.globalWindow.Notification(t,e)}):console.warn("Notifications not supported")},u.prototype.closeAllWindows=function(r){var a=this;return new Promise(function(n,t){var e=a.globalWindow[u.windowsPropertyKey];for(var o in e){var i=e[o];r&&a.globalWindow===i||i.close()}n()})},u.prototype.getAllWindows=function(){var r=this;return new Promise(function(n,t){var e=[],o=r.globalWindow[u.windowsPropertyKey];for(var i in o)e.push(r.wrapWindow(o[i]));n(e)})},u.prototype.getWindowById=function(o){var i=this;return new Promise(function(n,t){var e=i.globalWindow[u.windowsPropertyKey][o];n(e?i.wrapWindow(e):null)})},u.prototype.getWindowByName=function(i){var r=this;return new Promise(function(n,t){var e=r.globalWindow[u.windowsPropertyKey];for(var o in e)if(e[o][u.windowNamePropertyKey]===i)return void n(r.wrapWindow(e[o]));n(null)})},u.prototype.saveLayout=function(i){var d=this,f=new x;return new Promise(function(t,e){var o=[];d.getAllWindows().then(function(n){n.forEach(function(p){o.push(new Promise(function(r){return a=d,c=function(){var t,e,o,i;return l(this,function(n){switch(n.label){case 0:return t=p.nativeWindow,this.globalWindow===t?[3,2]:(o=(e=f.windows).push,i={name:p.name,url:t.location.toString(),id:p.id,bounds:{x:t.screenX,y:t.screenY,width:t.outerWidth,height:t.outerHeight},options:t[w.windowOptionsPropertyKey]},[4,p.getState()]);case 1:o.apply(e,[(i.state=n.sent(),i)]),n.label=2;case 2:return r(),[2]}})},new((u=s=void 0)||(u=Promise))(function(n,t){function e(n){try{i(c.next(n))}catch(n){t(n)}}function o(n){try{i(c.throw(n))}catch(n){t(n)}}function i(t){t.done?n(t.value):new u(function(n){n(t.value)}).then(e,o)}i((c=c.apply(a,s||[])).next())});var a,s,u,c}))}),Promise.all(o).then(function(){d.saveLayoutToStorage(i,f),t(f)}).catch(function(n){return e(n)})})})},u.windowsPropertyKey="desktopJS-windows",u.windowUuidPropertyKey="desktopJS-uuid",u.windowNamePropertyKey="desktopJS-name",u.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},u}(u);n.DefaultContainer=a;var i=function(){function n(n){this.window=n}return n.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(n){var t=new E;t.scaleFactor=e.window.devicePixelRatio,t.id="Current",t.bounds=new m(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.width,e.window.screen.height),t.workArea=new m(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.availWidth,e.window.screen.availHeight),n(t)})},n.prototype.getAllDisplays=function(){var n=this;return new Promise(function(t){n.getPrimaryDisplay().then(function(n){return t([n])})})},n.prototype.getMousePosition=function(){var e=this;return new Promise(function(n,t){n({x:e.window.event.screenX,y:e.window.event.screenY})})},n}()}(r.Default||(r.Default={}));var M=function(){},T=new Map;var k=function(){};r.version="3.0.0",r.LayoutEventArgs=n,r.Container=w,r.ContainerBase=t,r.WebContainerBase=u,r.EventArgs=a,r.EventEmitter=i,r.Guid=c,r.MessageBusSubscription=p,r.MessageBusOptions=e,r.MenuItem=d,r.NotificationOptions=f,r.ContainerNotification=h,r.PropertyMap=y,r.ContainerRegistration=M,r.clearRegistry=function(){T.clear(),r.container=void 0},r.registerContainer=function(n,t){T[n]=t},r.resolveContainer=function(n,t){var e=!1,o=t;if("boolean"==typeof n?e=n:o=n,!e&&r.container)return r.container;for(var i in T)try{if(T[i].condition(o))return r.container=T[i].create(o)}catch(n){console.error("Error resolving container '"+i+"': "+n.toString())}return r.container=new r.Default.DefaultContainer},r.Point=O,r.Display=E,r.TrayIconDetails=k,r.Rectangle=m,r.WindowEventArgs=b,r.ContainerWindow=W,r.PersistedWindow=P,r.PersistedWindowLayout=x,r.GroupWindowManager=S,r.SnapAssistWindowManager=L,Object.defineProperty(r,"__esModule",{value:!0})});
"undefined"==typeof desktopJS&&function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).desktopJS={})}(this,function(r){"use strict";var o=function(n,t){return(o=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 s(n,t){function e(){this.constructor=n}o(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}function l(e,o){var i,r,a,n,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(a=2&t[0]?r.return:t[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,t[1])).done)return a;switch(r=0,a&&(t=[2&t[0],a.value]),t[0]){case 0:case 1:a=t;break;case 4:return s.label++,{value:t[1],done:!1};case 5:s.label++,r=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3])){s.label=t[1];break}if(6===t[0]&&s.label<a[1]){s.label=a[1],a=t;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(t);break}a[2]&&s.ops.pop(),s.trys.pop();continue}t=o.call(e,s)}catch(n){t=[6,n],r=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,n])}}}var a=function(n,t,e){this.sender=n,this.name=t,this.innerEvent=e},i=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(n,t){return(this.eventListeners[n]=this.eventListeners[n]||[]).push(t),this},r.prototype.registerAndWrapListener=function(n,t){var e=this.wrapListener(n,t);return this.wrappedListeners.set(t,e),e},r.prototype.wrapListener=function(o,i){var r=this;return function(n){var t=new a(r,o,n);r.preProcessArgs(t);var e=i(t);return r.postProcessArgs(t),e}},r.prototype.preProcessArgs=function(n){},r.prototype.postProcessArgs=function(n){n&&void 0!==n.returnValue&&(n.innerEvent.returnValue=n.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(n){var t=this.wrappedListeners.get(n);return t&&this.wrappedListeners.delete(n),t},r.prototype.removeListener=function(n,t){var e=this.listeners(n);if(e){var o=e.indexOf(t);0<=o&&e.splice(o,1)}return this},r.prototype.listeners=function(n){return this.eventListeners[n]||[]},r.prototype.emit=function(n,t){for(var e=0,o=this.listeners(n);e<o.length;e++){(0,o[e])(t)}},Object.defineProperty(r,"ipc",{set:function(n){n&&n.subscribe(r.staticEventName,function(n,t){r.emit(t.eventName,t.eventArgs)})},enumerable:!0,configurable:!0}),r.addListener=function(n,t){(this.staticEventListeners[n]=this.staticEventListeners[n]||[]).push(t)},r.removeListener=function(n,t){var e=r.listeners(n);if(e){var o=e.indexOf(t);0<=o&&e.splice(o,1)}},r.listeners=function(n){return this.staticEventListeners[n]||[]},r.emit=function(n,t,e){if(e&&e.publish)e.publish(r.staticEventName,{eventName:n,eventArgs:t});else for(var o=0,i=r.listeners(n);o<i.length;o++){(0,i[o])(t)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),c=function(){function n(){}return n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var t=16*Math.random()|0;return("x"==n?t:3&t|8).toString(16)})},n}(),n=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return s(t,n),t}(a),w=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return s(o,e),Object.defineProperty(o,"ipc",{get:function(){return o._ipc},set:function(n){i.ipc=o._ipc=n},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"ipc",{get:function(){return o.ipc},set:function(n){o.ipc=n},enumerable:!0,configurable:!0}),o.prototype.addListener=function(n,t){return e.prototype.addListener.call(this,n,t)},o.prototype.removeListener=function(n,t){return e.prototype.removeListener.call(this,n,t)},o.prototype.emit=function(n,t){e.prototype.emit.call(this,n,t)},o.addListener=function(n,t){i.addListener(o.staticEventScopePrefix+n,t)},o.removeListener=function(n,t){i.removeListener(o.staticEventScopePrefix+n,t)},o.emit=function(n,t){i.emit(o.staticEventScopePrefix+n,t,o.ipc)},o.listeners=function(n){return i.listeners(o.staticEventScopePrefix+n)},o.staticEventScopePrefix="container-",o.windowOptionsPropertyKey="desktopJS-options",o}(i),t=function(t){function r(){var n=null!==t&&t.apply(this,arguments)||this;return n.uuid=c.newGuid(),n.storage="undefined"!=typeof window&&window?window.localStorage:void 0,n}return s(r,t),r.prototype.showNotification=function(n,t){throw new TypeError("Notifications not supported by this container")},r.prototype.addTrayIcon=function(n,t,e){throw new TypeError("Tray icons are not supported by this container.")},r.prototype.getLayoutFromStorage=function(n){return JSON.parse(this.storage.getItem(r.layoutsPropertyKey))[n]},r.prototype.saveLayoutToStorage=function(n,t){var e=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{};t.name||(t.name=n),e[n]=t,this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(e)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:t,layoutName:t.name}),w.emit("layout-saved",{name:"layout-saved",layout:t,layoutName:t.name})},r.prototype.loadLayout=function(u){var c=this;return new Promise(function(a,s){c.closeAllWindows(!0).then(function(){var r=c.getLayoutFromStorage(u);if(r&&r.windows){for(var n=[],t=0,e=r.windows;t<e.length;t++){var o=e[t],i=Object.assign(o.options||{},o.bounds);i.name=o.name,o.main?(c.getMainWindow().setBounds(o.bounds),n.push(Promise.resolve(c.getMainWindow()))):n.push(c.createWindow(o.url,i))}Promise.all(n).then(function(n){var i=new Map;n.forEach(function(e){var n=r.windows.find(function(n){return n.name===e.name});n&&n.state&&e.setState&&e.setState(n.state).catch(function(n){return c.log("error","Error invoking setState: "+n)});var o=!1;if(i.forEach(function(n,t){!o&&0<=n.indexOf(e.id)&&(o=!0)}),!o){var t=n?n.group:void 0;t&&0<t.length&&i.set(e,t.filter(function(n){return n!==e.id}))}}),i.forEach(function(n,e){n.forEach(function(t){c.getWindowByName(r.windows.find(function(n){return n.id===t}).name).then(function(n){n.joinGroup(e)})})})}),c.emit("layout-loaded",{sender:c,name:"layout-loaded",layout:r,layoutName:r.name}),w.emit("layout-loaded",{name:"layout-loaded",layout:r,layoutName:r.name}),a(r)}else s("Layout does not exist")})})},r.prototype.getLayouts=function(){var i=this;return new Promise(function(n,t){var e=i.storage.getItem(r.layoutsPropertyKey);if(e){var o=JSON.parse(e);n(Object.getOwnPropertyNames(o).map(function(n){return o[n]}))}n(void 0)})},r.prototype.log=function(e,o){return new Promise(function(n){var t;switch(e){case"debug":t=console.debug;break;case"warn":t=console.warn;break;case"error":t=console.error;break;default:t=console.log}t&&t(o),n()})},r.layoutsPropertyKey="desktopJS-layouts",r}(w),u=function(t){function n(n){var e=t.call(this)||this;e.globalWindow=n||"undefined"!=typeof window&&window||null,e.linkHelper={href:"unknown"};try{e.linkHelper=e.globalWindow.top.document.createElement("a")}catch(n){}if(e.globalWindow){var o=e.globalWindow.open;e.globalWindow.open=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e.onOpen.apply(e,[o].concat(n))}}return e}return s(n,t),n.prototype.onOpen=function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return n.apply(this.globalWindow,t)},n.prototype.ensureAbsoluteUrl=function(n){return this.linkHelper?(this.linkHelper.href=n,this.linkHelper.href):n},n}(t),p=function(n,t,e){this.topic=n,this.listener=t,this.options=e},e=function(){},d=function(){},f=function(){},h=function(){function t(n,t){}return t.requestPermission=function(n){return n&&n(t.permission),Promise.resolve(t.permission)},t.permission="granted",t}(),y=function(){};(r.ObjectTransform||(r.ObjectTransform={})).transformProperties=function(n,t){var e={};if(n)for(var o in n)try{o in t?e[t[o].target]=t[o].convert?t[o].convert(n[o],n,e):n[o]:e[o]=n[o]}catch(n){console.error("Error transforming property '"+o+"'")}return e};var g,v=function(){function n(n,t,e,o){this.x=n,this.y=t,this.width=e,this.height=o}return Object.defineProperty(n.prototype,"right",{get:function(){return n.getRight(this)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return n.getBottom(this)},enumerable:!0,configurable:!0}),n.getRight=function(n){return n.x+n.width},n.getBottom=function(n){return n.y+n.height},n}(),m=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return s(t,n),t}(a),b=function(n){function t(){return null!==n&&n.apply(this,arguments)||this}return s(t,n),t}(m),W=function(o){function e(n){var t=o.call(this)||this;return t.innerWindow=n,t}return s(e,o),Object.defineProperty(e.prototype,"allowGrouping",{get:function(){return!1},enumerable:!0,configurable:!0}),e.prototype.getGroup=function(){return Promise.resolve([])},e.prototype.joinGroup=function(n){return Promise.reject("Not supported")},e.prototype.leaveGroup=function(){return Promise.resolve()},e.prototype.bringToFront=function(){return this.focus()},e.prototype.getState=function(){return Promise.resolve(void 0)},e.prototype.setState=function(n){return Promise.resolve()},Object.defineProperty(e.prototype,"nativeWindow",{get:function(){},enumerable:!0,configurable:!0}),e.prototype.addListener=function(n,t){var e=this.registerAndWrapListener(n,t);return this.attachListener(n,e),o.prototype.addListener.call(this,n,e)},e.prototype.removeListener=function(n,t){var e=this.unwrapAndUnRegisterListener(t)||t;return this.detachListener(n,e),o.prototype.removeListener.call(this,n,e)},e.addListener=function(n,t){i.addListener(e.staticEventScopePrefix+n,t)},e.removeListener=function(n,t){i.removeListener(e.staticEventScopePrefix+n,t)},e.emit=function(n,t){i.emit(e.staticEventScopePrefix+n,t,w.ipc)},e.listeners=function(n){return i.listeners(e.staticEventScopePrefix+n)},e.staticEventScopePrefix="containerwindow-",e}(i),P=function(){},x=function(n){this.windows=[],this.name=n};function S(){return"undefined"!=typeof window&&window.fin}(g=r.WindowStateTracking||(r.WindowStateTracking={}))[g.None=0]="None",g[g.Main=1]="Main",g[g.Group=2]="Group";var L=function(){function n(n,t){this.windowStateTracking=r.WindowStateTracking.None,this.container=n,t&&"windowStateTracking"in t&&(this.windowStateTracking=t.windowStateTracking),this.attach()}return n.prototype.attach=function(n){var t=this;n?(n.addListener(S()?"minimized":"minimize",function(n){t.windowStateTracking&r.WindowStateTracking.Main&&t.container.getMainWindow().id===n.sender.id&&t.container.getAllWindows().then(function(n){n.forEach(function(n){return n.minimize()})}),t.windowStateTracking&r.WindowStateTracking.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.minimize()})})}),n.addListener(S()?"restored":"restore",function(n){t.windowStateTracking&r.WindowStateTracking.Main&&t.container.getMainWindow().id===n.sender.id&&t.container.getAllWindows().then(function(n){n.forEach(function(n){return n.restore()})}),t.windowStateTracking&r.WindowStateTracking.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.restore()})})})):(W.addListener("window-created",function(n){t.container&&t.container.getWindowById&&t.container.getWindowById(n.windowId).then(function(n){t.attach(n)})}),this.container&&this.container.getAllWindows().then(function(n){n.forEach(function(n){return t.attach(n)})}))},n}(),O=function(o){function n(n,t){var e=o.call(this,n,t)||this;return e.autoGrouping=!0,e.snapThreshold=15,e.snapOffset=15,e.targetGroup=new Map,t&&("snapThreshold"in t&&(e.snapThreshold=t.snapThreshold),"snapOffset"in t&&(e.snapOffset=t.snapOffset),"autoGrouping"in t&&(e.autoGrouping=t.autoGrouping)),e}return s(n,o),n.prototype.onAttached=function(n){var t=this;n.innerWindow&&n.innerWindow.disableFrame&&n.innerWindow.disableFrame(),S()?(n.addListener("disabled-frame-bounds-changed",function(){return t.onMoved(n)}),n.addListener("frame-enabled",function(){return n.innerWindow.disableFrame()})):n.innerWindow&&n.innerWindow.hookWindowMessage&&n.innerWindow.hookWindowMessage(562,function(){return t.onMoved(n)})},n.prototype.attach=function(t){var e=this;o.prototype.attach.call(this,t),t&&t.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||(e.onAttached(t),t.addListener(S()?"disabled-frame-bounds-changing":"move",function(n){return e.onMoving(n)}))})},n.prototype.onMoving=function(s){var u=this,e=s.sender.id;this.snappingWindow!==e&&s.sender.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||s.sender.getGroup().then(function(n){(S()?Promise.resolve(new v(s.innerEvent.left,s.innerEvent.top,s.innerEvent.width,s.innerEvent.height)):s.sender.getBounds()).then(function(a){if(0<n.length)S()&&u.moveWindow(s.sender,a);else{var t=[];u.container.getAllWindows().then(function(n){n.filter(function(n){return e!==n.id}).forEach(function(o){t.push(new Promise(function(e){o.getOptions().then(function(t){o.getBounds().then(function(n){return e({window:o,bounds:n,options:t})})})}))}),Promise.all(t).then(function(n){for(var t,e=!1,o=0,i=n.filter(function(n){return!(n.options&&void 0!==n.options.snap&&!1===n.options.snap)});o<i.length;o++){var r=i[o];(t=u.getSnapBounds(t||a,r.bounds))?(e=!0,u.showGroupingHint(r.window),u.moveWindow(s.sender,t)):u.hideGroupingHint(r.window)}!e&&S()&&u.moveWindow(s.sender,a)})})}})})})},n.prototype.moveWindow=function(n,t){var e=this;this.snappingWindow=n.id,n.setBounds(t).then(function(){return e.snappingWindow=void 0},function(){return e.snappingWindow=void 0})},n.prototype.onMoved=function(e){var t=this;if(this.autoGrouping){var n=[];this.targetGroup.forEach(function(e){return n.push(new Promise(function(t){e.getGroup().then(function(n){return t({window:e,isGrouped:0<n.length})})}))}),Promise.all(n).then(function(n){0<n.length&&e.joinGroup(n[0].window);for(var t=1;t<n.length;t++)n[t].isGrouped||n[t].window.joinGroup(e)})}this.targetGroup.forEach(function(n){return t.hideGroupingHint(n)}),this.targetGroup.clear()},n.prototype.showGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:.75}),this.targetGroup.set(n.id,n)},n.prototype.hideGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:1}),this.targetGroup.delete(n.id)},n.prototype.isHorizontallyAligned=function(n,t){return n.y>=t.y&&n.y<=t.bottom||n.bottom>=t.y&&n.bottom<=t.bottom||n.y<=t.y&&n.bottom>=t.bottom},n.prototype.isVerticallyAligned=function(n,t){return n.x>=t.x&&n.x<=t.right||n.right>=t.x&&n.right<=t.right||n.x<=t.x&&n.right>=t.right},n.prototype.getSnapBounds=function(n,t){var e,o,i,r,a,s,u,c;if(this.isHorizontallyAligned(n,t)&&(e=Math.abs(n.x-(t.right-this.snapOffset))<this.snapThreshold,o=Math.abs(n.x-t.x)<this.snapThreshold,i=Math.abs(n.right-this.snapOffset-t.x)<this.snapThreshold,r=Math.abs(n.right-t.right)<this.snapThreshold),this.isVerticallyAligned(n,t)&&(a=Math.abs(n.y-(t.bottom-this.snapOffset))<this.snapThreshold,s=Math.abs(n.y-t.y)<this.snapThreshold,u=Math.abs(n.bottom-this.snapOffset-t.y)<this.snapThreshold,c=Math.abs(n.bottom-t.bottom)<this.snapThreshold),e||i||a||u){var p=n.x,d=n.y;return e?p=t.x+t.width-this.snapOffset:o&&(p=t.x),i?p=t.x-n.width+this.snapOffset:r&&(p=t.x+t.width-n.width),a?d=t.y+t.height-Math.floor(this.snapOffset/2):s&&(d=t.y),u?d=t.y-n.height+Math.floor(this.snapOffset/2):c&&(d=t.y+t.height-n.height),new v(p,d,n.width,n.height)}},n}(L),E=function(){},M=function(){};!function(n){var e={close:"unload"},t=function(t){function n(n){return t.call(this,n)||this}return s(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow[a.windowUuidPropertyKey]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow[a.windowNamePropertyKey]},enumerable:!0,configurable:!0}),n.prototype.load=function(t,n){var e=this;return new Promise(function(n){e.innerWindow.location.replace(t),n()})},n.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},n.prototype.show=function(){return Promise.resolve()},n.prototype.hide=function(){return Promise.resolve()},n.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},n.prototype.minimize=function(){var t=this;return new Promise(function(n){t.innerWindow.minimize(),n()})},n.prototype.maximize=function(){var t=this;return new Promise(function(n){t.innerWindow.maximize(),n()})},n.prototype.restore=function(){var t=this;return new Promise(function(n){t.innerWindow.restore(),n()})},n.prototype.isShowing=function(){return Promise.resolve(!0)},n.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},n.prototype.flash=function(n,t){return Promise.reject("Not supported")},n.prototype.getBounds=function(){var t=this;return new Promise(function(n){n(new v(t.innerWindow.screenX,t.innerWindow.screenY,t.innerWindow.outerWidth,t.innerWindow.outerHeight))})},n.prototype.setBounds=function(t){var e=this;return new Promise(function(n){e.innerWindow.moveTo(t.x,t.y),e.innerWindow.resizeTo(t.width,t.height),n()})},n.prototype.getOptions=function(){var e=this;return new Promise(function(n,t){n(e.innerWindow[w.windowOptionsPropertyKey])})},n.prototype.getState=function(){var t=this;return new Promise(function(n){t.nativeWindow&&t.nativeWindow.getState?n(t.nativeWindow.getState()):n(void 0)})},n.prototype.setState=function(t){var e=this;return new Promise(function(n){e.nativeWindow&&e.nativeWindow.setState&&e.nativeWindow.setState(t),n()})},n.prototype.attachListener=function(n,t){this.innerWindow.addEventListener(e[n]||n,t)},n.prototype.detachListener=function(n,t){this.innerWindow.removeEventListener(e[n]||n,t)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!0,configurable:!0}),n}(W);n.DefaultContainerWindow=t;var o=function(){function u(n){this.container=n}return u.prototype.subscribe=function(r,a,n){var s=this;return new Promise(function(n,t){var e=new p(r,function(n){if(n.origin===s.container.globalWindow.location.origin){var t=n.data,e=t.source,o=t.topic,i=t.message;e===u.messageSource&&r===o&&a({topic:r},i)}});s.container.globalWindow&&s.container.globalWindow.addEventListener&&s.container.globalWindow.addEventListener("message",e.listener),n(e)})},u.prototype.unsubscribe=function(n){return Promise.resolve(this.container.globalWindow.removeEventListener("message",n.listener))},u.prototype.publish=function(n,t,e){var o=this.container.globalWindow?this.container.globalWindow[a.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[a.windowsPropertyKey]:[];if(o)for(var i in o){var r=o[i];e&&e.name&&e.name!==r[a.windowNamePropertyKey]||r.location.origin===this.container.globalWindow.location.origin&&r.postMessage({source:u.messageSource,topic:n,message:t},this.container.globalWindow.location.origin)}return Promise.resolve()},u.messageSource="desktopJS",u}();n.DefaultMessageBus=o;var a=function(e){function u(n){var t=e.call(this,n)||this;return t.windowOptionsMap=u.defaultWindowOptionsMap,t.hostType="Default",t.ipc=t.createMessageBus(),!t.globalWindow||u.windowsPropertyKey in t.globalWindow||(t.globalWindow[u.windowsPropertyKey]={root:t.globalWindow}),t.screen=new i(t.globalWindow),t}return s(u,e),u.prototype.createMessageBus=function(){return new o(this)},u.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=new t(this.globalWindow)),this.mainWindow},u.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},u.prototype.getWindowOptions=function(n){return r.ObjectTransform.transformProperties(n,this.windowOptionsMap)},u.prototype.wrapWindow=function(n){return new t(n)},u.prototype.onOpen=function(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];var o=n.apply(this.globalWindow,t),i=this.globalWindow[u.windowsPropertyKey],r=o[u.windowUuidPropertyKey]=c.newGuid();return(i[r]=o).addEventListener("beforeunload",function(){o.addEventListener("unload",function(){delete i[r]})}),o[u.windowsPropertyKey]=i,w.emit("window-created",{name:"window-created",windowId:r}),W.emit("window-created",{name:"window-created",windowId:r}),o},u.prototype.createWindow=function(n,t){var e,o="_blank",i=this.getWindowOptions(t);if(i){for(var r in i)e=(e||"")+r+"="+i[r]+",";i&&"target"in i&&(o=i.target)}var a=this.globalWindow.open(n,o,e);a[w.windowOptionsPropertyKey]=t,a[u.windowNamePropertyKey]=i.name;var s=this.wrapWindow(a);return this.emit("window-created",{sender:this,name:"window-created",window:s,windowId:s.id,windowName:i.name}),Promise.resolve(s)},u.prototype.showNotification=function(t,e){var o=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(n){"denied"===n?console.warn("Notifications not permitted"):"granted"===n&&new o.globalWindow.Notification(t,e)}):console.warn("Notifications not supported")},u.prototype.closeAllWindows=function(r){var a=this;return new Promise(function(n,t){var e=a.globalWindow[u.windowsPropertyKey];for(var o in e){var i=e[o];r&&a.globalWindow===i||i.close()}n()})},u.prototype.getAllWindows=function(){var r=this;return new Promise(function(n,t){var e=[],o=r.globalWindow[u.windowsPropertyKey];for(var i in o)e.push(r.wrapWindow(o[i]));n(e)})},u.prototype.getWindowById=function(o){var i=this;return new Promise(function(n,t){var e=i.globalWindow[u.windowsPropertyKey][o];n(e?i.wrapWindow(e):null)})},u.prototype.getWindowByName=function(i){var r=this;return new Promise(function(n,t){var e=r.globalWindow[u.windowsPropertyKey];for(var o in e)if(e[o][u.windowNamePropertyKey]===i)return void n(r.wrapWindow(e[o]));n(null)})},u.prototype.saveLayout=function(i){var d=this,f=new x;return new Promise(function(t,e){var o=[];d.getAllWindows().then(function(n){n.forEach(function(p){o.push(new Promise(function(r){return a=d,c=function(){var t,e,o,i;return l(this,function(n){switch(n.label){case 0:return t=p.nativeWindow,this.globalWindow===t?[3,2]:(o=(e=f.windows).push,i={name:p.name,url:t.location.toString(),id:p.id,bounds:{x:t.screenX,y:t.screenY,width:t.outerWidth,height:t.outerHeight},options:t[w.windowOptionsPropertyKey]},[4,p.getState()]);case 1:o.apply(e,[(i.state=n.sent(),i)]),n.label=2;case 2:return r(),[2]}})},new((u=s=void 0)||(u=Promise))(function(n,t){function e(n){try{i(c.next(n))}catch(n){t(n)}}function o(n){try{i(c.throw(n))}catch(n){t(n)}}function i(t){t.done?n(t.value):new u(function(n){n(t.value)}).then(e,o)}i((c=c.apply(a,s||[])).next())});var a,s,u,c}))}),Promise.all(o).then(function(){d.saveLayoutToStorage(i,f),t(f)}).catch(function(n){return e(n)})})})},u.windowsPropertyKey="desktopJS-windows",u.windowUuidPropertyKey="desktopJS-uuid",u.windowNamePropertyKey="desktopJS-name",u.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},u}(u);n.DefaultContainer=a;var i=function(){function n(n){this.window=n}return n.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(n){var t=new M;t.scaleFactor=e.window.devicePixelRatio,t.id="Current",t.bounds=new v(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.width,e.window.screen.height),t.workArea=new v(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.availWidth,e.window.screen.availHeight),n(t)})},n.prototype.getAllDisplays=function(){var n=this;return new Promise(function(t){n.getPrimaryDisplay().then(function(n){return t([n])})})},n.prototype.getMousePosition=function(){var e=this;return new Promise(function(n,t){n({x:e.window.event.screenX,y:e.window.event.screenY})})},n}()}(r.Default||(r.Default={}));var T=function(){},k=new Map;var G=function(){},N=function(){};r.version="3.1.0",r.LayoutEventArgs=n,r.Container=w,r.ContainerBase=t,r.WebContainerBase=u,r.EventArgs=a,r.EventEmitter=i,r.Guid=c,r.MessageBusSubscription=p,r.MessageBusOptions=e,r.MenuItem=d,r.NotificationOptions=f,r.ContainerNotification=h,r.PropertyMap=y,r.ContainerRegistration=T,r.clearRegistry=function(){k.clear(),r.container=void 0},r.registerContainer=function(n,t){k[n]=t},r.resolveContainer=function(n,t){var e=!1,o=t;if("boolean"==typeof n?e=n:o=n,!e&&r.container)return r.container;for(var i in k)try{if(k[i].condition(o))return r.container=k[i].create(o)}catch(n){console.error("Error resolving container '"+i+"': "+n.toString())}return r.container=new r.Default.DefaultContainer},r.Point=E,r.Display=M,r.TrayIconDetails=G,r.Rectangle=v,r.WindowEventArgs=m,r.WindowGroupEventArgs=b,r.ContainerWindow=W,r.PersistedWindow=P,r.PersistedWindowLayout=x,r.GroupWindowManager=L,r.SnapAssistWindowManager=O,r.GlobalShortcutManager=N,Object.defineProperty(r,"__esModule",{value:!0})});
//# sourceMappingURL=desktop.min.js.map

@@ -65,2 +65,6 @@ // Generated by dts-bundle v0.7.3

screen: ScreenManager;
/**
* Register/unregister global keyboard shortcut with the operating system.
*/
globalShortcut: GlobalShortcutManager;
addListener(eventName: ContainerEventType, listener: (event: ContainerEventArgs) => void): this;

@@ -438,3 +442,3 @@ removeListener(eventName: ContainerEventType, listener: (event: ContainerEventArgs) => void): this;

}
export type WindowEventType = "window-created" | "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore" | "beforeunload";
export type WindowEventType = "window-created" | "window-joinGroup" | "window-leaveGroup" | "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore" | "beforeunload";
export class WindowEventArgs extends EventArgs {

@@ -445,2 +449,5 @@ readonly window?: ContainerWindow;

}
export class WindowGroupEventArgs extends WindowEventArgs {
readonly targetWindowId?: string;
}
/** Represents a container window. */

@@ -484,2 +491,3 @@ export abstract class ContainerWindow extends EventEmitter {

leaveGroup(): Promise<void>;
bringToFront(): Promise<void>;
abstract getOptions(): Promise<any>;

@@ -514,5 +522,5 @@ /** Retrieves custom window state from underlying native window by invoking 'window.getState()' if defined. */

removeListener(eventName: WindowEventType, listener: (event: EventArgs) => void): this;
static addListener(eventName: WindowEventType, listener: (event: WindowEventArgs) => void): void;
static removeListener(eventName: WindowEventType, listener: (event: WindowEventArgs) => void): void;
static emit(eventName: WindowEventType, eventArgs: WindowEventArgs): void;
static addListener(eventName: WindowEventType, listener: (event: WindowEventArgs | WindowGroupEventArgs) => void): void;
static removeListener(eventName: WindowEventType, listener: (event: WindowEventArgs | WindowGroupEventArgs) => void): void;
static emit(eventName: WindowEventType, eventArgs: WindowEventArgs | WindowGroupEventArgs): void;
static listeners(eventName: string): ((event: EventArgs) => void)[];

@@ -620,2 +628,23 @@ }

/** Register/unregister a glboal keyboard shortcut with the operating system so that you
* can customize the operations for various shortcuts.
*/
export abstract class GlobalShortcutManager {
/** Registers a global shortcut.
* @param shortcut {string} [Accelerator]{@link https://electronjs.org/docs/api/accelerator}
*/
abstract register(shortcut: string, callback: () => void): Promise<void>;
/** Checks if a given shortcut has been registered.
* @param shortcut {string} [Accelerator]{@link https://electronjs.org/docs/api/accelerator}
* @returns {Promise<boolean>} A Promise that resolves to a boolean whether the shortcut is already registered.
*/
abstract isRegistered(shortcut: string): Promise<boolean>;
/** Removes a previously registered shortcut.
* @param shortcut {string} [Accelerator]{@link https://electronjs.org/docs/api/accelerator}
*/
abstract unregister(shortcut: string): Promise<void>;
/** Removes all registered shortcuts for the current application. */
abstract unregisterAll(): Promise<void>;
}
/**

@@ -622,0 +651,0 @@ * @module @morgan-stanley/desktopjs

@@ -481,3 +481,2 @@ var desktopJS = (function (exports) {

var fin = (typeof window !== "undefined") ? window.fin : undefined;
var Rectangle = (function () {

@@ -519,2 +518,9 @@ function Rectangle(x, y, width, height) {

}(EventArgs));
var WindowGroupEventArgs = (function (_super) {
__extends(WindowGroupEventArgs, _super);
function WindowGroupEventArgs() {
return _super !== null && _super.apply(this, arguments) || this;
}
return WindowGroupEventArgs;
}(WindowEventArgs));
var ContainerWindow = (function (_super) {

@@ -543,2 +549,5 @@ __extends(ContainerWindow, _super);

};
ContainerWindow.prototype.bringToFront = function () {
return this.focus();
};
ContainerWindow.prototype.getState = function () {

@@ -599,2 +608,5 @@ return Promise.resolve(undefined);

})(exports.WindowStateTracking || (exports.WindowStateTracking = {}));
function isOpenFin() {
return (typeof window !== "undefined" && window.fin);
}
var GroupWindowManager = (function () {

@@ -614,3 +626,3 @@ function GroupWindowManager(container, options) {

if (win) {
win.addListener((typeof fin !== "undefined") ? "minimized" : "minimize", function (e) {
win.addListener(isOpenFin() ? "minimized" : "minimize", function (e) {
if ((_this.windowStateTracking & exports.WindowStateTracking.Main) && _this.container.getMainWindow().id === e.sender.id) {

@@ -627,3 +639,3 @@ _this.container.getAllWindows().then(function (windows) {

});
win.addListener((typeof fin !== "undefined") ? "restored" : "restore", function (e) {
win.addListener(isOpenFin() ? "restored" : "restore", function (e) {
if ((_this.windowStateTracking & exports.WindowStateTracking.Main) && _this.container.getMainWindow().id === e.sender.id) {

@@ -684,4 +696,5 @@ _this.container.getAllWindows().then(function (windows) {

}
if (typeof fin !== "undefined") {
if (isOpenFin()) {
win.addListener("disabled-frame-bounds-changed", function () { return _this.onMoved(win); });
win.addListener("frame-enabled", function () { return win.innerWindow.disableFrame(); });
}

@@ -703,3 +716,3 @@ else {

_this.onAttached(win);
win.addListener((typeof fin !== "undefined") ? "disabled-frame-bounds-changing" : "move", function (e) { return _this.onMoving(e); });
win.addListener(isOpenFin() ? "disabled-frame-bounds-changing" : "move", function (e) { return _this.onMoving(e); });
});

@@ -719,3 +732,3 @@ }

e.sender.getGroup().then(function (groupedWindows) {
var getBounds = (typeof fin !== "undefined")
var getBounds = (isOpenFin())
? Promise.resolve(new Rectangle(e.innerEvent.left, e.innerEvent.top, e.innerEvent.width, e.innerEvent.height))

@@ -725,3 +738,3 @@ : e.sender.getBounds();

if (groupedWindows.length > 0) {
if (typeof fin !== "undefined") {
if (isOpenFin()) {
_this.moveWindow(e.sender, bounds);

@@ -755,3 +768,3 @@ }

}
if (!isSnapped && typeof fin !== "undefined") {
if (!isSnapped && isOpenFin()) {
_this.moveWindow(e.sender, bounds);

@@ -1299,4 +1312,10 @@ }

var version = "3.0.0";
var GlobalShortcutManager = (function () {
function GlobalShortcutManager() {
}
return GlobalShortcutManager;
}());
var version = "3.1.0";
exports.version = version;

@@ -1325,2 +1344,3 @@ exports.LayoutEventArgs = LayoutEventArgs;

exports.WindowEventArgs = WindowEventArgs;
exports.WindowGroupEventArgs = WindowGroupEventArgs;
exports.ContainerWindow = ContainerWindow;

@@ -1331,2 +1351,3 @@ exports.PersistedWindow = PersistedWindow;

exports.SnapAssistWindowManager = SnapAssistWindowManager;
exports.GlobalShortcutManager = GlobalShortcutManager;

@@ -1333,0 +1354,0 @@ return exports;

@@ -5,6 +5,6 @@ {

"description": "Library for abstracting common container hosting",
"version": "3.0.0",
"version": "3.1.0",
"publishConfig": {
"access": "public"
},
},
"main": "dist/desktop.js",

@@ -39,10 +39,10 @@ "types": "dist/desktopjs.d.ts",

"watch": "gulp watch",
"deploy": "npm publish"
"deploy": "npm publish",
"prepublishOnly": "copyfiles ../../README.md . -u 2"
},
"dependencies": {},
"devDependencies": {
"@types/jasmine": "^2.8.11",
"gulp": "^3.9.1",
"run-sequence": "^2.2.1"
"copyfiles": "^2.1.0",
"gulp": "^4.0.0"
}
}

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