@morgan-stanley/desktopjs-openfin
Advanced tools
Comparing version 3.12.0 to 3.13.1
@@ -5,17 +5,17 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.desktopJS = global.desktopJS || {}, global.desktopJS.OpenFin = {}), global.desktopJS)); | ||
}(this, (function (exports, desktopjs) { 'use strict'; | ||
})(this, (function (exports, desktopjs) { 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -27,3 +27,3 @@ /* global Reflect, Promise */ | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -33,2 +33,4 @@ }; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -40,6 +42,7 @@ function __() { this.constructor = d; } | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -55,3 +58,3 @@ }); | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -78,5 +81,2 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
/** | ||
* @module @morgan-stanley/desktopjs-openfin | ||
*/ | ||
desktopjs.registerContainer("OpenFin", { | ||
@@ -96,6 +96,3 @@ condition: function () { return typeof window !== "undefined" && "fin" in window && "desktop" in window.fin; }, | ||
}; | ||
/** | ||
* @augments ContainerWindow | ||
*/ | ||
var OpenFinContainerWindow = /** @class */ (function (_super) { | ||
var OpenFinContainerWindow = (function (_super) { | ||
__extends(OpenFinContainerWindow, _super); | ||
@@ -107,3 +104,3 @@ function OpenFinContainerWindow(wrap) { | ||
get: function () { | ||
return this.name; // Reuse name since it is the unique identifier | ||
return this.name; | ||
}, | ||
@@ -294,3 +291,2 @@ enumerable: false, | ||
var _this = this; | ||
// Split OpenFin bounds-changed event to separate resize/move events | ||
if (eventName === "resize") { | ||
@@ -326,6 +322,3 @@ return function (event) { | ||
}(desktopjs.ContainerWindow)); | ||
/** | ||
* @augments MessageBus | ||
*/ | ||
var OpenFinMessageBus = /** @class */ (function () { | ||
var OpenFinMessageBus = (function () { | ||
function OpenFinMessageBus(bus, uuid) { | ||
@@ -339,10 +332,5 @@ this.bus = bus; | ||
var subscription = new desktopjs.MessageBusSubscription(topic, function (message, uuid, name) { | ||
listener(/* Event */ { topic: topic }, message); | ||
listener({ topic: topic }, message); | ||
}, options); | ||
_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 | ||
_this.bus.subscribe(options && options.uuid || "*", options && options.name || undefined, subscription.topic, subscription.listener, function () { return resolve(subscription); }, reject); | ||
}); | ||
@@ -354,8 +342,3 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
_this.bus.unsubscribe(options && options.uuid || "*", // senderUuid | ||
options && options.name || undefined, // name | ||
topic, // topic | ||
listener, // listener | ||
resolve, // callback | ||
reject); // errorCallback | ||
_this.bus.unsubscribe(options && options.uuid || "*", options && options.name || undefined, topic, listener, resolve, reject); | ||
}); | ||
@@ -366,17 +349,7 @@ }; | ||
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, // destinationUuid | ||
options.name || undefined, // name | ||
topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
_this.bus.send(options.uuid || _this.uuid, options.name || undefined, topic, message, resolve, reject); | ||
} | ||
else { | ||
_this.bus.publish(topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
_this.bus.publish(topic, message, resolve, reject); | ||
} | ||
@@ -387,6 +360,3 @@ }); | ||
}()); | ||
/** | ||
* @extends WebContainerBase | ||
*/ | ||
var OpenFinContainer = /** @class */ (function (_super) { | ||
var OpenFinContainer = (function (_super) { | ||
__extends(OpenFinContainer, _super); | ||
@@ -431,3 +401,3 @@ function OpenFinContainer(desktop, win, options) { | ||
OpenFinContainer.prototype.getOptions = function () { | ||
return __awaiter(this, void 0, Promise, function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_1; | ||
@@ -440,8 +410,8 @@ var _a; | ||
_a = {}; | ||
return [4 /*yield*/, this.isAutoStartEnabledAtLogin()]; | ||
case 1: return [2 /*return*/, (_a.autoStartOnLogin = _b.sent(), _a)]; | ||
return [4, this.isAutoStartEnabledAtLogin()]; | ||
case 1: return [2, (_a.autoStartOnLogin = _b.sent(), _a)]; | ||
case 2: | ||
error_1 = _b.sent(); | ||
throw new Error("Error getting Container options. " + error_1); | ||
case 3: return [2 /*return*/]; | ||
case 3: return [2]; | ||
} | ||
@@ -462,6 +432,4 @@ }); | ||
if (typeof this.globalWindow !== "undefined" && this.globalWindow) { | ||
// Define owningContainer for closure to inner class | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
var owningContainer_1 = this; | ||
this.globalWindow["Notification"] = /** @class */ (function (_super) { | ||
this.globalWindow["Notification"] = (function (_super) { | ||
__extends(OpenFinNotification, _super); | ||
@@ -471,3 +439,2 @@ function OpenFinNotification(title, options) { | ||
options["notification"] = _this; | ||
// Forward OpenFin notification events back to Notification API | ||
options["onClick"] = function (event) { if (_this.onclick) { | ||
@@ -492,3 +459,3 @@ _this.onclick(event); | ||
_this.log("info", runtimeInfo); | ||
resolve("RVM/" + rvmInfo.version + " Runtime/" + runtimeInfo.version); | ||
resolve("RVM/".concat(rvmInfo.version, " Runtime/").concat(runtimeInfo.version)); | ||
}, reject); | ||
@@ -520,7 +487,5 @@ }, 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)) { | ||
@@ -540,4 +505,3 @@ newOptions.saveWindowState = false; | ||
var newOptions = this.getWindowOptions(options); | ||
newOptions.url = url; // createWindow param will always take precedence over any passed on options | ||
// OpenFin requires a name for the window to show | ||
newOptions.url = url; | ||
if (!("name" in newOptions)) { | ||
@@ -560,6 +524,6 @@ newOptions.name = desktopjs.Guid.newGuid(); | ||
var imgHtml = (item.icon) | ||
? "<span><img align=\"absmiddle\" class=\"context-menu-image\" src=\"" + this.ensureAbsoluteUrl(item.icon) + "\" /></span>" | ||
? "<span><img align=\"absmiddle\" class=\"context-menu-image\" src=\"".concat(this.ensureAbsoluteUrl(item.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: '" + item.id + "' });this.close()\">" + imgHtml + item.label + "</li>"); | ||
return "<li class=\"context-menu-item\" onclick=\"fin.desktop.InterApplicationBus.send('".concat(this.desktop.Application.getCurrent().uuid) | ||
+ "', null, 'TrayIcon_ContextMenuClick_".concat(this.uuid, "', { id: '").concat(item.id, "' });this.close()\">").concat(imgHtml).concat(item.label, "</li>"); | ||
}; | ||
@@ -570,3 +534,3 @@ OpenFinContainer.prototype.showMenu = function (x, y, monitorInfo, menuItems) { | ||
var contextMenu = new this.desktop.Window({ | ||
name: "trayMenu" + desktopjs.Guid.newGuid(), | ||
name: "trayMenu".concat(desktopjs.Guid.newGuid()), | ||
saveWindowState: false, | ||
@@ -598,6 +562,4 @@ autoShow: false, | ||
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 | ||
@@ -617,10 +579,9 @@ ? x - width - OpenFinContainer.trayIconMenuLeftOffset | ||
.setTrayIcon(this.ensureAbsoluteUrl(details.icon), function (clickInfo) { | ||
if (clickInfo.button === 0 && listener) { // Passthrough left click to addTrayIcon listener callback | ||
if (clickInfo.button === 0 && listener) { | ||
listener(); | ||
} | ||
else if (clickInfo.button === 2) { // handle right click ourselves to display context menu | ||
else if (clickInfo.button === 2) { | ||
_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) { | ||
@@ -673,3 +634,2 @@ for (var prop in _this.menuItemRef) { | ||
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 () { | ||
@@ -680,3 +640,3 @@ var windows, mainWindow, promises; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getAllWindows()]; | ||
case 0: return [4, this.getAllWindows()]; | ||
case 1: | ||
@@ -688,3 +648,2 @@ 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 () { | ||
@@ -694,3 +653,3 @@ var state, window; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, djsWindow.getState()]; | ||
case 0: return [4, djsWindow.getState()]; | ||
case 1: | ||
@@ -701,3 +660,2 @@ 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); | ||
@@ -708,3 +666,3 @@ if (customData && "persist" in customData && !customData.persist) { | ||
else { | ||
delete options.show; // show is an undocumented option that interferes with the createWindow mapping of show -> autoShow | ||
delete options.show; | ||
window.getGroup(function (group) { | ||
@@ -726,3 +684,3 @@ layout.windows.push({ | ||
}, innerReject); | ||
return [2 /*return*/]; | ||
return [2]; | ||
} | ||
@@ -735,3 +693,3 @@ }); | ||
}).catch(reject); | ||
return [2 /*return*/]; | ||
return [2]; | ||
} | ||
@@ -741,11 +699,5 @@ }); | ||
}; | ||
// 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; | ||
@@ -767,4 +719,3 @@ OpenFinContainer.windowOptionsMap = { | ||
}(desktopjs.WebContainerBase)); | ||
/** @private */ | ||
var OpenFinDisplayManager = /** @class */ (function () { | ||
var OpenFinDisplayManager = (function () { | ||
function OpenFinDisplayManager(desktop) { | ||
@@ -807,4 +758,3 @@ this.desktop = desktop; | ||
}()); | ||
/** @private */ | ||
var OpenFinGlobalShortcutManager = /** @class */ (function (_super) { | ||
var OpenFinGlobalShortcutManager = (function (_super) { | ||
__extends(OpenFinGlobalShortcutManager, _super); | ||
@@ -849,3 +799,3 @@ function OpenFinGlobalShortcutManager(desktop) { | ||
}))); | ||
})); | ||
//# sourceMappingURL=desktopjs-openfin.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],t):t(((n="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})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@morgan-stanley/desktopjs")):"function"==typeof define&&define.amd?define(["exports","@morgan-stanley/desktopjs"],n):n(((t="undefined"!=typeof globalThis?globalThis:t||self).desktopJS=t.desktopJS||{},t.desktopJS.OpenFin={}),t.desktopJS)}(this,function(t,f){"use strict";var o=function(t,n){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function c(t,a,s,u){return new(s=s||Promise)(function(e,n){function o(t){try{r(u.next(t))}catch(t){n(t)}}function i(t){try{r(u.throw(t))}catch(t){n(t)}}function r(t){var n;t.done?e(t.value):((n=t.value)instanceof s?n:new s(function(t){t(n)})).then(o,i)}r((u=u.apply(t,a||[])).next())})}function p(o,i){var r,a,s,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(e){return function(t){var n=[e,t];if(r)throw new TypeError("Generator is already executing.");for(;u=c&&n[c=0]?0:u;)try{if(r=1,a&&(s=2&n[0]?a.return:n[0]?a.throw||((s=a.return)&&s.call(a),0):a.next)&&!(s=s.call(a,n[1])).done)return s;switch(a=0,(n=s?[2&n[0],s.value]:n)[0]){case 0:case 1:s=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,a=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){u.label=n[1];break}if(6===n[0]&&u.label<s[1]){u.label=s[1],s=n;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(n);break}s[2]&&u.ops.pop(),u.trys.pop();continue}n=i.call(o,u)}catch(t){n=[6,t],a=0}finally{r=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}}}f.registerContainer("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in window.fin},create:function(t){return new l(null,null,t)}});var i,r={move:"bounds-changing",resize:"bounds-changing",close:"closing",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},e=(n(a,i=f.ContainerWindow),Object.defineProperty(a.prototype,"id",{get:function(){return this.name},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,configurable:!0}),a.prototype.load=function(e,t){var o=this;return new Promise(function(t,n){o.innerWindow.navigate(e,t,n)})},a.prototype.focus=function(){var e=this;return new Promise(function(t,n){e.innerWindow.focus(t,n)})},a.prototype.show=function(){var e=this;return new Promise(function(t,n){e.innerWindow.show(t,n)})},a.prototype.hide=function(){var e=this;return new Promise(function(t,n){e.innerWindow.hide(t,n)})},a.prototype.close=function(){var e=this;return new Promise(function(t,n){e.innerWindow.close(!1,t,n)})},a.prototype.minimize=function(){var e=this;return new Promise(function(t,n){e.innerWindow.minimize(t,n)})},a.prototype.maximize=function(){var e=this;return new Promise(function(t,n){e.innerWindow.maximize(t,n)})},a.prototype.restore=function(){var e=this;return new Promise(function(t,n){e.innerWindow.restore(t,n)})},a.prototype.isShowing=function(){var e=this;return new Promise(function(t,n){e.innerWindow.isShowing(t,n)})},a.prototype.getSnapshot=function(){var t=this;return new Promise(function(n,e){t.innerWindow.getSnapshot(function(t){return n("data:image/png;base64,"+t)},function(t){return e(t)})})},a.prototype.getBounds=function(){var e=this;return new Promise(function(n,t){e.innerWindow.getBounds(function(t){return n(new f.Rectangle(t.left,t.top,t.width,t.height))},t)})},a.prototype.flash=function(e,o){var i=this;return new Promise(function(t,n){e?i.innerWindow.flash(o,t,n):i.innerWindow.stopFlashing(t,n)})},a.prototype.getParent=function(){return Promise.resolve(null)},a.prototype.setParent=function(t){return new Promise(function(t,n){t()})},a.prototype.setBounds=function(e){var o=this;return new Promise(function(t,n){o.innerWindow.setBounds(e.x,e.y,e.width,e.height,t,n)})},Object.defineProperty(a.prototype,"allowGrouping",{get:function(){return!0},enumerable:!1,configurable:!0}),a.prototype.getGroup=function(){var e=this;return new Promise(function(n,t){e.innerWindow.getGroup(function(t){n(t.map(function(t){return new a(t)}))},t)})},a.prototype.joinGroup=function(e){var o=this;return e&&e.id!==this.id?new Promise(function(t,n){o.innerWindow.joinGroup(e.innerWindow,function(){f.ContainerWindow.emit("window-joinGroup",{name:"window-joinGroup",windowId:o.id,targetWindowId:e.id}),t()},n)}):Promise.resolve()},a.prototype.leaveGroup=function(){var e=this;return new Promise(function(t,n){e.innerWindow.leaveGroup(function(){f.ContainerWindow.emit("window-leaveGroup",{name:"window-leaveGroup",windowId:e.id}),t()},n)})},a.prototype.bringToFront=function(){var e=this;return new Promise(function(t,n){e.innerWindow.bringToFront(t,n)})},a.prototype.getOptions=function(){var e=this;return new Promise(function(n,t){e.innerWindow.getOptions(function(t){return n(t.customData?JSON.parse(t.customData):void 0)},t)})},a.prototype.getState=function(){var n=this;return new Promise(function(t){n.nativeWindow&&n.nativeWindow.getState?t(n.nativeWindow.getState()):t(void 0)})},a.prototype.setState=function(n){var e=this;return new Promise(function(t){e.nativeWindow&&e.nativeWindow.setState&&e.nativeWindow.setState(n),t()}).then(function(){e.emit("state-changed",{name:"state-changed",sender:e,state:n}),f.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:e.id,state:n})})},a.prototype.attachListener=function(t,n){var e=this;"beforeunload"===t?this.innerWindow.addEventListener("close-requested",function(t){t=new f.EventArgs(e,"beforeunload",t);n(t),void 0===t.returnValue&&e.innerWindow.close(!0)}):this.innerWindow.addEventListener(r[t]||t,n)},a.prototype.wrapListener=function(n,e){var o=this;return"resize"===n?function(t){1<=t.changeType&&e(new f.EventArgs(o,n,t))}:"move"===n?function(t){0===t.changeType&&e(new f.EventArgs(o,n,t))}:i.prototype.wrapListener.call(this,n,e)},a.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(r[t]||t,n)},Object.defineProperty(a.prototype,"nativeWindow",{get:function(){return this.innerWindow.getNativeWindow()},enumerable:!1,configurable:!0}),a);function a(t){return i.call(this,t)||this}u.prototype.subscribe=function(o,i,r){var a=this;return new Promise(function(t,n){var e=new f.MessageBusSubscription(o,function(t,n,e){i({topic:o},t)},r);a.bus.subscribe(r&&r.uuid||"*",r&&r.name||void 0,e.topic,e.listener,function(){return t(e)},n)})},u.prototype.unsubscribe=function(t){var e=this,o=t.topic,i=t.listener,r=t.options;return new Promise(function(t,n){e.bus.unsubscribe(r&&r.uuid||"*",r&&r.name||void 0,o,i,t,n)})},u.prototype.publish=function(e,o,i){var r=this;return new Promise(function(t,n){i&&i.uuid||i&&i.name?r.bus.send(i.uuid||r.uuid,i.name||void 0,e,o,t,n):r.bus.publish(e,o,t,n)})};var s=u;function u(t,n){this.bus=t,this.uuid=n}n(w,d=f.WebContainerBase),w.prototype.setOptions=function(t){t&&t.userName&&t.appName&&this.desktop.Application.getCurrent().registerUser(t.userName,t.appName),t&&t.autoStartOnLogin&&this.desktop.Application.getCurrent().setShortcuts({systemStartup:t.autoStartOnLogin});var n=w.replaceNotificationApi;(n=t&&void 0!==t.replaceNotificationApi?t.replaceNotificationApi:n)&&this.registerNotificationsApi()},w.prototype.getOptions=function(){return c(this,void 0,void 0,function(){var n,e;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(e.autoStartOnLogin=t.sent(),e)];case 2:throw n=t.sent(),new Error("Error getting Container options. "+n);case 3:return[2]}})})},w.prototype.isAutoStartEnabledAtLogin=function(){var e=this;return new Promise(function(n,t){e.desktop.Application.getCurrent().getShortcuts(function(t){return n(t.systemStartup)},t)})},w.prototype.createMessageBus=function(){return new s(this.desktop.InterApplicationBus,this.desktop.Application.getCurrent().uuid)},w.prototype.registerNotificationsApi=function(){var o,i;function t(t,n){var e=i.call(this,t,n)||this;return n.notification=e,n.onClick=function(t){e.onclick&&e.onclick(t)},n.onError=function(t){e.onerror&&e.onerror(t)},o.showNotification(e.title,e.options),e}void 0!==this.globalWindow&&this.globalWindow&&((o=this).globalWindow.Notification=(n(t,i=f.ContainerNotification),t))},w.prototype.getInfo=function(){var o=this;return new Promise(function(e,t){o.desktop.System.getRvmInfo(function(n){o.desktop.System.getRuntimeInfo(function(t){o.log("info",t),e("RVM/".concat(n.version," Runtime/").concat(t.version))},t)},t)})},w.prototype.log=function(e,o){var i=this;return new Promise(function(t,n){i.desktop.System.log(e,o,t,n)})},w.prototype.ready=function(){var n=this;return new Promise(function(t){return n.desktop.main(t)})},w.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},w.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},w.prototype.getWindowOptions=function(t){var n=f.ObjectTransform.transformProperties(t,this.windowOptionsMap);return n.customData=t?JSON.stringify(t):void 0,"autoShow"in n||(n.autoShow=!0),"saveWindowState"in n||!("defaultLeft"in n||"defaultTop"in n)||(n.saveWindowState=!1),"icon"in n&&(n.icon=this.ensureAbsoluteUrl(n.icon)),n},w.prototype.wrapWindow=function(t){return new e(t)},w.prototype.createWindow=function(t,n){var o=this,i=this.getWindowOptions(n);return i.url=t,"name"in i||(i.name=f.Guid.newGuid()),new Promise(function(n,t){var e=new o.desktop.Window(i,function(t){n(o.wrapWindow(e))},t)})},w.prototype.showNotification=function(t,n){new this.desktop.Notification(f.ObjectTransform.transformProperties(n,this.notificationOptionsMap))},w.prototype.getMenuHtml=function(){return w.menuHtml},w.prototype.getMenuItemHtml=function(t){var n=t.icon?'<span><img align="absmiddle" class="context-menu-image" src="'.concat(this.ensureAbsoluteUrl(t.icon),'" /></span>'):"<span> </span>";return'<li class="context-menu-item" onclick="fin.desktop.InterApplicationBus.send(\''.concat(this.desktop.Application.getCurrent().uuid)+"', null, 'TrayIcon_ContextMenuClick_".concat(this.uuid,"', { id: '").concat(t.id,"' });this.close()\">").concat(n).concat(t.label,"</li>")},w.prototype.showMenu=function(a,s,u,c){var p=this,d=(this.menuItemRef=c,new this.desktop.Window({name:"trayMenu".concat(f.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(){for(var t=d.getNativeWindow(),n=(t.document.open("text/html","replace"),t.document.write(p.getMenuHtml()),t.document.close(),""),e=0,o=c.filter(function(t){return t.label});e<o.length;e++){var i=o[e];i.id||(i.id=f.Guid.newGuid()),n+=p.getMenuItemHtml(i)}var t=t.document.getElementById("contextMenu"),r=(t.innerHTML=n,t.offsetWidth),t=t.offsetHeight,r=(d.resizeTo(r,t,"top-left"),a+r>u.primaryMonitor.monitorRect.right?a-r-w.trayIconMenuLeftOffset:a),t=s+t>u.primaryMonitor.monitorRect.bottom?s-t-w.trayIconMenuTopOffset:s;d.addEventListener("blurred",function(){return d.close()}),d.showAt(r,t,!1,function(){return d.focus()})}))},w.prototype.addTrayIcon=function(t,n,e){var o=this;this.desktop.Application.getCurrent().setTrayIcon(this.ensureAbsoluteUrl(t.icon),function(t){0===t.button&&n?n():2===t.button&&o.showMenu(t.x+w.trayIconMenuLeftOffset,t.y+w.trayIconMenuTopOffset,t.monitorInfo,e)},function(){o.desktop.InterApplicationBus.subscribe(o.desktop.Application.getCurrent().uuid,"TrayIcon_ContextMenuClick_"+o.uuid,function(t,n){for(var e in o.menuItemRef){e=o.menuItemRef[e];e.id===t.id&&e.click&&e.click(e)}})},function(t){o.log("error",t)})},w.prototype.closeAllWindows=function(){var e=this;return new Promise(function(n,t){var o=[];e.desktop.Application.getCurrent().getChildWindows(function(t){t.forEach(function(e){o.push(new Promise(function(t,n){return e.close(!0,t,n)}))}),Promise.all(o).then(function(){return n()})},t)})},w.prototype.getAllWindows=function(){var e=this;return new Promise(function(n,t){e.desktop.Application.getCurrent().getChildWindows(function(t){t.push(e.desktop.Application.getCurrent().getWindow()),n(t.map(function(t){return e.wrapWindow(t)}))},t)})},w.prototype.getWindowById=function(t){return this.getWindowByName(t)},w.prototype.getWindowByName=function(e){var o=this;return new Promise(function(n,t){o.desktop.Application.getCurrent().getChildWindows(function(t){t.push(o.desktop.Application.getCurrent().getWindow());t=t.find(function(t){return t.name===e});n(t?o.wrapWindow(t):null)})})},w.prototype.buildLayout=function(){var t=this,u=new f.PersistedWindowLayout;return new Promise(function(i,r){return c(t,void 0,void 0,function(){var n,s,e,o=this;return p(this,function(t){switch(t.label){case 0:return[4,this.getAllWindows()];case 1:return n=t.sent(),s=this.getMainWindow(),e=[],n.filter(function(t){return"queueCounter"!==t.name&&!t.name.startsWith(w.notificationGuid)}).forEach(function(n){e.push(new Promise(function(r,a){return c(o,void 0,void 0,function(){var o,i;return p(this,function(t){switch(t.label){case 0:return[4,n.getState()];case 1:return o=t.sent(),(i=n.innerWindow).getBounds(function(e){i.getOptions(function(n){var t=n.customData?JSON.parse(n.customData):void 0;t&&"persist"in t&&!t.persist?r():(delete n.show,i.getGroup(function(t){u.windows.push({name:i.name,id:i.name,url:i.getNativeWindow()?i.getNativeWindow().location.toString():n.url,main:s&&s.name===i.name,options:n,state:o,bounds:{x:e.left,y:e.top,width:e.width,height:e.height},group:t.map(function(t){return t.name})}),r()},a))},a)},a),[2]}})})}))}),Promise.all(e).then(function(){i(u)}).catch(r),[2]}})})})},w.trayIconMenuLeftOffset=4,w.trayIconMenuTopOffset=23,w.notificationGuid="A21B62E0-16B1-4B10-8BE3-BBB6B489D862",w.replaceNotificationApi=!0,w.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},w.notificationOptionsMap={body:{target:"message"}},w.menuHtml='<html>\n <head>\n <style>\n body:before, body:after {\n position: fixed;\n background: silver;\n }\n body {\n margin: 0px;\n overflow: hidden;\n }\n .context-menu {\n list-style: none;\n padding: 1px 0 1px 0;\n }\n .context-menu-item {\n display: block;\n cursor: default;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 9pt;\n margin-bottom: 2px;\n padding: 4px 0 4px 4px;\n white-space: nowrap;\n }\n .context-menu-item span {\n display: inline-block;\n min-width: 20px;\n }\n .context-menu-item:last-child {\n margin-bottom: 0;\n } \n .context-menu-item:hover {\n color: #fff;\n background-color: #0066aa;\n }\n .context-menu-image {\n width: 16px;\n height: 16px;\n margin-top: -1px;\n margin-right: 4px;\n } \n </style>\n <script>\n document.addEventListener(\'keydown\', (event) => {\n if (event.keyCode == 27) {\n window.close();\n }\n }, false);\n <\/script>\n </head>\n <body>\n <ul class="context-menu" id="contextMenu"></ul>\n </body>\n </html>';var d,l=w;function w(t,n,e){var o=d.call(this,n)||this;return o.windowOptionsMap=w.windowOptionsMap,o.notificationOptionsMap=w.notificationOptionsMap,o.desktop=t||window.fin.desktop,o.hostType="OpenFin",o.setOptions(e),o.ipc=o.createMessageBus(),o.desktop.Application.getCurrent().addEventListener("window-created",function(t){o.emit("window-created",{sender:o,name:"window-created",windowId:t.name,windowName:t.name}),f.Container.emit("window-created",{name:"window-created",windowId:t.name,windowName:t.name}),f.ContainerWindow.emit("window-created",{name:"window-created",windowId:t.name,windowName:t.name})}),o.screen=new m(o.desktop),o.desktop.GlobalHotkey?o.globalShortcut=new y(o.desktop):o.log("warn","Global shortcuts require minimum OpenFin runtime of 9.61.32.34"),o}h.prototype.createDisplay=function(t){var n=new f.Display;return n.id=t.name,n.scaleFactor=t.deviceScaleFactor,n.bounds=new f.Rectangle(t.monitorRect.left,t.monitorRect.top,t.monitorRect.right-t.monitorRect.left,t.monitorRect.bottom-t.monitorRect.top),n.workArea=new f.Rectangle(t.availableRect.left,t.availableRect.top,t.availableRect.right-t.availableRect.left,t.availableRect.bottom-t.availableRect.top),n},h.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(n,t){e.desktop.System.getMonitorInfo(function(t){n(e.createDisplay(t.primaryMonitor))},t)})},h.prototype.getAllDisplays=function(){var e=this;return new Promise(function(n,t){e.desktop.System.getMonitorInfo(function(t){n([t.primaryMonitor].concat(t.nonPrimaryMonitors).map(e.createDisplay))},t)})},h.prototype.getMousePosition=function(){var e=this;return new Promise(function(n,t){e.desktop.System.getMousePosition(function(t){n({x:t.left,y:t.top})},t)})};var m=h;function h(t){this.desktop=t}n(v,g=f.GlobalShortcutManager),v.prototype.register=function(e,o){var i=this;return new Promise(function(t,n){i.desktop.GlobalHotkey.register(e,o,t,n)})},v.prototype.isRegistered=function(e){var o=this;return new Promise(function(t,n){o.desktop.GlobalHotkey.isRegistered(e,t,n)})},v.prototype.unregister=function(e){var o=this;return new Promise(function(t,n){o.desktop.GlobalHotkey.unregister(e,t,n)})},v.prototype.unregisterAll=function(){var e=this;return new Promise(function(t,n){e.desktop.GlobalHotkey.unregisterAll(t,n)})};var g,y=v;function v(t){var n=g.call(this)||this;return n.desktop=t,n}t.OpenFinContainer=l,t.OpenFinContainerWindow=e,t.OpenFinMessageBus=s,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=desktopjs-openfin.min.js.map |
@@ -5,15 +5,15 @@ this.desktopJS = this.desktopJS || {}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -25,3 +25,3 @@ /* global Reflect, Promise */ | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -31,2 +31,4 @@ }; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -38,6 +40,7 @@ function __() { this.constructor = d; } | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -53,3 +56,3 @@ }); | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -76,5 +79,2 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
/** | ||
* @module @morgan-stanley/desktopjs-openfin | ||
*/ | ||
desktopjs.registerContainer("OpenFin", { | ||
@@ -94,6 +94,3 @@ condition: function () { return typeof window !== "undefined" && "fin" in window && "desktop" in window.fin; }, | ||
}; | ||
/** | ||
* @augments ContainerWindow | ||
*/ | ||
var OpenFinContainerWindow = /** @class */ (function (_super) { | ||
var OpenFinContainerWindow = (function (_super) { | ||
__extends(OpenFinContainerWindow, _super); | ||
@@ -105,3 +102,3 @@ function OpenFinContainerWindow(wrap) { | ||
get: function () { | ||
return this.name; // Reuse name since it is the unique identifier | ||
return this.name; | ||
}, | ||
@@ -292,3 +289,2 @@ enumerable: false, | ||
var _this = this; | ||
// Split OpenFin bounds-changed event to separate resize/move events | ||
if (eventName === "resize") { | ||
@@ -324,6 +320,3 @@ return function (event) { | ||
}(desktopjs.ContainerWindow)); | ||
/** | ||
* @augments MessageBus | ||
*/ | ||
var OpenFinMessageBus = /** @class */ (function () { | ||
var OpenFinMessageBus = (function () { | ||
function OpenFinMessageBus(bus, uuid) { | ||
@@ -337,10 +330,5 @@ this.bus = bus; | ||
var subscription = new desktopjs.MessageBusSubscription(topic, function (message, uuid, name) { | ||
listener(/* Event */ { topic: topic }, message); | ||
listener({ topic: topic }, message); | ||
}, options); | ||
_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 | ||
_this.bus.subscribe(options && options.uuid || "*", options && options.name || undefined, subscription.topic, subscription.listener, function () { return resolve(subscription); }, reject); | ||
}); | ||
@@ -352,8 +340,3 @@ }; | ||
return new Promise(function (resolve, reject) { | ||
_this.bus.unsubscribe(options && options.uuid || "*", // senderUuid | ||
options && options.name || undefined, // name | ||
topic, // topic | ||
listener, // listener | ||
resolve, // callback | ||
reject); // errorCallback | ||
_this.bus.unsubscribe(options && options.uuid || "*", options && options.name || undefined, topic, listener, resolve, reject); | ||
}); | ||
@@ -364,17 +347,7 @@ }; | ||
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, // destinationUuid | ||
options.name || undefined, // name | ||
topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
_this.bus.send(options.uuid || _this.uuid, options.name || undefined, topic, message, resolve, reject); | ||
} | ||
else { | ||
_this.bus.publish(topic, // topic | ||
message, // message | ||
resolve, // callback | ||
reject); // errorCallback | ||
_this.bus.publish(topic, message, resolve, reject); | ||
} | ||
@@ -385,6 +358,3 @@ }); | ||
}()); | ||
/** | ||
* @extends WebContainerBase | ||
*/ | ||
var OpenFinContainer = /** @class */ (function (_super) { | ||
var OpenFinContainer = (function (_super) { | ||
__extends(OpenFinContainer, _super); | ||
@@ -429,3 +399,3 @@ function OpenFinContainer(desktop, win, options) { | ||
OpenFinContainer.prototype.getOptions = function () { | ||
return __awaiter(this, void 0, Promise, function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_1; | ||
@@ -438,8 +408,8 @@ var _a; | ||
_a = {}; | ||
return [4 /*yield*/, this.isAutoStartEnabledAtLogin()]; | ||
case 1: return [2 /*return*/, (_a.autoStartOnLogin = _b.sent(), _a)]; | ||
return [4, this.isAutoStartEnabledAtLogin()]; | ||
case 1: return [2, (_a.autoStartOnLogin = _b.sent(), _a)]; | ||
case 2: | ||
error_1 = _b.sent(); | ||
throw new Error("Error getting Container options. " + error_1); | ||
case 3: return [2 /*return*/]; | ||
case 3: return [2]; | ||
} | ||
@@ -460,6 +430,4 @@ }); | ||
if (typeof this.globalWindow !== "undefined" && this.globalWindow) { | ||
// Define owningContainer for closure to inner class | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
var owningContainer_1 = this; | ||
this.globalWindow["Notification"] = /** @class */ (function (_super) { | ||
this.globalWindow["Notification"] = (function (_super) { | ||
__extends(OpenFinNotification, _super); | ||
@@ -469,3 +437,2 @@ function OpenFinNotification(title, options) { | ||
options["notification"] = _this; | ||
// Forward OpenFin notification events back to Notification API | ||
options["onClick"] = function (event) { if (_this.onclick) { | ||
@@ -490,3 +457,3 @@ _this.onclick(event); | ||
_this.log("info", runtimeInfo); | ||
resolve("RVM/" + rvmInfo.version + " Runtime/" + runtimeInfo.version); | ||
resolve("RVM/".concat(rvmInfo.version, " Runtime/").concat(runtimeInfo.version)); | ||
}, reject); | ||
@@ -518,7 +485,5 @@ }, 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)) { | ||
@@ -538,4 +503,3 @@ newOptions.saveWindowState = false; | ||
var newOptions = this.getWindowOptions(options); | ||
newOptions.url = url; // createWindow param will always take precedence over any passed on options | ||
// OpenFin requires a name for the window to show | ||
newOptions.url = url; | ||
if (!("name" in newOptions)) { | ||
@@ -558,6 +522,6 @@ newOptions.name = desktopjs.Guid.newGuid(); | ||
var imgHtml = (item.icon) | ||
? "<span><img align=\"absmiddle\" class=\"context-menu-image\" src=\"" + this.ensureAbsoluteUrl(item.icon) + "\" /></span>" | ||
? "<span><img align=\"absmiddle\" class=\"context-menu-image\" src=\"".concat(this.ensureAbsoluteUrl(item.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: '" + item.id + "' });this.close()\">" + imgHtml + item.label + "</li>"); | ||
return "<li class=\"context-menu-item\" onclick=\"fin.desktop.InterApplicationBus.send('".concat(this.desktop.Application.getCurrent().uuid) | ||
+ "', null, 'TrayIcon_ContextMenuClick_".concat(this.uuid, "', { id: '").concat(item.id, "' });this.close()\">").concat(imgHtml).concat(item.label, "</li>"); | ||
}; | ||
@@ -568,3 +532,3 @@ OpenFinContainer.prototype.showMenu = function (x, y, monitorInfo, menuItems) { | ||
var contextMenu = new this.desktop.Window({ | ||
name: "trayMenu" + desktopjs.Guid.newGuid(), | ||
name: "trayMenu".concat(desktopjs.Guid.newGuid()), | ||
saveWindowState: false, | ||
@@ -596,6 +560,4 @@ autoShow: false, | ||
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 | ||
@@ -615,10 +577,9 @@ ? x - width - OpenFinContainer.trayIconMenuLeftOffset | ||
.setTrayIcon(this.ensureAbsoluteUrl(details.icon), function (clickInfo) { | ||
if (clickInfo.button === 0 && listener) { // Passthrough left click to addTrayIcon listener callback | ||
if (clickInfo.button === 0 && listener) { | ||
listener(); | ||
} | ||
else if (clickInfo.button === 2) { // handle right click ourselves to display context menu | ||
else if (clickInfo.button === 2) { | ||
_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) { | ||
@@ -671,3 +632,2 @@ for (var prop in _this.menuItemRef) { | ||
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 () { | ||
@@ -678,3 +638,3 @@ var windows, mainWindow, promises; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.getAllWindows()]; | ||
case 0: return [4, this.getAllWindows()]; | ||
case 1: | ||
@@ -686,3 +646,2 @@ 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 () { | ||
@@ -692,3 +651,3 @@ var state, window; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, djsWindow.getState()]; | ||
case 0: return [4, djsWindow.getState()]; | ||
case 1: | ||
@@ -699,3 +658,2 @@ 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); | ||
@@ -706,3 +664,3 @@ if (customData && "persist" in customData && !customData.persist) { | ||
else { | ||
delete options.show; // show is an undocumented option that interferes with the createWindow mapping of show -> autoShow | ||
delete options.show; | ||
window.getGroup(function (group) { | ||
@@ -724,3 +682,3 @@ layout.windows.push({ | ||
}, innerReject); | ||
return [2 /*return*/]; | ||
return [2]; | ||
} | ||
@@ -733,3 +691,3 @@ }); | ||
}).catch(reject); | ||
return [2 /*return*/]; | ||
return [2]; | ||
} | ||
@@ -739,11 +697,5 @@ }); | ||
}; | ||
// 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; | ||
@@ -765,4 +717,3 @@ OpenFinContainer.windowOptionsMap = { | ||
}(desktopjs.WebContainerBase)); | ||
/** @private */ | ||
var OpenFinDisplayManager = /** @class */ (function () { | ||
var OpenFinDisplayManager = (function () { | ||
function OpenFinDisplayManager(desktop) { | ||
@@ -805,4 +756,3 @@ this.desktop = desktop; | ||
}()); | ||
/** @private */ | ||
var OpenFinGlobalShortcutManager = /** @class */ (function (_super) { | ||
var OpenFinGlobalShortcutManager = (function (_super) { | ||
__extends(OpenFinGlobalShortcutManager, _super); | ||
@@ -849,3 +799,3 @@ function OpenFinGlobalShortcutManager(desktop) { | ||
}({}, desktopJS)); | ||
})({}, desktopJS); | ||
//# sourceMappingURL=desktopjs-openfin.js.map |
@@ -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 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); | ||
this.desktopJS=this.desktopJS||{},this.desktopJS.OpenFin=function(t,f){"use strict";var o=function(t,n){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function c(t,a,u,s){return new(u=u||Promise)(function(e,n){function o(t){try{r(s.next(t))}catch(t){n(t)}}function i(t){try{r(s.throw(t))}catch(t){n(t)}}function r(t){var n;t.done?e(t.value):((n=t.value)instanceof u?n:new u(function(t){t(n)})).then(o,i)}r((s=s.apply(t,a||[])).next())})}function p(o,i){var r,a,u,s={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(e){return function(t){var n=[e,t];if(r)throw new TypeError("Generator is already executing.");for(;s=c&&n[c=0]?0:s;)try{if(r=1,a&&(u=2&n[0]?a.return:n[0]?a.throw||((u=a.return)&&u.call(a),0):a.next)&&!(u=u.call(a,n[1])).done)return u;switch(a=0,(n=u?[2&n[0],u.value]:n)[0]){case 0:case 1:u=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,a=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(!(u=0<(u=s.trys).length&&u[u.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!u||n[1]>u[0]&&n[1]<u[3])){s.label=n[1];break}if(6===n[0]&&s.label<u[1]){s.label=u[1],u=n;break}if(u&&s.label<u[2]){s.label=u[2],s.ops.push(n);break}u[2]&&s.ops.pop(),s.trys.pop();continue}n=i.call(o,s)}catch(t){n=[6,t],a=0}finally{r=u=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}}}f.registerContainer("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in window.fin},create:function(t){return new l(null,null,t)}});var i,r={move:"bounds-changing",resize:"bounds-changing",close:"closing",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},e=(n(a,i=f.ContainerWindow),Object.defineProperty(a.prototype,"id",{get:function(){return this.name},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!1,configurable:!0}),a.prototype.load=function(e,t){var o=this;return new Promise(function(t,n){o.innerWindow.navigate(e,t,n)})},a.prototype.focus=function(){var e=this;return new Promise(function(t,n){e.innerWindow.focus(t,n)})},a.prototype.show=function(){var e=this;return new Promise(function(t,n){e.innerWindow.show(t,n)})},a.prototype.hide=function(){var e=this;return new Promise(function(t,n){e.innerWindow.hide(t,n)})},a.prototype.close=function(){var e=this;return new Promise(function(t,n){e.innerWindow.close(!1,t,n)})},a.prototype.minimize=function(){var e=this;return new Promise(function(t,n){e.innerWindow.minimize(t,n)})},a.prototype.maximize=function(){var e=this;return new Promise(function(t,n){e.innerWindow.maximize(t,n)})},a.prototype.restore=function(){var e=this;return new Promise(function(t,n){e.innerWindow.restore(t,n)})},a.prototype.isShowing=function(){var e=this;return new Promise(function(t,n){e.innerWindow.isShowing(t,n)})},a.prototype.getSnapshot=function(){var t=this;return new Promise(function(n,e){t.innerWindow.getSnapshot(function(t){return n("data:image/png;base64,"+t)},function(t){return e(t)})})},a.prototype.getBounds=function(){var e=this;return new Promise(function(n,t){e.innerWindow.getBounds(function(t){return n(new f.Rectangle(t.left,t.top,t.width,t.height))},t)})},a.prototype.flash=function(e,o){var i=this;return new Promise(function(t,n){e?i.innerWindow.flash(o,t,n):i.innerWindow.stopFlashing(t,n)})},a.prototype.getParent=function(){return Promise.resolve(null)},a.prototype.setParent=function(t){return new Promise(function(t,n){t()})},a.prototype.setBounds=function(e){var o=this;return new Promise(function(t,n){o.innerWindow.setBounds(e.x,e.y,e.width,e.height,t,n)})},Object.defineProperty(a.prototype,"allowGrouping",{get:function(){return!0},enumerable:!1,configurable:!0}),a.prototype.getGroup=function(){var e=this;return new Promise(function(n,t){e.innerWindow.getGroup(function(t){n(t.map(function(t){return new a(t)}))},t)})},a.prototype.joinGroup=function(e){var o=this;return e&&e.id!==this.id?new Promise(function(t,n){o.innerWindow.joinGroup(e.innerWindow,function(){f.ContainerWindow.emit("window-joinGroup",{name:"window-joinGroup",windowId:o.id,targetWindowId:e.id}),t()},n)}):Promise.resolve()},a.prototype.leaveGroup=function(){var e=this;return new Promise(function(t,n){e.innerWindow.leaveGroup(function(){f.ContainerWindow.emit("window-leaveGroup",{name:"window-leaveGroup",windowId:e.id}),t()},n)})},a.prototype.bringToFront=function(){var e=this;return new Promise(function(t,n){e.innerWindow.bringToFront(t,n)})},a.prototype.getOptions=function(){var e=this;return new Promise(function(n,t){e.innerWindow.getOptions(function(t){return n(t.customData?JSON.parse(t.customData):void 0)},t)})},a.prototype.getState=function(){var n=this;return new Promise(function(t){n.nativeWindow&&n.nativeWindow.getState?t(n.nativeWindow.getState()):t(void 0)})},a.prototype.setState=function(n){var e=this;return new Promise(function(t){e.nativeWindow&&e.nativeWindow.setState&&e.nativeWindow.setState(n),t()}).then(function(){e.emit("state-changed",{name:"state-changed",sender:e,state:n}),f.ContainerWindow.emit("state-changed",{name:"state-changed",windowId:e.id,state:n})})},a.prototype.attachListener=function(t,n){var e=this;"beforeunload"===t?this.innerWindow.addEventListener("close-requested",function(t){t=new f.EventArgs(e,"beforeunload",t);n(t),void 0===t.returnValue&&e.innerWindow.close(!0)}):this.innerWindow.addEventListener(r[t]||t,n)},a.prototype.wrapListener=function(n,e){var o=this;return"resize"===n?function(t){1<=t.changeType&&e(new f.EventArgs(o,n,t))}:"move"===n?function(t){0===t.changeType&&e(new f.EventArgs(o,n,t))}:i.prototype.wrapListener.call(this,n,e)},a.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(r[t]||t,n)},Object.defineProperty(a.prototype,"nativeWindow",{get:function(){return this.innerWindow.getNativeWindow()},enumerable:!1,configurable:!0}),a);function a(t){return i.call(this,t)||this}s.prototype.subscribe=function(o,i,r){var a=this;return new Promise(function(t,n){var e=new f.MessageBusSubscription(o,function(t,n,e){i({topic:o},t)},r);a.bus.subscribe(r&&r.uuid||"*",r&&r.name||void 0,e.topic,e.listener,function(){return t(e)},n)})},s.prototype.unsubscribe=function(t){var e=this,o=t.topic,i=t.listener,r=t.options;return new Promise(function(t,n){e.bus.unsubscribe(r&&r.uuid||"*",r&&r.name||void 0,o,i,t,n)})},s.prototype.publish=function(e,o,i){var r=this;return new Promise(function(t,n){i&&i.uuid||i&&i.name?r.bus.send(i.uuid||r.uuid,i.name||void 0,e,o,t,n):r.bus.publish(e,o,t,n)})};var u=s;function s(t,n){this.bus=t,this.uuid=n}n(w,d=f.WebContainerBase),w.prototype.setOptions=function(t){t&&t.userName&&t.appName&&this.desktop.Application.getCurrent().registerUser(t.userName,t.appName),t&&t.autoStartOnLogin&&this.desktop.Application.getCurrent().setShortcuts({systemStartup:t.autoStartOnLogin});var n=w.replaceNotificationApi;(n=t&&void 0!==t.replaceNotificationApi?t.replaceNotificationApi:n)&&this.registerNotificationsApi()},w.prototype.getOptions=function(){return c(this,void 0,void 0,function(){var n,e;return p(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e={},[4,this.isAutoStartEnabledAtLogin()];case 1:return[2,(e.autoStartOnLogin=t.sent(),e)];case 2:throw n=t.sent(),new Error("Error getting Container options. "+n);case 3:return[2]}})})},w.prototype.isAutoStartEnabledAtLogin=function(){var e=this;return new Promise(function(n,t){e.desktop.Application.getCurrent().getShortcuts(function(t){return n(t.systemStartup)},t)})},w.prototype.createMessageBus=function(){return new u(this.desktop.InterApplicationBus,this.desktop.Application.getCurrent().uuid)},w.prototype.registerNotificationsApi=function(){var o,i;function t(t,n){var e=i.call(this,t,n)||this;return n.notification=e,n.onClick=function(t){e.onclick&&e.onclick(t)},n.onError=function(t){e.onerror&&e.onerror(t)},o.showNotification(e.title,e.options),e}void 0!==this.globalWindow&&this.globalWindow&&((o=this).globalWindow.Notification=(n(t,i=f.ContainerNotification),t))},w.prototype.getInfo=function(){var o=this;return new Promise(function(e,t){o.desktop.System.getRvmInfo(function(n){o.desktop.System.getRuntimeInfo(function(t){o.log("info",t),e("RVM/".concat(n.version," Runtime/").concat(t.version))},t)},t)})},w.prototype.log=function(e,o){var i=this;return new Promise(function(t,n){i.desktop.System.log(e,o,t,n)})},w.prototype.ready=function(){var n=this;return new Promise(function(t){return n.desktop.main(t)})},w.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},w.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},w.prototype.getWindowOptions=function(t){var n=f.ObjectTransform.transformProperties(t,this.windowOptionsMap);return n.customData=t?JSON.stringify(t):void 0,"autoShow"in n||(n.autoShow=!0),"saveWindowState"in n||!("defaultLeft"in n||"defaultTop"in n)||(n.saveWindowState=!1),"icon"in n&&(n.icon=this.ensureAbsoluteUrl(n.icon)),n},w.prototype.wrapWindow=function(t){return new e(t)},w.prototype.createWindow=function(t,n){var o=this,i=this.getWindowOptions(n);return i.url=t,"name"in i||(i.name=f.Guid.newGuid()),new Promise(function(n,t){var e=new o.desktop.Window(i,function(t){n(o.wrapWindow(e))},t)})},w.prototype.showNotification=function(t,n){new this.desktop.Notification(f.ObjectTransform.transformProperties(n,this.notificationOptionsMap))},w.prototype.getMenuHtml=function(){return w.menuHtml},w.prototype.getMenuItemHtml=function(t){var n=t.icon?'<span><img align="absmiddle" class="context-menu-image" src="'.concat(this.ensureAbsoluteUrl(t.icon),'" /></span>'):"<span> </span>";return'<li class="context-menu-item" onclick="fin.desktop.InterApplicationBus.send(\''.concat(this.desktop.Application.getCurrent().uuid)+"', null, 'TrayIcon_ContextMenuClick_".concat(this.uuid,"', { id: '").concat(t.id,"' });this.close()\">").concat(n).concat(t.label,"</li>")},w.prototype.showMenu=function(a,u,s,c){var p=this,d=(this.menuItemRef=c,new this.desktop.Window({name:"trayMenu".concat(f.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(){for(var t=d.getNativeWindow(),n=(t.document.open("text/html","replace"),t.document.write(p.getMenuHtml()),t.document.close(),""),e=0,o=c.filter(function(t){return t.label});e<o.length;e++){var i=o[e];i.id||(i.id=f.Guid.newGuid()),n+=p.getMenuItemHtml(i)}var t=t.document.getElementById("contextMenu"),r=(t.innerHTML=n,t.offsetWidth),t=t.offsetHeight,r=(d.resizeTo(r,t,"top-left"),a+r>s.primaryMonitor.monitorRect.right?a-r-w.trayIconMenuLeftOffset:a),t=u+t>s.primaryMonitor.monitorRect.bottom?u-t-w.trayIconMenuTopOffset:u;d.addEventListener("blurred",function(){return d.close()}),d.showAt(r,t,!1,function(){return d.focus()})}))},w.prototype.addTrayIcon=function(t,n,e){var o=this;this.desktop.Application.getCurrent().setTrayIcon(this.ensureAbsoluteUrl(t.icon),function(t){0===t.button&&n?n():2===t.button&&o.showMenu(t.x+w.trayIconMenuLeftOffset,t.y+w.trayIconMenuTopOffset,t.monitorInfo,e)},function(){o.desktop.InterApplicationBus.subscribe(o.desktop.Application.getCurrent().uuid,"TrayIcon_ContextMenuClick_"+o.uuid,function(t,n){for(var e in o.menuItemRef){e=o.menuItemRef[e];e.id===t.id&&e.click&&e.click(e)}})},function(t){o.log("error",t)})},w.prototype.closeAllWindows=function(){var e=this;return new Promise(function(n,t){var o=[];e.desktop.Application.getCurrent().getChildWindows(function(t){t.forEach(function(e){o.push(new Promise(function(t,n){return e.close(!0,t,n)}))}),Promise.all(o).then(function(){return n()})},t)})},w.prototype.getAllWindows=function(){var e=this;return new Promise(function(n,t){e.desktop.Application.getCurrent().getChildWindows(function(t){t.push(e.desktop.Application.getCurrent().getWindow()),n(t.map(function(t){return e.wrapWindow(t)}))},t)})},w.prototype.getWindowById=function(t){return this.getWindowByName(t)},w.prototype.getWindowByName=function(e){var o=this;return new Promise(function(n,t){o.desktop.Application.getCurrent().getChildWindows(function(t){t.push(o.desktop.Application.getCurrent().getWindow());t=t.find(function(t){return t.name===e});n(t?o.wrapWindow(t):null)})})},w.prototype.buildLayout=function(){var t=this,s=new f.PersistedWindowLayout;return new Promise(function(i,r){return c(t,void 0,void 0,function(){var n,u,e,o=this;return p(this,function(t){switch(t.label){case 0:return[4,this.getAllWindows()];case 1:return n=t.sent(),u=this.getMainWindow(),e=[],n.filter(function(t){return"queueCounter"!==t.name&&!t.name.startsWith(w.notificationGuid)}).forEach(function(n){e.push(new Promise(function(r,a){return c(o,void 0,void 0,function(){var o,i;return p(this,function(t){switch(t.label){case 0:return[4,n.getState()];case 1:return o=t.sent(),(i=n.innerWindow).getBounds(function(e){i.getOptions(function(n){var t=n.customData?JSON.parse(n.customData):void 0;t&&"persist"in t&&!t.persist?r():(delete n.show,i.getGroup(function(t){s.windows.push({name:i.name,id:i.name,url:i.getNativeWindow()?i.getNativeWindow().location.toString():n.url,main:u&&u.name===i.name,options:n,state:o,bounds:{x:e.left,y:e.top,width:e.width,height:e.height},group:t.map(function(t){return t.name})}),r()},a))},a)},a),[2]}})})}))}),Promise.all(e).then(function(){i(s)}).catch(r),[2]}})})})},w.trayIconMenuLeftOffset=4,w.trayIconMenuTopOffset=23,w.notificationGuid="A21B62E0-16B1-4B10-8BE3-BBB6B489D862",w.replaceNotificationApi=!0,w.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},w.notificationOptionsMap={body:{target:"message"}},w.menuHtml='<html>\n <head>\n <style>\n body:before, body:after {\n position: fixed;\n background: silver;\n }\n body {\n margin: 0px;\n overflow: hidden;\n }\n .context-menu {\n list-style: none;\n padding: 1px 0 1px 0;\n }\n .context-menu-item {\n display: block;\n cursor: default;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 9pt;\n margin-bottom: 2px;\n padding: 4px 0 4px 4px;\n white-space: nowrap;\n }\n .context-menu-item span {\n display: inline-block;\n min-width: 20px;\n }\n .context-menu-item:last-child {\n margin-bottom: 0;\n } \n .context-menu-item:hover {\n color: #fff;\n background-color: #0066aa;\n }\n .context-menu-image {\n width: 16px;\n height: 16px;\n margin-top: -1px;\n margin-right: 4px;\n } \n </style>\n <script>\n document.addEventListener(\'keydown\', (event) => {\n if (event.keyCode == 27) {\n window.close();\n }\n }, false);\n <\/script>\n </head>\n <body>\n <ul class="context-menu" id="contextMenu"></ul>\n </body>\n </html>';var d,l=w;function w(t,n,e){var o=d.call(this,n)||this;return o.windowOptionsMap=w.windowOptionsMap,o.notificationOptionsMap=w.notificationOptionsMap,o.desktop=t||window.fin.desktop,o.hostType="OpenFin",o.setOptions(e),o.ipc=o.createMessageBus(),o.desktop.Application.getCurrent().addEventListener("window-created",function(t){o.emit("window-created",{sender:o,name:"window-created",windowId:t.name,windowName:t.name}),f.Container.emit("window-created",{name:"window-created",windowId:t.name,windowName:t.name}),f.ContainerWindow.emit("window-created",{name:"window-created",windowId:t.name,windowName:t.name})}),o.screen=new m(o.desktop),o.desktop.GlobalHotkey?o.globalShortcut=new y(o.desktop):o.log("warn","Global shortcuts require minimum OpenFin runtime of 9.61.32.34"),o}h.prototype.createDisplay=function(t){var n=new f.Display;return n.id=t.name,n.scaleFactor=t.deviceScaleFactor,n.bounds=new f.Rectangle(t.monitorRect.left,t.monitorRect.top,t.monitorRect.right-t.monitorRect.left,t.monitorRect.bottom-t.monitorRect.top),n.workArea=new f.Rectangle(t.availableRect.left,t.availableRect.top,t.availableRect.right-t.availableRect.left,t.availableRect.bottom-t.availableRect.top),n},h.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(n,t){e.desktop.System.getMonitorInfo(function(t){n(e.createDisplay(t.primaryMonitor))},t)})},h.prototype.getAllDisplays=function(){var e=this;return new Promise(function(n,t){e.desktop.System.getMonitorInfo(function(t){n([t.primaryMonitor].concat(t.nonPrimaryMonitors).map(e.createDisplay))},t)})},h.prototype.getMousePosition=function(){var e=this;return new Promise(function(n,t){e.desktop.System.getMousePosition(function(t){n({x:t.left,y:t.top})},t)})};var m=h;function h(t){this.desktop=t}n(v,g=f.GlobalShortcutManager),v.prototype.register=function(e,o){var i=this;return new Promise(function(t,n){i.desktop.GlobalHotkey.register(e,o,t,n)})},v.prototype.isRegistered=function(e){var o=this;return new Promise(function(t,n){o.desktop.GlobalHotkey.isRegistered(e,t,n)})},v.prototype.unregister=function(e){var o=this;return new Promise(function(t,n){o.desktop.GlobalHotkey.unregister(e,t,n)})},v.prototype.unregisterAll=function(){var e=this;return new Promise(function(t,n){e.desktop.GlobalHotkey.unregisterAll(t,n)})};var g,y=v;function v(t){var n=g.call(this)||this;return n.desktop=t,n}return t.OpenFinContainer=l,t.OpenFinContainerWindow=e,t.OpenFinMessageBus=u,Object.defineProperty(t,"__esModule",{value:!0}),t}({},desktopJS); | ||
//# sourceMappingURL=desktopjs-openfin.min.js.map |
@@ -5,3 +5,3 @@ { | ||
"description": "desktopJS container implementation for OpenFin", | ||
"version": "3.12.0", | ||
"version": "3.13.1", | ||
"publishConfig": { | ||
@@ -14,3 +14,6 @@ "access": "public" | ||
"author": "Morgan Stanley", | ||
"repository": "https://github.com/MorganStanley/desktopJS/tree/main/packages/desktopjs-openfin", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/MorganStanley/desktopJS.git#main" | ||
}, | ||
"bugs": { | ||
@@ -31,13 +34,11 @@ "url": "https://github.com/MorganStanley/desktopJS/issues" | ||
"clean": "gulp clean", | ||
"build:lerna": "gulp build:lerna", | ||
"build:workspaces": "gulp build:workspaces", | ||
"build": "gulp build", | ||
"test": "gulp test", | ||
"watch": "gulp watch", | ||
"deploy": "npm publish" | ||
}, | ||
"homepage": "https://github.com/MorganStanley/desktopJS/tree/main#readme", | ||
"devDependencies": { | ||
"@morgan-stanley/desktopjs": "^3.12.0", | ||
"@types/jasmine": "^3.5.11", | ||
"gulp": "^4.0.2" | ||
"@morgan-stanley/desktopjs": "file:packages/desktopjs" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
367206
1
13
1899
1
2