@morgan-stanley/desktopjs-openfin
Advanced tools
Comparing version 3.11.0 to 3.12.0
@@ -70,2 +70,4 @@ // Generated by dts-bundle v0.7.3 | ||
constructor(desktop?: any, win?: Window, options?: any); | ||
setOptions(options: any): void; | ||
getOptions(): Promise<any>; | ||
protected createMessageBus(): MessageBus; | ||
@@ -72,0 +74,0 @@ protected registerNotificationsApi(): void; |
@@ -73,2 +73,5 @@ (function (global, factory) { | ||
/** | ||
* @module @morgan-stanley/desktopjs-openfin | ||
*/ | ||
desktopjs.registerContainer("OpenFin", { | ||
@@ -88,3 +91,6 @@ condition: function () { return typeof window !== "undefined" && "fin" in window && "desktop" in window.fin; }, | ||
}; | ||
var OpenFinContainerWindow = (function (_super) { | ||
/** | ||
* @augments ContainerWindow | ||
*/ | ||
var OpenFinContainerWindow = /** @class */ (function (_super) { | ||
__extends(OpenFinContainerWindow, _super); | ||
@@ -96,3 +102,3 @@ function OpenFinContainerWindow(wrap) { | ||
get: function () { | ||
return this.name; | ||
return this.name; // Reuse name since it is the unique identifier | ||
}, | ||
@@ -283,2 +289,3 @@ enumerable: false, | ||
var _this = this; | ||
// Split OpenFin bounds-changed event to separate resize/move events | ||
if (eventName === "resize") { | ||
@@ -314,3 +321,6 @@ return function (event) { | ||
}(desktopjs.ContainerWindow)); | ||
var OpenFinMessageBus = (function () { | ||
/** | ||
* @augments MessageBus | ||
*/ | ||
var OpenFinMessageBus = /** @class */ (function () { | ||
function OpenFinMessageBus(bus, uuid) { | ||
@@ -324,5 +334,10 @@ this.bus = bus; | ||
var subscription = new desktopjs.MessageBusSubscription(topic, function (message, uuid, name) { | ||
listener({ topic: topic }, message); | ||
listener(/* Event */ { topic: topic }, message); | ||
}, options); | ||
_this.bus.subscribe(options && options.uuid || "*", options && options.name || undefined, subscription.topic, subscription.listener, function () { return resolve(subscription); }, reject); | ||
_this.bus.subscribe(options && options.uuid || "*", // senderUuid | ||
options && options.name || undefined, // name | ||
subscription.topic, // topic | ||
subscription.listener, // listener | ||
function () { return resolve(subscription); }, // callback | ||
reject); // errorCallback | ||
}); | ||
@@ -334,3 +349,8 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
_this.bus.unsubscribe(options && options.uuid || "*", options && options.name || undefined, topic, listener, resolve, reject); | ||
_this.bus.unsubscribe(options && options.uuid || "*", // senderUuid | ||
options && options.name || undefined, // name | ||
topic, // topic | ||
listener, // listener | ||
resolve, // callback | ||
reject); // errorCallback | ||
}); | ||
@@ -341,7 +361,17 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
// If publisher has targets defined, use OpenFin send vs broadcast publish | ||
// If name is specified but not uuid, assume the user wants current app uuid | ||
if ((options && options.uuid) || (options && options.name)) { | ||
_this.bus.send(options.uuid || _this.uuid, options.name || undefined, topic, message, resolve, reject); | ||
_this.bus.send(options.uuid || _this.uuid, // destinationUuid | ||
options.name || undefined, // name | ||
topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
} | ||
else { | ||
_this.bus.publish(topic, message, resolve, reject); | ||
_this.bus.publish(topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
} | ||
@@ -352,3 +382,6 @@ }); | ||
}()); | ||
var OpenFinContainer = (function (_super) { | ||
/** | ||
* @extends WebContainerBase | ||
*/ | ||
var OpenFinContainer = /** @class */ (function (_super) { | ||
__extends(OpenFinContainer, _super); | ||
@@ -361,13 +394,4 @@ function OpenFinContainer(desktop, win, options) { | ||
_this.hostType = "OpenFin"; | ||
if (options && options.userName && options.appName) { | ||
_this.desktop.Application.getCurrent().registerUser(options.userName, options.appName); | ||
} | ||
_this.setOptions(options); | ||
_this.ipc = _this.createMessageBus(); | ||
var replaceNotificationApi = OpenFinContainer.replaceNotificationApi; | ||
if (options && typeof options.replaceNotificationApi !== "undefined") { | ||
replaceNotificationApi = options.replaceNotificationApi; | ||
} | ||
if (replaceNotificationApi) { | ||
_this.registerNotificationsApi(); | ||
} | ||
_this.desktop.Application.getCurrent().addEventListener("window-created", function (event) { | ||
@@ -383,6 +407,46 @@ _this.emit("window-created", { sender: _this, name: "window-created", windowId: event.name, windowName: event.name }); | ||
else { | ||
console.warn("Global shortcuts require minimum OpenFin runtime of 9.61.32.34"); | ||
_this.log("warn", "Global shortcuts require minimum OpenFin runtime of 9.61.32.34"); | ||
} | ||
return _this; | ||
} | ||
OpenFinContainer.prototype.setOptions = function (options) { | ||
if (options && options.userName && options.appName) { | ||
this.desktop.Application.getCurrent().registerUser(options.userName, options.appName); | ||
} | ||
if (options && options.autoStartOnLogin) { | ||
this.desktop.Application.getCurrent().setShortcuts({ systemStartup: options.autoStartOnLogin }); | ||
} | ||
var replaceNotificationApi = OpenFinContainer.replaceNotificationApi; | ||
if (options && typeof options.replaceNotificationApi !== "undefined") { | ||
replaceNotificationApi = options.replaceNotificationApi; | ||
} | ||
if (replaceNotificationApi) { | ||
this.registerNotificationsApi(); | ||
} | ||
}; | ||
OpenFinContainer.prototype.getOptions = function () { | ||
return __awaiter(this, void 0, Promise, function () { | ||
var error_1; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
_a = {}; | ||
return [4 /*yield*/, this.isAutoStartEnabledAtLogin()]; | ||
case 1: return [2 /*return*/, (_a.autoStartOnLogin = _b.sent(), _a)]; | ||
case 2: | ||
error_1 = _b.sent(); | ||
throw new Error("Error getting Container options. " + error_1); | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
OpenFinContainer.prototype.isAutoStartEnabledAtLogin = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.Application.getCurrent().getShortcuts(function (config) { return resolve(config.systemStartup); }, reject); | ||
}); | ||
}; | ||
OpenFinContainer.prototype.createMessageBus = function () { | ||
@@ -393,4 +457,6 @@ return new OpenFinMessageBus(this.desktop.InterApplicationBus, this.desktop.Application.getCurrent().uuid); | ||
if (typeof this.globalWindow !== "undefined" && this.globalWindow) { | ||
// Define owningContainer for closure to inner class | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
var owningContainer_1 = this; | ||
this.globalWindow["Notification"] = (function (_super) { | ||
this.globalWindow["Notification"] = /** @class */ (function (_super) { | ||
__extends(OpenFinNotification, _super); | ||
@@ -400,2 +466,3 @@ function OpenFinNotification(title, options) { | ||
options["notification"] = _this; | ||
// Forward OpenFin notification events back to Notification API | ||
options["onClick"] = function (event) { if (_this.onclick) { | ||
@@ -407,3 +474,3 @@ _this.onclick(event); | ||
} }; | ||
owningContainer_1.showNotification(title, options); | ||
owningContainer_1.showNotification(_this.title, _this.options); | ||
return _this; | ||
@@ -420,3 +487,3 @@ } | ||
_this.desktop.System.getRuntimeInfo(function (runtimeInfo) { | ||
console.log(runtimeInfo); | ||
_this.log("info", runtimeInfo); | ||
resolve("RVM/" + rvmInfo.version + " Runtime/" + runtimeInfo.version); | ||
@@ -449,5 +516,7 @@ }, reject); | ||
newOptions.customData = options ? JSON.stringify(options) : undefined; | ||
// Default behavior is to show window so if there is no override in options, show the window | ||
if (!("autoShow" in newOptions)) { | ||
newOptions.autoShow = true; | ||
} | ||
// Change default of window state saving to false | ||
if (!("saveWindowState" in newOptions) && ("defaultLeft" in newOptions || "defaultTop" in newOptions)) { | ||
@@ -467,3 +536,4 @@ newOptions.saveWindowState = false; | ||
var newOptions = this.getWindowOptions(options); | ||
newOptions.url = url; | ||
newOptions.url = url; // createWindow param will always take precedence over any passed on options | ||
// OpenFin requires a name for the window to show | ||
if (!("name" in newOptions)) { | ||
@@ -479,3 +549,3 @@ newOptions.name = desktopjs.Guid.newGuid(); | ||
OpenFinContainer.prototype.showNotification = function (title, options) { | ||
var msg = new this.desktop.Notification(desktopjs.ObjectTransform.transformProperties(options, this.notificationOptionsMap)); | ||
new this.desktop.Notification(desktopjs.ObjectTransform.transformProperties(options, this.notificationOptionsMap)); | ||
}; | ||
@@ -523,4 +593,6 @@ OpenFinContainer.prototype.getMenuHtml = function () { | ||
contextMenuElement.innerHTML = menuItemHtml; | ||
// Size <ul> to fit | ||
var width = contextMenuElement["offsetWidth"], height = contextMenuElement["offsetHeight"]; | ||
contextMenu.resizeTo(width, height, "top-left"); | ||
// If the menu will not fit on the monitor as right/down from x, y then show left/up | ||
var left = (x + width) > monitorInfo.primaryMonitor.monitorRect.right | ||
@@ -540,9 +612,10 @@ ? x - width - OpenFinContainer.trayIconMenuLeftOffset | ||
.setTrayIcon(this.ensureAbsoluteUrl(details.icon), function (clickInfo) { | ||
if (clickInfo.button === 0 && listener) { | ||
if (clickInfo.button === 0 && listener) { // Passthrough left click to addTrayIcon listener callback | ||
listener(); | ||
} | ||
else if (clickInfo.button === 2) { | ||
else if (clickInfo.button === 2) { // handle right click ourselves to display context menu | ||
_this.showMenu(clickInfo.x + OpenFinContainer.trayIconMenuLeftOffset, clickInfo.y + OpenFinContainer.trayIconMenuTopOffset, clickInfo.monitorInfo, menuItems); | ||
} | ||
}, function () { | ||
// Append desktopJS container instance uuid to topic so communication is unique to this tray icon and window | ||
_this.desktop.InterApplicationBus.subscribe(_this.desktop.Application.getCurrent().uuid, "TrayIcon_ContextMenuClick_" + _this.uuid, function (message, uuid) { | ||
@@ -556,3 +629,3 @@ for (var prop in _this.menuItemRef) { | ||
}); | ||
}, function (error) { console.error(error); }); | ||
}, function (error) { _this.log("error", error); }); | ||
}; | ||
@@ -596,2 +669,3 @@ OpenFinContainer.prototype.closeAllWindows = function () { | ||
var layout = new desktopjs.PersistedWindowLayout(); | ||
// eslint-disable-next-line no-async-promise-executor | ||
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -602,3 +676,3 @@ var windows, mainWindow, promises; | ||
switch (_a.label) { | ||
case 0: return [4, this.getAllWindows()]; | ||
case 0: return [4 /*yield*/, this.getAllWindows()]; | ||
case 1: | ||
@@ -610,2 +684,3 @@ windows = _a.sent(); | ||
.forEach(function (djsWindow) { | ||
// eslint-disable-next-line no-async-promise-executor | ||
promises.push(new Promise(function (innerResolve, innerReject) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -615,3 +690,3 @@ var state, window; | ||
switch (_a.label) { | ||
case 0: return [4, djsWindow.getState()]; | ||
case 0: return [4 /*yield*/, djsWindow.getState()]; | ||
case 1: | ||
@@ -622,2 +697,3 @@ state = _a.sent(); | ||
window.getOptions(function (options) { | ||
// If window was created with persist: false, skip from layout | ||
var customData = (options.customData ? JSON.parse(options.customData) : undefined); | ||
@@ -628,3 +704,3 @@ if (customData && "persist" in customData && !customData.persist) { | ||
else { | ||
delete options.show; | ||
delete options.show; // show is an undocumented option that interferes with the createWindow mapping of show -> autoShow | ||
window.getGroup(function (group) { | ||
@@ -646,3 +722,3 @@ layout.windows.push({ | ||
}, innerReject); | ||
return [2]; | ||
return [2 /*return*/]; | ||
} | ||
@@ -655,3 +731,3 @@ }); | ||
}).catch(reject); | ||
return [2]; | ||
return [2 /*return*/]; | ||
} | ||
@@ -661,5 +737,11 @@ }); | ||
}; | ||
// Offsets for tray icon mouse click to not show over icon | ||
OpenFinContainer.trayIconMenuLeftOffset = 4; | ||
OpenFinContainer.trayIconMenuTopOffset = 23; | ||
OpenFinContainer.notificationGuid = "A21B62E0-16B1-4B10-8BE3-BBB6B489D862"; | ||
/** | ||
* Gets or sets whether to replace the native web Notification API with OpenFin notifications. | ||
* @type {boolean} | ||
* @default true | ||
*/ | ||
OpenFinContainer.replaceNotificationApi = true; | ||
@@ -681,3 +763,4 @@ OpenFinContainer.windowOptionsMap = { | ||
}(desktopjs.WebContainerBase)); | ||
var OpenFinDisplayManager = (function () { | ||
/** @private */ | ||
var OpenFinDisplayManager = /** @class */ (function () { | ||
function OpenFinDisplayManager(desktop) { | ||
@@ -720,3 +803,4 @@ this.desktop = desktop; | ||
}()); | ||
var OpenFinGlobalShortcutManager = (function (_super) { | ||
/** @private */ | ||
var OpenFinGlobalShortcutManager = /** @class */ (function (_super) { | ||
__extends(OpenFinGlobalShortcutManager, _super); | ||
@@ -723,0 +807,0 @@ function OpenFinGlobalShortcutManager(desktop) { |
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],t):t(((n="undefined"!=typeof globalThis?globalThis:n||self).desktopJS=n.desktopJS||{},n.desktopJS.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:"closing",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:!1,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,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.getParent=function(){return Promise.resolve(null)},o.prototype.setParent=function(n){return new Promise(function(n,t){n()})},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:!1,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()}).then(function(){e.emit("state-changed",{name:"state-changed",sender:e,state:t}),g.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:e.id,state:t})})},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:!1,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.getInfo=function(){var o=this;return new Promise(function(e,n){o.desktop.System.getRvmInfo(function(t){o.desktop.System.getRuntimeInfo(function(n){console.log(n),e("RVM/"+t.version+" Runtime/"+n.version)},n)},n)})},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.ready=function(){var t=this;return new Promise(function(n){return t.desktop.main(n)})},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.buildLayout=function(){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){var n=t.customData?JSON.parse(t.customData):void 0;n&&"persist"in n&&!n.persist?r():(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(){i(s)}).catch(r),[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.OpenFinContainer=u,n.OpenFinContainerWindow=e,n.OpenFinMessageBus=i,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],t):t(((n="undefined"!=typeof globalThis?globalThis:n||self).desktopJS=n.desktopJS||{},n.desktopJS.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,s,a){return new(s||(s=Promise))(function(n,t){function e(n){try{i(a.next(n))}catch(n){t(n)}}function o(n){try{i(a.throw(n))}catch(n){t(n)}}function i(t){t.done?n(t.value):new s(function(n){n(t.value)}).then(e,o)}i((a=a.apply(r,u||[])).next())})}function p(e,o){var i,r,u,n,s={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(;s;)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 s.label++,{value:t[1],done:!1};case 5:s.label++,r=t[1],t=[0];continue;case 7:t=s.ops.pop(),s.trys.pop();continue;default:if(!(u=0<(u=s.trys).length&&u[u.length-1])&&(6===t[0]||2===t[0])){s=0;continue}if(3===t[0]&&(!u||t[1]>u[0]&&t[1]<u[3])){s.label=t[1];break}if(6===t[0]&&s.label<u[1]){s.label=u[1],u=t;break}if(u&&s.label<u[2]){s.label=u[2],s.ops.push(t);break}u[2]&&s.ops.pop(),s.trys.pop();continue}t=o.call(e,s)}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 i(null,null,n)}});var r={move:"bounds-changing",resize:"bounds-changing",close:"closing",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:!1,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,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.getParent=function(){return Promise.resolve(null)},o.prototype.setParent=function(n){return new Promise(function(n,t){n()})},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:!1,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()}).then(function(){e.emit("state-changed",{name:"state-changed",sender:e,state:t}),g.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:e.id,state:t})})},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:!1,configurable:!0}),o}(g.ContainerWindow),u=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}(),i=function(i){function h(n,t,e){var o=i.call(this,t)||this;return o.windowOptionsMap=h.windowOptionsMap,o.notificationOptionsMap=h.notificationOptionsMap,o.desktop=n||window.fin.desktop,o.hostType="OpenFin",o.setOptions(e),o.ipc=o.createMessageBus(),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 s(o.desktop),o.desktop.GlobalHotkey?o.globalShortcut=new a(o.desktop):o.log("warn","Global shortcuts require minimum OpenFin runtime of 9.61.32.34"),o}return t(h,i),h.prototype.setOptions=function(n){n&&n.userName&&n.appName&&this.desktop.Application.getCurrent().registerUser(n.userName,n.appName),n&&n.autoStartOnLogin&&this.desktop.Application.getCurrent().setShortcuts({systemStartup:n.autoStartOnLogin});var t=h.replaceNotificationApi;n&&void 0!==n.replaceNotificationApi&&(t=n.replaceNotificationApi),t&&this.registerNotificationsApi()},h.prototype.getOptions=function(){return c(this,void 0,Promise,function(){var t,e;return p(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(e.autoStartOnLogin=n.sent(),e)];case 2:throw t=n.sent(),new Error("Error getting Container options. "+t);case 3:return[2]}})})},h.prototype.isAutoStartEnabledAtLogin=function(){var e=this;return new Promise(function(t,n){e.desktop.Application.getCurrent().getShortcuts(function(n){return t(n.systemStartup)},n)})},h.prototype.createMessageBus=function(){return new u(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(e.title,e.options),e}return t(n,o),n}(g.ContainerNotification)}},h.prototype.getInfo=function(){var o=this;return new Promise(function(e,n){o.desktop.System.getRvmInfo(function(t){o.desktop.System.getRuntimeInfo(function(n){o.log("info",n),e("RVM/"+t.version+" Runtime/"+n.version)},n)},n)})},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.ready=function(){var t=this;return new Promise(function(n){return t.desktop.main(n)})},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,s=r.offsetHeight;m.resizeTo(u,s,"top-left");var a=p+u>f.primaryMonitor.monitorRect.right?p-u-h.trayIconMenuLeftOffset:p,c=d+s>f.primaryMonitor.monitorRect.bottom?d-s-h.trayIconMenuTopOffset:d;m.addEventListener("blurred",function(){return m.close()}),m.showAt(a,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){i.log("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.buildLayout=function(){var n=this,a=new g.PersistedWindowLayout;return new Promise(function(i,r){return c(n,void 0,void 0,function(){var t,s,e,o=this;return p(this,function(n){switch(n.label){case 0:return[4,this.getAllWindows()];case 1:return t=n.sent(),s=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){var n=t.customData?JSON.parse(t.customData):void 0;n&&"persist"in n&&!n.persist?r():(delete t.show,i.getGroup(function(n){a.windows.push({name:i.name,id:i.name,url:i.getNativeWindow()?i.getNativeWindow().location.toString():t.url,main:s&&s.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(){i(a)}).catch(r),[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),s=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}(),a=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.OpenFinContainer=i,n.OpenFinContainerWindow=e,n.OpenFinMessageBus=u,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=desktopjs-openfin.min.js.map |
@@ -71,2 +71,5 @@ this.desktopJS = this.desktopJS || {}; | ||
/** | ||
* @module @morgan-stanley/desktopjs-openfin | ||
*/ | ||
desktopjs.registerContainer("OpenFin", { | ||
@@ -86,3 +89,6 @@ condition: function () { return typeof window !== "undefined" && "fin" in window && "desktop" in window.fin; }, | ||
}; | ||
var OpenFinContainerWindow = (function (_super) { | ||
/** | ||
* @augments ContainerWindow | ||
*/ | ||
var OpenFinContainerWindow = /** @class */ (function (_super) { | ||
__extends(OpenFinContainerWindow, _super); | ||
@@ -94,3 +100,3 @@ function OpenFinContainerWindow(wrap) { | ||
get: function () { | ||
return this.name; | ||
return this.name; // Reuse name since it is the unique identifier | ||
}, | ||
@@ -281,2 +287,3 @@ enumerable: false, | ||
var _this = this; | ||
// Split OpenFin bounds-changed event to separate resize/move events | ||
if (eventName === "resize") { | ||
@@ -312,3 +319,6 @@ return function (event) { | ||
}(desktopjs.ContainerWindow)); | ||
var OpenFinMessageBus = (function () { | ||
/** | ||
* @augments MessageBus | ||
*/ | ||
var OpenFinMessageBus = /** @class */ (function () { | ||
function OpenFinMessageBus(bus, uuid) { | ||
@@ -322,5 +332,10 @@ this.bus = bus; | ||
var subscription = new desktopjs.MessageBusSubscription(topic, function (message, uuid, name) { | ||
listener({ topic: topic }, message); | ||
listener(/* Event */ { topic: topic }, message); | ||
}, options); | ||
_this.bus.subscribe(options && options.uuid || "*", options && options.name || undefined, subscription.topic, subscription.listener, function () { return resolve(subscription); }, reject); | ||
_this.bus.subscribe(options && options.uuid || "*", // senderUuid | ||
options && options.name || undefined, // name | ||
subscription.topic, // topic | ||
subscription.listener, // listener | ||
function () { return resolve(subscription); }, // callback | ||
reject); // errorCallback | ||
}); | ||
@@ -332,3 +347,8 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
_this.bus.unsubscribe(options && options.uuid || "*", options && options.name || undefined, topic, listener, resolve, reject); | ||
_this.bus.unsubscribe(options && options.uuid || "*", // senderUuid | ||
options && options.name || undefined, // name | ||
topic, // topic | ||
listener, // listener | ||
resolve, // callback | ||
reject); // errorCallback | ||
}); | ||
@@ -339,7 +359,17 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
// If publisher has targets defined, use OpenFin send vs broadcast publish | ||
// If name is specified but not uuid, assume the user wants current app uuid | ||
if ((options && options.uuid) || (options && options.name)) { | ||
_this.bus.send(options.uuid || _this.uuid, options.name || undefined, topic, message, resolve, reject); | ||
_this.bus.send(options.uuid || _this.uuid, // destinationUuid | ||
options.name || undefined, // name | ||
topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
} | ||
else { | ||
_this.bus.publish(topic, message, resolve, reject); | ||
_this.bus.publish(topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
} | ||
@@ -350,3 +380,6 @@ }); | ||
}()); | ||
var OpenFinContainer = (function (_super) { | ||
/** | ||
* @extends WebContainerBase | ||
*/ | ||
var OpenFinContainer = /** @class */ (function (_super) { | ||
__extends(OpenFinContainer, _super); | ||
@@ -359,13 +392,4 @@ function OpenFinContainer(desktop, win, options) { | ||
_this.hostType = "OpenFin"; | ||
if (options && options.userName && options.appName) { | ||
_this.desktop.Application.getCurrent().registerUser(options.userName, options.appName); | ||
} | ||
_this.setOptions(options); | ||
_this.ipc = _this.createMessageBus(); | ||
var replaceNotificationApi = OpenFinContainer.replaceNotificationApi; | ||
if (options && typeof options.replaceNotificationApi !== "undefined") { | ||
replaceNotificationApi = options.replaceNotificationApi; | ||
} | ||
if (replaceNotificationApi) { | ||
_this.registerNotificationsApi(); | ||
} | ||
_this.desktop.Application.getCurrent().addEventListener("window-created", function (event) { | ||
@@ -381,6 +405,46 @@ _this.emit("window-created", { sender: _this, name: "window-created", windowId: event.name, windowName: event.name }); | ||
else { | ||
console.warn("Global shortcuts require minimum OpenFin runtime of 9.61.32.34"); | ||
_this.log("warn", "Global shortcuts require minimum OpenFin runtime of 9.61.32.34"); | ||
} | ||
return _this; | ||
} | ||
OpenFinContainer.prototype.setOptions = function (options) { | ||
if (options && options.userName && options.appName) { | ||
this.desktop.Application.getCurrent().registerUser(options.userName, options.appName); | ||
} | ||
if (options && options.autoStartOnLogin) { | ||
this.desktop.Application.getCurrent().setShortcuts({ systemStartup: options.autoStartOnLogin }); | ||
} | ||
var replaceNotificationApi = OpenFinContainer.replaceNotificationApi; | ||
if (options && typeof options.replaceNotificationApi !== "undefined") { | ||
replaceNotificationApi = options.replaceNotificationApi; | ||
} | ||
if (replaceNotificationApi) { | ||
this.registerNotificationsApi(); | ||
} | ||
}; | ||
OpenFinContainer.prototype.getOptions = function () { | ||
return __awaiter(this, void 0, Promise, function () { | ||
var error_1; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_b.trys.push([0, 2, , 3]); | ||
_a = {}; | ||
return [4 /*yield*/, this.isAutoStartEnabledAtLogin()]; | ||
case 1: return [2 /*return*/, (_a.autoStartOnLogin = _b.sent(), _a)]; | ||
case 2: | ||
error_1 = _b.sent(); | ||
throw new Error("Error getting Container options. " + error_1); | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
OpenFinContainer.prototype.isAutoStartEnabledAtLogin = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
_this.desktop.Application.getCurrent().getShortcuts(function (config) { return resolve(config.systemStartup); }, reject); | ||
}); | ||
}; | ||
OpenFinContainer.prototype.createMessageBus = function () { | ||
@@ -391,4 +455,6 @@ return new OpenFinMessageBus(this.desktop.InterApplicationBus, this.desktop.Application.getCurrent().uuid); | ||
if (typeof this.globalWindow !== "undefined" && this.globalWindow) { | ||
// Define owningContainer for closure to inner class | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
var owningContainer_1 = this; | ||
this.globalWindow["Notification"] = (function (_super) { | ||
this.globalWindow["Notification"] = /** @class */ (function (_super) { | ||
__extends(OpenFinNotification, _super); | ||
@@ -398,2 +464,3 @@ function OpenFinNotification(title, options) { | ||
options["notification"] = _this; | ||
// Forward OpenFin notification events back to Notification API | ||
options["onClick"] = function (event) { if (_this.onclick) { | ||
@@ -405,3 +472,3 @@ _this.onclick(event); | ||
} }; | ||
owningContainer_1.showNotification(title, options); | ||
owningContainer_1.showNotification(_this.title, _this.options); | ||
return _this; | ||
@@ -418,3 +485,3 @@ } | ||
_this.desktop.System.getRuntimeInfo(function (runtimeInfo) { | ||
console.log(runtimeInfo); | ||
_this.log("info", runtimeInfo); | ||
resolve("RVM/" + rvmInfo.version + " Runtime/" + runtimeInfo.version); | ||
@@ -447,5 +514,7 @@ }, reject); | ||
newOptions.customData = options ? JSON.stringify(options) : undefined; | ||
// Default behavior is to show window so if there is no override in options, show the window | ||
if (!("autoShow" in newOptions)) { | ||
newOptions.autoShow = true; | ||
} | ||
// Change default of window state saving to false | ||
if (!("saveWindowState" in newOptions) && ("defaultLeft" in newOptions || "defaultTop" in newOptions)) { | ||
@@ -465,3 +534,4 @@ newOptions.saveWindowState = false; | ||
var newOptions = this.getWindowOptions(options); | ||
newOptions.url = url; | ||
newOptions.url = url; // createWindow param will always take precedence over any passed on options | ||
// OpenFin requires a name for the window to show | ||
if (!("name" in newOptions)) { | ||
@@ -477,3 +547,3 @@ newOptions.name = desktopjs.Guid.newGuid(); | ||
OpenFinContainer.prototype.showNotification = function (title, options) { | ||
var msg = new this.desktop.Notification(desktopjs.ObjectTransform.transformProperties(options, this.notificationOptionsMap)); | ||
new this.desktop.Notification(desktopjs.ObjectTransform.transformProperties(options, this.notificationOptionsMap)); | ||
}; | ||
@@ -521,4 +591,6 @@ OpenFinContainer.prototype.getMenuHtml = function () { | ||
contextMenuElement.innerHTML = menuItemHtml; | ||
// Size <ul> to fit | ||
var width = contextMenuElement["offsetWidth"], height = contextMenuElement["offsetHeight"]; | ||
contextMenu.resizeTo(width, height, "top-left"); | ||
// If the menu will not fit on the monitor as right/down from x, y then show left/up | ||
var left = (x + width) > monitorInfo.primaryMonitor.monitorRect.right | ||
@@ -538,9 +610,10 @@ ? x - width - OpenFinContainer.trayIconMenuLeftOffset | ||
.setTrayIcon(this.ensureAbsoluteUrl(details.icon), function (clickInfo) { | ||
if (clickInfo.button === 0 && listener) { | ||
if (clickInfo.button === 0 && listener) { // Passthrough left click to addTrayIcon listener callback | ||
listener(); | ||
} | ||
else if (clickInfo.button === 2) { | ||
else if (clickInfo.button === 2) { // handle right click ourselves to display context menu | ||
_this.showMenu(clickInfo.x + OpenFinContainer.trayIconMenuLeftOffset, clickInfo.y + OpenFinContainer.trayIconMenuTopOffset, clickInfo.monitorInfo, menuItems); | ||
} | ||
}, function () { | ||
// Append desktopJS container instance uuid to topic so communication is unique to this tray icon and window | ||
_this.desktop.InterApplicationBus.subscribe(_this.desktop.Application.getCurrent().uuid, "TrayIcon_ContextMenuClick_" + _this.uuid, function (message, uuid) { | ||
@@ -554,3 +627,3 @@ for (var prop in _this.menuItemRef) { | ||
}); | ||
}, function (error) { console.error(error); }); | ||
}, function (error) { _this.log("error", error); }); | ||
}; | ||
@@ -594,2 +667,3 @@ OpenFinContainer.prototype.closeAllWindows = function () { | ||
var layout = new desktopjs.PersistedWindowLayout(); | ||
// eslint-disable-next-line no-async-promise-executor | ||
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -600,3 +674,3 @@ var windows, mainWindow, promises; | ||
switch (_a.label) { | ||
case 0: return [4, this.getAllWindows()]; | ||
case 0: return [4 /*yield*/, this.getAllWindows()]; | ||
case 1: | ||
@@ -608,2 +682,3 @@ windows = _a.sent(); | ||
.forEach(function (djsWindow) { | ||
// eslint-disable-next-line no-async-promise-executor | ||
promises.push(new Promise(function (innerResolve, innerReject) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -613,3 +688,3 @@ var state, window; | ||
switch (_a.label) { | ||
case 0: return [4, djsWindow.getState()]; | ||
case 0: return [4 /*yield*/, djsWindow.getState()]; | ||
case 1: | ||
@@ -620,2 +695,3 @@ state = _a.sent(); | ||
window.getOptions(function (options) { | ||
// If window was created with persist: false, skip from layout | ||
var customData = (options.customData ? JSON.parse(options.customData) : undefined); | ||
@@ -626,3 +702,3 @@ if (customData && "persist" in customData && !customData.persist) { | ||
else { | ||
delete options.show; | ||
delete options.show; // show is an undocumented option that interferes with the createWindow mapping of show -> autoShow | ||
window.getGroup(function (group) { | ||
@@ -644,3 +720,3 @@ layout.windows.push({ | ||
}, innerReject); | ||
return [2]; | ||
return [2 /*return*/]; | ||
} | ||
@@ -653,3 +729,3 @@ }); | ||
}).catch(reject); | ||
return [2]; | ||
return [2 /*return*/]; | ||
} | ||
@@ -659,5 +735,11 @@ }); | ||
}; | ||
// Offsets for tray icon mouse click to not show over icon | ||
OpenFinContainer.trayIconMenuLeftOffset = 4; | ||
OpenFinContainer.trayIconMenuTopOffset = 23; | ||
OpenFinContainer.notificationGuid = "A21B62E0-16B1-4B10-8BE3-BBB6B489D862"; | ||
/** | ||
* Gets or sets whether to replace the native web Notification API with OpenFin notifications. | ||
* @type {boolean} | ||
* @default true | ||
*/ | ||
OpenFinContainer.replaceNotificationApi = true; | ||
@@ -679,3 +761,4 @@ OpenFinContainer.windowOptionsMap = { | ||
}(desktopjs.WebContainerBase)); | ||
var OpenFinDisplayManager = (function () { | ||
/** @private */ | ||
var OpenFinDisplayManager = /** @class */ (function () { | ||
function OpenFinDisplayManager(desktop) { | ||
@@ -718,3 +801,4 @@ this.desktop = desktop; | ||
}()); | ||
var OpenFinGlobalShortcutManager = (function (_super) { | ||
/** @private */ | ||
var OpenFinGlobalShortcutManager = /** @class */ (function (_super) { | ||
__extends(OpenFinGlobalShortcutManager, _super); | ||
@@ -757,2 +841,4 @@ function OpenFinGlobalShortcutManager(desktop) { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
return exports; | ||
@@ -759,0 +845,0 @@ |
@@ -1,2 +0,2 @@ | ||
this.desktopJS=this.desktopJS||{},this.desktopJS.OpenFin=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:"closing",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:!1,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,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.getParent=function(){return Promise.resolve(null)},o.prototype.setParent=function(n){return new Promise(function(n,t){n()})},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:!1,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()}).then(function(){e.emit("state-changed",{name:"state-changed",sender:e,state:t}),g.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:e.id,state:t})})},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:!1,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.getInfo=function(){var o=this;return new Promise(function(e,n){o.desktop.System.getRvmInfo(function(t){o.desktop.System.getRuntimeInfo(function(n){console.log(n),e("RVM/"+t.version+" Runtime/"+n.version)},n)},n)})},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.ready=function(){var t=this;return new Promise(function(n){return t.desktop.main(n)})},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.buildLayout=function(){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){var n=t.customData?JSON.parse(t.customData):void 0;n&&"persist"in n&&!n.persist?r():(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(){i(s)}).catch(r),[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);return n.OpenFinContainer=u,n.OpenFinContainerWindow=e,n.OpenFinMessageBus=i,n}({},desktopJS); | ||
this.desktopJS=this.desktopJS||{},this.desktopJS.OpenFin=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 i(null,null,n)}});var r={move:"bounds-changing",resize:"bounds-changing",close:"closing",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:!1,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,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.getParent=function(){return Promise.resolve(null)},o.prototype.setParent=function(n){return new Promise(function(n,t){n()})},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:!1,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()}).then(function(){e.emit("state-changed",{name:"state-changed",sender:e,state:t}),g.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:e.id,state:t})})},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:!1,configurable:!0}),o}(g.ContainerWindow),u=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}(),i=function(i){function h(n,t,e){var o=i.call(this,t)||this;return o.windowOptionsMap=h.windowOptionsMap,o.notificationOptionsMap=h.notificationOptionsMap,o.desktop=n||window.fin.desktop,o.hostType="OpenFin",o.setOptions(e),o.ipc=o.createMessageBus(),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):o.log("warn","Global shortcuts require minimum OpenFin runtime of 9.61.32.34"),o}return t(h,i),h.prototype.setOptions=function(n){n&&n.userName&&n.appName&&this.desktop.Application.getCurrent().registerUser(n.userName,n.appName),n&&n.autoStartOnLogin&&this.desktop.Application.getCurrent().setShortcuts({systemStartup:n.autoStartOnLogin});var t=h.replaceNotificationApi;n&&void 0!==n.replaceNotificationApi&&(t=n.replaceNotificationApi),t&&this.registerNotificationsApi()},h.prototype.getOptions=function(){return c(this,void 0,Promise,function(){var t,e;return p(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(e.autoStartOnLogin=n.sent(),e)];case 2:throw t=n.sent(),new Error("Error getting Container options. "+t);case 3:return[2]}})})},h.prototype.isAutoStartEnabledAtLogin=function(){var e=this;return new Promise(function(t,n){e.desktop.Application.getCurrent().getShortcuts(function(n){return t(n.systemStartup)},n)})},h.prototype.createMessageBus=function(){return new u(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(e.title,e.options),e}return t(n,o),n}(g.ContainerNotification)}},h.prototype.getInfo=function(){var o=this;return new Promise(function(e,n){o.desktop.System.getRvmInfo(function(t){o.desktop.System.getRuntimeInfo(function(n){o.log("info",n),e("RVM/"+t.version+" Runtime/"+n.version)},n)},n)})},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.ready=function(){var t=this;return new Promise(function(n){return t.desktop.main(n)})},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){i.log("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.buildLayout=function(){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){var n=t.customData?JSON.parse(t.customData):void 0;n&&"persist"in n&&!n.persist?r():(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(){i(s)}).catch(r),[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);return n.OpenFinContainer=i,n.OpenFinContainerWindow=e,n.OpenFinMessageBus=u,Object.defineProperty(n,"__esModule",{value:!0}),n}({},desktopJS); | ||
//# sourceMappingURL=desktopjs-openfin.min.js.map |
@@ -5,3 +5,3 @@ { | ||
"description": "desktopJS container implementation for OpenFin", | ||
"version": "3.11.0", | ||
"version": "3.12.0", | ||
"publishConfig": { | ||
@@ -14,5 +14,5 @@ "access": "public" | ||
"author": "Morgan Stanley", | ||
"repository": "https://github.com/Morgan-Stanley/desktopJS/tree/master/packages/desktopjs-openfin", | ||
"repository": "https://github.com/MorganStanley/desktopJS/tree/main/packages/desktopjs-openfin", | ||
"bugs": { | ||
"url": "https://github.com/Morgan-Stanley/desktopJS/issues" | ||
"url": "https://github.com/MorganStanley/desktopJS/issues" | ||
}, | ||
@@ -31,3 +31,2 @@ "keywords": [ | ||
"clean": "gulp clean", | ||
"tslint": "gulp tslint", | ||
"build:lerna": "gulp build:lerna", | ||
@@ -40,3 +39,3 @@ "build": "gulp build", | ||
"devDependencies": { | ||
"@morgan-stanley/desktopjs": "^3.11.0", | ||
"@morgan-stanley/desktopjs": "^3.12.0", | ||
"@types/jasmine": "^3.5.11", | ||
@@ -43,0 +42,0 @@ "gulp": "^4.0.2" |
# @morgan-stanley/desktopjs-openfin | ||
[desktopJS](https://github.com/Morgan-Stanley/desktopJS) container implementation for OpenFin | ||
[desktopJS](https://github.com/MorganStanley/desktopJS) container implementation for OpenFin |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
348879
1839