@morgan-stanley/desktopjs-openfin
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -34,2 +34,3 @@ // Generated by dts-bundle v0.7.3 | ||
leaveGroup(): Promise<void>; | ||
bringToFront(): Promise<void>; | ||
getOptions(): Promise<any>; | ||
@@ -36,0 +37,0 @@ getState(): Promise<any>; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@morgan-stanley/desktopjs')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@morgan-stanley/desktopjs'], factory) : | ||
(factory((global.desktopJS = global.desktopJS || {}, global.desktopJS.OpenFin = {}),global.desktopJS)); | ||
}(this, (function (exports,desktopjs) { 'use strict'; | ||
(global = global || self, factory((global.desktopJS = global.desktopJS || {}, global.desktopJS.OpenFin = {}), global.desktopJS)); | ||
}(this, function (exports, desktopjs) { 'use strict'; | ||
@@ -210,3 +210,6 @@ /*! ***************************************************************************** | ||
return new Promise(function (resolve, reject) { | ||
_this.innerWindow.joinGroup(target.innerWindow, resolve, reject); | ||
_this.innerWindow.joinGroup(target.innerWindow, function () { | ||
desktopjs.ContainerWindow.emit("window-joinGroup", { name: "window-joinGroup", windowId: _this.id, targetWindowId: target.id }); | ||
resolve(); | ||
}, reject); | ||
}); | ||
@@ -217,5 +220,14 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
_this.innerWindow.leaveGroup(resolve, reject); | ||
_this.innerWindow.leaveGroup(function () { | ||
desktopjs.ContainerWindow.emit("window-leaveGroup", { name: "window-leaveGroup", windowId: _this.id }); | ||
resolve(); | ||
}, reject); | ||
}); | ||
}; | ||
OpenFinContainerWindow.prototype.bringToFront = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.innerWindow.bringToFront(resolve, reject); | ||
}); | ||
}; | ||
OpenFinContainerWindow.prototype.getOptions = function () { | ||
@@ -348,2 +360,8 @@ var _this = this; | ||
_this.screen = new OpenFinDisplayManager(_this.desktop); | ||
if (_this.desktop.GlobalHotkey) { | ||
_this.globalShortcut = new OpenFinGlobalShortcutManager(_this.desktop); | ||
} | ||
else { | ||
console.warn("Global shortcuts require minimum OpenFin runtime of 9.61.32.34"); | ||
} | ||
return _this; | ||
@@ -643,2 +661,35 @@ } | ||
}()); | ||
var OpenFinGlobalShortcutManager = (function (_super) { | ||
__extends(OpenFinGlobalShortcutManager, _super); | ||
function OpenFinGlobalShortcutManager(desktop) { | ||
var _this = _super.call(this) || this; | ||
_this.desktop = desktop; | ||
return _this; | ||
} | ||
OpenFinGlobalShortcutManager.prototype.register = function (shortcut, callback) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.register(shortcut, callback, resolve, reject); | ||
}); | ||
}; | ||
OpenFinGlobalShortcutManager.prototype.isRegistered = function (shortcut) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.isRegistered(shortcut, resolve, reject); | ||
}); | ||
}; | ||
OpenFinGlobalShortcutManager.prototype.unregister = function (shortcut) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.unregister(shortcut, resolve, reject); | ||
}); | ||
}; | ||
OpenFinGlobalShortcutManager.prototype.unregisterAll = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.unregisterAll(resolve, reject); | ||
}); | ||
}; | ||
return OpenFinGlobalShortcutManager; | ||
}(desktopjs.GlobalShortcutManager)); | ||
@@ -651,3 +702,3 @@ exports.OpenFinContainerWindow = OpenFinContainerWindow; | ||
}))); | ||
})); | ||
//# sourceMappingURL=desktopjs-openfin.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],t):t((n.desktopJS=n.desktopJS||{},n.desktopJS.OpenFin={}),n.desktopJS)}(this,function(n,g){"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 t(n,t){function e(){this.constructor=n}o(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}function c(r,u,a,s){return new(a||(a=Promise))(function(n,t){function e(n){try{i(s.next(n))}catch(n){t(n)}}function o(n){try{i(s.throw(n))}catch(n){t(n)}}function i(t){t.done?n(t.value):new a(function(n){n(t.value)}).then(e,o)}i((s=s.apply(r,u||[])).next())})}function p(e,o){var i,r,u,n,a={label:0,sent:function(){if(1&u[0])throw u[1];return u[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(;a;)try{if(i=1,r&&(u=2&t[0]?r.return:t[0]?r.throw||((u=r.return)&&u.call(r),0):r.next)&&!(u=u.call(r,t[1])).done)return u;switch(r=0,u&&(t=[2&t[0],u.value]),t[0]){case 0:case 1:u=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,r=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(u=0<(u=a.trys).length&&u[u.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!u||t[1]>u[0]&&t[1]<u[3])){a.label=t[1];break}if(6===t[0]&&a.label<u[1]){a.label=u[1],u=t;break}if(u&&a.label<u[2]){a.label=u[2],a.ops.push(t);break}u[2]&&a.ops.pop(),a.trys.pop();continue}t=o.call(e,a)}catch(n){t=[6,n],r=0}finally{i=u=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,n])}}}g.registerContainer("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in window.fin},create:function(n){return new u(null,null,n)}});var r={move:"bounds-changing",resize:"bounds-changing",close:"close-requested",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},e=function(i){function o(n){return i.call(this,n)||this}return t(o,i),Object.defineProperty(o.prototype,"id",{get:function(){return this.name},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),o.prototype.load=function(e,n){var o=this;return new Promise(function(n,t){o.innerWindow.navigate(e,n,t)})},o.prototype.focus=function(){var e=this;return new Promise(function(n,t){e.innerWindow.focus(n,t)})},o.prototype.show=function(){var e=this;return new Promise(function(n,t){e.innerWindow.show(n,t)})},o.prototype.hide=function(){var e=this;return new Promise(function(n,t){e.innerWindow.hide(n,t)})},o.prototype.close=function(){var e=this;return new Promise(function(n,t){e.innerWindow.close(!1,n,t)})},o.prototype.minimize=function(){var e=this;return new Promise(function(n,t){e.innerWindow.minimize(n,t)})},o.prototype.maximize=function(){var e=this;return new Promise(function(n,t){e.innerWindow.maximize(n,t)})},o.prototype.restore=function(){var e=this;return new Promise(function(n,t){e.innerWindow.restore(n,t)})},o.prototype.isShowing=function(){var e=this;return new Promise(function(n,t){e.innerWindow.isShowing(n,t)})},o.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)})})},o.prototype.getBounds=function(){var e=this;return new Promise(function(t,n){e.innerWindow.getBounds(function(n){return t(new g.Rectangle(n.left,n.top,n.width,n.height))},n)})},o.prototype.flash=function(e,o){var i=this;return new Promise(function(n,t){e?i.innerWindow.flash(o,n,t):i.innerWindow.stopFlashing(n,t)})},o.prototype.setBounds=function(e){var o=this;return new Promise(function(n,t){o.innerWindow.setBounds(e.x,e.y,e.width,e.height,n,t)})},Object.defineProperty(o.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),o.prototype.getGroup=function(){var e=this;return new Promise(function(t,n){e.innerWindow.getGroup(function(n){t(n.map(function(n){return new o(n)}))},n)})},o.prototype.joinGroup=function(e){var o=this;return e&&e.id!==this.id?new Promise(function(n,t){o.innerWindow.joinGroup(e.innerWindow,n,t)}):Promise.resolve()},o.prototype.leaveGroup=function(){var e=this;return new Promise(function(n,t){e.innerWindow.leaveGroup(n,t)})},o.prototype.getOptions=function(){var e=this;return new Promise(function(t,n){e.innerWindow.getOptions(function(n){return t(n.customData?JSON.parse(n.customData):void 0)},n)})},o.prototype.getState=function(){var t=this;return new Promise(function(n){t.nativeWindow&&t.nativeWindow.getState?n(t.nativeWindow.getState()):n(void 0)})},o.prototype.setState=function(t){var e=this;return new Promise(function(n){e.nativeWindow&&e.nativeWindow.setState&&e.nativeWindow.setState(t),n()})},o.prototype.attachListener=function(n,e){var o=this;"beforeunload"===n?this.innerWindow.addEventListener("close-requested",function(n){var t=new g.EventArgs(o,"beforeunload",n);e(t),void 0===t.returnValue&&o.innerWindow.close(!0)}):this.innerWindow.addEventListener(r[n]||n,e)},o.prototype.wrapListener=function(t,e){var o=this;return"resize"===t?function(n){1<=n.changeType&&e(new g.EventArgs(o,t,n))}:"move"===t?function(n){0===n.changeType&&e(new g.EventArgs(o,t,n))}:i.prototype.wrapListener.call(this,t,e)},o.prototype.detachListener=function(n,t){this.innerWindow.removeEventListener(r[n]||n,t)},Object.defineProperty(o.prototype,"nativeWindow",{get:function(){return this.innerWindow.getNativeWindow()},enumerable:!0,configurable:!0}),o}(g.ContainerWindow),i=function(){function n(n,t){this.bus=n,this.uuid=t}return n.prototype.subscribe=function(o,i,r){var u=this;return new Promise(function(n,t){var e=new g.MessageBusSubscription(o,function(n,t,e){i({topic:o},n)},r);u.bus.subscribe(r&&r.uuid||"*",r&&r.name||void 0,e.topic,e.listener,function(){return n(e)},t)})},n.prototype.unsubscribe=function(n){var e=this,o=n.topic,i=n.listener,r=n.options;return new Promise(function(n,t){e.bus.unsubscribe(r&&r.uuid||"*",r&&r.name||void 0,o,i,n,t)})},n.prototype.publish=function(e,o,i){var r=this;return new Promise(function(n,t){i&&i.uuid||i&&i.name?r.bus.send(i.uuid||r.uuid,i.name||void 0,e,o,n,t):r.bus.publish(e,o,n,t)})},n}(),u=function(r){function h(n,t,e){var o=r.call(this,t)||this;o.windowOptionsMap=h.windowOptionsMap,o.notificationOptionsMap=h.notificationOptionsMap,o.desktop=n||window.fin.desktop,o.hostType="OpenFin",e&&e.userName&&e.appName&&o.desktop.Application.getCurrent().registerUser(e.userName,e.appName),o.ipc=o.createMessageBus();var i=h.replaceNotificationApi;return e&&void 0!==e.replaceNotificationApi&&(i=e.replaceNotificationApi),i&&o.registerNotificationsApi(),o.desktop.Application.getCurrent().addEventListener("window-created",function(n){o.emit("window-created",{sender:o,name:"window-created",windowId:n.name,windowName:n.name}),g.Container.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name}),g.ContainerWindow.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name})}),o.screen=new a(o.desktop),o}return t(h,r),h.prototype.createMessageBus=function(){return new i(this.desktop.InterApplicationBus,this.desktop.Application.getCurrent().uuid)},h.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var i=this;this.globalWindow.Notification=function(o){function n(n,t){var e=o.call(this,n,t)||this;return t.notification=e,t.onClick=function(n){e.onclick&&e.onclick(n)},t.onError=function(n){e.onerror&&e.onerror(n)},i.showNotification(n,t),e}return t(n,o),n}(g.ContainerNotification)}},h.prototype.log=function(e,o){var i=this;return new Promise(function(n,t){i.desktop.System.log(e,o,n,t)})},h.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},h.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},h.prototype.getWindowOptions=function(n){var t=g.ObjectTransform.transformProperties(n,this.windowOptionsMap);return t.customData=n?JSON.stringify(n):void 0,"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},h.prototype.wrapWindow=function(n){return new e(n)},h.prototype.createWindow=function(n,t){var o=this,i=this.getWindowOptions(t);return i.url=n,"name"in i||(i.name=g.Guid.newGuid()),new Promise(function(t,n){var e=new o.desktop.Window(i,function(n){t(o.wrapWindow(e))},n)})},h.prototype.showNotification=function(n,t){new this.desktop.Notification(g.ObjectTransform.transformProperties(t,this.notificationOptionsMap))},h.prototype.getMenuHtml=function(){return h.menuHtml},h.prototype.getMenuItemHtml=function(n){var t=n.icon?'<span><img align="absmiddle" class="context-menu-image" src="'+this.ensureAbsoluteUrl(n.icon)+'" /></span>':"<span> </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>"},h.prototype.showMenu=function(p,d,f,l){var w=this;this.menuItemRef=l;var m=new this.desktop.Window({name:"trayMenu"+g.Guid.newGuid(),saveWindowState:!1,autoShow:!1,defaultWidth:150,defaultHeight:100,showTaskbarIcon:!1,frame:!1,contextMenu:!0,resizable:!1,alwaysOnTop:!0,shadow:!0,smallWindow:!0},function(){var n=m.getNativeWindow();n.document.open("text/html","replace"),n.document.write(w.getMenuHtml()),n.document.close();for(var t="",e=0,o=l.filter(function(n){return n.label});e<o.length;e++){var i=o[e];i.id||(i.id=g.Guid.newGuid()),t+=w.getMenuItemHtml(i)}var r=n.document.getElementById("contextMenu");r.innerHTML=t;var u=r.offsetWidth,a=r.offsetHeight;m.resizeTo(u,a,"top-left");var s=p+u>f.primaryMonitor.monitorRect.right?p-u-h.trayIconMenuLeftOffset:p,c=d+a>f.primaryMonitor.monitorRect.bottom?d-a-h.trayIconMenuTopOffset:d;m.addEventListener("blurred",function(){return m.close()}),m.showAt(s,c,!1,function(){return m.focus()})})},h.prototype.addTrayIcon=function(n,t,e){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+h.trayIconMenuLeftOffset,n.y+h.trayIconMenuTopOffset,n.monitorInfo,e)},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)})},h.prototype.closeAllWindows=function(){var e=this;return new Promise(function(t,n){var o=[];e.desktop.Application.getCurrent().getChildWindows(function(n){n.forEach(function(e){o.push(new Promise(function(n,t){return e.close(!0,n,t)}))}),Promise.all(o).then(function(){return t()})},n)})},h.prototype.getAllWindows=function(){var e=this;return new Promise(function(t,n){e.desktop.Application.getCurrent().getChildWindows(function(n){n.push(e.desktop.Application.getCurrent().getWindow()),t(n.map(function(n){return e.wrapWindow(n)}))},n)})},h.prototype.getWindowById=function(n){return this.getWindowByName(n)},h.prototype.getWindowByName=function(o){var i=this;return new Promise(function(e,n){i.desktop.Application.getCurrent().getChildWindows(function(n){n.push(i.desktop.Application.getCurrent().getWindow());var t=n.find(function(n){return n.name===o});e(t?i.wrapWindow(t):null)})})},h.prototype.saveLayout=function(u){var n=this,s=new g.PersistedWindowLayout;return new Promise(function(i,r){return c(n,void 0,void 0,function(){var t,a,e,o=this;return p(this,function(n){switch(n.label){case 0:return[4,this.getAllWindows()];case 1:return t=n.sent(),a=this.getMainWindow(),e=[],t.filter(function(n){return"queueCounter"!==n.name&&!n.name.startsWith(h.notificationGuid)}).forEach(function(t){e.push(new Promise(function(r,u){return c(o,void 0,void 0,function(){var o,i;return p(this,function(n){switch(n.label){case 0:return[4,t.getState()];case 1:return o=n.sent(),(i=t.innerWindow).getBounds(function(e){i.getOptions(function(t){delete t.show,i.getGroup(function(n){s.windows.push({name:i.name,id:i.name,url:i.getNativeWindow()?i.getNativeWindow().location.toString():t.url,main:a&&a.name===i.name,options:t,state:o,bounds:{x:e.left,y:e.top,width:e.width,height:e.height},group:n.map(function(n){return n.name})}),r()},u)},u)},u),[2]}})})}))}),Promise.all(e).then(function(){o.saveLayoutToStorage(u,s),i(s)}).catch(function(n){return r(n)}),[2]}})})})},h.trayIconMenuLeftOffset=4,h.trayIconMenuTopOffset=23,h.notificationGuid="A21B62E0-16B1-4B10-8BE3-BBB6B489D862",h.replaceNotificationApi=!0,h.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},h.notificationOptionsMap={body:{target:"message"}},h.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>',h}(g.WebContainerBase),a=function(){function n(n){this.desktop=n}return n.prototype.createDisplay=function(n){var t=new g.Display;return t.id=n.name,t.scaleFactor=n.deviceScaleFactor,t.bounds=new g.Rectangle(n.monitorRect.left,n.monitorRect.top,n.monitorRect.right-n.monitorRect.left,n.monitorRect.bottom-n.monitorRect.top),t.workArea=new g.Rectangle(n.availableRect.left,n.availableRect.top,n.availableRect.right-n.availableRect.left,n.availableRect.bottom-n.availableRect.top),t},n.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(t,n){e.desktop.System.getMonitorInfo(function(n){t(e.createDisplay(n.primaryMonitor))},n)})},n.prototype.getAllDisplays=function(){var e=this;return new Promise(function(t,n){e.desktop.System.getMonitorInfo(function(n){t([n.primaryMonitor].concat(n.nonPrimaryMonitors).map(e.createDisplay))},n)})},n.prototype.getMousePosition=function(){var e=this;return new Promise(function(t,n){e.desktop.System.getMousePosition(function(n){t({x:n.left,y:n.top})},n)})},n}();n.OpenFinContainerWindow=e,n.OpenFinMessageBus=i,n.OpenFinContainer=u,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],t):t(((n=n||self).desktopJS=n.desktopJS||{},n.desktopJS.OpenFin={}),n.desktopJS)}(this,function(n,g){"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 t(n,t){function e(){this.constructor=n}o(n,t),n.prototype=null===t?Object.create(t):(e.prototype=t.prototype,new e)}function c(r,u,a,s){return new(a||(a=Promise))(function(n,t){function e(n){try{i(s.next(n))}catch(n){t(n)}}function o(n){try{i(s.throw(n))}catch(n){t(n)}}function i(t){t.done?n(t.value):new a(function(n){n(t.value)}).then(e,o)}i((s=s.apply(r,u||[])).next())})}function p(e,o){var i,r,u,n,a={label:0,sent:function(){if(1&u[0])throw u[1];return u[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(;a;)try{if(i=1,r&&(u=2&t[0]?r.return:t[0]?r.throw||((u=r.return)&&u.call(r),0):r.next)&&!(u=u.call(r,t[1])).done)return u;switch(r=0,u&&(t=[2&t[0],u.value]),t[0]){case 0:case 1:u=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,r=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(u=0<(u=a.trys).length&&u[u.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!u||t[1]>u[0]&&t[1]<u[3])){a.label=t[1];break}if(6===t[0]&&a.label<u[1]){a.label=u[1],u=t;break}if(u&&a.label<u[2]){a.label=u[2],a.ops.push(t);break}u[2]&&a.ops.pop(),a.trys.pop();continue}t=o.call(e,a)}catch(n){t=[6,n],r=0}finally{i=u=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,n])}}}g.registerContainer("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in window.fin},create:function(n){return new u(null,null,n)}});var r={move:"bounds-changing",resize:"bounds-changing",close:"close-requested",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},e=function(i){function o(n){return i.call(this,n)||this}return t(o,i),Object.defineProperty(o.prototype,"id",{get:function(){return this.name},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),o.prototype.load=function(e,n){var o=this;return new Promise(function(n,t){o.innerWindow.navigate(e,n,t)})},o.prototype.focus=function(){var e=this;return new Promise(function(n,t){e.innerWindow.focus(n,t)})},o.prototype.show=function(){var e=this;return new Promise(function(n,t){e.innerWindow.show(n,t)})},o.prototype.hide=function(){var e=this;return new Promise(function(n,t){e.innerWindow.hide(n,t)})},o.prototype.close=function(){var e=this;return new Promise(function(n,t){e.innerWindow.close(!1,n,t)})},o.prototype.minimize=function(){var e=this;return new Promise(function(n,t){e.innerWindow.minimize(n,t)})},o.prototype.maximize=function(){var e=this;return new Promise(function(n,t){e.innerWindow.maximize(n,t)})},o.prototype.restore=function(){var e=this;return new Promise(function(n,t){e.innerWindow.restore(n,t)})},o.prototype.isShowing=function(){var e=this;return new Promise(function(n,t){e.innerWindow.isShowing(n,t)})},o.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)})})},o.prototype.getBounds=function(){var e=this;return new Promise(function(t,n){e.innerWindow.getBounds(function(n){return t(new g.Rectangle(n.left,n.top,n.width,n.height))},n)})},o.prototype.flash=function(e,o){var i=this;return new Promise(function(n,t){e?i.innerWindow.flash(o,n,t):i.innerWindow.stopFlashing(n,t)})},o.prototype.setBounds=function(e){var o=this;return new Promise(function(n,t){o.innerWindow.setBounds(e.x,e.y,e.width,e.height,n,t)})},Object.defineProperty(o.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),o.prototype.getGroup=function(){var e=this;return new Promise(function(t,n){e.innerWindow.getGroup(function(n){t(n.map(function(n){return new o(n)}))},n)})},o.prototype.joinGroup=function(e){var o=this;return e&&e.id!==this.id?new Promise(function(n,t){o.innerWindow.joinGroup(e.innerWindow,function(){g.ContainerWindow.emit("window-joinGroup",{name:"window-joinGroup",windowId:o.id,targetWindowId:e.id}),n()},t)}):Promise.resolve()},o.prototype.leaveGroup=function(){var e=this;return new Promise(function(n,t){e.innerWindow.leaveGroup(function(){g.ContainerWindow.emit("window-leaveGroup",{name:"window-leaveGroup",windowId:e.id}),n()},t)})},o.prototype.bringToFront=function(){var e=this;return new Promise(function(n,t){e.innerWindow.bringToFront(n,t)})},o.prototype.getOptions=function(){var e=this;return new Promise(function(t,n){e.innerWindow.getOptions(function(n){return t(n.customData?JSON.parse(n.customData):void 0)},n)})},o.prototype.getState=function(){var t=this;return new Promise(function(n){t.nativeWindow&&t.nativeWindow.getState?n(t.nativeWindow.getState()):n(void 0)})},o.prototype.setState=function(t){var e=this;return new Promise(function(n){e.nativeWindow&&e.nativeWindow.setState&&e.nativeWindow.setState(t),n()})},o.prototype.attachListener=function(n,e){var o=this;"beforeunload"===n?this.innerWindow.addEventListener("close-requested",function(n){var t=new g.EventArgs(o,"beforeunload",n);e(t),void 0===t.returnValue&&o.innerWindow.close(!0)}):this.innerWindow.addEventListener(r[n]||n,e)},o.prototype.wrapListener=function(t,e){var o=this;return"resize"===t?function(n){1<=n.changeType&&e(new g.EventArgs(o,t,n))}:"move"===t?function(n){0===n.changeType&&e(new g.EventArgs(o,t,n))}:i.prototype.wrapListener.call(this,t,e)},o.prototype.detachListener=function(n,t){this.innerWindow.removeEventListener(r[n]||n,t)},Object.defineProperty(o.prototype,"nativeWindow",{get:function(){return this.innerWindow.getNativeWindow()},enumerable:!0,configurable:!0}),o}(g.ContainerWindow),i=function(){function n(n,t){this.bus=n,this.uuid=t}return n.prototype.subscribe=function(o,i,r){var u=this;return new Promise(function(n,t){var e=new g.MessageBusSubscription(o,function(n,t,e){i({topic:o},n)},r);u.bus.subscribe(r&&r.uuid||"*",r&&r.name||void 0,e.topic,e.listener,function(){return n(e)},t)})},n.prototype.unsubscribe=function(n){var e=this,o=n.topic,i=n.listener,r=n.options;return new Promise(function(n,t){e.bus.unsubscribe(r&&r.uuid||"*",r&&r.name||void 0,o,i,n,t)})},n.prototype.publish=function(e,o,i){var r=this;return new Promise(function(n,t){i&&i.uuid||i&&i.name?r.bus.send(i.uuid||r.uuid,i.name||void 0,e,o,n,t):r.bus.publish(e,o,n,t)})},n}(),u=function(r){function h(n,t,e){var o=r.call(this,t)||this;o.windowOptionsMap=h.windowOptionsMap,o.notificationOptionsMap=h.notificationOptionsMap,o.desktop=n||window.fin.desktop,o.hostType="OpenFin",e&&e.userName&&e.appName&&o.desktop.Application.getCurrent().registerUser(e.userName,e.appName),o.ipc=o.createMessageBus();var i=h.replaceNotificationApi;return e&&void 0!==e.replaceNotificationApi&&(i=e.replaceNotificationApi),i&&o.registerNotificationsApi(),o.desktop.Application.getCurrent().addEventListener("window-created",function(n){o.emit("window-created",{sender:o,name:"window-created",windowId:n.name,windowName:n.name}),g.Container.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name}),g.ContainerWindow.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name})}),o.screen=new a(o.desktop),o.desktop.GlobalHotkey?o.globalShortcut=new s(o.desktop):console.warn("Global shortcuts require minimum OpenFin runtime of 9.61.32.34"),o}return t(h,r),h.prototype.createMessageBus=function(){return new i(this.desktop.InterApplicationBus,this.desktop.Application.getCurrent().uuid)},h.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var i=this;this.globalWindow.Notification=function(o){function n(n,t){var e=o.call(this,n,t)||this;return t.notification=e,t.onClick=function(n){e.onclick&&e.onclick(n)},t.onError=function(n){e.onerror&&e.onerror(n)},i.showNotification(n,t),e}return t(n,o),n}(g.ContainerNotification)}},h.prototype.log=function(e,o){var i=this;return new Promise(function(n,t){i.desktop.System.log(e,o,n,t)})},h.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},h.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},h.prototype.getWindowOptions=function(n){var t=g.ObjectTransform.transformProperties(n,this.windowOptionsMap);return t.customData=n?JSON.stringify(n):void 0,"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},h.prototype.wrapWindow=function(n){return new e(n)},h.prototype.createWindow=function(n,t){var o=this,i=this.getWindowOptions(t);return i.url=n,"name"in i||(i.name=g.Guid.newGuid()),new Promise(function(t,n){var e=new o.desktop.Window(i,function(n){t(o.wrapWindow(e))},n)})},h.prototype.showNotification=function(n,t){new this.desktop.Notification(g.ObjectTransform.transformProperties(t,this.notificationOptionsMap))},h.prototype.getMenuHtml=function(){return h.menuHtml},h.prototype.getMenuItemHtml=function(n){var t=n.icon?'<span><img align="absmiddle" class="context-menu-image" src="'+this.ensureAbsoluteUrl(n.icon)+'" /></span>':"<span> </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>"},h.prototype.showMenu=function(p,d,f,l){var w=this;this.menuItemRef=l;var m=new this.desktop.Window({name:"trayMenu"+g.Guid.newGuid(),saveWindowState:!1,autoShow:!1,defaultWidth:150,defaultHeight:100,showTaskbarIcon:!1,frame:!1,contextMenu:!0,resizable:!1,alwaysOnTop:!0,shadow:!0,smallWindow:!0},function(){var n=m.getNativeWindow();n.document.open("text/html","replace"),n.document.write(w.getMenuHtml()),n.document.close();for(var t="",e=0,o=l.filter(function(n){return n.label});e<o.length;e++){var i=o[e];i.id||(i.id=g.Guid.newGuid()),t+=w.getMenuItemHtml(i)}var r=n.document.getElementById("contextMenu");r.innerHTML=t;var u=r.offsetWidth,a=r.offsetHeight;m.resizeTo(u,a,"top-left");var s=p+u>f.primaryMonitor.monitorRect.right?p-u-h.trayIconMenuLeftOffset:p,c=d+a>f.primaryMonitor.monitorRect.bottom?d-a-h.trayIconMenuTopOffset:d;m.addEventListener("blurred",function(){return m.close()}),m.showAt(s,c,!1,function(){return m.focus()})})},h.prototype.addTrayIcon=function(n,t,e){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+h.trayIconMenuLeftOffset,n.y+h.trayIconMenuTopOffset,n.monitorInfo,e)},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)})},h.prototype.closeAllWindows=function(){var e=this;return new Promise(function(t,n){var o=[];e.desktop.Application.getCurrent().getChildWindows(function(n){n.forEach(function(e){o.push(new Promise(function(n,t){return e.close(!0,n,t)}))}),Promise.all(o).then(function(){return t()})},n)})},h.prototype.getAllWindows=function(){var e=this;return new Promise(function(t,n){e.desktop.Application.getCurrent().getChildWindows(function(n){n.push(e.desktop.Application.getCurrent().getWindow()),t(n.map(function(n){return e.wrapWindow(n)}))},n)})},h.prototype.getWindowById=function(n){return this.getWindowByName(n)},h.prototype.getWindowByName=function(o){var i=this;return new Promise(function(e,n){i.desktop.Application.getCurrent().getChildWindows(function(n){n.push(i.desktop.Application.getCurrent().getWindow());var t=n.find(function(n){return n.name===o});e(t?i.wrapWindow(t):null)})})},h.prototype.saveLayout=function(u){var n=this,s=new g.PersistedWindowLayout;return new Promise(function(i,r){return c(n,void 0,void 0,function(){var t,a,e,o=this;return p(this,function(n){switch(n.label){case 0:return[4,this.getAllWindows()];case 1:return t=n.sent(),a=this.getMainWindow(),e=[],t.filter(function(n){return"queueCounter"!==n.name&&!n.name.startsWith(h.notificationGuid)}).forEach(function(t){e.push(new Promise(function(r,u){return c(o,void 0,void 0,function(){var o,i;return p(this,function(n){switch(n.label){case 0:return[4,t.getState()];case 1:return o=n.sent(),(i=t.innerWindow).getBounds(function(e){i.getOptions(function(t){delete t.show,i.getGroup(function(n){s.windows.push({name:i.name,id:i.name,url:i.getNativeWindow()?i.getNativeWindow().location.toString():t.url,main:a&&a.name===i.name,options:t,state:o,bounds:{x:e.left,y:e.top,width:e.width,height:e.height},group:n.map(function(n){return n.name})}),r()},u)},u)},u),[2]}})})}))}),Promise.all(e).then(function(){o.saveLayoutToStorage(u,s),i(s)}).catch(function(n){return r(n)}),[2]}})})})},h.trayIconMenuLeftOffset=4,h.trayIconMenuTopOffset=23,h.notificationGuid="A21B62E0-16B1-4B10-8BE3-BBB6B489D862",h.replaceNotificationApi=!0,h.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},h.notificationOptionsMap={body:{target:"message"}},h.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>',h}(g.WebContainerBase),a=function(){function n(n){this.desktop=n}return n.prototype.createDisplay=function(n){var t=new g.Display;return t.id=n.name,t.scaleFactor=n.deviceScaleFactor,t.bounds=new g.Rectangle(n.monitorRect.left,n.monitorRect.top,n.monitorRect.right-n.monitorRect.left,n.monitorRect.bottom-n.monitorRect.top),t.workArea=new g.Rectangle(n.availableRect.left,n.availableRect.top,n.availableRect.right-n.availableRect.left,n.availableRect.bottom-n.availableRect.top),t},n.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(t,n){e.desktop.System.getMonitorInfo(function(n){t(e.createDisplay(n.primaryMonitor))},n)})},n.prototype.getAllDisplays=function(){var e=this;return new Promise(function(t,n){e.desktop.System.getMonitorInfo(function(n){t([n.primaryMonitor].concat(n.nonPrimaryMonitors).map(e.createDisplay))},n)})},n.prototype.getMousePosition=function(){var e=this;return new Promise(function(t,n){e.desktop.System.getMousePosition(function(n){t({x:n.left,y:n.top})},n)})},n}(),s=function(e){function n(n){var t=e.call(this)||this;return t.desktop=n,t}return t(n,e),n.prototype.register=function(e,o){var i=this;return new Promise(function(n,t){i.desktop.GlobalHotkey.register(e,o,n,t)})},n.prototype.isRegistered=function(e){var o=this;return new Promise(function(n,t){o.desktop.GlobalHotkey.isRegistered(e,n,t)})},n.prototype.unregister=function(e){var o=this;return new Promise(function(n,t){o.desktop.GlobalHotkey.unregister(e,n,t)})},n.prototype.unregisterAll=function(){var e=this;return new Promise(function(n,t){e.desktop.GlobalHotkey.unregisterAll(n,t)})},n}(g.GlobalShortcutManager);n.OpenFinContainerWindow=e,n.OpenFinMessageBus=i,n.OpenFinContainer=u,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=desktopjs-openfin.min.js.map |
this.desktopJS = this.desktopJS || {}; | ||
this.desktopJS.OpenFin = (function (exports,desktopjs) { | ||
this.desktopJS.OpenFin = (function (exports, desktopjs) { | ||
'use strict'; | ||
@@ -208,3 +208,6 @@ | ||
return new Promise(function (resolve, reject) { | ||
_this.innerWindow.joinGroup(target.innerWindow, resolve, reject); | ||
_this.innerWindow.joinGroup(target.innerWindow, function () { | ||
desktopjs.ContainerWindow.emit("window-joinGroup", { name: "window-joinGroup", windowId: _this.id, targetWindowId: target.id }); | ||
resolve(); | ||
}, reject); | ||
}); | ||
@@ -215,5 +218,14 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
_this.innerWindow.leaveGroup(resolve, reject); | ||
_this.innerWindow.leaveGroup(function () { | ||
desktopjs.ContainerWindow.emit("window-leaveGroup", { name: "window-leaveGroup", windowId: _this.id }); | ||
resolve(); | ||
}, reject); | ||
}); | ||
}; | ||
OpenFinContainerWindow.prototype.bringToFront = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.innerWindow.bringToFront(resolve, reject); | ||
}); | ||
}; | ||
OpenFinContainerWindow.prototype.getOptions = function () { | ||
@@ -346,2 +358,8 @@ var _this = this; | ||
_this.screen = new OpenFinDisplayManager(_this.desktop); | ||
if (_this.desktop.GlobalHotkey) { | ||
_this.globalShortcut = new OpenFinGlobalShortcutManager(_this.desktop); | ||
} | ||
else { | ||
console.warn("Global shortcuts require minimum OpenFin runtime of 9.61.32.34"); | ||
} | ||
return _this; | ||
@@ -641,2 +659,35 @@ } | ||
}()); | ||
var OpenFinGlobalShortcutManager = (function (_super) { | ||
__extends(OpenFinGlobalShortcutManager, _super); | ||
function OpenFinGlobalShortcutManager(desktop) { | ||
var _this = _super.call(this) || this; | ||
_this.desktop = desktop; | ||
return _this; | ||
} | ||
OpenFinGlobalShortcutManager.prototype.register = function (shortcut, callback) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.register(shortcut, callback, resolve, reject); | ||
}); | ||
}; | ||
OpenFinGlobalShortcutManager.prototype.isRegistered = function (shortcut) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.isRegistered(shortcut, resolve, reject); | ||
}); | ||
}; | ||
OpenFinGlobalShortcutManager.prototype.unregister = function (shortcut) { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.unregister(shortcut, resolve, reject); | ||
}); | ||
}; | ||
OpenFinGlobalShortcutManager.prototype.unregisterAll = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.GlobalHotkey.unregisterAll(resolve, reject); | ||
}); | ||
}; | ||
return OpenFinGlobalShortcutManager; | ||
}(desktopjs.GlobalShortcutManager)); | ||
@@ -649,3 +700,3 @@ exports.OpenFinContainerWindow = OpenFinContainerWindow; | ||
}({},desktopJS)); | ||
}({}, desktopJS)); | ||
//# sourceMappingURL=desktopjs-openfin.js.map |
@@ -5,3 +5,3 @@ { | ||
"description": "desktopJS container implementation for OpenFin", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"publishConfig": { | ||
@@ -24,3 +24,3 @@ "access": "public" | ||
"hadouken" | ||
], | ||
], | ||
"files": [ | ||
@@ -39,8 +39,7 @@ "dist" | ||
"devDependencies": { | ||
"@morgan-stanley/desktopjs": "^3.0.0", | ||
"@morgan-stanley/desktopjs": "^3.1.0", | ||
"@types/jasmine": "^2.8.11", | ||
"@types/node": "^10.12.6", | ||
"gulp": "^3.9.1", | ||
"run-sequence": "^2.2.1" | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
251890
4
1528