@morgan-stanley/desktopjs
Advanced tools
Comparing version 3.11.0 to 3.12.0
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).desktopJS={})}(this,function(u){"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)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function a(t,n){function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function w(e,o){var i,r,a,t,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function n(n){return function(t){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(a=2&n[0]?r.return:n[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,n[1])).done)return a;switch(r=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,r=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){s.label=n[1];break}if(6===n[0]&&s.label<a[1]){s.label=a[1],a=n;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(n);break}a[2]&&s.ops.pop(),s.trys.pop();continue}n=o.call(e,s)}catch(t){n=[6,t],r=0}finally{i=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,t])}}}var s=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},i=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},r.prototype.registerAndWrapListener=function(t,n){var e=this.wrapListener(t,n);return this.wrappedListeners.set(n,e),e},r.prototype.wrapListener=function(o,i){var r=this;return function(t){var n=new s(r,o,t);r.preProcessArgs(n);var e=i(n);return r.postProcessArgs(n),e}},r.prototype.preProcessArgs=function(t){},r.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},r.prototype.removeListener=function(t,n){var e=this.listeners(t);if(e){var o=e.indexOf(n);0<=o&&e.splice(o,1)}return this},r.prototype.listeners=function(t){return this.eventListeners[t]||[]},r.prototype.emit=function(t,n){for(var e=0,o=this.listeners(t);e<o.length;e++){(0,o[e])(n)}},Object.defineProperty(r,"ipc",{set:function(t){t&&t.subscribe(r.staticEventName,function(t,n){r.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),r.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},r.removeListener=function(t,n){var e=r.listeners(t);if(e){var o=e.indexOf(n);0<=o&&e.splice(o,1)}},r.listeners=function(t){return this.staticEventListeners[t]||[]},r.emit=function(t,n,e){if(e&&e.publish)e.publish(r.staticEventName,{eventName:t,eventArgs:n});else for(var o=0,i=r.listeners(t);o<i.length;o++){(0,i[o])(n)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),p=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)})},t}(),t=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return a(n,t),n}(s),h=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return a(o,e),o.prototype.getInfo=function(){return Promise.resolve(void 0)},o.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(o,"ipc",{get:function(){return o._ipc},set:function(t){i.ipc=o._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"ipc",{get:function(){return o.ipc},set:function(t){o.ipc=t},enumerable:!1,configurable:!0}),o.prototype.addListener=function(t,n){return e.prototype.addListener.call(this,t,n)},o.prototype.removeListener=function(t,n){return e.prototype.removeListener.call(this,t,n)},o.prototype.emit=function(t,n){e.prototype.emit.call(this,t,n)},o.addListener=function(t,n){i.addListener(o.staticEventScopePrefix+t,n)},o.removeListener=function(t,n){i.removeListener(o.staticEventScopePrefix+t,n)},o.emit=function(t,n){i.emit(o.staticEventScopePrefix+t,n,o.ipc)},o.listeners=function(t){return i.listeners(o.staticEventScopePrefix+t)},o.staticEventScopePrefix="container-",o.windowOptionsPropertyKey="desktopJS-options",o}(i),n=function(n){function r(){var t=null!==n&&n.apply(this,arguments)||this;return t.uuid=p.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}return a(r,n),r.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},r.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},r.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(r.layoutsPropertyKey))[t]},r.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(e)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:n,layoutName:n.name}),h.emit("layout-saved",{name:"layout-saved",layout:n,layoutName:n.name})},r.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(n)),this.emit("layout-deleted",{sender:this,name:"layout-deleted",layoutName:e.name}),h.emit("layout-deleted",{name:"layout-deleted",layoutName:e.name}))},r.prototype.loadLayout=function(u){var c=this;return new Promise(function(a,s){c.closeAllWindows(!0).then(function(){var r="string"==typeof u?c.getLayoutFromStorage(u):u;if(r&&r.windows){for(var t=[],n=0,e=r.windows;n<e.length;n++){var o=e[n],i=Object.assign(o.options||{},o.bounds);i.name=o.name,o.main?(c.getMainWindow().setBounds(o.bounds),t.push(Promise.resolve(c.getMainWindow()))):t.push(c.createWindow(o.url,i))}Promise.all(t).then(function(t){var i=new Map;t.forEach(function(e){var t=r.windows.find(function(t){return t.name===e.name});t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)});var o=!1;if(i.forEach(function(t,n){!o&&0<=t.indexOf(e.id)&&(o=!0)}),!o){var n=t?t.group:void 0;n&&0<n.length&&i.set(e,n.filter(function(t){return t!==e.id}))}}),i.forEach(function(t,e){t.forEach(function(n){c.getWindowByName(r.windows.find(function(t){return t.id===n}).name).then(function(t){t.joinGroup(e)})})})}),c.emit("layout-loaded",{sender:c,name:"layout-loaded",layout:r,layoutName:r.name}),h.emit("layout-loaded",{name:"layout-loaded",layout:r,layoutName:r.name}),a(r)}else s("Layout does not exist or is invalid")})})},r.prototype.saveLayout=function(e){var o=this;return new Promise(function(n,t){o.buildLayout().then(function(t){o.saveLayoutToStorage(e,t),n(t)}).catch(t)})},r.prototype.deleteLayout=function(e){var o=this;return new Promise(function(t,n){t(o.deleteLayoutFromStorage(e))})},r.prototype.getLayouts=function(){var i=this;return new Promise(function(t,n){var e=i.storage.getItem(r.layoutsPropertyKey);if(e){var o=JSON.parse(e);t(Object.getOwnPropertyNames(o).map(function(t){return o[t]}))}t(void 0)})},r.prototype.log=function(e,o){return new Promise(function(t){var n;switch(e){case"debug":n=console.debug;break;case"warn":n=console.warn;break;case"error":n=console.error;break;default:n=console.log}n&&n(o),t()})},r.layoutsPropertyKey="desktopJS-layouts",r}(h),r=function(n){function t(t){var e=n.call(this)||this;e.globalWindow=t||"undefined"!=typeof window&&window||null,e.linkHelper={href:"unknown"};try{e.linkHelper=e.globalWindow.top.document.createElement("a")}catch(t){}if(e.globalWindow){var o=e.globalWindow.open;e.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.onOpen.apply(e,function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var o=Array(t),i=0;for(n=0;n<e;n++)for(var r=arguments[n],a=0,s=r.length;a<s;a++,i++)o[i]=r[a];return o}([o],t))}}return e}return a(t,n),t.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},t.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t},t}(n),c=function(t,n,e){this.topic=t,this.listener=n,this.options=e},e=function(){},d=function(){},f=function(){},l=function(){function n(t,n){}return n.requestPermission=function(t){return t&&t(n.permission),Promise.resolve(n.permission)},n.permission="granted",n}(),y=function(){};(u.ObjectTransform||(u.ObjectTransform={})).transformProperties=function(t,n){var e={};if(t)for(var o in t)try{o in n?e[n[o].target]=n[o].convert?n[o].convert(t[o],t,e):t[o]:e[o]=t[o]}catch(t){console.error("Error transforming property '"+o+"'")}return e};var g,v=function(){function t(t,n,e,o){this.x=t,this.y=n,this.width=e,this.height=o}return Object.defineProperty(t.prototype,"right",{get:function(){return t.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return t.getBottom(this)},enumerable:!1,configurable:!0}),t.getRight=function(t){return t.x+t.width},t.getBottom=function(t){return t.y+t.height},t}(),m=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return a(n,t),n}(s),b=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return a(n,t),n}(m),W=function(o){function e(t){var n=o.call(this)||this;return n.innerWindow=t,n}return a(e,o),Object.defineProperty(e.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.getGroup=function(){return Promise.resolve([])},e.prototype.joinGroup=function(t){return Promise.reject("Not supported")},e.prototype.leaveGroup=function(){return Promise.resolve()},e.prototype.bringToFront=function(){return this.focus()},e.prototype.getState=function(){return Promise.resolve(void 0)},e.prototype.setState=function(t){return Promise.resolve()},Object.defineProperty(e.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),e.prototype.addListener=function(t,n){var e=this.registerAndWrapListener(t,n);return this.attachListener(t,e),o.prototype.addListener.call(this,t,e)},e.prototype.removeListener=function(t,n){var e=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,e),o.prototype.removeListener.call(this,t,e)},e.addListener=function(t,n){i.addListener(e.staticEventScopePrefix+t,n)},e.removeListener=function(t,n){i.removeListener(e.staticEventScopePrefix+t,n)},e.emit=function(t,n){i.emit(e.staticEventScopePrefix+t,n,h.ipc)},e.listeners=function(t){return i.listeners(e.staticEventScopePrefix+t)},e.staticEventScopePrefix="containerwindow-",e}(i),P=function(){},x=function(t){this.windows=[],this.name=t};function S(){return"undefined"!=typeof window&&window.fin}(g=u.WindowStateTracking||(u.WindowStateTracking={}))[g.None=0]="None",g[g.Main=1]="Main",g[g.Group=2]="Group";var L=function(){function t(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}return t.prototype.attach=function(t){var n=this;t?(t.addListener(S()?"minimized":"minimize",function(t){n.windowStateTracking&u.WindowStateTracking.Main&&n.container.getMainWindow().id===t.sender.id&&n.container.getAllWindows().then(function(t){t.forEach(function(t){return t.minimize()})}),n.windowStateTracking&u.WindowStateTracking.Group&&t.sender.getGroup().then(function(t){t.forEach(function(t){return t.minimize()})})}),t.addListener(S()?"restored":"restore",function(t){n.windowStateTracking&u.WindowStateTracking.Main&&n.container.getMainWindow().id===t.sender.id&&n.container.getAllWindows().then(function(t){t.forEach(function(t){return t.restore()})}),n.windowStateTracking&u.WindowStateTracking.Group&&t.sender.getGroup().then(function(t){t.forEach(function(t){return t.restore()})})})):(W.addListener("window-created",function(t){n.container&&n.container.getWindowById&&n.container.getWindowById(t.windowId).then(function(t){n.attach(t)})}),this.container&&this.container.getAllWindows().then(function(t){t.forEach(function(t){return n.attach(t)})}))},t}(),O=function(o){function t(t,n){var e=o.call(this,t,n)||this;return e.autoGrouping=!0,e.snapThreshold=15,e.snapOffset=15,e.targetGroup=new Map,n&&("snapThreshold"in n&&(e.snapThreshold=n.snapThreshold),"snapOffset"in n&&(e.snapOffset=n.snapOffset),"autoGrouping"in n&&(e.autoGrouping=n.autoGrouping)),e}return a(t,o),t.prototype.onAttached=function(t){var n=this;t.innerWindow&&t.innerWindow.disableFrame&&t.innerWindow.disableFrame(),S()?(t.addListener("disabled-frame-bounds-changed",function(){return n.onMoved(t)}),t.addListener("frame-enabled",function(){return t.innerWindow.disableFrame()})):t.innerWindow&&t.innerWindow.hookWindowMessage&&t.innerWindow.hookWindowMessage(562,function(){return n.onMoved(t)})},t.prototype.attach=function(n){var e=this;o.prototype.attach.call(this,n),n&&n.getOptions().then(function(t){t&&void 0!==t.snap&&!1===t.snap||(e.onAttached(n),n.addListener(S()?"disabled-frame-bounds-changing":"move",function(t){return e.onMoving(t)}))})},t.prototype.onMoving=function(s){var u=this,e=s.sender.id;this.snappingWindow!==e&&s.sender.getOptions().then(function(t){t&&void 0!==t.snap&&!1===t.snap||s.sender.getGroup().then(function(t){(S()?Promise.resolve(new v(s.innerEvent.left,s.innerEvent.top,s.innerEvent.width,s.innerEvent.height)):s.sender.getBounds()).then(function(a){if(0<t.length)S()&&u.moveWindow(s.sender,a);else{var n=[];u.container.getAllWindows().then(function(t){t.filter(function(t){return e!==t.id}).forEach(function(o){n.push(new Promise(function(e){o.getOptions().then(function(n){o.getBounds().then(function(t){return e({window:o,bounds:t,options:n})})})}))}),Promise.all(n).then(function(t){for(var n,e=!1,o=0,i=t.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});o<i.length;o++){var r=i[o];(n=u.getSnapBounds(n||a,r.bounds))?(e=!0,u.showGroupingHint(r.window),u.moveWindow(s.sender,n)):u.hideGroupingHint(r.window)}!e&&S()&&u.moveWindow(s.sender,a)})})}})})})},t.prototype.moveWindow=function(t,n){var e=this;this.snappingWindow=t.id,t.setBounds(n).then(function(){return e.snappingWindow=void 0},function(){return e.snappingWindow=void 0})},t.prototype.onMoved=function(e){var n=this;if(this.autoGrouping){var t=[];this.targetGroup.forEach(function(e){return t.push(new Promise(function(n){e.getGroup().then(function(t){return n({window:e,isGrouped:0<t.length})})}))}),Promise.all(t).then(function(t){0<t.length&&e.joinGroup(t[0].window);for(var n=1;n<t.length;n++)t[n].isGrouped||t[n].window.joinGroup(e)})}this.targetGroup.forEach(function(t){return n.hideGroupingHint(t)}),this.targetGroup.clear()},t.prototype.showGroupingHint=function(t){t.innerWindow&&t.innerWindow.updateOptions&&t.innerWindow.updateOptions({opacity:.75}),this.targetGroup.set(t.id,t)},t.prototype.hideGroupingHint=function(t){t.innerWindow&&t.innerWindow.updateOptions&&t.innerWindow.updateOptions({opacity:1}),this.targetGroup.delete(t.id)},t.prototype.isHorizontallyAligned=function(t,n){return t.y>=n.y&&t.y<=n.bottom||t.bottom>=n.y&&t.bottom<=n.bottom||t.y<=n.y&&t.bottom>=n.bottom},t.prototype.isVerticallyAligned=function(t,n){return t.x>=n.x&&t.x<=n.right||t.right>=n.x&&t.right<=n.right||t.x<=n.x&&t.right>=n.right},t.prototype.getSnapBounds=function(t,n){var e,o,i,r,a,s,u,c;if(this.isHorizontallyAligned(t,n)&&(e=Math.abs(t.x-(n.right-this.snapOffset))<this.snapThreshold,o=Math.abs(t.x-n.x)<this.snapThreshold,i=Math.abs(t.right-this.snapOffset-n.x)<this.snapThreshold,r=Math.abs(t.right-n.right)<this.snapThreshold),this.isVerticallyAligned(t,n)&&(a=Math.abs(t.y-(n.bottom-this.snapOffset))<this.snapThreshold,s=Math.abs(t.y-n.y)<this.snapThreshold,u=Math.abs(t.bottom-this.snapOffset-n.y)<this.snapThreshold,c=Math.abs(t.bottom-n.bottom)<this.snapThreshold),e||i||a||u){var p=t.x,d=t.y;return e?p=n.x+n.width-this.snapOffset:o&&(p=n.x),i?p=n.x-t.width+this.snapOffset:r&&(p=n.x+n.width-t.width),a?d=n.y+n.height-Math.floor(this.snapOffset/2):s&&(d=n.y),u?d=n.y-t.height+Math.floor(this.snapOffset/2):c&&(d=n.y+n.height-t.height),new v(p,d,t.width,t.height)}},t}(L),E=function(){},M=function(){};!function(t){var e={close:"unload"},n=function(n){function t(t){return n.call(this,t)||this}return a(t,n),Object.defineProperty(t.prototype,"id",{get:function(){return this.innerWindow[s.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.innerWindow[s.windowNamePropertyKey]},enumerable:!1,configurable:!0}),t.prototype.load=function(n,t){var e=this;return new Promise(function(t){e.innerWindow.location.replace(n),t()})},t.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},t.prototype.show=function(){return Promise.resolve()},t.prototype.hide=function(){return Promise.resolve()},t.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},t.prototype.minimize=function(){var n=this;return new Promise(function(t){n.innerWindow.minimize(),t()})},t.prototype.maximize=function(){var n=this;return new Promise(function(t){n.innerWindow.maximize(),t()})},t.prototype.restore=function(){var n=this;return new Promise(function(t){n.innerWindow.restore(),t()})},t.prototype.isShowing=function(){return Promise.resolve(!0)},t.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},t.prototype.flash=function(t,n){return Promise.reject("Not supported")},t.prototype.getParent=function(){return Promise.resolve(null)},t.prototype.setParent=function(t){return Promise.resolve()},t.prototype.getBounds=function(){var n=this;return new Promise(function(t){t(new v(n.innerWindow.screenX,n.innerWindow.screenY,n.innerWindow.outerWidth,n.innerWindow.outerHeight))})},t.prototype.setBounds=function(n){var e=this;return new Promise(function(t){e.innerWindow.moveTo(n.x,n.y),e.innerWindow.resizeTo(n.width,n.height),t()})},t.prototype.getOptions=function(){var e=this;return new Promise(function(t,n){t(e.innerWindow[h.windowOptionsPropertyKey])})},t.prototype.getState=function(){var n=this;return new Promise(function(t){n.nativeWindow&&n.nativeWindow.getState?t(n.nativeWindow.getState()):t(void 0)})},t.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}),W.emit("state-changed",{name:"state-changed",windowId:e.id,state:n})})},t.prototype.attachListener=function(t,n){this.innerWindow.addEventListener(e[t]||t,n)},t.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(e[t]||t,n)},Object.defineProperty(t.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),t}(W);t.DefaultContainerWindow=n;var o=function(){function u(t){this.container=t}return u.prototype.subscribe=function(r,a,t){var s=this;return new Promise(function(t,n){var e=new c(r,function(t){if(t.origin===s.container.globalWindow.location.origin){var n=t.data,e=n.source,o=n.topic,i=n.message;e===u.messageSource&&r===o&&a({topic:r},i)}});s.container.globalWindow&&s.container.globalWindow.addEventListener&&s.container.globalWindow.addEventListener("message",e.listener),t(e)})},u.prototype.unsubscribe=function(t){return Promise.resolve(this.container.globalWindow.removeEventListener("message",t.listener))},u.prototype.publish=function(t,n,e){var o=this.container.globalWindow?this.container.globalWindow[s.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[s.windowsPropertyKey]:[];if(o)for(var i in o){var r=o[i];if(!e||!e.name||e.name===r[s.windowNamePropertyKey]){var a=(null==e?void 0:e.targetOrigin)||this.container.globalWindow.location.origin;r.postMessage({source:u.messageSource,topic:t,message:n},a)}}return Promise.resolve()},u.messageSource="desktopJS",u}();t.DefaultMessageBus=o;var s=function(e){function c(t){var n=e.call(this,t)||this;return n.windowOptionsMap=c.defaultWindowOptionsMap,n.hostType="Default",n.ipc=n.createMessageBus(),!n.globalWindow||c.windowsPropertyKey in n.globalWindow||(n.globalWindow[c.windowsPropertyKey]={root:n.globalWindow},n.globalWindow[c.windowNamePropertyKey]=n.globalWindow[c.windowUuidPropertyKey]=c.rootWindowUuid),n.screen=new i(n.globalWindow),n}return a(c,e),c.prototype.createMessageBus=function(){return new o(this)},c.prototype.getInfo=function(){return Promise.resolve(this.globalWindow.navigator.appVersion)},c.prototype.getMainWindow=function(){if(!this.mainWindow){var t=this.globalWindow[c.windowsPropertyKey].root;this.mainWindow=t?this.wrapWindow(t):null}return this.mainWindow},c.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},c.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},c.prototype.wrapWindow=function(t){return new n(t)},c.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var o=t.apply(this.globalWindow,n),i=p.newGuid();try{var r=this.globalWindow[c.windowsPropertyKey];(r[i]=o)[c.windowUuidPropertyKey]=i,o.addEventListener("beforeunload",function(){o.addEventListener("unload",function(){delete r[i]})}),o[c.windowsPropertyKey]=r}catch(t){console.warn("Error tracking new window, '"+t.message+"'")}return h.emit("window-created",{name:"window-created",windowId:i}),W.emit("window-created",{name:"window-created",windowId:i}),o},c.prototype.createWindow=function(t,n){var e,o="_blank",i=this.getWindowOptions(n);if(i){for(var r in i)e=(e||"")+r+"="+i[r]+",";i&&"target"in i&&(o=i.target)}var a=this.globalWindow.open(t,o,e),s=!0;try{a[h.windowOptionsPropertyKey]=n,a[c.windowNamePropertyKey]=i.name}catch(t){s=!1,console.warn("Error proprogating properties to new window, '"+t.message+"'")}var u=this.wrapWindow(a);return this.emit("window-created",{sender:this,name:"window-created",window:u,windowId:s?u.id:void 0,windowName:i.name}),Promise.resolve(u)},c.prototype.showNotification=function(n,e){var o=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(t){"denied"===t?console.warn("Notifications not permitted"):"granted"===t&&new o.globalWindow.Notification(n,e)}):console.warn("Notifications not supported")},c.prototype.closeAllWindows=function(r){var a=this;return new Promise(function(t,n){var e=a.globalWindow[c.windowsPropertyKey];for(var o in e){var i=e[o];r&&a.globalWindow===i||i.close()}t()})},c.prototype.getAllWindows=function(){var r=this;return new Promise(function(t,n){var e=[],o=r.globalWindow[c.windowsPropertyKey];for(var i in o)e.push(r.wrapWindow(o[i]));t(e)})},c.prototype.getWindowById=function(o){var i=this;return new Promise(function(t,n){var e=i.globalWindow[c.windowsPropertyKey][o];t(e?i.wrapWindow(e):null)})},c.prototype.getWindowByName=function(i){var r=this;return new Promise(function(t,n){var e=r.globalWindow[c.windowsPropertyKey];for(var o in e)if(e[o][c.windowNamePropertyKey]===i)return void t(r.wrapWindow(e[o]));t(null)})},c.prototype.buildLayout=function(){var f=this,l=new x;return new Promise(function(n,e){var o=[];f.getAllWindows().then(function(t){t.forEach(function(c){var p=c.nativeWindow;try{var d=p[h.windowOptionsPropertyKey];if(d&&"persist"in d&&!d.persist)return;o.push(new Promise(function(i){return r=f,u=function(){var n,e,o;return w(this,function(t){switch(t.label){case 0:return this.globalWindow===p?[3,2]:(e=(n=l.windows).push,o={name:c.name,url:p&&p.location?p.location.toString():void 0,id:c.id,bounds:{x:p.screenX,y:p.screenY,width:p.innerWidth,height:p.innerHeight},options:d},[4,c.getState()]);case 1:e.apply(n,[(o.state=t.sent(),o)]),t.label=2;case 2:return i(),[2]}})},new((s=a=void 0)||(s=Promise))(function(t,n){function e(t){try{i(u.next(t))}catch(t){n(t)}}function o(t){try{i(u.throw(t))}catch(t){n(t)}}function i(n){n.done?t(n.value):new s(function(t){t(n.value)}).then(e,o)}i((u=u.apply(r,a||[])).next())});var r,a,s,u}))}catch(t){console.warn("Error while accessing window so skipping, '"+t.message+"'")}}),Promise.all(o).then(function(){n(l)}).catch(e)})})},c.windowsPropertyKey="desktopJS-windows",c.windowUuidPropertyKey="desktopJS-uuid",c.windowNamePropertyKey="desktopJS-name",c.rootWindowUuid="root",c.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},c}(r);t.DefaultContainer=s;var i=function(){function t(t){this.window=t}return t.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(t){var n=new M;n.scaleFactor=e.window.devicePixelRatio,n.id="Current",n.bounds=new v(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.width,e.window.screen.height),n.workArea=new v(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.availWidth,e.window.screen.availHeight),t(n)})},t.prototype.getAllDisplays=function(){var t=this;return new Promise(function(n){t.getPrimaryDisplay().then(function(t){return n([t])})})},t.prototype.getMousePosition=function(){var e=this;return new Promise(function(t,n){t({x:e.window.event.screenX,y:e.window.event.screenY})})},t}()}(u.Default||(u.Default={}));var T=function(){},k=[];var N=function(){},G=function(){};u.Container=h,u.ContainerBase=n,u.ContainerNotification=l,u.ContainerRegistration=T,u.ContainerWindow=W,u.Display=M,u.EventArgs=s,u.EventEmitter=i,u.GlobalShortcutManager=G,u.GroupWindowManager=L,u.Guid=p,u.LayoutEventArgs=t,u.MenuItem=d,u.MessageBusOptions=e,u.MessageBusSubscription=c,u.NotificationOptions=f,u.PersistedWindow=P,u.PersistedWindowLayout=x,u.Point=E,u.PropertyMap=y,u.Rectangle=v,u.SnapAssistWindowManager=O,u.TrayIconDetails=N,u.WebContainerBase=r,u.WindowEventArgs=m,u.WindowGroupEventArgs=b,u.clearRegistry=function(){k.splice(0,k.length),u.container=void 0},u.registerContainer=function(t,n){k.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e,o,i=!1,r=n;if("boolean"==typeof t?i=t:r=t,!i&&u.container)return u.container;try{for(var a=0;a<k.length;a++){o=k[a].id;var s=k[a].registration;e=s.condition(r)?s:e}u.container=e?e.create(r):void 0}catch(t){console.error("Error resolving container '"+o+"' : "+t.toString())}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="3.11.0",Object.defineProperty(u,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).desktopJS={})}(this,function(u){"use strict";var i=function(t,n){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function r(t,n){function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function v(r,s,a,u){return new(a||(a=Promise))(function(t,n){function e(t){try{o(u.next(t))}catch(t){n(t)}}function i(t){try{o(u.throw(t))}catch(t){n(t)}}function o(n){n.done?t(n.value):new a(function(t){t(n.value)}).then(e,i)}o((u=u.apply(r,s||[])).next())})}function g(e,i){var o,r,s,t,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function n(n){return function(t){return function(n){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(s=2&n[0]?r.return:n[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,n[1])).done)return s;switch(r=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,r=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===n[0]||2===n[0])){a=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){a.label=n[1];break}if(6===n[0]&&a.label<s[1]){a.label=s[1],s=n;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(n);break}s[2]&&a.ops.pop(),a.trys.pop();continue}n=i.call(e,a)}catch(t){n=[6,t],r=0}finally{o=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,t])}}}var s=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},o=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},r.prototype.registerAndWrapListener=function(t,n){var e=this.wrapListener(t,n);return this.wrappedListeners.set(n,e),e},r.prototype.wrapListener=function(i,o){var r=this;return function(t){var n=new s(r,i,t);r.preProcessArgs(n);var e=o(n);return r.postProcessArgs(n),e}},r.prototype.preProcessArgs=function(t){},r.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},r.prototype.removeListener=function(t,n){var e=this.listeners(t);if(e){var i=e.indexOf(n);0<=i&&e.splice(i,1)}return this},r.prototype.listeners=function(t){return this.eventListeners[t]||[]},r.prototype.emit=function(t,n){for(var e=0,i=this.listeners(t);e<i.length;e++){(0,i[e])(n)}},Object.defineProperty(r,"ipc",{set:function(t){t&&t.subscribe(r.staticEventName,function(t,n){r.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),r.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},r.removeListener=function(t,n){var e=r.listeners(t);if(e){var i=e.indexOf(n);0<=i&&e.splice(i,1)}},r.listeners=function(t){return this.staticEventListeners[t]||[]},r.emit=function(t,n,e){if(e&&e.publish)e.publish(r.staticEventName,{eventName:t,eventArgs:n});else for(var i=0,o=r.listeners(t);i<o.length;i++){(0,o[i])(n)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),a=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)})},t}(),t=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n}(s),p=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return r(i,e),i.prototype.getInfo=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,void 0]})})},i.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(i,"ipc",{get:function(){return i._ipc},set:function(t){o.ipc=i._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"ipc",{get:function(){return i.ipc},set:function(t){i.ipc=t},enumerable:!1,configurable:!0}),i.prototype.addListener=function(t,n){return e.prototype.addListener.call(this,t,n)},i.prototype.removeListener=function(t,n){return e.prototype.removeListener.call(this,t,n)},i.prototype.emit=function(t,n){e.prototype.emit.call(this,t,n)},i.addListener=function(t,n){o.addListener(i.staticEventScopePrefix+t,n)},i.removeListener=function(t,n){o.removeListener(i.staticEventScopePrefix+t,n)},i.emit=function(t,n){o.emit(i.staticEventScopePrefix+t,n,i.ipc)},i.listeners=function(t){return o.listeners(i.staticEventScopePrefix+t)},i.staticEventScopePrefix="container-",i.windowOptionsPropertyKey="desktopJS-options",i}(o),n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.uuid=a.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}return r(i,n),i.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},i.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},i.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(i.layoutsPropertyKey))[t]},i.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(i.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(i.layoutsPropertyKey,JSON.stringify(e)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:n,layoutName:n.name}),p.emit("layout-saved",{name:"layout-saved",layout:n,layoutName:n.name})},i.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(i.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(i.layoutsPropertyKey,JSON.stringify(n)),this.emit("layout-deleted",{sender:this,name:"layout-deleted",layoutName:e.name}),p.emit("layout-deleted",{name:"layout-deleted",layoutName:e.name}))},i.prototype.loadLayout=function(d){return v(this,void 0,Promise,function(){var o,n,e,i,r,s,a,u,c=this;return g(this,function(t){switch(t.label){case 0:return[4,this.closeAllWindows(!0)];case 1:if(t.sent(),!(null==(o="string"==typeof d?this.getLayoutFromStorage(d):d)?void 0:o.windows))return[3,3];for(n=[],e=0,i=o.windows;e<i.length;e++)r=i[e],(s=Object.assign(r.options||{},r.bounds)).name=r.name,r.main?(this.getMainWindow().setBounds(r.bounds),n.push(Promise.resolve(this.getMainWindow()))):n.push(this.createWindow(r.url,s));return[4,Promise.all(n)];case 2:return a=t.sent(),u=new Map,a.forEach(function(e){var t=o.windows.find(function(t){return t.name===e.name});t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)});var i=!1;if(u.forEach(function(t,n){!i&&0<=t.indexOf(e.id)&&(i=!0)}),!i){var n=t?t.group:void 0;n&&0<n.length&&u.set(e,n.filter(function(t){return t!==e.id}))}}),u.forEach(function(t,e){t.forEach(function(n){c.getWindowByName(o.windows.find(function(t){return t.id===n}).name).then(function(t){t.joinGroup(e)})})}),this.emit("layout-loaded",{sender:this,name:"layout-loaded",layout:o,layoutName:o.name}),p.emit("layout-loaded",{name:"layout-loaded",layout:o,layoutName:o.name}),[2,o];case 3:throw new Error("Layout does not exist or is invalid")}})})},i.prototype.saveLayout=function(e){return v(this,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return[4,this.buildLayout()];case 1:return n=t.sent(),this.saveLayoutToStorage(e,n),[2,n]}})})},i.prototype.deleteLayout=function(n){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,this.deleteLayoutFromStorage(n)]})})},i.prototype.getLayouts=function(){return v(this,void 0,Promise,function(){var n,e;return g(this,function(t){return(n=this.storage.getItem(i.layoutsPropertyKey))?(e=JSON.parse(n),[2,Object.getOwnPropertyNames(e).map(function(t){return e[t]})]):[2]})})},i.prototype.log=function(e,i){return v(this,void 0,void 0,function(){var n;return g(this,function(t){switch(e){case"debug":case"warn":case"error":n=console[e];break;default:n=console.log}return n&&n(i),[2]})})},i.layoutsPropertyKey="desktopJS-layouts",i}(p),c=function(n){function t(t){var e=n.call(this)||this;e.globalWindow=t||"undefined"!=typeof window&&window||null,e.linkHelper={href:"unknown"};try{e.linkHelper=e.globalWindow.top.document.createElement("a")}catch(t){}if(e.globalWindow){var i=e.globalWindow.open;e.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.onOpen.apply(e,function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var i=Array(t),o=0;for(n=0;n<e;n++)for(var r=arguments[n],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}([i],t))}}return e}return r(t,n),t.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},t.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t},t}(n),h=function(t,n,e){this.topic=t,this.listener=n,this.options=e},e=function(){},d=function(){},f=function(){},l=function(){function e(t,n){this.title=t,this.options=n}return e.requestPermission=function(n){return v(this,void 0,Promise,function(){return g(this,function(t){return n&&n(e.permission),[2,e.permission]})})},e.permission="granted",e}(),w=function(){};u.ObjectTransform=void 0,(u.ObjectTransform||(u.ObjectTransform={})).transformProperties=function(t,n){var e={};if(t)for(var i in t)try{i in n?e[n[i].target]=n[i].convert?n[i].convert(t[i],t,e):t[i]:e[i]=t[i]}catch(t){console.error("Error transforming property '"+i+"'")}return e};var y,m=function(){function t(t,n,e,i){this.x=t,this.y=n,this.width=e,this.height=i}return Object.defineProperty(t.prototype,"right",{get:function(){return t.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return t.getBottom(this)},enumerable:!1,configurable:!0}),t.getRight=function(t){return t.x+t.width},t.getBottom=function(t){return t.y+t.height},t}(),b=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n}(s),W=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n}(b),P=function(i){function e(t){var n=i.call(this)||this;return n.innerWindow=t,n}return r(e,i),Object.defineProperty(e.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.getGroup=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,[]]})})},e.prototype.joinGroup=function(t){return v(this,void 0,Promise,function(){return g(this,function(t){throw new Error("Not supported")})})},e.prototype.leaveGroup=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2]})})},e.prototype.bringToFront=function(){return this.focus()},e.prototype.getState=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2]})})},e.prototype.setState=function(t){return v(this,void 0,Promise,function(){return g(this,function(t){return[2]})})},Object.defineProperty(e.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),e.prototype.addListener=function(t,n){var e=this.registerAndWrapListener(t,n);return this.attachListener(t,e),i.prototype.addListener.call(this,t,e)},e.prototype.removeListener=function(t,n){var e=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,e),i.prototype.removeListener.call(this,t,e)},e.addListener=function(t,n){o.addListener(e.staticEventScopePrefix+t,n)},e.removeListener=function(t,n){o.removeListener(e.staticEventScopePrefix+t,n)},e.emit=function(t,n){o.emit(e.staticEventScopePrefix+t,n,p.ipc)},e.listeners=function(t){return o.listeners(e.staticEventScopePrefix+t)},e.staticEventScopePrefix="containerwindow-",e}(o),x=function(){},S=function(t){this.windows=[],this.name=t};function L(){return"undefined"!=typeof window&&window.fin}u.WindowStateTracking=void 0,(y=u.WindowStateTracking||(u.WindowStateTracking={}))[y.None=0]="None",y[y.Main=1]="Main",y[y.Group=2]="Group";var O=function(){function t(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}return t.prototype.attach=function(t){var i=this;t?(t.addListener(L()?"minimized":"minimize",function(n){return v(i,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.windowStateTracking&u.WindowStateTracking.Main&&this.container.getMainWindow().id===n.sender.id?[4,this.container.getAllWindows()]:[3,2];case 1:t.sent().forEach(function(t){return t.minimize()}),t.label=2;case 2:return this.windowStateTracking&u.WindowStateTracking.Group?[4,n.sender.getGroup()]:[3,4];case 3:t.sent().forEach(function(t){return t.minimize()}),t.label=4;case 4:return[2]}})})}),t.addListener(L()?"restored":"restore",function(n){return v(i,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.windowStateTracking&u.WindowStateTracking.Main&&this.container.getMainWindow().id===n.sender.id?[4,this.container.getAllWindows()]:[3,2];case 1:t.sent().forEach(function(t){return t.restore()}),t.label=2;case 2:return this.windowStateTracking&u.WindowStateTracking.Group?[4,n.sender.getGroup()]:[3,4];case 3:t.sent().forEach(function(t){return t.restore()}),t.label=4;case 4:return[2]}})})})):(P.addListener("window-created",function(e){return v(i,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return this.container&&this.container.getWindowById?[4,this.container.getWindowById(e.windowId)]:[3,2];case 1:n=t.sent(),this.attach(n),t.label=2;case 2:return[2]}})})}),this.container&&this.container.getAllWindows().then(function(t){t.forEach(function(t){return i.attach(t)})}))},t}(),E=function(i){function t(t,n){var e=i.call(this,t,n)||this;return e.autoGrouping=!0,e.snapThreshold=15,e.snapOffset=15,e.targetGroup=new Map,n&&("snapThreshold"in n&&(e.snapThreshold=n.snapThreshold),"snapOffset"in n&&(e.snapOffset=n.snapOffset),"autoGrouping"in n&&(e.autoGrouping=n.autoGrouping)),e}return r(t,i),t.prototype.onAttached=function(t){var n=this;t.innerWindow&&t.innerWindow.disableFrame&&t.innerWindow.disableFrame(),L()?(t.addListener("disabled-frame-bounds-changed",function(){return n.onMoved(t)}),t.addListener("frame-enabled",function(){return t.innerWindow.disableFrame()})):t.innerWindow&&t.innerWindow.hookWindowMessage&&t.innerWindow.hookWindowMessage(562,function(){return n.onMoved(t)})},t.prototype.attach=function(n){var e=this;i.prototype.attach.call(this,n),n&&n.getOptions().then(function(t){t&&void 0!==t.snap&&!1===t.snap||(e.onAttached(n),n.addListener(L()?"disabled-frame-bounds-changing":"move",function(t){return e.onMoving(t)}))})},t.prototype.onMoving=function(y){return v(this,void 0,void 0,function(){var n,e,i,o,r,s,a,u,c,d,p,h,f,l,w=this;return g(this,function(t){switch(t.label){case 0:return n=y.sender.id,this.snappingWindow===n?[2]:[4,(e=y.sender).getOptions()];case 1:return(i=t.sent())&&void 0!==i.snap&&!1===i.snap?[2]:[4,e.getGroup()];case 2:return o=t.sent(),L()?(s=new m(y.innerEvent.left,y.innerEvent.top,y.innerEvent.width,y.innerEvent.height),[3,5]):[3,3];case 3:return[4,e.getBounds()];case 4:s=t.sent(),t.label=5;case 5:return r=s,0<o.length?(L()&&this.moveWindow(e,r),[2]):[4,this.container.getAllWindows()];case 6:return a=t.sent(),u=a.filter(function(t){return n!==t.id}).map(function(e){return v(w,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return n={window:e},[4,e.getBounds()];case 1:return n.bounds=t.sent(),[4,e.getOptions()];case 2:return[2,(n.options=t.sent(),n)]}})})}),[4,Promise.all(u)];case 7:for(c=t.sent(),d=!1,h=0,f=c.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});h<f.length;h++)l=f[h],(p=this.getSnapBounds(p||r,l.bounds))?(d=!0,this.showGroupingHint(l.window),this.moveWindow(y.sender,p)):this.hideGroupingHint(l.window);return!d&&L()&&this.moveWindow(y.sender,r),[2]}})})},t.prototype.moveWindow=function(n,e){return v(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:this.snappingWindow=n.id,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.setBounds(e)];case 2:case 3:return t.sent(),[3,4];case 4:return this.snappingWindow=void 0,[2]}})})},t.prototype.onMoved=function(e){var n=this;if(this.autoGrouping){var t=Array.from(this.targetGroup,function(t){t[0];var e=t[1];return v(n,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return n={window:e},[4,e.getGroup()];case 1:return[2,(n.isGrouped=0<t.sent().length,n)]}})})});Promise.all(t).then(function(t){0<t.length&&e.joinGroup(t[0].window);for(var n=1;n<t.length;n++)t[n].isGrouped||t[n].window.joinGroup(e)})}this.targetGroup.forEach(function(t){return n.hideGroupingHint(t)}),this.targetGroup.clear()},t.prototype.showGroupingHint=function(t){var n,e;null===(e=null===(n=t.innerWindow)||void 0===n?void 0:n.updateOptions)||void 0===e||e.call(n,{opacity:.75}),this.targetGroup.set(t.id,t)},t.prototype.hideGroupingHint=function(t){var n,e;null===(e=null===(n=t.innerWindow)||void 0===n?void 0:n.updateOptions)||void 0===e||e.call(n,{opacity:1}),this.targetGroup.delete(t.id)},t.prototype.isHorizontallyAligned=function(t,n){return t.y>=n.y&&t.y<=n.bottom||t.bottom>=n.y&&t.bottom<=n.bottom||t.y<=n.y&&t.bottom>=n.bottom},t.prototype.isVerticallyAligned=function(t,n){return t.x>=n.x&&t.x<=n.right||t.right>=n.x&&t.right<=n.right||t.x<=n.x&&t.right>=n.right},t.prototype.getSnapBounds=function(t,n){var e,i,o,r,s,a,u,c;if(this.isHorizontallyAligned(t,n)&&(e=Math.abs(t.x-(n.right-this.snapOffset))<this.snapThreshold,i=Math.abs(t.x-n.x)<this.snapThreshold,o=Math.abs(t.right-this.snapOffset-n.x)<this.snapThreshold,r=Math.abs(t.right-n.right)<this.snapThreshold),this.isVerticallyAligned(t,n)&&(s=Math.abs(t.y-(n.bottom-this.snapOffset))<this.snapThreshold,a=Math.abs(t.y-n.y)<this.snapThreshold,u=Math.abs(t.bottom-this.snapOffset-n.y)<this.snapThreshold,c=Math.abs(t.bottom-n.bottom)<this.snapThreshold),e||o||s||u){var d=t.x,p=t.y;return e?d=n.x+n.width-this.snapOffset:i&&(d=n.x),o?d=n.x-t.width+this.snapOffset:r&&(d=n.x+n.width-t.width),s?p=n.y+n.height-Math.floor(this.snapOffset/2):a&&(p=n.y),u?p=n.y-t.height+Math.floor(this.snapOffset/2):c&&(p=n.y+n.height-t.height),new m(d,p,t.width,t.height)}},t}(O),M=function(){},T=function(){};u.Default=void 0,function(t){var e={close:"unload"},n=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow[d.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow[d.windowNamePropertyKey]},enumerable:!1,configurable:!0}),n.prototype.load=function(n,t){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.location.replace(n),[2]})})},n.prototype.focus=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.focus(),[2]})})},n.prototype.show=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2]})})},n.prototype.hide=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2]})})},n.prototype.close=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.close(),[2]})})},n.prototype.minimize=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.minimize(),[2]})})},n.prototype.maximize=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.maximize(),[2]})})},n.prototype.restore=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.restore(),[2]})})},n.prototype.isShowing=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,!0]})})},n.prototype.getSnapshot=function(){return v(this,void 0,Promise,function(){return g(this,function(t){throw new Error("getSnapshot requires an implementation.")})})},n.prototype.flash=function(t,n){return v(this,void 0,void 0,function(){return g(this,function(t){throw new Error("Not supported")})})},n.prototype.getParent=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,null]})})},n.prototype.setParent=function(t){return v(this,void 0,void 0,function(){return g(this,function(t){return[2]})})},n.prototype.getBounds=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,new m(this.innerWindow.screenX,this.innerWindow.screenY,this.innerWindow.outerWidth,this.innerWindow.outerHeight)]})})},n.prototype.setBounds=function(n){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.moveTo(n.x,n.y),this.innerWindow.resizeTo(n.width,n.height),[2]})})},n.prototype.getOptions=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,this.innerWindow[p.windowOptionsPropertyKey]]})})},n.prototype.getState=function(){var n,e;return v(this,void 0,void 0,function(){return g(this,function(t){return[2,null===(e=null===(n=this.nativeWindow)||void 0===n?void 0:n.getState)||void 0===e?void 0:e.call(n)]})})},n.prototype.setState=function(e){var i,o;return v(this,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return n=null===(o=null===(i=this.nativeWindow)||void 0===i?void 0:i.setState)||void 0===o?void 0:o.call(i,e),this.emit("state-changed",{name:"state-changed",sender:this,state:e}),P.emit("state-changed",{name:"state-changed",windowId:this.id,state:e}),[4,n];case 1:return t.sent(),[2]}})})},n.prototype.attachListener=function(t,n){this.innerWindow.addEventListener(e[t]||t,n)},n.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(e[t]||t,n)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),n}(P);t.DefaultContainerWindow=n;var i=function(){function c(t){this.container=t}return c.prototype.subscribe=function(s,a,t){var e,i;return v(this,void 0,void 0,function(){var n,r=this;return g(this,function(t){return n=new h(s,function(t){if(t.origin===r.container.globalWindow.location.origin){var n=t.data,e=n.source,i=n.topic,o=n.message;e===c.messageSource&&s===i&&a({topic:s},o)}}),null===(i=null===(e=this.container.globalWindow)||void 0===e?void 0:e.addEventListener)||void 0===i||i.call(e,"message",n.listener),[2,n]})})},c.prototype.unsubscribe=function(n){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,this.container.globalWindow.removeEventListener("message",n.listener)]})})},c.prototype.publish=function(r,s,a){var u;return v(this,void 0,void 0,function(){var n,e,i,o;return g(this,function(t){if(n=this.container.globalWindow?this.container.globalWindow[d.windowsPropertyKey]||(null===(u=this.container.globalWindow.opener)||void 0===u?void 0:u[d.windowsPropertyKey]):[])for(e in n)i=n[e],null!=a&&a.name&&a.name!==i[d.windowNamePropertyKey]||(o=(null==a?void 0:a.targetOrigin)||this.container.globalWindow.location.origin,i.postMessage({source:c.messageSource,topic:r,message:s},o));return[2]})})},c.messageSource="desktopJS",c}();t.DefaultMessageBus=i;var d=function(e){function d(t){var n=e.call(this,t)||this;return n.windowOptionsMap=d.defaultWindowOptionsMap,n.hostType="Default",n.ipc=n.createMessageBus(),!n.globalWindow||d.windowsPropertyKey in n.globalWindow||(n.globalWindow[d.windowsPropertyKey]={root:n.globalWindow},n.globalWindow[d.windowNamePropertyKey]=n.globalWindow[d.windowUuidPropertyKey]=d.rootWindowUuid),n.screen=new o(n.globalWindow),n}return r(d,e),d.prototype.createMessageBus=function(){return new i(this)},d.prototype.setOptions=function(t){},d.prototype.getOptions=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,{}]})})},d.prototype.getInfo=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,this.globalWindow.navigator.appVersion]})})},d.prototype.getMainWindow=function(){if(!this.mainWindow){var t=this.globalWindow[d.windowsPropertyKey].root;this.mainWindow=t?this.wrapWindow(t):null}return this.mainWindow},d.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},d.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},d.prototype.wrapWindow=function(t){return new n(t)},d.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var i=t.apply(this.globalWindow,n),o=a.newGuid();try{var r=this.globalWindow[d.windowsPropertyKey];(r[o]=i)[d.windowUuidPropertyKey]=o,i.addEventListener("beforeunload",function(){i.addEventListener("unload",function(){delete r[o]})}),i[d.windowsPropertyKey]=r}catch(t){this.log("warn","Error tracking new window, '"+t.message+"'")}return p.emit("window-created",{name:"window-created",windowId:o}),P.emit("window-created",{name:"window-created",windowId:o}),i},d.prototype.createWindow=function(u,c){return v(this,void 0,Promise,function(){var n,e,i,o,r,s,a;return g(this,function(t){if(e="_blank",i=this.getWindowOptions(c)){for(o in i)n=(n||"")+o+"="+i[o]+",";i&&"target"in i&&(e=i.target)}r=this.globalWindow.open(u,e,n),s=!0;try{r[p.windowOptionsPropertyKey]=c,r[d.windowNamePropertyKey]=i.name}catch(t){s=!1,this.log("warn","Error proprogating properties to new window, '"+t.message+"'")}return a=this.wrapWindow(r),this.emit("window-created",{sender:this,name:"window-created",window:a,windowId:s?a.id:void 0,windowName:i.name}),[2,a]})})},d.prototype.showNotification=function(n,e){var i=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(t){"denied"===t?i.log("warn","Notifications not permitted"):"granted"===t&&new i.globalWindow.Notification(n,e)}):this.log("warn","Notifications not supported")},d.prototype.closeAllWindows=function(o){return void 0===o&&(o=!1),v(this,void 0,void 0,function(){var n,e,i;return g(this,function(t){for(e in n=this.globalWindow[d.windowsPropertyKey])i=n[e],o&&this.globalWindow===i||i.close();return[2]})})},d.prototype.getAllWindows=function(){return v(this,void 0,void 0,function(){var n,e,i;return g(this,function(t){for(i in n=[],e=this.globalWindow[d.windowsPropertyKey])n.push(this.wrapWindow(e[i]));return[2,n]})})},d.prototype.getWindowById=function(e){return v(this,void 0,Promise,function(){var n;return g(this,function(t){return[2,(n=this.globalWindow[d.windowsPropertyKey][e])?this.wrapWindow(n):null]})})},d.prototype.getWindowByName=function(i){return v(this,void 0,Promise,function(){var n,e;return g(this,function(t){for(e in n=this.globalWindow[d.windowsPropertyKey])if(n[e][d.windowNamePropertyKey]===i)return[2,this.wrapWindow(n[e])];return[2,null]})})},d.prototype.buildLayout=function(){return v(this,void 0,void 0,function(){var a,n,e=this;return g(this,function(t){switch(t.label){case 0:return a=new S,n=[],[4,this.getAllWindows()];case 1:return t.sent().forEach(function(o){var r=o.nativeWindow;try{var s=r[p.windowOptionsPropertyKey];if(s&&"persist"in s&&!s.persist)return;n.push(v(e,void 0,void 0,function(){var n,e,i;return g(this,function(t){switch(t.label){case 0:return this.globalWindow===r?[3,2]:(e=(n=a.windows).push,i={name:o.name,url:r&&r.location?r.location.toString():void 0,id:o.id,bounds:{x:r.screenX,y:r.screenY,width:r.innerWidth,height:r.innerHeight},options:s},[4,o.getState()]);case 1:e.apply(n,[(i.state=t.sent(),i)]),t.label=2;case 2:return[2]}})}))}catch(t){e.log("warn","Error while accessing window so skipping, '"+t.message+"'")}}),[4,Promise.all(n)];case 2:return t.sent(),[2,a]}})})},d.windowsPropertyKey="desktopJS-windows",d.windowUuidPropertyKey="desktopJS-uuid",d.windowNamePropertyKey="desktopJS-name",d.rootWindowUuid="root",d.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},d}(c);t.DefaultContainer=d;var o=function(){function t(t){this.window=t}return t.prototype.getPrimaryDisplay=function(){return v(this,void 0,void 0,function(){var n;return g(this,function(t){return(n=new T).scaleFactor=this.window.devicePixelRatio,n.id="Current",n.bounds=new m(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.width,this.window.screen.height),n.workArea=new m(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.availWidth,this.window.screen.availHeight),[2,n]})})},t.prototype.getAllDisplays=function(){return v(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this.getPrimaryDisplay()];case 1:return[2,[t.sent()]]}})})},t.prototype.getMousePosition=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,{x:this.window.event.screenX,y:this.window.event.screenY}]})})},t}()}(u.Default||(u.Default={}));var k=function(){},N=[];u.container=void 0;var G=function(){},A=function(){};u.Container=p,u.ContainerBase=n,u.ContainerNotification=l,u.ContainerRegistration=k,u.ContainerWindow=P,u.Display=T,u.EventArgs=s,u.EventEmitter=o,u.GlobalShortcutManager=A,u.GroupWindowManager=O,u.Guid=a,u.LayoutEventArgs=t,u.MenuItem=d,u.MessageBusOptions=e,u.MessageBusSubscription=h,u.NotificationOptions=f,u.PersistedWindow=x,u.PersistedWindowLayout=S,u.Point=M,u.PropertyMap=w,u.Rectangle=m,u.SnapAssistWindowManager=E,u.TrayIconDetails=G,u.WebContainerBase=c,u.WindowEventArgs=b,u.WindowGroupEventArgs=W,u.clearRegistry=function(){N.splice(0,N.length),u.container=void 0},u.registerContainer=function(t,n){N.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e,i,o=!1,r=n;if("boolean"==typeof t?o=t:r=t,!o&&u.container)return u.container;try{for(var s=0;s<N.length;s++){i=N[s].id;var a=N[s].registration;e=a.condition(r)?a:e}u.container=e?e.create(r):void 0}catch(t){console.error("Error resolving container '"+i+"' : "+t.toString())}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="3.12.0",Object.defineProperty(u,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=desktop.min.js.map |
@@ -7,3 +7,3 @@ // Generated by dts-bundle v0.7.3 | ||
*/ | ||
export const version: string; | ||
export const version = "PACKAGE_VERSION"; | ||
@@ -57,2 +57,7 @@ /** | ||
abstract getWindowByName(name: string): Promise<ContainerWindow | null>; | ||
/** | ||
* Set information on the container based on the options | ||
*/ | ||
abstract setOptions(options: any): any; | ||
abstract getOptions(): Promise<any>; | ||
static get ipc(): MessageBus; | ||
@@ -99,3 +104,3 @@ static set ipc(value: MessageBus); | ||
protected deleteLayoutFromStorage(name: string): void; | ||
protected abstract closeAllWindows(excludeSelf?: Boolean): Promise<void>; | ||
protected abstract closeAllWindows(excludeSelf?: boolean): Promise<void>; | ||
loadLayout(layout: string | PersistedWindowLayout): Promise<PersistedWindowLayout>; | ||
@@ -285,2 +290,4 @@ abstract buildLayout(): Promise<PersistedWindowLayout>; | ||
export abstract class ContainerNotification { | ||
protected title: string; | ||
protected options?: NotificationOptions; | ||
/** | ||
@@ -644,4 +651,4 @@ * A string representing the current permission to display notifications. | ||
attach(win?: ContainerWindow): void; | ||
protected onMoving(e: any): void; | ||
protected moveWindow(win: ContainerWindow, bounds: Rectangle): void; | ||
protected onMoving(e: any): Promise<void>; | ||
protected moveWindow(win: ContainerWindow, bounds: Rectangle): Promise<void>; | ||
protected onMoved(win: ContainerWindow): void; | ||
@@ -681,3 +688,2 @@ protected showGroupingHint(win: ContainerWindow): void; | ||
class DefaultContainerWindow extends ContainerWindow { | ||
constructor(wrap: any); | ||
get id(): string; | ||
@@ -727,2 +733,4 @@ get name(): string; | ||
protected createMessageBus(): MessageBus; | ||
setOptions(options: any): void; | ||
getOptions(): Promise<any>; | ||
getInfo(): Promise<string | undefined>; | ||
@@ -736,3 +744,3 @@ getMainWindow(): ContainerWindow; | ||
showNotification(title: string, options?: NotificationOptions): void; | ||
protected closeAllWindows(excludeSelf?: Boolean): Promise<void>; | ||
protected closeAllWindows(excludeSelf?: boolean): Promise<void>; | ||
getAllWindows(): Promise<ContainerWindow[]>; | ||
@@ -739,0 +747,0 @@ getWindowById(id: string): Promise<ContainerWindow | null>; |
@@ -1,2 +0,2 @@ | ||
var desktopJS=function(u){"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)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function a(t,n){function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function w(e,o){var i,r,a,t,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function n(n){return function(t){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(a=2&n[0]?r.return:n[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,n[1])).done)return a;switch(r=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return s.label++,{value:n[1],done:!1};case 5:s.label++,r=n[1],n=[0];continue;case 7:n=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){s=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){s.label=n[1];break}if(6===n[0]&&s.label<a[1]){s.label=a[1],a=n;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(n);break}a[2]&&s.ops.pop(),s.trys.pop();continue}n=o.call(e,s)}catch(t){n=[6,t],r=0}finally{i=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,t])}}}var s=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},i=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},r.prototype.registerAndWrapListener=function(t,n){var e=this.wrapListener(t,n);return this.wrappedListeners.set(n,e),e},r.prototype.wrapListener=function(o,i){var r=this;return function(t){var n=new s(r,o,t);r.preProcessArgs(n);var e=i(n);return r.postProcessArgs(n),e}},r.prototype.preProcessArgs=function(t){},r.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},r.prototype.removeListener=function(t,n){var e=this.listeners(t);if(e){var o=e.indexOf(n);0<=o&&e.splice(o,1)}return this},r.prototype.listeners=function(t){return this.eventListeners[t]||[]},r.prototype.emit=function(t,n){for(var e=0,o=this.listeners(t);e<o.length;e++){(0,o[e])(n)}},Object.defineProperty(r,"ipc",{set:function(t){t&&t.subscribe(r.staticEventName,function(t,n){r.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),r.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},r.removeListener=function(t,n){var e=r.listeners(t);if(e){var o=e.indexOf(n);0<=o&&e.splice(o,1)}},r.listeners=function(t){return this.staticEventListeners[t]||[]},r.emit=function(t,n,e){if(e&&e.publish)e.publish(r.staticEventName,{eventName:t,eventArgs:n});else for(var o=0,i=r.listeners(t);o<i.length;o++){(0,i[o])(n)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),p=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)})},t}(),t=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return a(n,t),n}(s),h=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return a(o,e),o.prototype.getInfo=function(){return Promise.resolve(void 0)},o.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(o,"ipc",{get:function(){return o._ipc},set:function(t){i.ipc=o._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"ipc",{get:function(){return o.ipc},set:function(t){o.ipc=t},enumerable:!1,configurable:!0}),o.prototype.addListener=function(t,n){return e.prototype.addListener.call(this,t,n)},o.prototype.removeListener=function(t,n){return e.prototype.removeListener.call(this,t,n)},o.prototype.emit=function(t,n){e.prototype.emit.call(this,t,n)},o.addListener=function(t,n){i.addListener(o.staticEventScopePrefix+t,n)},o.removeListener=function(t,n){i.removeListener(o.staticEventScopePrefix+t,n)},o.emit=function(t,n){i.emit(o.staticEventScopePrefix+t,n,o.ipc)},o.listeners=function(t){return i.listeners(o.staticEventScopePrefix+t)},o.staticEventScopePrefix="container-",o.windowOptionsPropertyKey="desktopJS-options",o}(i),n=function(n){function r(){var t=null!==n&&n.apply(this,arguments)||this;return t.uuid=p.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}return a(r,n),r.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},r.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},r.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(r.layoutsPropertyKey))[t]},r.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(e)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:n,layoutName:n.name}),h.emit("layout-saved",{name:"layout-saved",layout:n,layoutName:n.name})},r.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(n)),this.emit("layout-deleted",{sender:this,name:"layout-deleted",layoutName:e.name}),h.emit("layout-deleted",{name:"layout-deleted",layoutName:e.name}))},r.prototype.loadLayout=function(u){var c=this;return new Promise(function(a,s){c.closeAllWindows(!0).then(function(){var r="string"==typeof u?c.getLayoutFromStorage(u):u;if(r&&r.windows){for(var t=[],n=0,e=r.windows;n<e.length;n++){var o=e[n],i=Object.assign(o.options||{},o.bounds);i.name=o.name,o.main?(c.getMainWindow().setBounds(o.bounds),t.push(Promise.resolve(c.getMainWindow()))):t.push(c.createWindow(o.url,i))}Promise.all(t).then(function(t){var i=new Map;t.forEach(function(e){var t=r.windows.find(function(t){return t.name===e.name});t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)});var o=!1;if(i.forEach(function(t,n){!o&&0<=t.indexOf(e.id)&&(o=!0)}),!o){var n=t?t.group:void 0;n&&0<n.length&&i.set(e,n.filter(function(t){return t!==e.id}))}}),i.forEach(function(t,e){t.forEach(function(n){c.getWindowByName(r.windows.find(function(t){return t.id===n}).name).then(function(t){t.joinGroup(e)})})})}),c.emit("layout-loaded",{sender:c,name:"layout-loaded",layout:r,layoutName:r.name}),h.emit("layout-loaded",{name:"layout-loaded",layout:r,layoutName:r.name}),a(r)}else s("Layout does not exist or is invalid")})})},r.prototype.saveLayout=function(e){var o=this;return new Promise(function(n,t){o.buildLayout().then(function(t){o.saveLayoutToStorage(e,t),n(t)}).catch(t)})},r.prototype.deleteLayout=function(e){var o=this;return new Promise(function(t,n){t(o.deleteLayoutFromStorage(e))})},r.prototype.getLayouts=function(){var i=this;return new Promise(function(t,n){var e=i.storage.getItem(r.layoutsPropertyKey);if(e){var o=JSON.parse(e);t(Object.getOwnPropertyNames(o).map(function(t){return o[t]}))}t(void 0)})},r.prototype.log=function(e,o){return new Promise(function(t){var n;switch(e){case"debug":n=console.debug;break;case"warn":n=console.warn;break;case"error":n=console.error;break;default:n=console.log}n&&n(o),t()})},r.layoutsPropertyKey="desktopJS-layouts",r}(h),r=function(n){function t(t){var e=n.call(this)||this;e.globalWindow=t||"undefined"!=typeof window&&window||null,e.linkHelper={href:"unknown"};try{e.linkHelper=e.globalWindow.top.document.createElement("a")}catch(t){}if(e.globalWindow){var o=e.globalWindow.open;e.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.onOpen.apply(e,function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var o=Array(t),i=0;for(n=0;n<e;n++)for(var r=arguments[n],a=0,s=r.length;a<s;a++,i++)o[i]=r[a];return o}([o],t))}}return e}return a(t,n),t.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},t.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t},t}(n),c=function(t,n,e){this.topic=t,this.listener=n,this.options=e},e=function(){},d=function(){},f=function(){},l=function(){function n(t,n){}return n.requestPermission=function(t){return t&&t(n.permission),Promise.resolve(n.permission)},n.permission="granted",n}(),y=function(){};(u.ObjectTransform||(u.ObjectTransform={})).transformProperties=function(t,n){var e={};if(t)for(var o in t)try{o in n?e[n[o].target]=n[o].convert?n[o].convert(t[o],t,e):t[o]:e[o]=t[o]}catch(t){console.error("Error transforming property '"+o+"'")}return e};var g,v=function(){function t(t,n,e,o){this.x=t,this.y=n,this.width=e,this.height=o}return Object.defineProperty(t.prototype,"right",{get:function(){return t.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return t.getBottom(this)},enumerable:!1,configurable:!0}),t.getRight=function(t){return t.x+t.width},t.getBottom=function(t){return t.y+t.height},t}(),m=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return a(n,t),n}(s),b=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return a(n,t),n}(m),W=function(o){function e(t){var n=o.call(this)||this;return n.innerWindow=t,n}return a(e,o),Object.defineProperty(e.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.getGroup=function(){return Promise.resolve([])},e.prototype.joinGroup=function(t){return Promise.reject("Not supported")},e.prototype.leaveGroup=function(){return Promise.resolve()},e.prototype.bringToFront=function(){return this.focus()},e.prototype.getState=function(){return Promise.resolve(void 0)},e.prototype.setState=function(t){return Promise.resolve()},Object.defineProperty(e.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),e.prototype.addListener=function(t,n){var e=this.registerAndWrapListener(t,n);return this.attachListener(t,e),o.prototype.addListener.call(this,t,e)},e.prototype.removeListener=function(t,n){var e=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,e),o.prototype.removeListener.call(this,t,e)},e.addListener=function(t,n){i.addListener(e.staticEventScopePrefix+t,n)},e.removeListener=function(t,n){i.removeListener(e.staticEventScopePrefix+t,n)},e.emit=function(t,n){i.emit(e.staticEventScopePrefix+t,n,h.ipc)},e.listeners=function(t){return i.listeners(e.staticEventScopePrefix+t)},e.staticEventScopePrefix="containerwindow-",e}(i),P=function(){},x=function(t){this.windows=[],this.name=t};function S(){return"undefined"!=typeof window&&window.fin}(g=u.WindowStateTracking||(u.WindowStateTracking={}))[g.None=0]="None",g[g.Main=1]="Main",g[g.Group=2]="Group";var L=function(){function t(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}return t.prototype.attach=function(t){var n=this;t?(t.addListener(S()?"minimized":"minimize",function(t){n.windowStateTracking&u.WindowStateTracking.Main&&n.container.getMainWindow().id===t.sender.id&&n.container.getAllWindows().then(function(t){t.forEach(function(t){return t.minimize()})}),n.windowStateTracking&u.WindowStateTracking.Group&&t.sender.getGroup().then(function(t){t.forEach(function(t){return t.minimize()})})}),t.addListener(S()?"restored":"restore",function(t){n.windowStateTracking&u.WindowStateTracking.Main&&n.container.getMainWindow().id===t.sender.id&&n.container.getAllWindows().then(function(t){t.forEach(function(t){return t.restore()})}),n.windowStateTracking&u.WindowStateTracking.Group&&t.sender.getGroup().then(function(t){t.forEach(function(t){return t.restore()})})})):(W.addListener("window-created",function(t){n.container&&n.container.getWindowById&&n.container.getWindowById(t.windowId).then(function(t){n.attach(t)})}),this.container&&this.container.getAllWindows().then(function(t){t.forEach(function(t){return n.attach(t)})}))},t}(),O=function(o){function t(t,n){var e=o.call(this,t,n)||this;return e.autoGrouping=!0,e.snapThreshold=15,e.snapOffset=15,e.targetGroup=new Map,n&&("snapThreshold"in n&&(e.snapThreshold=n.snapThreshold),"snapOffset"in n&&(e.snapOffset=n.snapOffset),"autoGrouping"in n&&(e.autoGrouping=n.autoGrouping)),e}return a(t,o),t.prototype.onAttached=function(t){var n=this;t.innerWindow&&t.innerWindow.disableFrame&&t.innerWindow.disableFrame(),S()?(t.addListener("disabled-frame-bounds-changed",function(){return n.onMoved(t)}),t.addListener("frame-enabled",function(){return t.innerWindow.disableFrame()})):t.innerWindow&&t.innerWindow.hookWindowMessage&&t.innerWindow.hookWindowMessage(562,function(){return n.onMoved(t)})},t.prototype.attach=function(n){var e=this;o.prototype.attach.call(this,n),n&&n.getOptions().then(function(t){t&&void 0!==t.snap&&!1===t.snap||(e.onAttached(n),n.addListener(S()?"disabled-frame-bounds-changing":"move",function(t){return e.onMoving(t)}))})},t.prototype.onMoving=function(s){var u=this,e=s.sender.id;this.snappingWindow!==e&&s.sender.getOptions().then(function(t){t&&void 0!==t.snap&&!1===t.snap||s.sender.getGroup().then(function(t){(S()?Promise.resolve(new v(s.innerEvent.left,s.innerEvent.top,s.innerEvent.width,s.innerEvent.height)):s.sender.getBounds()).then(function(a){if(0<t.length)S()&&u.moveWindow(s.sender,a);else{var n=[];u.container.getAllWindows().then(function(t){t.filter(function(t){return e!==t.id}).forEach(function(o){n.push(new Promise(function(e){o.getOptions().then(function(n){o.getBounds().then(function(t){return e({window:o,bounds:t,options:n})})})}))}),Promise.all(n).then(function(t){for(var n,e=!1,o=0,i=t.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});o<i.length;o++){var r=i[o];(n=u.getSnapBounds(n||a,r.bounds))?(e=!0,u.showGroupingHint(r.window),u.moveWindow(s.sender,n)):u.hideGroupingHint(r.window)}!e&&S()&&u.moveWindow(s.sender,a)})})}})})})},t.prototype.moveWindow=function(t,n){var e=this;this.snappingWindow=t.id,t.setBounds(n).then(function(){return e.snappingWindow=void 0},function(){return e.snappingWindow=void 0})},t.prototype.onMoved=function(e){var n=this;if(this.autoGrouping){var t=[];this.targetGroup.forEach(function(e){return t.push(new Promise(function(n){e.getGroup().then(function(t){return n({window:e,isGrouped:0<t.length})})}))}),Promise.all(t).then(function(t){0<t.length&&e.joinGroup(t[0].window);for(var n=1;n<t.length;n++)t[n].isGrouped||t[n].window.joinGroup(e)})}this.targetGroup.forEach(function(t){return n.hideGroupingHint(t)}),this.targetGroup.clear()},t.prototype.showGroupingHint=function(t){t.innerWindow&&t.innerWindow.updateOptions&&t.innerWindow.updateOptions({opacity:.75}),this.targetGroup.set(t.id,t)},t.prototype.hideGroupingHint=function(t){t.innerWindow&&t.innerWindow.updateOptions&&t.innerWindow.updateOptions({opacity:1}),this.targetGroup.delete(t.id)},t.prototype.isHorizontallyAligned=function(t,n){return t.y>=n.y&&t.y<=n.bottom||t.bottom>=n.y&&t.bottom<=n.bottom||t.y<=n.y&&t.bottom>=n.bottom},t.prototype.isVerticallyAligned=function(t,n){return t.x>=n.x&&t.x<=n.right||t.right>=n.x&&t.right<=n.right||t.x<=n.x&&t.right>=n.right},t.prototype.getSnapBounds=function(t,n){var e,o,i,r,a,s,u,c;if(this.isHorizontallyAligned(t,n)&&(e=Math.abs(t.x-(n.right-this.snapOffset))<this.snapThreshold,o=Math.abs(t.x-n.x)<this.snapThreshold,i=Math.abs(t.right-this.snapOffset-n.x)<this.snapThreshold,r=Math.abs(t.right-n.right)<this.snapThreshold),this.isVerticallyAligned(t,n)&&(a=Math.abs(t.y-(n.bottom-this.snapOffset))<this.snapThreshold,s=Math.abs(t.y-n.y)<this.snapThreshold,u=Math.abs(t.bottom-this.snapOffset-n.y)<this.snapThreshold,c=Math.abs(t.bottom-n.bottom)<this.snapThreshold),e||i||a||u){var p=t.x,d=t.y;return e?p=n.x+n.width-this.snapOffset:o&&(p=n.x),i?p=n.x-t.width+this.snapOffset:r&&(p=n.x+n.width-t.width),a?d=n.y+n.height-Math.floor(this.snapOffset/2):s&&(d=n.y),u?d=n.y-t.height+Math.floor(this.snapOffset/2):c&&(d=n.y+n.height-t.height),new v(p,d,t.width,t.height)}},t}(L),E=function(){},M=function(){};!function(t){var e={close:"unload"},n=function(n){function t(t){return n.call(this,t)||this}return a(t,n),Object.defineProperty(t.prototype,"id",{get:function(){return this.innerWindow[s.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this.innerWindow[s.windowNamePropertyKey]},enumerable:!1,configurable:!0}),t.prototype.load=function(n,t){var e=this;return new Promise(function(t){e.innerWindow.location.replace(n),t()})},t.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},t.prototype.show=function(){return Promise.resolve()},t.prototype.hide=function(){return Promise.resolve()},t.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},t.prototype.minimize=function(){var n=this;return new Promise(function(t){n.innerWindow.minimize(),t()})},t.prototype.maximize=function(){var n=this;return new Promise(function(t){n.innerWindow.maximize(),t()})},t.prototype.restore=function(){var n=this;return new Promise(function(t){n.innerWindow.restore(),t()})},t.prototype.isShowing=function(){return Promise.resolve(!0)},t.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},t.prototype.flash=function(t,n){return Promise.reject("Not supported")},t.prototype.getParent=function(){return Promise.resolve(null)},t.prototype.setParent=function(t){return Promise.resolve()},t.prototype.getBounds=function(){var n=this;return new Promise(function(t){t(new v(n.innerWindow.screenX,n.innerWindow.screenY,n.innerWindow.outerWidth,n.innerWindow.outerHeight))})},t.prototype.setBounds=function(n){var e=this;return new Promise(function(t){e.innerWindow.moveTo(n.x,n.y),e.innerWindow.resizeTo(n.width,n.height),t()})},t.prototype.getOptions=function(){var e=this;return new Promise(function(t,n){t(e.innerWindow[h.windowOptionsPropertyKey])})},t.prototype.getState=function(){var n=this;return new Promise(function(t){n.nativeWindow&&n.nativeWindow.getState?t(n.nativeWindow.getState()):t(void 0)})},t.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}),W.emit("state-changed",{name:"state-changed",windowId:e.id,state:n})})},t.prototype.attachListener=function(t,n){this.innerWindow.addEventListener(e[t]||t,n)},t.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(e[t]||t,n)},Object.defineProperty(t.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),t}(W);t.DefaultContainerWindow=n;var o=function(){function u(t){this.container=t}return u.prototype.subscribe=function(r,a,t){var s=this;return new Promise(function(t,n){var e=new c(r,function(t){if(t.origin===s.container.globalWindow.location.origin){var n=t.data,e=n.source,o=n.topic,i=n.message;e===u.messageSource&&r===o&&a({topic:r},i)}});s.container.globalWindow&&s.container.globalWindow.addEventListener&&s.container.globalWindow.addEventListener("message",e.listener),t(e)})},u.prototype.unsubscribe=function(t){return Promise.resolve(this.container.globalWindow.removeEventListener("message",t.listener))},u.prototype.publish=function(t,n,e){var o=this.container.globalWindow?this.container.globalWindow[s.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[s.windowsPropertyKey]:[];if(o)for(var i in o){var r=o[i];if(!e||!e.name||e.name===r[s.windowNamePropertyKey]){var a=(null==e?void 0:e.targetOrigin)||this.container.globalWindow.location.origin;r.postMessage({source:u.messageSource,topic:t,message:n},a)}}return Promise.resolve()},u.messageSource="desktopJS",u}();t.DefaultMessageBus=o;var s=function(e){function c(t){var n=e.call(this,t)||this;return n.windowOptionsMap=c.defaultWindowOptionsMap,n.hostType="Default",n.ipc=n.createMessageBus(),!n.globalWindow||c.windowsPropertyKey in n.globalWindow||(n.globalWindow[c.windowsPropertyKey]={root:n.globalWindow},n.globalWindow[c.windowNamePropertyKey]=n.globalWindow[c.windowUuidPropertyKey]=c.rootWindowUuid),n.screen=new i(n.globalWindow),n}return a(c,e),c.prototype.createMessageBus=function(){return new o(this)},c.prototype.getInfo=function(){return Promise.resolve(this.globalWindow.navigator.appVersion)},c.prototype.getMainWindow=function(){if(!this.mainWindow){var t=this.globalWindow[c.windowsPropertyKey].root;this.mainWindow=t?this.wrapWindow(t):null}return this.mainWindow},c.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},c.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},c.prototype.wrapWindow=function(t){return new n(t)},c.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var o=t.apply(this.globalWindow,n),i=p.newGuid();try{var r=this.globalWindow[c.windowsPropertyKey];(r[i]=o)[c.windowUuidPropertyKey]=i,o.addEventListener("beforeunload",function(){o.addEventListener("unload",function(){delete r[i]})}),o[c.windowsPropertyKey]=r}catch(t){console.warn("Error tracking new window, '"+t.message+"'")}return h.emit("window-created",{name:"window-created",windowId:i}),W.emit("window-created",{name:"window-created",windowId:i}),o},c.prototype.createWindow=function(t,n){var e,o="_blank",i=this.getWindowOptions(n);if(i){for(var r in i)e=(e||"")+r+"="+i[r]+",";i&&"target"in i&&(o=i.target)}var a=this.globalWindow.open(t,o,e),s=!0;try{a[h.windowOptionsPropertyKey]=n,a[c.windowNamePropertyKey]=i.name}catch(t){s=!1,console.warn("Error proprogating properties to new window, '"+t.message+"'")}var u=this.wrapWindow(a);return this.emit("window-created",{sender:this,name:"window-created",window:u,windowId:s?u.id:void 0,windowName:i.name}),Promise.resolve(u)},c.prototype.showNotification=function(n,e){var o=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(t){"denied"===t?console.warn("Notifications not permitted"):"granted"===t&&new o.globalWindow.Notification(n,e)}):console.warn("Notifications not supported")},c.prototype.closeAllWindows=function(r){var a=this;return new Promise(function(t,n){var e=a.globalWindow[c.windowsPropertyKey];for(var o in e){var i=e[o];r&&a.globalWindow===i||i.close()}t()})},c.prototype.getAllWindows=function(){var r=this;return new Promise(function(t,n){var e=[],o=r.globalWindow[c.windowsPropertyKey];for(var i in o)e.push(r.wrapWindow(o[i]));t(e)})},c.prototype.getWindowById=function(o){var i=this;return new Promise(function(t,n){var e=i.globalWindow[c.windowsPropertyKey][o];t(e?i.wrapWindow(e):null)})},c.prototype.getWindowByName=function(i){var r=this;return new Promise(function(t,n){var e=r.globalWindow[c.windowsPropertyKey];for(var o in e)if(e[o][c.windowNamePropertyKey]===i)return void t(r.wrapWindow(e[o]));t(null)})},c.prototype.buildLayout=function(){var f=this,l=new x;return new Promise(function(n,e){var o=[];f.getAllWindows().then(function(t){t.forEach(function(c){var p=c.nativeWindow;try{var d=p[h.windowOptionsPropertyKey];if(d&&"persist"in d&&!d.persist)return;o.push(new Promise(function(i){return r=f,u=function(){var n,e,o;return w(this,function(t){switch(t.label){case 0:return this.globalWindow===p?[3,2]:(e=(n=l.windows).push,o={name:c.name,url:p&&p.location?p.location.toString():void 0,id:c.id,bounds:{x:p.screenX,y:p.screenY,width:p.innerWidth,height:p.innerHeight},options:d},[4,c.getState()]);case 1:e.apply(n,[(o.state=t.sent(),o)]),t.label=2;case 2:return i(),[2]}})},new((s=a=void 0)||(s=Promise))(function(t,n){function e(t){try{i(u.next(t))}catch(t){n(t)}}function o(t){try{i(u.throw(t))}catch(t){n(t)}}function i(n){n.done?t(n.value):new s(function(t){t(n.value)}).then(e,o)}i((u=u.apply(r,a||[])).next())});var r,a,s,u}))}catch(t){console.warn("Error while accessing window so skipping, '"+t.message+"'")}}),Promise.all(o).then(function(){n(l)}).catch(e)})})},c.windowsPropertyKey="desktopJS-windows",c.windowUuidPropertyKey="desktopJS-uuid",c.windowNamePropertyKey="desktopJS-name",c.rootWindowUuid="root",c.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},c}(r);t.DefaultContainer=s;var i=function(){function t(t){this.window=t}return t.prototype.getPrimaryDisplay=function(){var e=this;return new Promise(function(t){var n=new M;n.scaleFactor=e.window.devicePixelRatio,n.id="Current",n.bounds=new v(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.width,e.window.screen.height),n.workArea=new v(e.window.screen.availLeft,e.window.screen.availTop,e.window.screen.availWidth,e.window.screen.availHeight),t(n)})},t.prototype.getAllDisplays=function(){var t=this;return new Promise(function(n){t.getPrimaryDisplay().then(function(t){return n([t])})})},t.prototype.getMousePosition=function(){var e=this;return new Promise(function(t,n){t({x:e.window.event.screenX,y:e.window.event.screenY})})},t}()}(u.Default||(u.Default={}));var T=function(){},k=[];var N=function(){},G=function(){};return u.Container=h,u.ContainerBase=n,u.ContainerNotification=l,u.ContainerRegistration=T,u.ContainerWindow=W,u.Display=M,u.EventArgs=s,u.EventEmitter=i,u.GlobalShortcutManager=G,u.GroupWindowManager=L,u.Guid=p,u.LayoutEventArgs=t,u.MenuItem=d,u.MessageBusOptions=e,u.MessageBusSubscription=c,u.NotificationOptions=f,u.PersistedWindow=P,u.PersistedWindowLayout=x,u.Point=E,u.PropertyMap=y,u.Rectangle=v,u.SnapAssistWindowManager=O,u.TrayIconDetails=N,u.WebContainerBase=r,u.WindowEventArgs=m,u.WindowGroupEventArgs=b,u.clearRegistry=function(){k.splice(0,k.length),u.container=void 0},u.registerContainer=function(t,n){k.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e,o,i=!1,r=n;if("boolean"==typeof t?i=t:r=t,!i&&u.container)return u.container;try{for(var a=0;a<k.length;a++){o=k[a].id;var s=k[a].registration;e=s.condition(r)?s:e}u.container=e?e.create(r):void 0}catch(t){console.error("Error resolving container '"+o+"' : "+t.toString())}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="3.11.0",u}({}); | ||
var desktopJS=function(u){"use strict";var i=function(t,n){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function r(t,n){function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function v(r,s,a,u){return new(a||(a=Promise))(function(t,n){function e(t){try{o(u.next(t))}catch(t){n(t)}}function i(t){try{o(u.throw(t))}catch(t){n(t)}}function o(n){n.done?t(n.value):new a(function(t){t(n.value)}).then(e,i)}o((u=u.apply(r,s||[])).next())})}function g(e,i){var o,r,s,t,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function n(n){return function(t){return function(n){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(s=2&n[0]?r.return:n[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,n[1])).done)return s;switch(r=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,r=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===n[0]||2===n[0])){a=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){a.label=n[1];break}if(6===n[0]&&a.label<s[1]){a.label=s[1],s=n;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(n);break}s[2]&&a.ops.pop(),a.trys.pop();continue}n=i.call(e,a)}catch(t){n=[6,t],r=0}finally{o=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,t])}}}var s=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},o=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},r.prototype.registerAndWrapListener=function(t,n){var e=this.wrapListener(t,n);return this.wrappedListeners.set(n,e),e},r.prototype.wrapListener=function(i,o){var r=this;return function(t){var n=new s(r,i,t);r.preProcessArgs(n);var e=o(n);return r.postProcessArgs(n),e}},r.prototype.preProcessArgs=function(t){},r.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},r.prototype.removeListener=function(t,n){var e=this.listeners(t);if(e){var i=e.indexOf(n);0<=i&&e.splice(i,1)}return this},r.prototype.listeners=function(t){return this.eventListeners[t]||[]},r.prototype.emit=function(t,n){for(var e=0,i=this.listeners(t);e<i.length;e++){(0,i[e])(n)}},Object.defineProperty(r,"ipc",{set:function(t){t&&t.subscribe(r.staticEventName,function(t,n){r.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),r.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},r.removeListener=function(t,n){var e=r.listeners(t);if(e){var i=e.indexOf(n);0<=i&&e.splice(i,1)}},r.listeners=function(t){return this.staticEventListeners[t]||[]},r.emit=function(t,n,e){if(e&&e.publish)e.publish(r.staticEventName,{eventName:t,eventArgs:n});else for(var i=0,o=r.listeners(t);i<o.length;i++){(0,o[i])(n)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),a=function(){function t(){}return t.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)})},t}(),t=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n}(s),p=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return r(i,e),i.prototype.getInfo=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,void 0]})})},i.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(i,"ipc",{get:function(){return i._ipc},set:function(t){o.ipc=i._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"ipc",{get:function(){return i.ipc},set:function(t){i.ipc=t},enumerable:!1,configurable:!0}),i.prototype.addListener=function(t,n){return e.prototype.addListener.call(this,t,n)},i.prototype.removeListener=function(t,n){return e.prototype.removeListener.call(this,t,n)},i.prototype.emit=function(t,n){e.prototype.emit.call(this,t,n)},i.addListener=function(t,n){o.addListener(i.staticEventScopePrefix+t,n)},i.removeListener=function(t,n){o.removeListener(i.staticEventScopePrefix+t,n)},i.emit=function(t,n){o.emit(i.staticEventScopePrefix+t,n,i.ipc)},i.listeners=function(t){return o.listeners(i.staticEventScopePrefix+t)},i.staticEventScopePrefix="container-",i.windowOptionsPropertyKey="desktopJS-options",i}(o),n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.uuid=a.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}return r(i,n),i.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},i.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},i.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(i.layoutsPropertyKey))[t]},i.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(i.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(i.layoutsPropertyKey,JSON.stringify(e)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:n,layoutName:n.name}),p.emit("layout-saved",{name:"layout-saved",layout:n,layoutName:n.name})},i.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(i.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(i.layoutsPropertyKey,JSON.stringify(n)),this.emit("layout-deleted",{sender:this,name:"layout-deleted",layoutName:e.name}),p.emit("layout-deleted",{name:"layout-deleted",layoutName:e.name}))},i.prototype.loadLayout=function(d){return v(this,void 0,Promise,function(){var o,n,e,i,r,s,a,u,c=this;return g(this,function(t){switch(t.label){case 0:return[4,this.closeAllWindows(!0)];case 1:if(t.sent(),!(null==(o="string"==typeof d?this.getLayoutFromStorage(d):d)?void 0:o.windows))return[3,3];for(n=[],e=0,i=o.windows;e<i.length;e++)r=i[e],(s=Object.assign(r.options||{},r.bounds)).name=r.name,r.main?(this.getMainWindow().setBounds(r.bounds),n.push(Promise.resolve(this.getMainWindow()))):n.push(this.createWindow(r.url,s));return[4,Promise.all(n)];case 2:return a=t.sent(),u=new Map,a.forEach(function(e){var t=o.windows.find(function(t){return t.name===e.name});t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)});var i=!1;if(u.forEach(function(t,n){!i&&0<=t.indexOf(e.id)&&(i=!0)}),!i){var n=t?t.group:void 0;n&&0<n.length&&u.set(e,n.filter(function(t){return t!==e.id}))}}),u.forEach(function(t,e){t.forEach(function(n){c.getWindowByName(o.windows.find(function(t){return t.id===n}).name).then(function(t){t.joinGroup(e)})})}),this.emit("layout-loaded",{sender:this,name:"layout-loaded",layout:o,layoutName:o.name}),p.emit("layout-loaded",{name:"layout-loaded",layout:o,layoutName:o.name}),[2,o];case 3:throw new Error("Layout does not exist or is invalid")}})})},i.prototype.saveLayout=function(e){return v(this,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return[4,this.buildLayout()];case 1:return n=t.sent(),this.saveLayoutToStorage(e,n),[2,n]}})})},i.prototype.deleteLayout=function(n){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,this.deleteLayoutFromStorage(n)]})})},i.prototype.getLayouts=function(){return v(this,void 0,Promise,function(){var n,e;return g(this,function(t){return(n=this.storage.getItem(i.layoutsPropertyKey))?(e=JSON.parse(n),[2,Object.getOwnPropertyNames(e).map(function(t){return e[t]})]):[2]})})},i.prototype.log=function(e,i){return v(this,void 0,void 0,function(){var n;return g(this,function(t){switch(e){case"debug":case"warn":case"error":n=console[e];break;default:n=console.log}return n&&n(i),[2]})})},i.layoutsPropertyKey="desktopJS-layouts",i}(p),c=function(n){function t(t){var e=n.call(this)||this;e.globalWindow=t||"undefined"!=typeof window&&window||null,e.linkHelper={href:"unknown"};try{e.linkHelper=e.globalWindow.top.document.createElement("a")}catch(t){}if(e.globalWindow){var i=e.globalWindow.open;e.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.onOpen.apply(e,function(){for(var t=0,n=0,e=arguments.length;n<e;n++)t+=arguments[n].length;var i=Array(t),o=0;for(n=0;n<e;n++)for(var r=arguments[n],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}([i],t))}}return e}return r(t,n),t.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},t.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t},t}(n),h=function(t,n,e){this.topic=t,this.listener=n,this.options=e},e=function(){},d=function(){},f=function(){},l=function(){function e(t,n){this.title=t,this.options=n}return e.requestPermission=function(n){return v(this,void 0,Promise,function(){return g(this,function(t){return n&&n(e.permission),[2,e.permission]})})},e.permission="granted",e}(),w=function(){};u.ObjectTransform=void 0,(u.ObjectTransform||(u.ObjectTransform={})).transformProperties=function(t,n){var e={};if(t)for(var i in t)try{i in n?e[n[i].target]=n[i].convert?n[i].convert(t[i],t,e):t[i]:e[i]=t[i]}catch(t){console.error("Error transforming property '"+i+"'")}return e};var y,m=function(){function t(t,n,e,i){this.x=t,this.y=n,this.width=e,this.height=i}return Object.defineProperty(t.prototype,"right",{get:function(){return t.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return t.getBottom(this)},enumerable:!1,configurable:!0}),t.getRight=function(t){return t.x+t.width},t.getBottom=function(t){return t.y+t.height},t}(),b=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n}(s),W=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n}(b),P=function(i){function e(t){var n=i.call(this)||this;return n.innerWindow=t,n}return r(e,i),Object.defineProperty(e.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),e.prototype.getGroup=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,[]]})})},e.prototype.joinGroup=function(t){return v(this,void 0,Promise,function(){return g(this,function(t){throw new Error("Not supported")})})},e.prototype.leaveGroup=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2]})})},e.prototype.bringToFront=function(){return this.focus()},e.prototype.getState=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2]})})},e.prototype.setState=function(t){return v(this,void 0,Promise,function(){return g(this,function(t){return[2]})})},Object.defineProperty(e.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),e.prototype.addListener=function(t,n){var e=this.registerAndWrapListener(t,n);return this.attachListener(t,e),i.prototype.addListener.call(this,t,e)},e.prototype.removeListener=function(t,n){var e=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,e),i.prototype.removeListener.call(this,t,e)},e.addListener=function(t,n){o.addListener(e.staticEventScopePrefix+t,n)},e.removeListener=function(t,n){o.removeListener(e.staticEventScopePrefix+t,n)},e.emit=function(t,n){o.emit(e.staticEventScopePrefix+t,n,p.ipc)},e.listeners=function(t){return o.listeners(e.staticEventScopePrefix+t)},e.staticEventScopePrefix="containerwindow-",e}(o),x=function(){},S=function(t){this.windows=[],this.name=t};function L(){return"undefined"!=typeof window&&window.fin}u.WindowStateTracking=void 0,(y=u.WindowStateTracking||(u.WindowStateTracking={}))[y.None=0]="None",y[y.Main=1]="Main",y[y.Group=2]="Group";var O=function(){function t(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}return t.prototype.attach=function(t){var i=this;t?(t.addListener(L()?"minimized":"minimize",function(n){return v(i,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.windowStateTracking&u.WindowStateTracking.Main&&this.container.getMainWindow().id===n.sender.id?[4,this.container.getAllWindows()]:[3,2];case 1:t.sent().forEach(function(t){return t.minimize()}),t.label=2;case 2:return this.windowStateTracking&u.WindowStateTracking.Group?[4,n.sender.getGroup()]:[3,4];case 3:t.sent().forEach(function(t){return t.minimize()}),t.label=4;case 4:return[2]}})})}),t.addListener(L()?"restored":"restore",function(n){return v(i,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return this.windowStateTracking&u.WindowStateTracking.Main&&this.container.getMainWindow().id===n.sender.id?[4,this.container.getAllWindows()]:[3,2];case 1:t.sent().forEach(function(t){return t.restore()}),t.label=2;case 2:return this.windowStateTracking&u.WindowStateTracking.Group?[4,n.sender.getGroup()]:[3,4];case 3:t.sent().forEach(function(t){return t.restore()}),t.label=4;case 4:return[2]}})})})):(P.addListener("window-created",function(e){return v(i,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return this.container&&this.container.getWindowById?[4,this.container.getWindowById(e.windowId)]:[3,2];case 1:n=t.sent(),this.attach(n),t.label=2;case 2:return[2]}})})}),this.container&&this.container.getAllWindows().then(function(t){t.forEach(function(t){return i.attach(t)})}))},t}(),E=function(i){function t(t,n){var e=i.call(this,t,n)||this;return e.autoGrouping=!0,e.snapThreshold=15,e.snapOffset=15,e.targetGroup=new Map,n&&("snapThreshold"in n&&(e.snapThreshold=n.snapThreshold),"snapOffset"in n&&(e.snapOffset=n.snapOffset),"autoGrouping"in n&&(e.autoGrouping=n.autoGrouping)),e}return r(t,i),t.prototype.onAttached=function(t){var n=this;t.innerWindow&&t.innerWindow.disableFrame&&t.innerWindow.disableFrame(),L()?(t.addListener("disabled-frame-bounds-changed",function(){return n.onMoved(t)}),t.addListener("frame-enabled",function(){return t.innerWindow.disableFrame()})):t.innerWindow&&t.innerWindow.hookWindowMessage&&t.innerWindow.hookWindowMessage(562,function(){return n.onMoved(t)})},t.prototype.attach=function(n){var e=this;i.prototype.attach.call(this,n),n&&n.getOptions().then(function(t){t&&void 0!==t.snap&&!1===t.snap||(e.onAttached(n),n.addListener(L()?"disabled-frame-bounds-changing":"move",function(t){return e.onMoving(t)}))})},t.prototype.onMoving=function(y){return v(this,void 0,void 0,function(){var n,e,i,o,r,s,a,u,c,d,p,h,f,l,w=this;return g(this,function(t){switch(t.label){case 0:return n=y.sender.id,this.snappingWindow===n?[2]:[4,(e=y.sender).getOptions()];case 1:return(i=t.sent())&&void 0!==i.snap&&!1===i.snap?[2]:[4,e.getGroup()];case 2:return o=t.sent(),L()?(s=new m(y.innerEvent.left,y.innerEvent.top,y.innerEvent.width,y.innerEvent.height),[3,5]):[3,3];case 3:return[4,e.getBounds()];case 4:s=t.sent(),t.label=5;case 5:return r=s,0<o.length?(L()&&this.moveWindow(e,r),[2]):[4,this.container.getAllWindows()];case 6:return a=t.sent(),u=a.filter(function(t){return n!==t.id}).map(function(e){return v(w,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return n={window:e},[4,e.getBounds()];case 1:return n.bounds=t.sent(),[4,e.getOptions()];case 2:return[2,(n.options=t.sent(),n)]}})})}),[4,Promise.all(u)];case 7:for(c=t.sent(),d=!1,h=0,f=c.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});h<f.length;h++)l=f[h],(p=this.getSnapBounds(p||r,l.bounds))?(d=!0,this.showGroupingHint(l.window),this.moveWindow(y.sender,p)):this.hideGroupingHint(l.window);return!d&&L()&&this.moveWindow(y.sender,r),[2]}})})},t.prototype.moveWindow=function(n,e){return v(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:this.snappingWindow=n.id,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.setBounds(e)];case 2:case 3:return t.sent(),[3,4];case 4:return this.snappingWindow=void 0,[2]}})})},t.prototype.onMoved=function(e){var n=this;if(this.autoGrouping){var t=Array.from(this.targetGroup,function(t){t[0];var e=t[1];return v(n,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return n={window:e},[4,e.getGroup()];case 1:return[2,(n.isGrouped=0<t.sent().length,n)]}})})});Promise.all(t).then(function(t){0<t.length&&e.joinGroup(t[0].window);for(var n=1;n<t.length;n++)t[n].isGrouped||t[n].window.joinGroup(e)})}this.targetGroup.forEach(function(t){return n.hideGroupingHint(t)}),this.targetGroup.clear()},t.prototype.showGroupingHint=function(t){var n,e;null===(e=null===(n=t.innerWindow)||void 0===n?void 0:n.updateOptions)||void 0===e||e.call(n,{opacity:.75}),this.targetGroup.set(t.id,t)},t.prototype.hideGroupingHint=function(t){var n,e;null===(e=null===(n=t.innerWindow)||void 0===n?void 0:n.updateOptions)||void 0===e||e.call(n,{opacity:1}),this.targetGroup.delete(t.id)},t.prototype.isHorizontallyAligned=function(t,n){return t.y>=n.y&&t.y<=n.bottom||t.bottom>=n.y&&t.bottom<=n.bottom||t.y<=n.y&&t.bottom>=n.bottom},t.prototype.isVerticallyAligned=function(t,n){return t.x>=n.x&&t.x<=n.right||t.right>=n.x&&t.right<=n.right||t.x<=n.x&&t.right>=n.right},t.prototype.getSnapBounds=function(t,n){var e,i,o,r,s,a,u,c;if(this.isHorizontallyAligned(t,n)&&(e=Math.abs(t.x-(n.right-this.snapOffset))<this.snapThreshold,i=Math.abs(t.x-n.x)<this.snapThreshold,o=Math.abs(t.right-this.snapOffset-n.x)<this.snapThreshold,r=Math.abs(t.right-n.right)<this.snapThreshold),this.isVerticallyAligned(t,n)&&(s=Math.abs(t.y-(n.bottom-this.snapOffset))<this.snapThreshold,a=Math.abs(t.y-n.y)<this.snapThreshold,u=Math.abs(t.bottom-this.snapOffset-n.y)<this.snapThreshold,c=Math.abs(t.bottom-n.bottom)<this.snapThreshold),e||o||s||u){var d=t.x,p=t.y;return e?d=n.x+n.width-this.snapOffset:i&&(d=n.x),o?d=n.x-t.width+this.snapOffset:r&&(d=n.x+n.width-t.width),s?p=n.y+n.height-Math.floor(this.snapOffset/2):a&&(p=n.y),u?p=n.y-t.height+Math.floor(this.snapOffset/2):c&&(p=n.y+n.height-t.height),new m(d,p,t.width,t.height)}},t}(O),M=function(){},T=function(){};u.Default=void 0,function(t){var e={close:"unload"},n=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow[d.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow[d.windowNamePropertyKey]},enumerable:!1,configurable:!0}),n.prototype.load=function(n,t){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.location.replace(n),[2]})})},n.prototype.focus=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.focus(),[2]})})},n.prototype.show=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2]})})},n.prototype.hide=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2]})})},n.prototype.close=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.close(),[2]})})},n.prototype.minimize=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.minimize(),[2]})})},n.prototype.maximize=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.maximize(),[2]})})},n.prototype.restore=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.restore(),[2]})})},n.prototype.isShowing=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,!0]})})},n.prototype.getSnapshot=function(){return v(this,void 0,Promise,function(){return g(this,function(t){throw new Error("getSnapshot requires an implementation.")})})},n.prototype.flash=function(t,n){return v(this,void 0,void 0,function(){return g(this,function(t){throw new Error("Not supported")})})},n.prototype.getParent=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,null]})})},n.prototype.setParent=function(t){return v(this,void 0,void 0,function(){return g(this,function(t){return[2]})})},n.prototype.getBounds=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,new m(this.innerWindow.screenX,this.innerWindow.screenY,this.innerWindow.outerWidth,this.innerWindow.outerHeight)]})})},n.prototype.setBounds=function(n){return v(this,void 0,void 0,function(){return g(this,function(t){return this.innerWindow.moveTo(n.x,n.y),this.innerWindow.resizeTo(n.width,n.height),[2]})})},n.prototype.getOptions=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,this.innerWindow[p.windowOptionsPropertyKey]]})})},n.prototype.getState=function(){var n,e;return v(this,void 0,void 0,function(){return g(this,function(t){return[2,null===(e=null===(n=this.nativeWindow)||void 0===n?void 0:n.getState)||void 0===e?void 0:e.call(n)]})})},n.prototype.setState=function(e){var i,o;return v(this,void 0,void 0,function(){var n;return g(this,function(t){switch(t.label){case 0:return n=null===(o=null===(i=this.nativeWindow)||void 0===i?void 0:i.setState)||void 0===o?void 0:o.call(i,e),this.emit("state-changed",{name:"state-changed",sender:this,state:e}),P.emit("state-changed",{name:"state-changed",windowId:this.id,state:e}),[4,n];case 1:return t.sent(),[2]}})})},n.prototype.attachListener=function(t,n){this.innerWindow.addEventListener(e[t]||t,n)},n.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(e[t]||t,n)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),n}(P);t.DefaultContainerWindow=n;var i=function(){function c(t){this.container=t}return c.prototype.subscribe=function(s,a,t){var e,i;return v(this,void 0,void 0,function(){var n,r=this;return g(this,function(t){return n=new h(s,function(t){if(t.origin===r.container.globalWindow.location.origin){var n=t.data,e=n.source,i=n.topic,o=n.message;e===c.messageSource&&s===i&&a({topic:s},o)}}),null===(i=null===(e=this.container.globalWindow)||void 0===e?void 0:e.addEventListener)||void 0===i||i.call(e,"message",n.listener),[2,n]})})},c.prototype.unsubscribe=function(n){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,this.container.globalWindow.removeEventListener("message",n.listener)]})})},c.prototype.publish=function(r,s,a){var u;return v(this,void 0,void 0,function(){var n,e,i,o;return g(this,function(t){if(n=this.container.globalWindow?this.container.globalWindow[d.windowsPropertyKey]||(null===(u=this.container.globalWindow.opener)||void 0===u?void 0:u[d.windowsPropertyKey]):[])for(e in n)i=n[e],null!=a&&a.name&&a.name!==i[d.windowNamePropertyKey]||(o=(null==a?void 0:a.targetOrigin)||this.container.globalWindow.location.origin,i.postMessage({source:c.messageSource,topic:r,message:s},o));return[2]})})},c.messageSource="desktopJS",c}();t.DefaultMessageBus=i;var d=function(e){function d(t){var n=e.call(this,t)||this;return n.windowOptionsMap=d.defaultWindowOptionsMap,n.hostType="Default",n.ipc=n.createMessageBus(),!n.globalWindow||d.windowsPropertyKey in n.globalWindow||(n.globalWindow[d.windowsPropertyKey]={root:n.globalWindow},n.globalWindow[d.windowNamePropertyKey]=n.globalWindow[d.windowUuidPropertyKey]=d.rootWindowUuid),n.screen=new o(n.globalWindow),n}return r(d,e),d.prototype.createMessageBus=function(){return new i(this)},d.prototype.setOptions=function(t){},d.prototype.getOptions=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,{}]})})},d.prototype.getInfo=function(){return v(this,void 0,Promise,function(){return g(this,function(t){return[2,this.globalWindow.navigator.appVersion]})})},d.prototype.getMainWindow=function(){if(!this.mainWindow){var t=this.globalWindow[d.windowsPropertyKey].root;this.mainWindow=t?this.wrapWindow(t):null}return this.mainWindow},d.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},d.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},d.prototype.wrapWindow=function(t){return new n(t)},d.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var i=t.apply(this.globalWindow,n),o=a.newGuid();try{var r=this.globalWindow[d.windowsPropertyKey];(r[o]=i)[d.windowUuidPropertyKey]=o,i.addEventListener("beforeunload",function(){i.addEventListener("unload",function(){delete r[o]})}),i[d.windowsPropertyKey]=r}catch(t){this.log("warn","Error tracking new window, '"+t.message+"'")}return p.emit("window-created",{name:"window-created",windowId:o}),P.emit("window-created",{name:"window-created",windowId:o}),i},d.prototype.createWindow=function(u,c){return v(this,void 0,Promise,function(){var n,e,i,o,r,s,a;return g(this,function(t){if(e="_blank",i=this.getWindowOptions(c)){for(o in i)n=(n||"")+o+"="+i[o]+",";i&&"target"in i&&(e=i.target)}r=this.globalWindow.open(u,e,n),s=!0;try{r[p.windowOptionsPropertyKey]=c,r[d.windowNamePropertyKey]=i.name}catch(t){s=!1,this.log("warn","Error proprogating properties to new window, '"+t.message+"'")}return a=this.wrapWindow(r),this.emit("window-created",{sender:this,name:"window-created",window:a,windowId:s?a.id:void 0,windowName:i.name}),[2,a]})})},d.prototype.showNotification=function(n,e){var i=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(t){"denied"===t?i.log("warn","Notifications not permitted"):"granted"===t&&new i.globalWindow.Notification(n,e)}):this.log("warn","Notifications not supported")},d.prototype.closeAllWindows=function(o){return void 0===o&&(o=!1),v(this,void 0,void 0,function(){var n,e,i;return g(this,function(t){for(e in n=this.globalWindow[d.windowsPropertyKey])i=n[e],o&&this.globalWindow===i||i.close();return[2]})})},d.prototype.getAllWindows=function(){return v(this,void 0,void 0,function(){var n,e,i;return g(this,function(t){for(i in n=[],e=this.globalWindow[d.windowsPropertyKey])n.push(this.wrapWindow(e[i]));return[2,n]})})},d.prototype.getWindowById=function(e){return v(this,void 0,Promise,function(){var n;return g(this,function(t){return[2,(n=this.globalWindow[d.windowsPropertyKey][e])?this.wrapWindow(n):null]})})},d.prototype.getWindowByName=function(i){return v(this,void 0,Promise,function(){var n,e;return g(this,function(t){for(e in n=this.globalWindow[d.windowsPropertyKey])if(n[e][d.windowNamePropertyKey]===i)return[2,this.wrapWindow(n[e])];return[2,null]})})},d.prototype.buildLayout=function(){return v(this,void 0,void 0,function(){var a,n,e=this;return g(this,function(t){switch(t.label){case 0:return a=new S,n=[],[4,this.getAllWindows()];case 1:return t.sent().forEach(function(o){var r=o.nativeWindow;try{var s=r[p.windowOptionsPropertyKey];if(s&&"persist"in s&&!s.persist)return;n.push(v(e,void 0,void 0,function(){var n,e,i;return g(this,function(t){switch(t.label){case 0:return this.globalWindow===r?[3,2]:(e=(n=a.windows).push,i={name:o.name,url:r&&r.location?r.location.toString():void 0,id:o.id,bounds:{x:r.screenX,y:r.screenY,width:r.innerWidth,height:r.innerHeight},options:s},[4,o.getState()]);case 1:e.apply(n,[(i.state=t.sent(),i)]),t.label=2;case 2:return[2]}})}))}catch(t){e.log("warn","Error while accessing window so skipping, '"+t.message+"'")}}),[4,Promise.all(n)];case 2:return t.sent(),[2,a]}})})},d.windowsPropertyKey="desktopJS-windows",d.windowUuidPropertyKey="desktopJS-uuid",d.windowNamePropertyKey="desktopJS-name",d.rootWindowUuid="root",d.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},d}(c);t.DefaultContainer=d;var o=function(){function t(t){this.window=t}return t.prototype.getPrimaryDisplay=function(){return v(this,void 0,void 0,function(){var n;return g(this,function(t){return(n=new T).scaleFactor=this.window.devicePixelRatio,n.id="Current",n.bounds=new m(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.width,this.window.screen.height),n.workArea=new m(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.availWidth,this.window.screen.availHeight),[2,n]})})},t.prototype.getAllDisplays=function(){return v(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this.getPrimaryDisplay()];case 1:return[2,[t.sent()]]}})})},t.prototype.getMousePosition=function(){return v(this,void 0,void 0,function(){return g(this,function(t){return[2,{x:this.window.event.screenX,y:this.window.event.screenY}]})})},t}()}(u.Default||(u.Default={}));var k=function(){},N=[];u.container=void 0;var G=function(){},A=function(){};return u.Container=p,u.ContainerBase=n,u.ContainerNotification=l,u.ContainerRegistration=k,u.ContainerWindow=P,u.Display=T,u.EventArgs=s,u.EventEmitter=o,u.GlobalShortcutManager=A,u.GroupWindowManager=O,u.Guid=a,u.LayoutEventArgs=t,u.MenuItem=d,u.MessageBusOptions=e,u.MessageBusSubscription=h,u.NotificationOptions=f,u.PersistedWindow=x,u.PersistedWindowLayout=S,u.Point=M,u.PropertyMap=w,u.Rectangle=m,u.SnapAssistWindowManager=E,u.TrayIconDetails=G,u.WebContainerBase=c,u.WindowEventArgs=b,u.WindowGroupEventArgs=W,u.clearRegistry=function(){N.splice(0,N.length),u.container=void 0},u.registerContainer=function(t,n){N.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e,i,o=!1,r=n;if("boolean"==typeof t?o=t:r=t,!o&&u.container)return u.container;try{for(var s=0;s<N.length;s++){i=N[s].id;var a=N[s].registration;e=a.condition(r)?a:e}u.container=e?e.create(r):void 0}catch(t){console.error("Error resolving container '"+i+"' : "+t.toString())}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="3.12.0",Object.defineProperty(u,"__esModule",{value:!0}),u}({}); | ||
//# sourceMappingURL=desktop.min.js.map |
@@ -5,3 +5,3 @@ { | ||
"description": "Library for abstracting common container hosting", | ||
"version": "3.11.0", | ||
"version": "3.12.0", | ||
"publishConfig": { | ||
@@ -16,6 +16,6 @@ "access": "public" | ||
"type": "git", | ||
"url": "https://github.com/Morgan-Stanley/desktopJS.git" | ||
"url": "https://github.com/MorganStanley/desktopJS.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Morgan-Stanley/desktopJS/issues" | ||
"url": "https://github.com/MorganStanley/desktopJS/issues" | ||
}, | ||
@@ -35,3 +35,2 @@ "keywords": [ | ||
"clean": "gulp clean", | ||
"tslint": "gulp tslint", | ||
"build:lerna": "gulp build:lerna", | ||
@@ -38,0 +37,0 @@ "build": "gulp build", |
@@ -1,11 +0,7 @@ | ||
 | ||
 | ||
========== | ||
[](https://www.npmjs.com/package/@morgan-stanley/desktopjs) | ||
[](https://travis-ci.com/Morgan-Stanley/desktopJS?branch=master) | ||
[](https://codecov.io/gh/Morgan-Stanley/desktopJS) | ||
[](https://github.com/MorganStanley/desktopJS/actions/workflows/continuous-integration.yml) | ||
[](https://codecov.io/gh/MorganStanley/desktopJS) | ||
[](https://david-dm.org/Morgan-Stanley/desktopJS?type=dev) | ||
[](https://david-dm.org/Morgan-Stanley/desktopJS) | ||
[](https://gitpitch.com/Morgan-Stanley/desktopJS/master?grs=github&t=white&p=pitch) | ||
desktopJS is a common API across multiple HTML5 containers. By programming to a | ||
@@ -20,3 +16,3 @@ common API, applications can target multiple HTML5 containers without change. Detecting | ||
The first step is to simply [resolve](https://morgan-stanley.github.io/desktopJS/modules/_desktopjs_src_registry_.html#resolvecontainer) the current [container](https://morgan-stanley.github.io/desktopJS/classes/_desktopjs_src_container_.container.html). This enumerates | ||
The first step is to simply [resolve](http://opensource.morganstanley.com/desktopJS/modules/_desktopjs_src_registry_.html#resolvecontainer) the current [container](http://opensource.morganstanley.com/desktopJS/classes/_desktopjs_src_container_.container.html). This enumerates | ||
all registered containers (including your own custom container or derived custom implementations) and | ||
@@ -30,3 +26,3 @@ returns the container implementation that matches. | ||
Interact with the [container](https://morgan-stanley.github.io/desktopJS/classes/_desktopjs_src_container_.container.html) via a single api instead of having conditional code or applications | ||
Interact with the [container](http://opensource.morganstanley.com/desktopJS/classes/_desktopjs_src_container_.container.html) via a single api instead of having conditional code or applications | ||
based on deployment. | ||
@@ -102,3 +98,3 @@ | ||
Examples showcasing usage of desktopJS for various containers and scenarios can be found under | ||
the [examples](https://github.com/Morgan-Stanley/desktopJS/tree/master/examples) directory. | ||
the [examples](https://github.com/MorganStanley/desktopJS/tree/main/examples) directory. | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
710097
4646
98