New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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 1.0.0 to 2.0.0

2

dist/desktop.min.js

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.desktopJS=t()}(this,function(){"use strict";function n(n,t){function e(){this.constructor=n}for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}function t(n,t){W[n]=t}function e(n){if(!n&&g)return g;for(var t in W)try{if(W[t].condition())return g=W[t].create()}catch(n){console.error("Error resolving container '"+t+"': "+n.toString())}return g=new y}var o=function(){function n(n,t,e){this.sender=n,this.name=t,this.innerEvent=e}return n}(),i=function(){function n(t){var e=this;this.eventListeners=new Map,this.wrappedListeners=new Map,t&&t.subscribe(n.staticEventName,function(n,t){e.emit(t.eventName,t.eventArgs)})}return n.prototype.addListener=function(n,t){return(this.eventListeners[n]=this.eventListeners[n]||[]).push(t),this},n.prototype.registerAndWrapListener=function(n,t){var e=this,i=function(i){t(new o(e,n,i))};return this.wrappedListeners.set(t,i),i},n.prototype.unwrapAndUnRegisterListener=function(n){var t=this.wrappedListeners.get(n);return t&&this.wrappedListeners.delete(n),t},n.prototype.removeListener=function(n,t){var e=this.listeners(n);if(e){var o=e.indexOf(t);o>=0&&e.splice(o,1)}return this},n.prototype.listeners=function(n){return this.eventListeners[n]||[]},n.prototype.emit=function(t,e,o){if(o)o.publish(n.staticEventName,{eventName:t,eventArgs:e});else for(var i=0,r=this.listeners(t);i<r.length;i++){var s=r[i];s(e)}},n}();i.staticEventName="desktopJS.static-event";var r=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}(),s=(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}n(e,t)}(o),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}n(e,t)}(o),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e,"ipc",{get:function(){return e._ipc},set:function(n){e._ipc=n,e.staticEmitter=new i(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ipc",{get:function(){return e.ipc},set:function(n){e.ipc=n},enumerable:!0,configurable:!0}),e.prototype.addListener=function(n,e){return t.prototype.addListener.call(this,n,e)},e.prototype.removeListener=function(n,e){return t.prototype.removeListener.call(this,n,e)},e.prototype.emit=function(n,e){t.prototype.emit.call(this,n,e)},e.addListener=function(n,t){e.staticEmitter&&e.staticEmitter.addListener(n,t)},e.removeListener=function(n,t){e.staticEmitter&&e.staticEmitter.removeListener(n,t)},e.emit=function(n,t){e.staticEmitter&&e.staticEmitter.emit(n,t,e.ipc)},e.listeners=function(n){return e.staticEmitter.listeners(n)},e}(i));s.staticEmitter=new i;var a=function(t){function e(){var n=null!==t&&t.apply(this,arguments)||this;return n.uuid=r.newGuid(),n.storage="undefined"!=typeof window&&window?window.localStorage:void 0,n}return n(e,t),e.prototype.showNotification=function(n,t){throw new TypeError("Notifications not supported by this container")},e.prototype.addTrayIcon=function(n,t,e){throw new TypeError("Tray icons are not supported by this container.")},e.prototype.getLayoutFromStorage=function(n){return JSON.parse(this.storage.getItem(e.layoutsPropertyKey))[n]},e.prototype.saveLayoutToStorage=function(n,t){var o=JSON.parse(this.storage.getItem(e.layoutsPropertyKey))||{};t.name||(t.name=n),o[n]=t,this.storage.setItem(e.layoutsPropertyKey,JSON.stringify(o)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:t,layoutName:t.name}),s.emit("layout-saved",{name:"layout-saved",layout:t,layoutName:t.name})},e.prototype.loadLayout=function(n){var t=this;return new Promise(function(e,o){t.closeAllWindows(!0).then(function(){var o=t.getLayoutFromStorage(n);if(o&&o.windows)for(var i=0,r=o.windows;i<r.length;i++){var a=r[i],u=Object.assign({},a.bounds);u.name=a.name,t.createWindow(a.url,u)}t.emit("layout-loaded",{sender:t,name:"layout-loaded",layout:o,layoutName:o.name}),s.emit("layout-loaded",{name:"layout-loaded",layout:o,layoutName:o.name}),e(o)})})},e.prototype.getLayouts=function(){var n=this;return new Promise(function(t,o){var i=n.storage.getItem(e.layoutsPropertyKey);if(i){var r=JSON.parse(i);t(Object.getOwnPropertyNames(r).map(function(n){return r[n]}))}t(void 0)})},e}(s);a.layoutsPropertyKey="desktopJS-layouts";var u,c=function(t){function e(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){}return e}return n(e,t),e.prototype.ensureAbsoluteUrl=function(n){return this.linkHelper?(this.linkHelper.href=n,this.linkHelper.href):n},e}(a),p=function(){function n(n,t,e,o){this.x=n,this.y=t,this.width=e,this.height=o}return n}(),d=function(t){function e(n){var e=t.call(this)||this;return e.innerWindow=n,e}return n(e,t),e.prototype.addListener=function(n,e){var o=this.registerAndWrapListener(n,e);return this.attachListener(n,o),t.prototype.addListener.call(this,n,o)},e.prototype.removeListener=function(n,e){var o=this.unwrapAndUnRegisterListener(e)||e;return this.detachListener(n,o),t.prototype.removeListener.call(this,n,o)},e}(i),w=function(){function n(n){this.windows=[],this.name=n}return n}();!function(n){function t(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}n.transformProperties=t}(u||(u={}));var l=function(){function n(n,t,e){this.topic=n,this.listener=t,this.options=e}return n}(),f={close:"unload"},h=function(t){function e(n){return t.call(this,n)||this}return n(e,t),e.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},e.prototype.show=function(){return Promise.resolve()},e.prototype.hide=function(){return Promise.resolve()},e.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},e.prototype.isShowing=function(){return Promise.resolve(!0)},e.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},e.prototype.getBounds=function(){var n=this;return new Promise(function(t){t(new p(n.innerWindow.screenX,n.innerWindow.screenY,n.innerWindow.outerWidth,n.innerWindow.outerHeight))})},e.prototype.setBounds=function(n){var t=this;return new Promise(function(e){t.innerWindow.moveTo(n.x,n.y),t.innerWindow.resizeTo(n.width,n.height),e()})},e.prototype.attachListener=function(n,t){this.innerWindow.addEventListener(f[n]||n,t)},e.prototype.detachListener=function(n,t){this.innerWindow.removeEventListener(f[n]||n,t)},e}(d),m=function(){function n(n){this.container=n}return n.prototype.subscribe=function(t,e,o){var i=this;return new Promise(function(o,r){var s=new l(t,function(o){if(o.origin===i.container.globalWindow.location.origin){var r=JSON.parse(o.data),s=r.source,a=r.topic,u=r.message;s===n.messageSource&&t===a&&e({topic:t},u)}});i.container.globalWindow&&i.container.globalWindow.addEventListener&&i.container.globalWindow.addEventListener("message",s.listener),o(s)})},n.prototype.unsubscribe=function(n){return Promise.resolve(this.container.globalWindow.removeEventListener("message",n.listener))},n.prototype.publish=function(t,e,o){var i=this.container.globalWindow?this.container.globalWindow[y.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[y.windowsPropertyKey]:[];if(i)for(var r in i){var s=i[r];if(!o||!o.name||o.name===s[y.windowNamePropertyKey]){if(s.location.origin!==this.container.globalWindow.location.origin)return;s.postMessage(JSON.stringify({source:n.messageSource,topic:t,message:e}),this.container.globalWindow.location.origin)}}return Promise.resolve()},n}();m.messageSource="desktopJS";var y=function(t){function e(n){var o=t.call(this,n)||this;return o.windowOptionsMap=e.defaultWindowOptionsMap,o.hostType="Default",o.ipc=new m(o),!o.globalWindow||e.windowsPropertyKey in o.globalWindow||(o.globalWindow[e.windowsPropertyKey]={root:o.globalWindow}),o}return n(e,t),e.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=new h(this.globalWindow)),this.mainWindow},e.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},e.prototype.getWindowOptions=function(n){return u.transformProperties(n,this.windowOptionsMap)},e.prototype.wrapWindow=function(n){return new h(n)},e.prototype.createWindow=function(n,t){var o,i="_blank",a=this.getWindowOptions(t);if(a){for(var u in a)o=(o||"")+u+"="+a[u]+",";a&&"target"in a&&(i=a.target)}var c=this.globalWindow.open(n,i,o);c[e.windowNamePropertyKey]=a.name;var p=this.globalWindow[e.windowsPropertyKey],d=c[e.windowUuidPropertyKey]=r.newGuid();p[d]=c,c.addEventListener("beforeunload",function(){c.addEventListener("unload",function(){delete p[d]})}),c[e.windowsPropertyKey]=p;var w=this.wrapWindow(c);return this.emit("window-created",{sender:this,name:"window-created",window:w,windowId:d,windowName:a.name}),s.emit("window-created",{name:"window-created",windowId:d,windowName:a.name}),w},e.prototype.showNotification=function(n,t){var e=this;if(!("Notification"in this.globalWindow))return void console.warn("Notifications not supported");this.globalWindow.Notification.requestPermission(function(o){"denied"===o?console.warn("Notifications not permitted"):"granted"===o&&new e.globalWindow.Notification(n,t)})},e.prototype.closeAllWindows=function(n){var t=this;return new Promise(function(o,i){var r=t.globalWindow[e.windowsPropertyKey];for(var s in r){var a=r[s];n&&t.globalWindow===a||a.close()}o()})},e.prototype.getAllWindows=function(){var n=this;return new Promise(function(t,o){var i=[],r=n.globalWindow[e.windowsPropertyKey];for(var s in r)i.push(r[s]);t(i)})},e.prototype.saveLayout=function(n){var t=this,o=new w;return new Promise(function(i,r){var s=t.globalWindow[e.windowsPropertyKey];for(var a in s){var u=s[a];t.globalWindow!==u&&o.windows.push({name:u.name,url:u.location.toString(),bounds:{x:u.screenX,y:u.screenY,width:u.outerWidth,height:u.outerHeight}})}t.saveLayoutToStorage(n,o),i(o)})},e}(c);y.windowsPropertyKey="desktopJS-windows",y.windowUuidPropertyKey="desktopJS-uuid",y.windowNamePropertyKey="desktopJS-name",y.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}};var g,v=Object.freeze({DefaultContainerWindow:h,DefaultMessageBus:m,DefaultContainer:y}),W={},b=function(){function n(n,t){}return n.requestPermission=function(t){return t&&t(n.permission),Promise.resolve(n.permission)},n}();b.permission="granted",t("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(){return new k}});var P={},x=function(t){function e(n){return t.call(this,n)||this}return n(e,t),e.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},e.prototype.show=function(){return this.innerWindow.show(),Promise.resolve()},e.prototype.hide=function(){return this.innerWindow.hide(),Promise.resolve()},e.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},e.prototype.isShowing=function(){var n=this;return new Promise(function(t,e){t(n.innerWindow.isVisible())})},e.prototype.getSnapshot=function(){var n=this;return new Promise(function(t,e){n.innerWindow.capturePage(function(n){t("data:image/png;base64,"+n.toPNG().toString("base64"))})})},e.prototype.getBounds=function(){var n=this;return new Promise(function(t){t(n.innerWindow.getBounds())})},e.prototype.setBounds=function(n){var t=this;return new Promise(function(e){t.innerWindow.setBounds(n),e()})},e.prototype.attachListener=function(n,t){this.innerWindow.addListener(P[n]||n,t)},e.prototype.detachListener=function(n,t){this.innerWindow.removeListener(P[n]||n,t)},e}(d),L=function(){function n(n,t){this.ipc=n,this.browserWindow=t}return n.prototype.subscribe=function(n,t,e){var o=this;return new Promise(function(e,i){var r=new l(n,function(e,o){t({topic:n},o)});o.ipc.on(n,r.listener),e(r)})},n.prototype.unsubscribe=function(n){var t=n.topic,e=n.listener;n.options;return Promise.resolve(this.ipc.removeListener(t,e))},n.prototype.publish=function(n,t,e){if(void 0!==this.ipc.send&&(e&&e.name||this.ipc.send(n,t)),this.browserWindow&&this.browserWindow.getAllWindows)for(var o=0,i=this.browserWindow.getAllWindows();o<i.length;o++){var r=i[o];e&&e.name?e.name===r.name&&r.webContents.send(n,t):r.webContents.send(n,t)}return Promise.resolve()},n}(),k=function(t){function e(n,o,i){var r=t.call(this,i)||this;r.isRemote=!0,r.windowOptionsMap=e.windowOptionsMap,r.hostType="Electron";try{n?r.electron=n:(r.electron=require("electron").remote,void 0===r.electron&&(r.electron=require("electron"),r.isRemote=!1)),r.app=r.electron.app,r.browserWindow=r.electron.BrowserWindow,r.tray=r.electron.Tray,r.menu=r.electron.Menu,r.internalIpc=o||(r.isRemote?require("electron").ipcRenderer:r.electron.ipcMain),r.ipc=new L(r.internalIpc,r.browserWindow),r.isRemote||r.internalIpc.on("setWindowName",function(n,t){var e=t.id,o=t.name;r.browserWindow.fromId(e).name=o,n.returnValue=o})}catch(n){console.error(n)}return r.registerNotificationsApi(),r}return n(e,t),e.prototype.registerNotificationsApi=function(){if(e.replaceNotificationApi&&void 0!==this.globalWindow&&this.globalWindow){var t=this;this.globalWindow.Notification=function(e){function o(n,o){var i=e.call(this,n,o)||this;return o.notification=i,t.showNotification(n,o),i}return n(o,e),o}(b)}},e.prototype.getMainWindow=function(){if(!this.mainWindow){for(var n=this.electron.getCurrentWindow();n.getParentWindow();)n=n.getParentWindow();this.mainWindow=this.wrapWindow(n)}return this.mainWindow},e.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},e.prototype.getWindowOptions=function(n){return u.transformProperties(n,this.windowOptionsMap)},e.prototype.wrapWindow=function(n){return new x(n)},e.prototype.createWindow=function(n,t){var e=this.getWindowOptions(t),o=new this.browserWindow(e),i=e.name||r.newGuid();o.name=this.isRemote?this.internalIpc.sendSync("setWindowName",{id:o.id,name:i}):i,o.loadURL(n);var a=this.wrapWindow(o);return this.emit("window-created",{sender:this,name:"window-created",window:a,windowId:o.id,windowName:i}),s.emit("window-created",{name:"window-created",windowId:o.id,windowName:i}),a},e.prototype.showNotification=function(n,t){throw new TypeError("showNotification requires an implementation.")},e.prototype.addTrayIcon=function(n,t,e){var o=new this.tray(n.icon);n.text&&o.setToolTip(n.text),e&&o.setContextMenu(this.menu.buildFromTemplate(e)),t&&o.on("click",t)},e.prototype.closeAllWindows=function(n){var t=this;return new Promise(function(e,o){for(var i=0,r=t.browserWindow.getAllWindows();i<r.length;i++){var s=r[i];n&&s===t.electron.getCurrentWindow()||s.close()}e()})},e.prototype.getAllWindows=function(){var n=this;return Promise.resolve(this.browserWindow.getAllWindows().map(function(t){return n.wrapWindow(t)}))},e.prototype.saveLayout=function(n){var t=this,e=new w;return new Promise(function(o,i){for(var r=0,s=t.browserWindow.getAllWindows();r<s.length;r++){var a=s[r];a!==t.electron.getCurrentWindow()&&e.windows.push({name:a.name,url:a.webContents.getURL(),bounds:a.getBounds()})}t.saveLayoutToStorage(n,e),o(e)})},e}(c);k.replaceNotificationApi=!0,k.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,t,e){return!n}}};var N=Object.freeze({ElectronContainerWindow:x,ElectronMessageBus:L,ElectronContainer:k});t("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in fin},create:function(){return new S}});var O={move:"bounds-changing",resize:"bounds-changed",close:"close-requested",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},M=function(t){function e(n){return t.call(this,n)||this}return n(e,t),e.prototype.focus=function(){var n=this;return new Promise(function(t,e){n.innerWindow.focus(t,e)})},e.prototype.show=function(){var n=this;return new Promise(function(t,e){n.innerWindow.show(t,e)})},e.prototype.hide=function(){var n=this;return new Promise(function(t,e){n.innerWindow.hide(t,e)})},e.prototype.close=function(){var n=this;return new Promise(function(t,e){n.innerWindow.close(!1,t,e)})},e.prototype.isShowing=function(){var n=this;return new Promise(function(t,e){n.innerWindow.isShowing(t,e)})},e.prototype.getSnapshot=function(){var n=this;return new Promise(function(t,e){n.innerWindow.getSnapshot(function(n){return t("data:image/png;base64,"+n)},function(n){return e(n)})})},e.prototype.getBounds=function(){var n=this;return new Promise(function(t,e){n.innerWindow.getBounds(function(n){return t(new p(n.left,n.top,n.width,n.height))},e)})},e.prototype.setBounds=function(n){var t=this;return new Promise(function(e,o){t.innerWindow.setBounds(n.x,n.y,n.width,n.height,e,o)})},e.prototype.attachListener=function(n,t){this.innerWindow.addEventListener(O[n]||n,t)},e.prototype.detachListener=function(n,t){this.innerWindow.removeEventListener(O[n]||n,t)},e}(d),A=function(){function n(n,t){this.bus=n,this.uuid=t}return n.prototype.subscribe=function(n,t,e){var o=this;return new Promise(function(i,r){var s=new l(n,function(e,o,i){t({topic:n},e)},e);o.bus.subscribe(e&&e.uuid||"*",e&&e.name||void 0,s.topic,s.listener,function(){return i(s)},r)})},n.prototype.unsubscribe=function(n){var t=this,e=n.topic,o=n.listener,i=n.options;return new Promise(function(n,r){t.bus.unsubscribe(i&&i.uuid||"*",i&&i.name||void 0,e,o,n,r)})},n.prototype.publish=function(n,t,e){var o=this;return new Promise(function(i,r){e&&e.uuid||e&&e.name?o.bus.send(e.uuid||o.uuid,e.name||void 0,n,t,i,r):o.bus.publish(n,t,i,r)})},n}(),S=function(t){function e(n,o){var i=t.call(this,o)||this;return i.windowOptionsMap=e.windowOptionsMap,i.notificationOptionsMap=e.notificationOptionsMap,i.desktop=n||fin.desktop,i.hostType="OpenFin",i.ipc=new A(i.desktop.InterApplicationBus,i.desktop.Application.getCurrent().uuid),i.registerNotificationsApi(),i}return n(e,t),e.prototype.registerNotificationsApi=function(){if(e.replaceNotificationApi&&void 0!==this.globalWindow&&this.globalWindow){var t=this;this.globalWindow.Notification=function(e){function o(n,o){var i=e.call(this,n,o)||this;return o.notification=i,o.onClick=function(n){i.onclick&&i.onclick(n)},o.onError=function(n){i.onerror&&i.onerror(n)},t.showNotification(n,o),i}return n(o,e),o}(b)}},e.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},e.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},e.prototype.getWindowOptions=function(n){var t=u.transformProperties(n,this.windowOptionsMap);return"autoShow"in t||(t.autoShow=!0),"saveWindowState"in t||!("defaultLeft"in t||"defaultTop"in t)||(t.saveWindowState=!1),"icon"in t&&(t.icon=this.ensureAbsoluteUrl(t.icon)),t},e.prototype.wrapWindow=function(n){return new M(n)},e.prototype.createWindow=function(n,t){var e=this.getWindowOptions(t);e.url=n,"name"in e||(e.name=r.newGuid());var o=this.wrapWindow(new this.desktop.Window(e));return this.emit("window-created",{sender:this,name:"window-created",window:o,windowId:e.name,windowName:e.name}),s.emit("window-created",{name:"window-created",windowId:e.name,windowName:e.name}),o},e.prototype.showNotification=function(n,t){new this.desktop.Notification(u.transformProperties(t,this.notificationOptionsMap))},e.prototype.getMenuHtml=function(){return e.menuHtml},e.prototype.getMenuItemHtml=function(n){var t=n.icon?'<span><img align="absmiddle" class="context-menu-image" src="'+this.ensureAbsoluteUrl(n.icon)+'" /></span>':"<span>&nbsp;</span>";return'<li class="context-menu-item" onclick="fin.desktop.InterApplicationBus.send(\''+this.desktop.Application.getCurrent().uuid+"', null, 'TrayIcon_ContextMenuClick_"+this.uuid+"', { id: '"+n.id+"' });this.close()\">"+t+n.label+"</li>"},e.prototype.showMenu=function(n,t,o,i){var s=this;this.menuItemRef=i;var a=new this.desktop.Window({name:"trayMenu"+r.newGuid(),saveWindowState:!1,autoShow:!1,defaultWidth:150,defaultHeight:100,showTaskbarIcon:!1,frame:!1,contextMenu:!0,resizable:!1,alwaysOnTop:!0,shadow:!0},function(){var u=a.getNativeWindow();u.document.open("text/html","replace"),u.document.write(s.getMenuHtml()),u.document.close();for(var c="",p=0,d=i.filter(function(n){return n.label});p<d.length;p++){var w=d[p];w.id||(w.id=r.newGuid()),c+=s.getMenuItemHtml(w)}var l=u.document.getElementById("contextMenu");l.innerHTML=c;var f=l.offsetWidth,h=l.offsetHeight;a.resizeTo(f,h,"top-left");var m=n+f>o.primaryMonitor.monitorRect.right?n-f-e.trayIconMenuLeftOffset:n,y=t+h>o.primaryMonitor.monitorRect.bottom?t-h-e.trayIconMenuTopOffset:t;a.addEventListener("blurred",function(){return a.close()}),a.showAt(m,y,!1,function(){return a.focus()})})},e.prototype.addTrayIcon=function(n,t,o){var i=this;this.desktop.Application.getCurrent().setTrayIcon(this.ensureAbsoluteUrl(n.icon),function(n){0===n.button&&t?t():2===n.button&&i.showMenu(n.x+e.trayIconMenuLeftOffset,n.y+e.trayIconMenuTopOffset,n.monitorInfo,o)},function(){i.desktop.InterApplicationBus.subscribe(i.desktop.Application.getCurrent().uuid,"TrayIcon_ContextMenuClick_"+i.uuid,function(n,t){for(var e in i.menuItemRef){var o=i.menuItemRef[e];o.id===n.id&&o.click&&o.click(o)}})},function(n){console.error(n)})},e.prototype.closeAllWindows=function(){var n=this;return new Promise(function(t,e){var o=[];n.desktop.Application.getCurrent().getChildWindows(function(n){n.forEach(function(n){o.push(new Promise(function(t,e){return n.close(!0,t,e)}))}),Promise.all(o).then(function(){return t()})},e)})},e.prototype.getAllWindows=function(){var n=this;return new Promise(function(t,e){n.desktop.Application.getCurrent().getChildWindows(function(e){e.push(n.desktop.Application.getCurrent().getWindow()),t(e.map(function(t){return n.wrapWindow(t)}))},e)})},e.prototype.saveLayout=function(n){var t=this,e=new w;return new Promise(function(o,i){t.desktop.Application.getCurrent().getChildWindows(function(i){var r=[];i.forEach(function(n){r.push(new Promise(function(t,o){n.getBounds(function(o){n.getOptions(function(i){e.windows.push({name:n.name,url:i.url,bounds:{x:o.left,y:o.top,width:o.width,height:o.height}}),t()})})}))}),Promise.all(r).then(function(){t.saveLayoutToStorage(n,e),o(e)})})})},e}(c);S.trayIconMenuLeftOffset=4,S.trayIconMenuTopOffset=23,S.replaceNotificationApi=!0,S.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},S.notificationOptionsMap={body:{target:"message"}},S.menuHtml='<html>\n <head>\n <style>\n body:before, body:after {\n position: fixed;\n background: silver;\n }\n body {\n margin: 0px;\n overflow: hidden;\n }\n .context-menu {\n list-style: none;\n padding: 1px 0 1px 0;\n }\n .context-menu-item {\n display: block;\n cursor: default;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 9pt;\n margin-bottom: 2px;\n padding: 4px 0 4px 4px;\n white-space: nowrap;\n }\n .context-menu-item span {\n display: inline-block;\n min-width: 20px;\n }\n .context-menu-item:last-child {\n margin-bottom: 0;\n } \n .context-menu-item:hover {\n color: #fff;\n background-color: #0066aa;\n }\n .context-menu-image {\n width: 16px;\n height: 16px;\n margin-top: -1px;\n margin-right: 4px;\n } \n </style>\n <script>\n document.addEventListener(\'keydown\', (event) => {\n if (event.keyCode == 27) {\n window.close();\n }\n }, false);\n <\/script>\n </head>\n <body>\n <ul class="context-menu" id="contextMenu"></ul>\n </body>\n </html>';var C=Object.freeze({OpenFinContainerWindow:M,OpenFinMessageBus:A,OpenFinContainer:S});return{Container:s,container:g,registerContainer:t,resolveContainer:e,Default:v,Electron:N,OpenFin:C}});
"undefined"==typeof desktopJS&&function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.desktopJS=e()}(this,function(){"use strict";function n(n,e){function t(){this.constructor=n}for(var o in e)e.hasOwnProperty(o)&&(n[o]=e[o]);n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}function e(n,e){W[n]=e}function t(n){if(!n&&w)return w;for(var e in W)try{if(W[e].condition())return w=W[e].create()}catch(n){console.error("Error resolving container '"+e+"': "+n.toString())}return w=new y}var o,i=function(){return function(n,e,t){this.sender=n,this.name=e,this.innerEvent=t}}(),r=function(){function n(){this.eventListeners=new Map,this.wrappedListeners=new Map}return n.prototype.addListener=function(n,e){return(this.eventListeners[n]=this.eventListeners[n]||[]).push(e),this},n.prototype.registerAndWrapListener=function(n,e){var t=this,o=function(o){e(new i(t,n,o))};return this.wrappedListeners.set(e,o),o},n.prototype.unwrapAndUnRegisterListener=function(n){var e=this.wrappedListeners.get(n);return e&&this.wrappedListeners.delete(n),e},n.prototype.removeListener=function(n,e){var t=this.listeners(n);if(t){var o=t.indexOf(e);o>=0&&t.splice(o,1)}return this},n.prototype.listeners=function(n){return this.eventListeners[n]||[]},n.prototype.emit=function(n,e){for(var t=0,o=this.listeners(n);t<o.length;t++){(0,o[t])(e)}},Object.defineProperty(n,"ipc",{set:function(e){e&&e.subscribe(n.staticEventName,function(e,t){n.emit(t.eventName,t.eventArgs)})},enumerable:!0,configurable:!0}),n.addListener=function(n,e){(this.staticEventListeners[n]=this.staticEventListeners[n]||[]).push(e)},n.removeListener=function(e,t){var o=n.listeners(e);if(o){var i=o.indexOf(t);i>=0&&o.splice(i,1)}},n.listeners=function(n){return this.staticEventListeners[n]||[]},n.emit=function(e,t,o){if(o&&o.publish)o.publish(n.staticEventName,{eventName:e,eventArgs:t});else for(var i=0,r=n.listeners(e);i<r.length;i++){(0,r[i])(t)}},n.staticEventListeners=new Map,n.staticEventName="desktopJS.static-event",n}(),s=function(){function n(){}return n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var e=16*Math.random()|0;return("x"==n?e:3&e|8).toString(16)})},n}(),u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(i),function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),Object.defineProperty(t,"ipc",{get:function(){return t._ipc},set:function(n){r.ipc=t._ipc=n},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ipc",{get:function(){return t.ipc},set:function(n){t.ipc=n},enumerable:!0,configurable:!0}),t.prototype.addListener=function(n,t){return e.prototype.addListener.call(this,n,t)},t.prototype.removeListener=function(n,t){return e.prototype.removeListener.call(this,n,t)},t.prototype.emit=function(n,t){e.prototype.emit.call(this,n,t)},t.addListener=function(n,e){r.addListener(t.staticEventScopePrefix+n,e)},t.removeListener=function(n,e){r.removeListener(t.staticEventScopePrefix+n,e)},t.emit=function(n,e){r.emit(t.staticEventScopePrefix+n,e,t.ipc)},t.listeners=function(n){return r.listeners(t.staticEventScopePrefix+n)},t.staticEventScopePrefix="container-",t}(r)),a=function(e){function t(n){var t=e.call(this)||this;t.globalWindow=n||"undefined"!=typeof window&&window||null,t.linkHelper={href:"unknown"};try{t.linkHelper=t.globalWindow.top.document.createElement("a")}catch(n){}return t}return n(t,e),t.prototype.ensureAbsoluteUrl=function(n){return this.linkHelper?(this.linkHelper.href=n,this.linkHelper.href):n},t}(function(e){function t(){var n=null!==e&&e.apply(this,arguments)||this;return n.uuid=s.newGuid(),n.storage="undefined"!=typeof window&&window?window.localStorage:void 0,n}return n(t,e),t.prototype.showNotification=function(n,e){throw new TypeError("Notifications not supported by this container")},t.prototype.addTrayIcon=function(n,e,t){throw new TypeError("Tray icons are not supported by this container.")},t.prototype.getLayoutFromStorage=function(n){return JSON.parse(this.storage.getItem(t.layoutsPropertyKey))[n]},t.prototype.saveLayoutToStorage=function(n,e){var o=JSON.parse(this.storage.getItem(t.layoutsPropertyKey))||{};e.name||(e.name=n),o[n]=e,this.storage.setItem(t.layoutsPropertyKey,JSON.stringify(o)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:e,layoutName:e.name}),u.emit("layout-saved",{name:"layout-saved",layout:e,layoutName:e.name})},t.prototype.loadLayout=function(n){var e=this;return new Promise(function(t,o){e.closeAllWindows(!0).then(function(){var i=e.getLayoutFromStorage(n);if(i&&i.windows){for(var r=[],s=0,a=i.windows;s<a.length;s++){var d=a[s],c=Object.assign({},d.bounds);c.name=d.name,d.main?(e.getMainWindow().setBounds(d.bounds),r.push(Promise.resolve(e.getMainWindow()))):r.push(e.createWindow(d.url,c))}Promise.all(r).then(function(n){n.forEach(function(n){var t=i.windows.find(function(e){return e.name===n.name}).group;t&&t.length>0&&t.filter(function(e){return e!==n.id}).forEach(function(t){e.getWindowByName(i.windows.find(function(n){return n.id===t}).name).then(function(e){n.joinGroup(e)})})})}),e.emit("layout-loaded",{sender:e,name:"layout-loaded",layout:i,layoutName:i.name}),u.emit("layout-loaded",{name:"layout-loaded",layout:i,layoutName:i.name}),t(i)}else o("Layout does not exist")})})},t.prototype.getLayouts=function(){var n=this;return new Promise(function(e,o){var i=n.storage.getItem(t.layoutsPropertyKey);if(i){var r=JSON.parse(i);e(Object.getOwnPropertyNames(r).map(function(n){return r[n]}))}e(void 0)})},t.layoutsPropertyKey="desktopJS-layouts",t}(u)),d=function(){function n(n,e,t,o){this.x=n,this.y=e,this.width=t,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}(),c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(i),function(e){function t(n){var t=e.call(this)||this;return t.innerWindow=n,t}return n(t,e),Object.defineProperty(t.prototype,"allowGrouping",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype.getGroup=function(){return Promise.resolve([])},t.prototype.joinGroup=function(n){return Promise.reject("Not supported")},t.prototype.leaveGroup=function(){return Promise.resolve()},t.prototype.addListener=function(n,t){var o=this.registerAndWrapListener(n,t);return this.attachListener(n,o),e.prototype.addListener.call(this,n,o)},t.prototype.removeListener=function(n,t){var o=this.unwrapAndUnRegisterListener(t)||t;return this.detachListener(n,o),e.prototype.removeListener.call(this,n,o)},t.addListener=function(n,e){r.addListener(t.staticEventScopePrefix+n,e)},t.removeListener=function(n,e){r.removeListener(t.staticEventScopePrefix+n,e)},t.emit=function(n,e){r.emit(t.staticEventScopePrefix+n,e,u.ipc)},t.listeners=function(n){return r.listeners(t.staticEventScopePrefix+n)},t.staticEventScopePrefix="containerwindow-",t}(r)),p=function(){return function(n){this.windows=[],this.name=n}}(),f=function(){function n(n,e){this.autoGrouping=!0,this.snapThreshold=20,this.snapOffset=15,this.targetGroup=new Map,this.container=n,e&&("snapThreshold"in e&&(this.snapThreshold=e.snapThreshold),"snapOffset"in e&&(this.snapOffset=e.snapOffset),"autoGrouping"in e&&(this.autoGrouping=e.autoGrouping)),this.attach()}return n.prototype.onAttached=function(n){var e=this;n.innerWindow&&n.innerWindow.disableFrame&&n.innerWindow.disableFrame(),"undefined"!=typeof fin?n.addListener("disabled-frame-bounds-changed",function(){return e.onMoved(n)}):n.innerWindow&&n.innerWindow.hookWindowMessage&&n.innerWindow.hookWindowMessage(562,function(){return e.onMoved(n)})},n.prototype.attach=function(n){var e=this;n?(this.onAttached(n),n.addListener("undefined"!=typeof fin?"disabled-frame-bounds-changing":"move",function(n){var t=n.sender.id;e.snappingWindow!==t&&n.sender.getGroup().then(function(o){("undefined"!=typeof fin?Promise.resolve(new d(n.innerEvent.left,n.innerEvent.top,n.innerEvent.width,n.innerEvent.height)):n.sender.getBounds()).then(function(i){if(o.length>0)"undefined"!=typeof fin&&e.moveWindow(n.sender,i);else{var r=[];e.container.getAllWindows().then(function(o){o.filter(function(n){return t!==n.id}).forEach(function(n){r.push(new Promise(function(e){n.getBounds().then(function(t){return e({window:n,bounds:t})})}))}),Promise.all(r).then(function(t){for(var o,r=!1,s=0,u=t;s<u.length;s++){var a=u[s];(o=e.getSnapBounds(o||i,a.bounds))?(r=!0,e.showGroupingHint(a.window),e.moveWindow(n.sender,o)):e.hideGroupingHint(a.window)}r||"undefined"==typeof fin||e.moveWindow(n.sender,i)})})}})})})):(c.addListener("window-created",function(n){e.container.getWindowById(n.windowId).then(function(n){e.attach(n)})}),this.container&&this.container.getAllWindows().then(function(n){n.forEach(function(n){return e.attach(n)})}))},n.prototype.moveWindow=function(n,e){var t=this;this.snappingWindow=n.id,n.setBounds(e).then(function(){return t.snappingWindow=void 0},function(){return t.snappingWindow=void 0})},n.prototype.onMoved=function(n){var e=this;if(this.autoGrouping){var t=[];this.targetGroup.forEach(function(n){return t.push(new Promise(function(e){n.getGroup().then(function(t){return e({window:n,isGrouped:t.length>0})})}))}),Promise.all(t).then(function(e){e.length>0&&n.joinGroup(e[0].window);for(var t=1;t<e.length;t++)e[t].isGrouped||e[t].window.joinGroup(n)})}this.targetGroup.forEach(function(n){return e.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,e){return n.y>=e.y&&n.y<=e.bottom||n.bottom>=e.y&&n.bottom<=e.bottom||n.y<=e.y&&n.bottom>=e.bottom},n.prototype.isVerticallyAligned=function(n,e){return n.x>=e.x&&n.x<=e.right||n.right>=e.x&&n.right<=e.right||n.x<=e.x&&n.right>=e.right},n.prototype.getSnapBounds=function(n,e){var t,o,i,r,s,u,a,c;if(this.isHorizontallyAligned(n,e)&&(t=Math.abs(n.x-(e.right-this.snapOffset))<this.snapThreshold,o=Math.abs(n.x-e.x)<this.snapThreshold,i=Math.abs(n.right-this.snapOffset-e.x)<this.snapThreshold,r=Math.abs(n.right-e.right)<this.snapThreshold),this.isVerticallyAligned(n,e)&&(s=Math.abs(n.y-(e.bottom-this.snapOffset))<this.snapThreshold,u=Math.abs(n.y-e.y)<this.snapThreshold,a=Math.abs(n.bottom-this.snapOffset-e.y)<this.snapThreshold,c=Math.abs(n.bottom-e.bottom)<this.snapThreshold),t||i||s||a){var p=n.x,f=n.y;return t?p=e.x+e.width-this.snapOffset:o&&(p=e.x),i?p=e.x-n.width+this.snapOffset:r&&(p=e.x+e.width-n.width),s?f=e.y+e.height-Math.floor(this.snapOffset/2):u&&(f=e.y),a?f=e.y-n.height+Math.floor(this.snapOffset/2):c&&(f=e.y+e.height-n.height),new d(p,f,n.width,n.height)}},n}();!function(n){(o||(o={})).transformProperties=function(n,e){var t={};if(n)for(var o in n)try{o in e?t[e[o].target]=e[o].convert?e[o].convert(n[o],n,t):n[o]:t[o]=n[o]}catch(n){console.error("Error transforming property '"+o+"'")}return t}}();var w,l=function(){return function(n,e,t){this.topic=n,this.listener=e,this.options=t}}(),h={close:"unload"},g=function(e){function t(n){return e.call(this,n)||this}return n(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this.innerWindow[y.windowUuidPropertyKey]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.innerWindow[y.windowNamePropertyKey]},enumerable:!0,configurable:!0}),t.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},t.prototype.show=function(){return Promise.resolve()},t.prototype.hide=function(){return Promise.resolve()},t.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},t.prototype.isShowing=function(){return Promise.resolve(!0)},t.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},t.prototype.getBounds=function(){var n=this;return new Promise(function(e){e(new d(n.innerWindow.screenX,n.innerWindow.screenY,n.innerWindow.outerWidth,n.innerWindow.outerHeight))})},t.prototype.setBounds=function(n){var e=this;return new Promise(function(t){e.innerWindow.moveTo(n.x,n.y),e.innerWindow.resizeTo(n.width,n.height),t()})},t.prototype.attachListener=function(n,e){this.innerWindow.addEventListener(h[n]||n,e)},t.prototype.detachListener=function(n,e){this.innerWindow.removeEventListener(h[n]||n,e)},t}(c),m=function(){function n(n){this.container=n}return n.prototype.subscribe=function(e,t,o){var i=this;return new Promise(function(o,r){var s=new l(e,function(o){if(o.origin===i.container.globalWindow.location.origin){var r=JSON.parse(o.data),s=r.source,u=r.topic,a=r.message;s===n.messageSource&&e===u&&t({topic:e},a)}});i.container.globalWindow&&i.container.globalWindow.addEventListener&&i.container.globalWindow.addEventListener("message",s.listener),o(s)})},n.prototype.unsubscribe=function(n){return Promise.resolve(this.container.globalWindow.removeEventListener("message",n.listener))},n.prototype.publish=function(e,t,o){var i=this.container.globalWindow?this.container.globalWindow[y.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[y.windowsPropertyKey]:[];if(i)for(var r in i){var s=i[r];o&&o.name&&o.name!==s[y.windowNamePropertyKey]||s.location.origin===this.container.globalWindow.location.origin&&s.postMessage(JSON.stringify({source:n.messageSource,topic:e,message:t}),this.container.globalWindow.location.origin)}return Promise.resolve()},n.messageSource="desktopJS",n}(),y=function(e){function t(n){var o=e.call(this,n)||this;return o.windowOptionsMap=t.defaultWindowOptionsMap,o.hostType="Default",o.ipc=new m(o),!o.globalWindow||t.windowsPropertyKey in o.globalWindow||(o.globalWindow[t.windowsPropertyKey]={root:o.globalWindow}),o}return n(t,e),t.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=new g(this.globalWindow)),this.mainWindow},t.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},t.prototype.getWindowOptions=function(n){return o.transformProperties(n,this.windowOptionsMap)},t.prototype.wrapWindow=function(n){return new g(n)},t.prototype.createWindow=function(n,e){var o,i="_blank",r=this.getWindowOptions(e);if(r){for(var a in r)o=(o||"")+a+"="+r[a]+",";r&&"target"in r&&(i=r.target)}var d=this.globalWindow.open(n,i,o);d[t.windowNamePropertyKey]=r.name;var p=this.globalWindow[t.windowsPropertyKey],f=d[t.windowUuidPropertyKey]=s.newGuid();p[f]=d,d.addEventListener("beforeunload",function(){d.addEventListener("unload",function(){delete p[f]})}),d[t.windowsPropertyKey]=p;var w=this.wrapWindow(d);return this.emit("window-created",{sender:this,name:"window-created",window:w,windowId:f,windowName:r.name}),u.emit("window-created",{name:"window-created",windowId:f,windowName:r.name}),c.emit("window-created",{name:"window-created",windowId:f,windowName:r.name}),Promise.resolve(w)},t.prototype.showNotification=function(n,e){var t=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(o){"denied"===o?console.warn("Notifications not permitted"):"granted"===o&&new t.globalWindow.Notification(n,e)}):console.warn("Notifications not supported")},t.prototype.closeAllWindows=function(n){var e=this;return new Promise(function(o,i){var r=e.globalWindow[t.windowsPropertyKey];for(var s in r){var u=r[s];n&&e.globalWindow===u||u.close()}o()})},t.prototype.getAllWindows=function(){var n=this;return new Promise(function(e,o){var i=[],r=n.globalWindow[t.windowsPropertyKey];for(var s in r)i.push(r[s]);e(i)})},t.prototype.getWindowById=function(n){var e=this;return new Promise(function(o,i){var r=e.globalWindow[t.windowsPropertyKey][n];o(r?e.wrapWindow(r):null)})},t.prototype.getWindowByName=function(n){var e=this;return new Promise(function(o,i){var r=e.globalWindow[t.windowsPropertyKey];for(var s in r)if(r[s][t.windowNamePropertyKey]===n)return void o(e.wrapWindow(r[s]));o(null)})},t.prototype.saveLayout=function(n){var e=this,o=new p;return new Promise(function(i,r){var s=e.globalWindow[t.windowsPropertyKey];for(var u in s){var a=s[u];e.globalWindow!==a&&o.windows.push({name:a.name,url:a.location.toString(),bounds:{x:a.screenX,y:a.screenY,width:a.outerWidth,height:a.outerHeight}})}e.saveLayoutToStorage(n,o),i(o)})},t.windowsPropertyKey="desktopJS-windows",t.windowUuidPropertyKey="desktopJS-uuid",t.windowNamePropertyKey="desktopJS-name",t.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},t}(a),v=Object.freeze({DefaultContainerWindow:g,DefaultMessageBus:m,DefaultContainer:y}),W={},b=function(){function n(n,e){}return n.requestPermission=function(e){return e&&e(n.permission),Promise.resolve(n.permission)},n.permission="granted",n}();e("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(){return new M}});var P=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}(),x={},O=function(e){function t(n,t){var o=e.call(this,n)||this;return o.container=t,o}return n(t,e),Object.defineProperty(t.prototype,"isRemote",{get:function(){return this.container.internalIpc.send},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this.innerWindow.id},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),t.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},t.prototype.show=function(){return this.innerWindow.show(),Promise.resolve()},t.prototype.hide=function(){return this.innerWindow.hide(),Promise.resolve()},t.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},t.prototype.isShowing=function(){var n=this;return new Promise(function(e,t){e(n.innerWindow.isVisible())})},t.prototype.getSnapshot=function(){var n=this;return new Promise(function(e,t){n.innerWindow.capturePage(function(n){e("data:image/png;base64,"+n.toPNG().toString("base64"))})})},t.prototype.getBounds=function(){var n=this;return new Promise(function(e){var t=n.innerWindow.getBounds(),o=t.x,i=t.y,r=t.width,s=t.height;e(new d(o,i,r,s))})},t.prototype.setBounds=function(n){var e=this;return new Promise(function(t){e.innerWindow.setBounds(n),t()})},Object.defineProperty(t.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.getGroup=function(){var n=this;return new Promise(function(e){e((n.isRemote?n.container.internalIpc.sendSync(P.getGroup,{source:n.id}):n.container.windowManager.getGroup(n.innerWindow)).map(function(e){return e===n.id?n:n.container.wrapWindow(n.container.browserWindow.fromId(e))}))})},t.prototype.joinGroup=function(n){return n&&n.id!==this.id?(this.isRemote?this.container.internalIpc.send(P.joinGroup,{source:this.id,target:n.id}):this.container.windowManager.groupWindows(n.innerWindow,this.innerWindow),Promise.resolve()):Promise.resolve()},t.prototype.leaveGroup=function(){return this.isRemote?this.container.internalIpc.send(P.leaveGroup,{source:this.id}):this.container.windowManager.ungroupWindows(this.innerWindow),Promise.resolve()},t.prototype.attachListener=function(n,e){this.innerWindow.addListener(x[n]||n,e)},t.prototype.detachListener=function(n,e){this.innerWindow.removeListener(x[n]||n,e)},t}(c),L=function(){function n(n,e){this.ipc=n,this.browserWindow=e}return n.prototype.subscribe=function(n,e,t){var o=this;return new Promise(function(t,i){var r=new l(n,function(t,o){e({topic:n},o)});o.ipc.on(n,r.listener),t(r)})},n.prototype.unsubscribe=function(n){var e=n.topic,t=n.listener;n.options;return Promise.resolve(this.ipc.removeListener(e,t))},n.prototype.publish=function(n,e,t){if(t&&t.name||(void 0!==this.ipc.send?this.ipc.send(n,e):this.ipc.listeners(n).forEach(function(t){return t({topic:n},e)})),this.browserWindow&&this.browserWindow.getAllWindows)for(var o=0,i=this.browserWindow.getAllWindows();o<i.length;o++){var r=i[o];t&&t.name?t.name===r.name&&r.webContents.send(n,e):r.webContents.send(n,e)}return Promise.resolve()},n}(),M=function(e){function t(n,o,i){var r=e.call(this,i)||this;r.isRemote=!0,r.windowOptionsMap=t.windowOptionsMap,r.hostType="Electron";try{n?r.electron=n:(r.electron=require("electron").remote,void 0===r.electron&&(r.electron=require("electron"),r.isRemote=!1)),r.app=r.electron.app,r.browserWindow=r.electron.BrowserWindow,r.tray=r.electron.Tray,r.menu=r.electron.Menu,r.internalIpc=o||(r.isRemote?require("electron").ipcRenderer:r.electron.ipcMain),r.ipc=new L(r.internalIpc,r.browserWindow),r.isRemote||(r.windowManager=new k(r.app,r.internalIpc,r.browserWindow))}catch(n){console.error(n)}return r.registerNotificationsApi(),r}return n(t,e),t.prototype.registerNotificationsApi=function(){if(t.replaceNotificationApi&&void 0!==this.globalWindow&&this.globalWindow){var e=this;this.globalWindow.Notification=function(t){function o(n,o){var i=t.call(this,n,o)||this;return o.notification=i,e.showNotification(n,o),i}return n(o,t),o}(b)}},t.prototype.getMainWindow=function(){for(var n=0,e=this.browserWindow.getAllWindows();n<e.length;n++){var t=e[n];if(t.options&&t.options.main)return this.wrapWindow(t)}var o=this.browserWindow.fromId(1);return o?this.wrapWindow(o):void 0},t.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},t.prototype.getWindowOptions=function(n){return o.transformProperties(n,this.windowOptionsMap)},t.prototype.wrapWindow=function(n){return new O(n,this)},t.prototype.createWindow=function(n,e){var t=this.getWindowOptions(e),o=new this.browserWindow(t),i=t.name||s.newGuid();this.isRemote?o.name=this.internalIpc.sendSync(P.initialize,{id:o.id,name:i,options:t}):this.windowManager.initializeWindow(o,i,t),o.loadURL(n);var r=this.wrapWindow(o);return this.emit("window-created",{sender:this,name:"window-created",window:r,windowId:o.id,windowName:i}),u.emit("window-created",{name:"window-created",windowId:o.id,windowName:i}),c.emit("window-created",{name:"window-created",windowId:o.id,windowName:i}),Promise.resolve(r)},t.prototype.showNotification=function(n,e){throw new TypeError("showNotification requires an implementation.")},t.prototype.addTrayIcon=function(n,e,t){var o=new this.tray(n.icon);n.text&&o.setToolTip(n.text),t&&o.setContextMenu(this.menu.buildFromTemplate(t)),e&&o.on("click",e)},t.prototype.closeAllWindows=function(n){var e=this;return new Promise(function(t,o){for(var i=0,r=e.browserWindow.getAllWindows();i<r.length;i++){var s=r[i];n&&s===e.electron.getCurrentWindow()||s.close()}t()})},t.prototype.getAllWindows=function(){var n=this;return Promise.resolve(this.browserWindow.getAllWindows().map(function(e){return n.wrapWindow(e)}))},t.prototype.getWindowById=function(n){var e=this;return new Promise(function(t,o){var i=e.browserWindow.fromId(n);t(i?e.wrapWindow(i):null)})},t.prototype.getWindowByName=function(n){var e=this;return new Promise(function(t,o){var i=e.browserWindow.getAllWindows().find(function(e){return e.name===n});t(i?e.wrapWindow(i):null)})},t.prototype.saveLayout=function(n){var e=this,t=new p,o=this.getMainWindow().innerWindow,i=[];return new Promise(function(r,s){e.getAllWindows().then(function(s){s.forEach(function(n){i.push(new Promise(function(e,i){n.getGroup().then(function(i){t.windows.push({id:n.id,name:n.name,url:n.innerWindow.webContents.getURL(),main:o===n.innerWindow,bounds:n.innerWindow.getBounds(),group:i.map(function(n){return n.id})}),e()})}))}),Promise.all(i).then(function(){e.saveLayoutToStorage(n,t),r(t)})})})},t.replaceNotificationApi=!0,t.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,e,t){return!n}}},t}(a),k=function(){function n(n,e,t){var o=this;this.lastBounds=new Map,this.ignoredWindows=[],this.app=n||require("electron").app,this.ipc=e||require("electron").ipcMain,this.browserWindow=t||require("electron").BrowserWindow,this.ipc.on(P.initialize,function(n,e){var t=e.id,i=e.name,r=e.options,s=o.browserWindow.fromId(t);o.initializeWindow(s,i,r),n.returnValue=i}),this.ipc.on(P.joinGroup,function(n,e){var t=e.source,i=e.target,r=o.browserWindow.fromId(t),s=o.browserWindow.fromId(i);o.groupWindows(s,r)}),this.ipc.on(P.leaveGroup,function(n,e){var t=e.source;o.ungroupWindows(o.browserWindow.fromId(t))}),this.ipc.on(P.getGroup,function(n,e){var t=e.source;n.returnValue=o.getGroup(o.browserWindow.fromId(t))})}return n.prototype.initializeWindow=function(n,e,t){var o=this;n.name=e,n.options=t,!t||!t.main||"quitOnClose"in t&&!t.quitOnClose||n.on("closed",function(){o.app.quit()})},n.prototype.registerWindowEvents=function(n){var e=this;n&&!n.moveHandler&&(this.lastBounds.set(n.id,n.getBounds()),n.moveHandler=function(t){return e.handleMove(n)},n.on("move",n.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(n){return n.group?this.browserWindow.getAllWindows().filter(function(e){return e.group===n.group}).map(function(n){return n.id}):[]},n.prototype.groupWindows=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var o=0,i=e;o<i.length;o++){var r=i[o];r.group=n.group||(n.group=s.newGuid()),this.registerWindowEvents(r)}this.registerWindowEvents(n)},n.prototype.ungroupWindows=function(){for(var n=this,e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var o=0,i=e;o<i.length;o++){var r=i[o];this.unregisterWindowEvents(r),r.group=null}this.groupBy(this.browserWindow.getAllWindows(),"group").filter(function(n){return n.key&&n.values&&1===n.values.length}).forEach(function(e){for(var t=0,o=e.values;t<o.length;t++){var i=o[t];n.unregisterWindowEvents(i),i.group=null}})},n.prototype.handleMove=function(n){var e=this,t=this.lastBounds.get(n.id),o=n.getBounds();if(this.lastBounds.set(n.id,o),t.width===o.width&&t.height===o.height&&!(this.ignoredWindows.indexOf(n.id)>=0)&&n.group){var i=this.browserWindow.getAllWindows().filter(function(e){return e.group===n.group&&e.id!==n.id});if(i&&i.length>0){var r=t.x-o.x,s=t.y-o.y;i.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,e){return n.reduce(function(n,t){var o=e instanceof Function?e(t):t[e],i=n.find(function(n){return n&&n.key===o});return i?i.values.push(t):n.push({key:o,values:[t]}),n},[])},n}(),E=Object.freeze({ElectronContainerWindow:O,ElectronMessageBus:L,ElectronContainer:M,ElectronWindowManager:k});e("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in fin},create:function(){return new A}});var G={move:"bounds-changing",resize:"bounds-changed",close:"close-requested",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},S=function(e){function t(n){return e.call(this,n)||this}return n(t,e),Object.defineProperty(t.prototype,"id",{get:function(){return this.name},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),t.prototype.focus=function(){var n=this;return new Promise(function(e,t){n.innerWindow.focus(e,t)})},t.prototype.show=function(){var n=this;return new Promise(function(e,t){n.innerWindow.show(e,t)})},t.prototype.hide=function(){var n=this;return new Promise(function(e,t){n.innerWindow.hide(e,t)})},t.prototype.close=function(){var n=this;return new Promise(function(e,t){n.innerWindow.close(!1,e,t)})},t.prototype.isShowing=function(){var n=this;return new Promise(function(e,t){n.innerWindow.isShowing(e,t)})},t.prototype.getSnapshot=function(){var n=this;return new Promise(function(e,t){n.innerWindow.getSnapshot(function(n){return e("data:image/png;base64,"+n)},function(n){return t(n)})})},t.prototype.getBounds=function(){var n=this;return new Promise(function(e,t){n.innerWindow.getBounds(function(n){return e(new d(n.left,n.top,n.width,n.height))},t)})},t.prototype.setBounds=function(n){var e=this;return new Promise(function(t,o){e.innerWindow.setBounds(n.x,n.y,n.width,n.height,t,o)})},Object.defineProperty(t.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.getGroup=function(){var n=this;return new Promise(function(e,o){n.innerWindow.getGroup(function(n){e(n.map(function(n){return new t(n)}))},o)})},t.prototype.joinGroup=function(n){var e=this;return n&&n.id!==this.id?new Promise(function(t,o){e.innerWindow.joinGroup(n.innerWindow,t,o)}):Promise.resolve()},t.prototype.leaveGroup=function(){var n=this;return new Promise(function(e,t){n.innerWindow.leaveGroup(e,t)})},t.prototype.attachListener=function(n,e){this.innerWindow.addEventListener(G[n]||n,e)},t.prototype.detachListener=function(n,e){this.innerWindow.removeEventListener(G[n]||n,e)},t}(c),N=function(){function n(n,e){this.bus=n,this.uuid=e}return n.prototype.subscribe=function(n,e,t){var o=this;return new Promise(function(i,r){var s=new l(n,function(t,o,i){e({topic:n},t)},t);o.bus.subscribe(t&&t.uuid||"*",t&&t.name||void 0,s.topic,s.listener,function(){return i(s)},r)})},n.prototype.unsubscribe=function(n){var e=this,t=n.topic,o=n.listener,i=n.options;return new Promise(function(n,r){e.bus.unsubscribe(i&&i.uuid||"*",i&&i.name||void 0,t,o,n,r)})},n.prototype.publish=function(n,e,t){var o=this;return new Promise(function(i,r){t&&t.uuid||t&&t.name?o.bus.send(t.uuid||o.uuid,t.name||void 0,n,e,i,r):o.bus.publish(n,e,i,r)})},n}(),A=function(e){function t(n,o){var i=e.call(this,o)||this;return i.windowOptionsMap=t.windowOptionsMap,i.notificationOptionsMap=t.notificationOptionsMap,i.desktop=n||fin.desktop,i.hostType="OpenFin",i.ipc=new N(i.desktop.InterApplicationBus,i.desktop.Application.getCurrent().uuid),i.registerNotificationsApi(),i}return n(t,e),t.prototype.registerNotificationsApi=function(){if(t.replaceNotificationApi&&void 0!==this.globalWindow&&this.globalWindow){var e=this;this.globalWindow.Notification=function(t){function o(n,o){var i=t.call(this,n,o)||this;return o.notification=i,o.onClick=function(n){i.onclick&&i.onclick(n)},o.onError=function(n){i.onerror&&i.onerror(n)},e.showNotification(n,o),i}return n(o,t),o}(b)}},t.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},t.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},t.prototype.getWindowOptions=function(n){var e=o.transformProperties(n,this.windowOptionsMap);return"autoShow"in e||(e.autoShow=!0),"saveWindowState"in e||!("defaultLeft"in e||"defaultTop"in e)||(e.saveWindowState=!1),"icon"in e&&(e.icon=this.ensureAbsoluteUrl(e.icon)),e},t.prototype.wrapWindow=function(n){return new S(n)},t.prototype.createWindow=function(n,e){var t=this,o=this.getWindowOptions(e);return o.url=n,"name"in o||(o.name=s.newGuid()),new Promise(function(n,e){var i=new t.desktop.Window(o,function(e){var r=t.wrapWindow(i);t.emit("window-created",{sender:t,name:"window-created",window:r,windowId:o.name,windowName:o.name}),u.emit("window-created",{name:"window-created",windowId:o.name,windowName:o.name}),c.emit("window-created",{name:"window-created",windowId:o.name,windowName:o.name}),n(r)},e)})},t.prototype.showNotification=function(n,e){new this.desktop.Notification(o.transformProperties(e,this.notificationOptionsMap))},t.prototype.getMenuHtml=function(){return t.menuHtml},t.prototype.getMenuItemHtml=function(n){var e=n.icon?'<span><img align="absmiddle" class="context-menu-image" src="'+this.ensureAbsoluteUrl(n.icon)+'" /></span>':"<span>&nbsp;</span>";return'<li class="context-menu-item" onclick="fin.desktop.InterApplicationBus.send(\''+this.desktop.Application.getCurrent().uuid+"', null, 'TrayIcon_ContextMenuClick_"+this.uuid+"', { id: '"+n.id+"' });this.close()\">"+e+n.label+"</li>"},t.prototype.showMenu=function(n,e,o,i){var r=this;this.menuItemRef=i;var u=new this.desktop.Window({name:"trayMenu"+s.newGuid(),saveWindowState:!1,autoShow:!1,defaultWidth:150,defaultHeight:100,showTaskbarIcon:!1,frame:!1,contextMenu:!0,resizable:!1,alwaysOnTop:!0,shadow:!0},function(){var a=u.getNativeWindow();a.document.open("text/html","replace"),a.document.write(r.getMenuHtml()),a.document.close();for(var d="",c=0,p=i.filter(function(n){return n.label});c<p.length;c++){var f=p[c];f.id||(f.id=s.newGuid()),d+=r.getMenuItemHtml(f)}var w=a.document.getElementById("contextMenu");w.innerHTML=d;var l=w.offsetWidth,h=w.offsetHeight;u.resizeTo(l,h,"top-left");var g=n+l>o.primaryMonitor.monitorRect.right?n-l-t.trayIconMenuLeftOffset:n,m=e+h>o.primaryMonitor.monitorRect.bottom?e-h-t.trayIconMenuTopOffset:e;u.addEventListener("blurred",function(){return u.close()}),u.showAt(g,m,!1,function(){return u.focus()})})},t.prototype.addTrayIcon=function(n,e,o){var i=this;this.desktop.Application.getCurrent().setTrayIcon(this.ensureAbsoluteUrl(n.icon),function(n){0===n.button&&e?e():2===n.button&&i.showMenu(n.x+t.trayIconMenuLeftOffset,n.y+t.trayIconMenuTopOffset,n.monitorInfo,o)},function(){i.desktop.InterApplicationBus.subscribe(i.desktop.Application.getCurrent().uuid,"TrayIcon_ContextMenuClick_"+i.uuid,function(n,e){for(var t in i.menuItemRef){var o=i.menuItemRef[t];o.id===n.id&&o.click&&o.click(o)}})},function(n){console.error(n)})},t.prototype.closeAllWindows=function(){var n=this;return new Promise(function(e,t){var o=[];n.desktop.Application.getCurrent().getChildWindows(function(n){n.forEach(function(n){o.push(new Promise(function(e,t){return n.close(!0,e,t)}))}),Promise.all(o).then(function(){return e()})},t)})},t.prototype.getAllWindows=function(){var n=this;return new Promise(function(e,t){n.desktop.Application.getCurrent().getChildWindows(function(t){t.push(n.desktop.Application.getCurrent().getWindow()),e(t.map(function(e){return n.wrapWindow(e)}))},t)})},t.prototype.getWindowById=function(n){return this.getWindowByName(n)},t.prototype.getWindowByName=function(n){var e=this;return new Promise(function(t,o){e.desktop.Application.getCurrent().getChildWindows(function(o){o.push(e.desktop.Application.getCurrent().getWindow());var i=o.find(function(e){return e.name===n});t(i?e.wrapWindow(i):null)})})},t.prototype.saveLayout=function(n){var e=this,t=new p;return new Promise(function(o,i){e.desktop.Application.getCurrent().getChildWindows(function(r){var s=[],u=e.desktop.Application.getCurrent().getWindow();r.concat(u).forEach(function(n){s.push(new Promise(function(e,o){n.getBounds(function(i){n.getGroup(function(o){t.windows.push({name:n.name,id:n.name,url:n.getNativeWindow().location.toString(),main:u.name===n.name,bounds:{x:i.left,y:i.top,width:i.width,height:i.height},group:o.map(function(n){return n.name})}),e()},o)},o)}))}),Promise.all(s).then(function(){e.saveLayoutToStorage(n,t),o(t)}).catch(function(n){return i(n)})})})},t.trayIconMenuLeftOffset=4,t.trayIconMenuTopOffset=23,t.replaceNotificationApi=!0,t.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},t.notificationOptionsMap={body:{target:"message"}},t.menuHtml='<html>\n <head>\n <style>\n body:before, body:after {\n position: fixed;\n background: silver;\n }\n body {\n margin: 0px;\n overflow: hidden;\n }\n .context-menu {\n list-style: none;\n padding: 1px 0 1px 0;\n }\n .context-menu-item {\n display: block;\n cursor: default;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 9pt;\n margin-bottom: 2px;\n padding: 4px 0 4px 4px;\n white-space: nowrap;\n }\n .context-menu-item span {\n display: inline-block;\n min-width: 20px;\n }\n .context-menu-item:last-child {\n margin-bottom: 0;\n } \n .context-menu-item:hover {\n color: #fff;\n background-color: #0066aa;\n }\n .context-menu-image {\n width: 16px;\n height: 16px;\n margin-top: -1px;\n margin-right: 4px;\n } \n </style>\n <script>\n document.addEventListener(\'keydown\', (event) => {\n if (event.keyCode == 27) {\n window.close();\n }\n }, false);\n <\/script>\n </head>\n <body>\n <ul class="context-menu" id="contextMenu"></ul>\n </body>\n </html>',t}(a),I=Object.freeze({OpenFinContainerWindow:S,OpenFinMessageBus:N,OpenFinContainer:A});return function(){function n(){}return Object.defineProperty(n,"version",{get:function(){return"2.0.0"},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Container",{get:function(){return u},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ContainerWindow",{get:function(){return c},enumerable:!0,configurable:!0}),Object.defineProperty(n,"registerContainer",{get:function(){return e},enumerable:!0,configurable:!0}),Object.defineProperty(n,"resolveContainer",{get:function(){return t},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Default",{get:function(){return v},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Electron",{get:function(){return E},enumerable:!0,configurable:!0}),Object.defineProperty(n,"OpenFin",{get:function(){return I},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SnapAssistWindowManager",{get:function(){return f},enumerable:!0,configurable:!0}),n}()});
//# sourceMappingURL=desktop.min.js.map
// Generated by dts-bundle v0.7.3
const exportDesktopJS: {
Container: typeof Container;
container: Container;
registerContainer: (id: string, registration: ContainerRegistration) => void;
resolveContainer: (force?: boolean) => Container;
Default: typeof Default;
Electron: typeof Electron;
OpenFin: typeof OpenFin;
};
export default exportDesktopJS;
export default class Desktop {
static readonly version: string;
static readonly Container: typeof Container;
static readonly ContainerWindow: typeof ContainerWindow;
static readonly registerContainer: typeof registerContainer;
static readonly resolveContainer: typeof resolveContainer;
static readonly Default: typeof Default;
static readonly Electron: typeof Electron;
static readonly OpenFin: typeof OpenFin;
static readonly SnapAssistWindowManager: typeof SnapAssistWindowManager;
}

@@ -34,7 +35,2 @@ /** Represents the registration details of a container. */

export type ContainerEventType = "window-created" | "layout-loaded" | "layout-saved";
export class WindowEventArgs extends EventArgs {
readonly window?: ContainerWindow;
readonly windowId: string;
readonly windowName?: string;
}
export class LayoutEventArgs extends EventArgs {

@@ -63,3 +59,3 @@ readonly layout?: PersistedWindowLayout;

abstract getCurrentWindow(): ContainerWindow;
abstract createWindow(url: string, options?: any): ContainerWindow;
abstract createWindow(url: string, options?: any): Promise<ContainerWindow>;
abstract saveLayout(name: string): Promise<PersistedWindowLayout>;

@@ -77,2 +73,4 @@ abstract loadLayout(name: string): Promise<PersistedWindowLayout>;

abstract getAllWindows(): Promise<ContainerWindow[]>;
abstract getWindowById(id: string): Promise<ContainerWindow | null>;
abstract getWindowByName(name: string): Promise<ContainerWindow | null>;
static ipc: MessageBus;

@@ -127,2 +125,168 @@ /**

/** Represents the bounds of a rectangle */
export class Rectangle {
/** The x coordinate of the origin of the rectangle
* @type {number}
*/
readonly x: number;
/** The y coordinate of the origin of the rectangle
* @type {number}
*/
readonly y: number;
/** The width of the rectangle
* @type {number}
*/
readonly width: number;
/** The height of the rectangle
* @type {number}
*/
readonly height: number;
readonly right: number;
readonly bottom: number;
static getRight(r: Rectangle): number;
static getBottom(r: Rectangle): number;
constructor(x: number, y: number, width: number, height: number);
}
export type WindowEventType = "window-created" | "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore";
export class WindowEventArgs extends EventArgs {
readonly window?: ContainerWindow;
readonly windowId: string;
readonly windowName?: string;
}
/** Represents a container window. */
export abstract class ContainerWindow extends EventEmitter {
/** The underlying concrete container window. */
readonly innerWindow: any;
readonly id: string;
readonly name: string;
constructor(wrap: any);
/** Gives focus to the window. */
abstract focus(): Promise<void>;
/** Shows the window if hidden. */
abstract show(): Promise<void>;
/** Hides the window if showing. */
abstract hide(): Promise<void>;
/** Try to close the window. This has the same effect as clicking the close button on the window. */
abstract close(): Promise<void>;
/** Determines whether the window is currently showing. */
abstract isShowing(): Promise<boolean>;
/** Gets a base64 encoded snapshot of the window. */
abstract getSnapshot(): Promise<string>;
/** Gets the current bounds of the window. */
abstract getBounds(): Promise<Rectangle>;
/** Set the current bounds of the window.
* @param {Rectangle} bounds
*/
abstract setBounds(bounds: Rectangle): Promise<void>;
readonly allowGrouping: boolean;
getGroup(): Promise<ContainerWindow[]>;
joinGroup(target: ContainerWindow): Promise<void>;
leaveGroup(): Promise<void>;
/**
* Override to provide custom container logic for adding an event handler.
*/
protected abstract attachListener(eventName: WindowEventType, listener: (event: EventArgs) => void): void;
/**
* Registers an event listener on the specified event.
* @param eventName {WindowEventType} eventName The type of the event.
* @param listener {(event: EventArgs) => void} The event handler function.
*/
addListener(eventName: WindowEventType, listener: (event: EventArgs) => void): this;
/**
* Override to provide custom container logic for removing an event handler.
*/
protected abstract detachListener(eventName: WindowEventType, listener: (event: EventArgs) => void): void;
/**
* Removes a previous registered event listener from the specified event.
* @param eventName {WindowEventType} eventName The type of the event.
* @param listener {(event: EventArgs) => void} The event handler function.
*/
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 listeners(eventName: string): ((event: EventArgs) => void)[];
}
/** Represents window management capability */
export interface ContainerWindowManager {
/**
* Gets the main ContainerWindow of the application.
* @returns {ContainerWindow} The main ContainerWindow.
*/
getMainWindow(): ContainerWindow;
/**
* Gets the current ContainerWindow
* @returns {ContainerWindow} The current ContainerWindow
*/
getCurrentWindow(): ContainerWindow;
/**
* Retrieves a list of {@link ContainerWindow} wrapped native windows.
* @returns {Promise<ContainerWindow[]>} - A promise that returns an array of {@link ContainerWindow} if resolved
*/
getAllWindows(): Promise<ContainerWindow[]>;
/**
* Retrieve a {@link ContainerWindow} with provided id.
* @returns {Promise<ContainerWindow>} - A promise that returns a {ContainerWindow} if resolved
*/
getWindowById(id: string): Promise<ContainerWindow | null>;
/**
* Retrieve a {@link ContainerWindow} with provided name.
* @returns {Promise<ContainerWindow>} - A promise that returns a {ContainerWindow} if resolved
*/
getWindowByName(name: string): Promise<ContainerWindow | null>;
/**
* Creates a new ContainerWindow.
* @param {string} url url
* @param {any} options (Optional)
* @returns {ContainerWindow} A new native container window wrapped within a generic ContainerWindow.
*/
createWindow(url: string, options?: any): Promise<ContainerWindow>;
/**
* Loads a window layout from persistence
* @param {string} name - Name of the window layout to load
*/
loadLayout(name: string): Promise<PersistedWindowLayout>;
/** Persists a window layout
* @param {string} name - Name of the window layout to save
* @returns {Promise<PersistedWindowLayout>} - A promise that returns {@link PersistedWindowLayout} if resolved
*/
saveLayout(name: string): Promise<PersistedWindowLayout>;
/**
* Retrieve a list of persisted window layouts
* @returns {Promise<PersistedWindowLayout[]>} - A promise that returns an array of {@link PersistedWindowLayout} if resolved
*/
getLayouts(): Promise<PersistedWindowLayout[]>;
}
/** Represents a persisted window in a layout */
export class PersistedWindow {
name: string;
id: string;
bounds: any;
url?: string;
main?: boolean;
group?: string[];
}
/** Represents a persisted window layout */
export class PersistedWindowLayout {
name: string;
windows: PersistedWindow[];
constructor(name?: string);
}
export class SnapAssistWindowManager {
autoGrouping: boolean;
snapThreshold: number;
snapOffset: number;
protected readonly targetGroup: Map<string, ContainerWindow>;
constructor(container: Container, options?: any);
/**
* Invoked on attach of each window to prepare windows for snap/dock feature
*/
protected onAttached(win: ContainerWindow): void;
attach(win?: ContainerWindow): void;
protected moveWindow(win: ContainerWindow, bounds: Rectangle): void;
protected onMoved(win: ContainerWindow): void;
protected showGroupingHint(win: ContainerWindow): void;
protected hideGroupingHint(win: ContainerWindow): void;
}
export module Default {

@@ -134,2 +298,4 @@ /**

constructor(wrap: any);
readonly id: string;
readonly name: string;
focus(): Promise<void>;

@@ -168,7 +334,9 @@ show(): Promise<void>;

protected getWindowOptions(options?: any): any;
protected wrapWindow(containerWindow: any): DefaultContainerWindow;
createWindow(url: string, options?: any): ContainerWindow;
wrapWindow(containerWindow: any): DefaultContainerWindow;
createWindow(url: string, options?: any): Promise<ContainerWindow>;
showNotification(title: string, options?: NotificationOptions): void;
protected closeAllWindows(excludeSelf?: Boolean): Promise<void>;
getAllWindows(): Promise<ContainerWindow[]>;
getWindowById(id: string): Promise<ContainerWindow | null>;
getWindowByName(name: string): Promise<ContainerWindow | null>;
saveLayout(name: string): Promise<PersistedWindowLayout>;

@@ -183,3 +351,5 @@ }

export class ElectronContainerWindow extends ContainerWindow {
constructor(wrap: any);
constructor(wrap: any, container: ElectronContainer);
readonly id: string;
readonly name: string;
focus(): Promise<void>;

@@ -193,2 +363,6 @@ show(): Promise<void>;

setBounds(bounds: Rectangle): Promise<void>;
readonly allowGrouping: boolean;
getGroup(): Promise<any[]>;
joinGroup(target: ContainerWindow): Promise<void>;
leaveGroup(): Promise<void>;
protected attachListener(eventName: string, listener: (...args: any[]) => void): void;

@@ -212,9 +386,8 @@ protected detachListener(eventName: string, listener: (...args: any[]) => void): void;

protected isRemote: Boolean;
protected mainWindow: ElectronContainerWindow;
protected electron: any;
protected app: any;
protected browserWindow: any;
browserWindow: any;
protected tray: any;
protected menu: any;
protected internalIpc: NodeJS.EventEmitter;
internalIpc: NodeJS.EventEmitter;
/**

@@ -233,4 +406,4 @@ * Gets or sets whether to replace the native web Notification API with a wrapper around showNotification.

protected getWindowOptions(options?: any): any;
protected wrapWindow(containerWindow: any): ElectronContainerWindow;
createWindow(url: string, options?: any): ContainerWindow;
wrapWindow(containerWindow: any): ElectronContainerWindow;
createWindow(url: string, options?: any): Promise<ContainerWindow>;
showNotification(title: string, options?: NotificationOptions): void;

@@ -240,5 +413,14 @@ addTrayIcon(details: TrayIconDetails, listener: () => void, menuItems?: MenuItem[]): void;

getAllWindows(): Promise<ContainerWindow[]>;
getWindowById(id: string): Promise<ContainerWindow | null>;
getWindowByName(name: string): Promise<ContainerWindow | null>;
saveLayout(name: string): Promise<PersistedWindowLayout>;
}
export class ElectronWindowManager {
constructor(app?: any, ipc?: NodeJS.EventEmitter, browserWindow?: any);
initializeWindow(win: any, name: string, options: any): void;
getGroup(window: any): any[];
groupWindows(target: any, ...windows: any[]): void;
ungroupWindows(...windows: any[]): void;
}
}

@@ -251,2 +433,4 @@ export module OpenFin {

constructor(wrap: any);
readonly id: string;
readonly name: string;
focus(): Promise<void>;

@@ -260,2 +444,6 @@ show(): Promise<void>;

setBounds(bounds: Rectangle): Promise<void>;
readonly allowGrouping: boolean;
getGroup(): Promise<ContainerWindow[]>;
joinGroup(target: ContainerWindow): Promise<void>;
leaveGroup(): Promise<void>;
protected attachListener(eventName: string, listener: (...args: any[]) => void): void;

@@ -293,4 +481,4 @@ protected detachListener(eventName: string, listener: (...args: any[]) => void): any;

protected getWindowOptions(options?: any): any;
protected wrapWindow(containerWindow: any): OpenFinContainerWindow;
createWindow(url: string, options?: any): ContainerWindow;
wrapWindow(containerWindow: any): OpenFinContainerWindow;
createWindow(url: string, options?: any): Promise<ContainerWindow>;
showNotification(title: string, options?: NotificationOptions): void;

@@ -302,2 +490,4 @@ protected getMenuHtml(): string;

getAllWindows(): Promise<ContainerWindow[]>;
getWindowById(id: string): Promise<ContainerWindow | null>;
getWindowByName(name: string): Promise<ContainerWindow | null>;
saveLayout(name: string): Promise<PersistedWindowLayout>;

@@ -307,120 +497,2 @@ }

/** Represents the bounds of a rectangle */
export class Rectangle {
/** The x coordinate of the origin of the rectangle
* @type {number}
*/
readonly x: number;
/** The y coordinate of the origin of the rectangle
* @type {number}
*/
readonly y: number;
/** The width of the rectangle
* @type {number}
*/
readonly width: number;
/** The height of the rectangle
* @type {number}
*/
readonly height: number;
constructor(x: number, y: number, width: number, height: number);
}
export type WindowEventType = "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore";
/** Represents a container window. */
export abstract class ContainerWindow extends EventEmitter {
/** The underlying concrete container window. */
readonly innerWindow: any;
constructor(wrap: any);
/** Gives focus to the window. */
abstract focus(): Promise<void>;
/** Shows the window if hidden. */
abstract show(): Promise<void>;
/** Hides the window if showing. */
abstract hide(): Promise<void>;
/** Try to close the window. This has the same effect as clicking the close button on the window. */
abstract close(): Promise<void>;
/** Determines whether the window is currently showing. */
abstract isShowing(): Promise<boolean>;
/** Gets a base64 encoded snapshot of the window. */
abstract getSnapshot(): Promise<string>;
/** Gets the current bounds of the window. */
abstract getBounds(): Promise<Rectangle>;
/** Set the current bounds of the window.
* @param {Rectangle} bounds
*/
abstract setBounds(bounds: Rectangle): Promise<void>;
/**
* Override to provide custom container logic for adding an event handler.
*/
protected abstract attachListener(eventName: WindowEventType, listener: (event: EventArgs) => void): void;
/**
* Registers an event listener on the specified event.
* @param eventName {WindowEventType} eventName The type of the event.
* @param listener {(event: EventArgs) => void} The event handler function.
*/
addListener(eventName: WindowEventType, listener: (event: EventArgs) => void): this;
/**
* Override to provide custom container logic for removing an event handler.
*/
protected abstract detachListener(eventName: WindowEventType, listener: (event: EventArgs) => void): void;
/**
* Removes a previous registered event listener from the specified event.
* @param eventName {WindowEventType} eventName The type of the event.
* @param listener {(event: EventArgs) => void} The event handler function.
*/
removeListener(eventName: WindowEventType, listener: (event: EventArgs) => void): this;
}
/** Represents window management capability */
export interface ContainerWindowManager {
/**
* Gets the main ContainerWindow of the application.
* @returns {ContainerWindow} The main ContainerWindow.
*/
getMainWindow(): ContainerWindow;
/**
* Gets the current ContainerWindow
* @returns {ContainerWindow} The current ContainerWindow
*/
getCurrentWindow(): ContainerWindow;
/**
* Retrieves a list of {@link ContainerWindow} wrapped native windows.
* @returns {Promise<ContainerWindow[]>} - A promise that returns an array of {@link ContainerWindow} if resolved
*/
getAllWindows(): Promise<ContainerWindow[]>;
/**
* Creates a new ContainerWindow.
* @param {string} url url
* @param {any} options (Optional)
* @returns {ContainerWindow} A new native container window wrapped within a generic ContainerWindow.
*/
createWindow(url: string, options?: any): ContainerWindow;
/**
* Loads a window layout from persistence
* @param {string} name - Name of the window layout to load
*/
loadLayout(name: string): Promise<PersistedWindowLayout>;
/** Persists a window layout
* @param {string} name - Name of the window layout to save
* @returns {Promise<PersistedWindowLayout>} - A promise that returns {@link PersistedWindowLayout} if resolved
*/
saveLayout(name: string): Promise<PersistedWindowLayout>;
/**
* Retrieve a list of persisted window layouts
* @returns {Promise<PersistedWindowLayout[]>} - A promise that returns an array of {@link PersistedWindowLayout} if resolved
*/
getLayouts(): Promise<PersistedWindowLayout[]>;
}
/** Represents a persisted window in a layout */
export class PersistedWindow {
name: any;
bounds: any;
url: string;
}
/** Represents a persisted window layout */
export class PersistedWindowLayout {
name: string;
windows: PersistedWindow[];
constructor(name?: string);
}
export class NotificationOptions {

@@ -473,6 +545,2 @@ url?: string;

/**
* @param {MessageBus} ipc (Optional) The {MessageBus} in which to subscribe for broadcast events to raise
*/
constructor(ipc?: MessageBus);
/**
* Registers an event listener on the specified event.

@@ -501,3 +569,25 @@ * @param {string} eventName The type of the event.

*/
emit(eventName: string, eventArgs: EventArgs, ipc?: MessageBus): void;
emit(eventName: string, eventArgs: EventArgs): void;
/**
* Set message bus used for static event broadcasting across windows.
*/
static ipc: MessageBus;
/**
* Registers an event listener on the specified static event.
* @param {string} eventName The type of the event.
* @param {(event: EventArgs) => void} listener The event handler function.
*/
static addListener(eventName: string, listener: (event: EventArgs) => void): void;
/**
* Removes a previous registered event listener from the specified static event.
* @param {string} eventName The type of the event.
* @param {(event: EventArgs) => void} listener The event handler function.
*/
static removeListener(eventName: string, listener: (event: EventArgs) => void): void;
/**
* Gets an array of listeners for a specific static event type.
* @param {string} eventName eventName The type of the event.
*/
static listeners(eventName: string): ((event: EventArgs) => void)[];
static emit(eventName: string, eventArgs: EventArgs, ipc?: MessageBus): void;
}

@@ -504,0 +594,0 @@

@@ -5,4 +5,4 @@ {

"description": "Library for abstracting common container hosting",
"version": "1.0.0",
"publishConfig":{
"version": "2.0.0",
"publishConfig": {
"access": "public"

@@ -32,16 +32,17 @@ },

],
"dependencies": {},
"dependencies": {
"@types/node": "*",
"@types/openfin": "*"
},
"devDependencies": {
"@types/jasmine": "^2.5.47",
"@types/node": "^7.0.12",
"@types/openfin": "^17.0.2",
"codecov": "^2.2.0",
"codecov": "^3.0.0",
"dts-bundle": "^0.7.2",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-clean": "^0.4.0",
"gulp-istanbul": "^1.1.1",
"gulp-istanbul-enforcer": "^1.0.3",
"gulp-jasmine": "^2.4.2",
"gulp-jasmine": "^3.0.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-replace": "^0.6.1",
"gulp-sourcemaps": "^2.5.0",

@@ -51,19 +52,27 @@ "gulp-tslint": "^8.1.0",

"gulp-typescript": "^3.1.6",
"gulp-uglify": "^2.1.2",
"gulp-uglify": "^3.0.0",
"gulp-webserver": "^0.9.1",
"merge2": "^1.0.3",
"remap-istanbul": "^0.9.5",
"remap-istanbul": "^0.10.0",
"rollup": "^0.41.6",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-typescript": "^0.8.1",
"run-sequence": "^2.2.0",
"tslib": "^1.6.0",
"tslint": "^5.3.2",
"tslint-microsoft-contrib": "^5.0.0",
"tsutils": "^1.6.0",
"typedoc": "^0.7.1",
"typescript": "2.3.3"
"tsutils": "^2.12.1",
"typedoc": "^0.9.0",
"typescript": "2.6.1"
},
"greenkeeper": {
"ignore": [
"rollup"
]
},
"scripts": {
"tslint": "./node_modules/.bin/gulp tslint",
"clean": "./node_modules/.bin/gulp clean",
"build": "./node_modules/.bin/gulp",

@@ -70,0 +79,0 @@ "watch": "./node_modules/.bin/gulp watch",

![desktopJS](https://raw.githubusercontent.com/wiki/morgan-stanley/desktopJS/images/logo.png)
==========
[![npm version](https://badge.fury.io/js/%40morgan-stanley%2Fdesktopjs.svg)](https://www.npmjs.com/package/@morgan-stanley/desktopjs)
[![Build Status](https://travis-ci.org/Morgan-Stanley/desktopJS.svg?branch=master)](https://travis-ci.org/Morgan-Stanley/desktopJS)
[![codecov](https://codecov.io/gh/Morgan-Stanley/desktopJS/branch/master/graph/badge.svg)](https://codecov.io/gh/Morgan-Stanley/desktopJS)
[![Greenkeeper badge](https://badges.greenkeeper.io/Morgan-Stanley/desktopJS.svg)](https://greenkeeper.io/)
[![devDependencies Status](https://david-dm.org/Morgan-Stanley/desktopJS/dev-status.svg)](https://david-dm.org/Morgan-Stanley/desktopJS?type=dev)

@@ -18,3 +20,3 @@ [![dependencies Status](https://david-dm.org/Morgan-Stanley/desktopJS/status.svg)](https://david-dm.org/Morgan-Stanley/desktopJS)

The first step is to simply [resolve](https://morgan-stanley.github.io/desktopJS/modules/_registry_.html#resolvecontainer) the current [container](https://morgan-stanley.github.io/desktopJS/interfaces/_container_.container.html). This enumerates
The first step is to simply [resolve](https://morgan-stanley.github.io/desktopJS/modules/_registry_.html#resolvecontainer) the current [container](https://morgan-stanley.github.io/desktopJS/classes/_container_.container.html). This enumerates
all registered containers (including your own custom container or derived custom implementations) and

@@ -28,3 +30,3 @@ returns the container implementation that matches.

Interact with the [container](https://morgan-stanley.github.io/desktopJS/interfaces/_container_.container.html) via a single api instead of having conditional code or applications
Interact with the [container](https://morgan-stanley.github.io/desktopJS/classes/_container_.container.html) via a single api instead of having conditional code or applications
based on deployment.

@@ -79,3 +81,3 @@

```
npm run test
$ npm run test
```

@@ -102,3 +104,3 @@

Examples showcasing usage of desktopJS for various containers and scenarios can be found under
the [examples](examples/README.md) directory.
the [examples](https://github.com/Morgan-Stanley/desktopJS/tree/master/examples) directory.

Sorry, the diff of this file is too big to display

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 too big to display

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