@morgan-stanley/desktopjs
Advanced tools
Comparing version 3.13.1 to 4.0.0
@@ -9,3 +9,3 @@ import { ContainerWindowManager, ContainerWindow, PersistedWindowLayout, WindowEventArgs } from "./window"; | ||
import { GlobalShortcutManager } from "./shortcut"; | ||
export declare type ContainerEventType = "window-created" | "layout-loaded" | "layout-saved" | "layout-deleted"; | ||
export type ContainerEventType = "window-created" | "layout-loaded" | "layout-saved" | "layout-deleted"; | ||
export declare class LayoutEventArgs extends EventArgs { | ||
@@ -15,3 +15,3 @@ readonly layout?: PersistedWindowLayout; | ||
} | ||
export declare type ContainerEventArgs = EventArgs | WindowEventArgs | LayoutEventArgs; | ||
export type ContainerEventArgs = EventArgs | WindowEventArgs | LayoutEventArgs; | ||
export declare abstract class Container extends EventEmitter implements ContainerWindowManager, ContainerNotificationManager { | ||
@@ -18,0 +18,0 @@ private static readonly staticEventScopePrefix; |
@@ -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 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)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function w(t,s,a,u){return new(a=a||Promise)(function(e,n){function i(t){try{r(u.next(t))}catch(t){n(t)}}function o(t){try{r(u.throw(t))}catch(t){n(t)}}function r(t){var n;t.done?e(t.value):((n=t.value)instanceof a?n:new a(function(t){t(n)})).then(i,o)}r((u=u.apply(t,s||[])).next())})}function y(i,o){var r,s,a,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(e){return function(t){var n=[e,t];if(r)throw new TypeError("Generator is already executing.");for(;u=c&&n[c=0]?0:u;)try{if(r=1,s&&(a=2&n[0]?s.return:n[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,n[1])).done)return a;switch(s=0,(n=a?[2&n[0],a.value]:n)[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,s=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(!(a=0<(a=u.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){u.label=n[1];break}if(6===n[0]&&u.label<a[1]){u.label=a[1],a=n;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=o.call(i,u)}catch(t){n=[6,t],s=0}finally{r=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}}}var r=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},e=(s.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},s.prototype.registerAndWrapListener=function(t,n){t=this.wrapListener(t,n);return this.wrappedListeners.set(n,t),t},s.prototype.wrapListener=function(e,i){var o=this;return function(t){var t=new r(o,e,t),n=(o.preProcessArgs(t),i(t));return o.postProcessArgs(t),n}},s.prototype.preProcessArgs=function(t){},s.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},s.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},s.prototype.removeListener=function(t,n){t=this.listeners(t);return t&&0<=(n=t.indexOf(n))&&t.splice(n,1),this},s.prototype.listeners=function(t){return this.eventListeners[t]||[]},s.prototype.emit=function(t,n){for(var e=0,i=this.listeners(t);e<i.length;e++)(0,i[e])(n)},Object.defineProperty(s,"ipc",{set:function(t){t&&t.subscribe(s.staticEventName,function(t,n){s.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),s.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},s.removeListener=function(t,n){t=s.listeners(t);t&&0<=(n=t.indexOf(n))&&t.splice(n,1)},s.listeners=function(t){return this.staticEventListeners[t]||[]},s.emit=function(t,n,e){if(e&&e.publish)e.publish(s.staticEventName,{eventName:t,eventArgs:n});else for(var i=0,o=s.listeners(t);i<o.length;i++)(0,o[i])(n)},s.staticEventListeners=new Map,s.staticEventName="desktopJS.static-event",s);function s(){this.eventListeners=new Map,this.wrappedListeners=new Map}B.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)})};var a=B;function B(){}t(H,n=r);var n,I=H;function H(){return null!==n&&n.apply(this,arguments)||this}t(c,o=e),c.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,void 0]})})},c.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(c,"ipc",{get:function(){return c._ipc},set:function(t){e.ipc=c._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"ipc",{get:function(){return c.ipc},set:function(t){c.ipc=t},enumerable:!1,configurable:!0}),c.prototype.addListener=function(t,n){return o.prototype.addListener.call(this,t,n)},c.prototype.removeListener=function(t,n){return o.prototype.removeListener.call(this,t,n)},c.prototype.emit=function(t,n){o.prototype.emit.call(this,t,n)},c.addListener=function(t,n){e.addListener(c.staticEventScopePrefix+t,n)},c.removeListener=function(t,n){e.removeListener(c.staticEventScopePrefix+t,n)},c.emit=function(t,n){e.emit(c.staticEventScopePrefix+t,n,c.ipc)},c.listeners=function(t){return e.listeners(c.staticEventScopePrefix+t)},c.staticEventScopePrefix="container-",c.windowOptionsPropertyKey="desktopJS-options";var o,p=c;function c(){return null!==o&&o.apply(this,arguments)||this}t(h,d=p),h.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},h.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},h.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(h.layoutsPropertyKey))[t]},h.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(h.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})},h.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(h.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}))},h.prototype.loadLayout=function(d){return w(this,void 0,void 0,function(){var o,n,e,i,r,s,a,u,c=this;return y(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)||!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}),i=(t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)}),!1);u.forEach(function(t,n){!i&&0<=t.indexOf(e.id)&&(i=!0)}),i||(t=t?t.group:void 0)&&0<t.length&&u.set(e,t.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")}})})},h.prototype.saveLayout=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return[4,this.buildLayout()];case 1:return n=t.sent(),this.saveLayoutToStorage(e,n),[2,n]}})})},h.prototype.deleteLayout=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.deleteLayoutFromStorage(n)]})})},h.prototype.getLayouts=function(){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){return(n=this.storage.getItem(h.layoutsPropertyKey))?(e=JSON.parse(n),[2,Object.getOwnPropertyNames(e).map(function(t){return e[t]})]):[2]})})},h.prototype.log=function(e,i){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(e){case"debug":case"warn":case"error":n=console[e];break;default:n=console.log}return n&&n(i),[2]})})},h.layoutsPropertyKey="desktopJS-layouts";var d,C=h;function h(){var t=null!==d&&d.apply(this,arguments)||this;return t.uuid=a.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}t(l,D=C),l.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},l.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t};var D,J=l;function l(t){var e,i=D.call(this)||this;i.globalWindow=t||"undefined"!=typeof window&&window||null,i.linkHelper={href:"unknown"};try{i.linkHelper=i.globalWindow.top.document.createElement("a")}catch(t){}return i.globalWindow&&(e=i.globalWindow.open,i.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i.onOpen.apply(i,function(t,n,e){if(e||2===arguments.length)for(var i,o=0,r=n.length;o<r;o++)!i&&o in n||((i=i||Array.prototype.slice.call(n,0,o))[o]=n[o]);return t.concat(i||Array.prototype.slice.call(n))}([e],t,!1))}),i}function _(){}function z(){}function F(){}var U=function(t,n,e){this.topic=t,this.listener=n,this.options=e},R=(f.requestPermission=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return n&&n(f.permission),[2,f.permission]})})},f.permission="granted",f);function f(t,n){this.title=t,this.options=n}function V(){}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},Object.defineProperty(g.prototype,"right",{get:function(){return g.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"bottom",{get:function(){return g.getBottom(this)},enumerable:!1,configurable:!0}),g.getRight=function(t){return t.x+t.width},g.getBottom=function(t){return t.y+t.height};var v=g;function g(t,n,e,i){this.x=t,this.y=n,this.width=e,this.height=i}t(X,m=r);var m,q=X;function X(){return null!==m&&m.apply(this,arguments)||this}t(Q,b=q);var b,Y=Q;function Q(){return null!==b&&b.apply(this,arguments)||this}t(x,W=e),Object.defineProperty(x.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),x.prototype.getGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,[]]})})},x.prototype.joinGroup=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},x.prototype.leaveGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.bringToFront=function(){return this.focus()},x.prototype.getState=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.setState=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},Object.defineProperty(x.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),x.prototype.addListener=function(t,n){n=this.registerAndWrapListener(t,n);return this.attachListener(t,n),W.prototype.addListener.call(this,t,n)},x.prototype.removeListener=function(t,n){n=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,n),W.prototype.removeListener.call(this,t,n)},x.addListener=function(t,n){e.addListener(x.staticEventScopePrefix+t,n)},x.removeListener=function(t,n){e.removeListener(x.staticEventScopePrefix+t,n)},x.emit=function(t,n){e.emit(x.staticEventScopePrefix+t,n,p.ipc)},x.listeners=function(t){return e.listeners(x.staticEventScopePrefix+t)},x.staticEventScopePrefix="containerwindow-";var W,P=x;function x(t){var n=W.call(this)||this;return n.innerWindow=t,n}function Z(){}var $=function(t){this.windows=[],this.name=t};function S(){return"undefined"!=typeof window&&window.fin}u.WindowStateTracking=void 0,(L=u.WindowStateTracking||(u.WindowStateTracking={}))[L.None=0]="None",L[L.Main=1]="Main",L[L.Group=2]="Group";tt.prototype.attach=function(t){var i=this;t?(t.addListener(S()?"minimized":"minimize",function(n){return w(i,void 0,void 0,function(){return y(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(S()?"restored":"restore",function(n){return w(i,void 0,void 0,function(){return y(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 w(i,void 0,void 0,function(){var n;return y(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)})}))};var L=tt;function tt(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}t(E,O=L),E.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)})},E.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)}))})},E.prototype.onMoving=function(f){return w(this,void 0,void 0,function(){var n,e,i,o,r,s,a,u,c,d,p,h,l=this;return y(this,function(t){switch(t.label){case 0:return(n=f.sender.id,this.snappingWindow===n)?[2]:[4,(e=f.sender).getOptions()];case 1:return(s=t.sent())&&void 0!==s.snap&&!1===s.snap?[2]:[4,e.getGroup()];case 2:return(i=t.sent(),S())?(r=new v(f.innerEvent.left,f.innerEvent.top,f.innerEvent.width,f.innerEvent.height),[3,5]):[3,3];case 3:return[4,e.getBounds()];case 4:r=t.sent(),t.label=5;case 5:return o=r,0<i.length?(S()&&this.moveWindow(e,o),[2]):[4,this.container.getAllWindows()];case 6:return s=t.sent(),a=s.filter(function(t){return n!==t.id}).map(function(e){return w(l,void 0,void 0,function(){var n;return y(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(a)];case 7:for(a=t.sent(),u=!1,d=0,p=a.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});d<p.length;d++)h=p[d],(c=this.getSnapBounds(c||o,h.bounds))?(u=!0,this.showGroupingHint(h.window),this.moveWindow(f.sender,c)):this.hideGroupingHint(h.window);return!u&&S()&&this.moveWindow(f.sender,o),[2]}})})},E.prototype.moveWindow=function(n,e){return w(this,void 0,void 0,function(){return y(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]}})})},E.prototype.onMoved=function(e){var t,n=this;this.autoGrouping&&(t=Array.from(this.targetGroup,function(t){t[0];var e=t[1];return w(n,void 0,void 0,function(){var n;return y(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()},E.prototype.showGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:.75}),this.targetGroup.set(t.id,t)},E.prototype.hideGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:1}),this.targetGroup.delete(t.id)},E.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},E.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},E.prototype.getSnapBounds=function(t,n){var e,i,o,r,s,a,u,c,d,p;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)return d=t.x,p=t.y,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 v(d,p,t.width,t.height)};var O,nt=E;function E(t,n){t=O.call(this,t,n)||this;return t.autoGrouping=!0,t.snapThreshold=15,t.snapOffset=15,t.targetGroup=new Map,n&&("snapThreshold"in n&&(t.snapThreshold=n.snapThreshold),"snapOffset"in n&&(t.snapOffset=n.snapOffset),"autoGrouping"in n&&(t.autoGrouping=n.autoGrouping)),t}function et(){}var M,it=function(){},T=(u.Default=void 0,u.Default||(u.Default={})),ot={close:"unload"},rt=(t(k,M=P),Object.defineProperty(k.prototype,"id",{get:function(){return this.innerWindow[G.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"name",{get:function(){return this.innerWindow[G.windowNamePropertyKey]},enumerable:!1,configurable:!0}),k.prototype.load=function(n,t){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.location.replace(n),[2]})})},k.prototype.focus=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.focus(),[2]})})},k.prototype.show=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},k.prototype.hide=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},k.prototype.close=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.close(),[2]})})},k.prototype.minimize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.minimize(),[2]})})},k.prototype.maximize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.maximize(),[2]})})},k.prototype.restore=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.restore(),[2]})})},k.prototype.isShowing=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,!0]})})},k.prototype.getSnapshot=function(){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("getSnapshot requires an implementation.")})})},k.prototype.flash=function(t,n){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},k.prototype.getParent=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null]})})},k.prototype.setParent=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},k.prototype.getBounds=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,new v(this.innerWindow.screenX,this.innerWindow.screenY,this.innerWindow.outerWidth,this.innerWindow.outerHeight)]})})},k.prototype.setBounds=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.moveTo(n.x,n.y),this.innerWindow.resizeTo(n.width,n.height),[2]})})},k.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.innerWindow[p.windowOptionsPropertyKey]]})})},k.prototype.getState=function(){var n,e;return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null==(e=null==(n=this.nativeWindow)?void 0:n.getState)?void 0:e.call(n)]})})},k.prototype.setState=function(e){var i,o;return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return n=null==(o=null==(i=this.nativeWindow)?void 0:i.setState)?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]}})})},k.prototype.attachListener=function(t,n){this.innerWindow.addEventListener(ot[t]||t,n)},k.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(ot[t]||t,n)},Object.defineProperty(k.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),k);function k(){return null!==M&&M.apply(this,arguments)||this}T.DefaultContainerWindow=rt,N.prototype.subscribe=function(o,r,t){var e,s;return w(this,void 0,void 0,function(){var n,i=this;return y(this,function(t){return n=new U(o,function(t){var n,e;t.origin===i.container.globalWindow.location.origin&&(n=(t=t.data).source,e=t.topic,t=t.message,n===N.messageSource&&o===e&&r({topic:o},t))}),null!=(s=null==(e=this.container.globalWindow)?void 0:e.addEventListener)&&s.call(e,"message",n.listener),[2,n]})})},N.prototype.unsubscribe=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.container.globalWindow.removeEventListener("message",n.listener)]})})},N.prototype.publish=function(r,s,a){var u;return w(this,void 0,void 0,function(){var n,e,i,o;return y(this,function(t){if(n=this.container.globalWindow?this.container.globalWindow[G.windowsPropertyKey]||(null==(u=this.container.globalWindow.opener)?void 0:u[G.windowsPropertyKey]):[])for(e in n)i=n[e],null!=a&&a.name&&a.name!==i[G.windowNamePropertyKey]||(o=(null==a?void 0:a.targetOrigin)||this.container.globalWindow.location.origin,i.postMessage({source:N.messageSource,topic:r,message:s},o));return[2]})})},N.messageSource="desktopJS";var st=N;function N(t){this.container=t}T.DefaultMessageBus=st,t(A,at=J),A.prototype.createMessageBus=function(){return new st(this)},A.prototype.setOptions=function(t){},A.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{}]})})},A.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.globalWindow.navigator.appVersion]})})},A.prototype.getMainWindow=function(){var t;return this.mainWindow||(t=this.globalWindow[A.windowsPropertyKey].root,this.mainWindow=t?this.wrapWindow(t):null),this.mainWindow},A.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},A.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},A.prototype.wrapWindow=function(t){return new rt(t)},A.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);if(i){var o=a.newGuid();try{var r=this.globalWindow[A.windowsPropertyKey];(r[o]=i)[A.windowUuidPropertyKey]=o,i.addEventListener("beforeunload",function(){i.addEventListener("unload",function(){delete r[o]})}),i[A.windowsPropertyKey]=r}catch(t){this.log("warn","Error tracking new window, '".concat(t.message,"'"))}p.emit("window-created",{name:"window-created",windowId:o}),P.emit("window-created",{name:"window-created",windowId:o})}return i},A.prototype.createWindow=function(s,a){return w(this,void 0,void 0,function(){var n,e,i,o,r;return y(this,function(t){if(r="_blank",e=this.getWindowOptions(a)){for(i in e)n=(n||"")+i+"="+e[i]+",";e&&"target"in e&&(r=e.target)}r=this.globalWindow.open(s,r,n),o=!0;try{r[p.windowOptionsPropertyKey]=a,r[A.windowNamePropertyKey]=e.name}catch(t){o=!1,this.log("warn","Error propagating properties to new window, '".concat(t.message,"'"))}return r=this.wrapWindow(r),this.emit("window-created",{sender:this,name:"window-created",window:r,windowId:o?r.id:void 0,windowName:e.name}),[2,r]})})},A.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")},A.prototype.closeAllWindows=function(o){return void 0===o&&(o=!1),w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])i=n[e],o&&this.globalWindow===i||i.close();return[2]})})},A.prototype.getAllWindows=function(){return w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(i in n=[],e=this.globalWindow[A.windowsPropertyKey])n.push(this.wrapWindow(e[i]));return[2,n]})})},A.prototype.getWindowById=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return[2,(n=this.globalWindow[A.windowsPropertyKey][e])?this.wrapWindow(n):null]})})},A.prototype.getWindowByName=function(i){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])if(n[e][A.windowNamePropertyKey]===i)return[2,this.wrapWindow(n[e])];return[2,null]})})},A.prototype.buildLayout=function(){return w(this,void 0,void 0,function(){var a,n,e=this;return y(this,function(t){switch(t.label){case 0:return a=new $,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(w(e,void 0,void 0,function(){var n,e,i;return y(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, '".concat(t.message,"'"))}}),[4,Promise.all(n)];case 2:return t.sent(),[2,a]}})})},A.windowsPropertyKey="desktopJS-windows",A.windowUuidPropertyKey="desktopJS-uuid",A.windowNamePropertyKey="desktopJS-name",A.rootWindowUuid="root",A.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}};var at,G=A;function A(t){t=at.call(this,t)||this;return t.windowOptionsMap=A.defaultWindowOptionsMap,t.hostType="Default",t.ipc=t.createMessageBus(),!t.globalWindow||A.windowsPropertyKey in t.globalWindow||(t.globalWindow[A.windowsPropertyKey]={root:t.globalWindow},t.globalWindow[A.windowNamePropertyKey]=t.globalWindow[A.windowUuidPropertyKey]=A.rootWindowUuid),t.screen=new ut(t.globalWindow),t}T.DefaultContainer=G,K.prototype.getPrimaryDisplay=function(){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return(n=new it).scaleFactor=this.window.devicePixelRatio,n.id="Current",n.bounds=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.width,this.window.screen.height),n.workArea=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.availWidth,this.window.screen.availHeight),[2,n]})})},K.prototype.getAllDisplays=function(){return w(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.getPrimaryDisplay()];case 1:return[2,[t.sent()]]}})})},K.prototype.getMousePosition=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{x:this.window.event.screenX,y:this.window.event.screenY}]})})};var ut=K;function K(t){this.window=t}function ct(){}var j=[];u.container=void 0;function dt(){}function pt(){}u.Container=p,u.ContainerBase=C,u.ContainerNotification=R,u.ContainerRegistration=ct,u.ContainerWindow=P,u.Display=it,u.EventArgs=r,u.EventEmitter=e,u.GlobalShortcutManager=pt,u.GroupWindowManager=L,u.Guid=a,u.LayoutEventArgs=I,u.MenuItem=z,u.MessageBusOptions=_,u.MessageBusSubscription=U,u.NotificationOptions=F,u.PersistedWindow=Z,u.PersistedWindowLayout=$,u.Point=et,u.PropertyMap=V,u.Rectangle=v,u.SnapAssistWindowManager=nt,u.TrayIconDetails=dt,u.WebContainerBase=J,u.WindowEventArgs=q,u.WindowGroupEventArgs=Y,u.clearRegistry=function(){j.splice(0,j.length),u.container=void 0},u.registerContainer=function(t,n){j.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e=!1,i=n;if("boolean"==typeof t?e=t:i=t,e||!u.container)try{for(var o=0;o<j.length;o++)var r=j[o].id,s=j[o].registration,a=s.condition(i)?s:a;u.container=a?a.create(i):void 0}catch(t){console.error("Error resolving container '".concat(r,"' : ").concat(t.toString()))}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="3.13.1",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)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}))(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function w(t,s,a,u){return new(a=a||Promise)(function(e,n){function i(t){try{r(u.next(t))}catch(t){n(t)}}function o(t){try{r(u.throw(t))}catch(t){n(t)}}function r(t){var n;t.done?e(t.value):((n=t.value)instanceof a?n:new a(function(t){t(n)})).then(i,o)}r((u=u.apply(t,s||[])).next())})}function y(i,o){var r,s,a,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(e){return function(t){var n=[e,t];if(r)throw new TypeError("Generator is already executing.");for(;u=c&&n[c=0]?0:u;)try{if(r=1,s&&(a=2&n[0]?s.return:n[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,n[1])).done)return a;switch(s=0,(n=a?[2&n[0],a.value]:n)[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,s=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(!(a=0<(a=u.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3]))u.label=n[1];else if(6===n[0]&&u.label<a[1])u.label=a[1],a=n;else{if(!(a&&u.label<a[2])){a[2]&&u.ops.pop(),u.trys.pop();continue}u.label=a[2],u.ops.push(n)}}n=o.call(i,u)}catch(t){n=[6,t],s=0}finally{r=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}}}var r=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},e=(s.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},s.prototype.registerAndWrapListener=function(t,n){t=this.wrapListener(t,n);return this.wrappedListeners.set(n,t),t},s.prototype.wrapListener=function(e,i){var o=this;return function(t){var t=new r(o,e,t),n=(o.preProcessArgs(t),i(t));return o.postProcessArgs(t),n}},s.prototype.preProcessArgs=function(t){},s.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},s.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},s.prototype.removeListener=function(t,n){t=this.listeners(t);return t&&0<=(n=t.indexOf(n))&&t.splice(n,1),this},s.prototype.listeners=function(t){return this.eventListeners[t]||[]},s.prototype.emit=function(t,n){for(var e=0,i=this.listeners(t);e<i.length;e++)(0,i[e])(n)},Object.defineProperty(s,"ipc",{set:function(t){t&&t.subscribe(s.staticEventName,function(t,n){s.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),s.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},s.removeListener=function(t,n){t=s.listeners(t);t&&0<=(n=t.indexOf(n))&&t.splice(n,1)},s.listeners=function(t){return this.staticEventListeners[t]||[]},s.emit=function(t,n,e){if(e&&e.publish)e.publish(s.staticEventName,{eventName:t,eventArgs:n});else for(var i=0,o=s.listeners(t);i<o.length;i++)(0,o[i])(n)},s.staticEventListeners=new Map,s.staticEventName="desktopJS.static-event",s);function s(){this.eventListeners=new Map,this.wrappedListeners=new Map}B.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)})};var a=B;function B(){}t(H,n=r);var n,I=H;function H(){return null!==n&&n.apply(this,arguments)||this}t(c,o=e),c.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,void 0]})})},c.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(c,"ipc",{get:function(){return c._ipc},set:function(t){e.ipc=c._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"ipc",{get:function(){return c.ipc},set:function(t){c.ipc=t},enumerable:!1,configurable:!0}),c.prototype.addListener=function(t,n){return o.prototype.addListener.call(this,t,n)},c.prototype.removeListener=function(t,n){return o.prototype.removeListener.call(this,t,n)},c.prototype.emit=function(t,n){o.prototype.emit.call(this,t,n)},c.addListener=function(t,n){e.addListener(c.staticEventScopePrefix+t,n)},c.removeListener=function(t,n){e.removeListener(c.staticEventScopePrefix+t,n)},c.emit=function(t,n){e.emit(c.staticEventScopePrefix+t,n,c.ipc)},c.listeners=function(t){return e.listeners(c.staticEventScopePrefix+t)},c.staticEventScopePrefix="container-",c.windowOptionsPropertyKey="desktopJS-options";var o,p=c;function c(){return null!==o&&o.apply(this,arguments)||this}t(h,d=p),h.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},h.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},h.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(h.layoutsPropertyKey))[t]},h.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(h.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})},h.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(h.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}))},h.prototype.loadLayout=function(d){return w(this,void 0,void 0,function(){var o,n,e,i,r,s,a,u,c=this;return y(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)||!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}),i=(t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)}),!1);u.forEach(function(t,n){!i&&0<=t.indexOf(e.id)&&(i=!0)}),i||(t=t?t.group:void 0)&&0<t.length&&u.set(e,t.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")}})})},h.prototype.saveLayout=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return[4,this.buildLayout()];case 1:return n=t.sent(),this.saveLayoutToStorage(e,n),[2,n]}})})},h.prototype.deleteLayout=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.deleteLayoutFromStorage(n)]})})},h.prototype.getLayouts=function(){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){return(n=this.storage.getItem(h.layoutsPropertyKey))?(e=JSON.parse(n),[2,Object.getOwnPropertyNames(e).map(function(t){return e[t]})]):[2]})})},h.prototype.log=function(e,i){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(e){case"debug":case"warn":case"error":n=console[e];break;default:n=console.log}return n&&n(i),[2]})})},h.layoutsPropertyKey="desktopJS-layouts";var d,C=h;function h(){var t=null!==d&&d.apply(this,arguments)||this;return t.uuid=a.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}t(l,D=C),l.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},l.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t};var D,J=l;function l(t){var e,i=D.call(this)||this;i.globalWindow=t||"undefined"!=typeof window&&window||null,i.linkHelper={href:"unknown"};try{i.linkHelper=i.globalWindow.top.document.createElement("a")}catch(t){}return i.globalWindow&&(e=i.globalWindow.open,i.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i.onOpen.apply(i,function(t,n,e){if(e||2===arguments.length)for(var i,o=0,r=n.length;o<r;o++)!i&&o in n||((i=i||Array.prototype.slice.call(n,0,o))[o]=n[o]);return t.concat(i||Array.prototype.slice.call(n))}([e],t,!1))}),i}function z(){}function _(){}function F(){}var U=function(t,n,e){this.topic=t,this.listener=n,this.options=e},R=(f.requestPermission=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return n&&n(f.permission),[2,f.permission]})})},f.permission="granted",f);function f(t,n){this.title=t,this.options=n}function V(){}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},Object.defineProperty(g.prototype,"right",{get:function(){return g.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"bottom",{get:function(){return g.getBottom(this)},enumerable:!1,configurable:!0}),g.getRight=function(t){return t.x+t.width},g.getBottom=function(t){return t.y+t.height};var v=g;function g(t,n,e,i){this.x=t,this.y=n,this.width=e,this.height=i}t(X,m=r);var m,q=X;function X(){return null!==m&&m.apply(this,arguments)||this}t(Q,b=q);var b,Y=Q;function Q(){return null!==b&&b.apply(this,arguments)||this}t(x,W=e),Object.defineProperty(x.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),x.prototype.getGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,[]]})})},x.prototype.joinGroup=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},x.prototype.leaveGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.bringToFront=function(){return this.focus()},x.prototype.getState=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.setState=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},Object.defineProperty(x.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),x.prototype.addListener=function(t,n){n=this.registerAndWrapListener(t,n);return this.attachListener(t,n),W.prototype.addListener.call(this,t,n)},x.prototype.removeListener=function(t,n){n=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,n),W.prototype.removeListener.call(this,t,n)},x.addListener=function(t,n){e.addListener(x.staticEventScopePrefix+t,n)},x.removeListener=function(t,n){e.removeListener(x.staticEventScopePrefix+t,n)},x.emit=function(t,n){e.emit(x.staticEventScopePrefix+t,n,p.ipc)},x.listeners=function(t){return e.listeners(x.staticEventScopePrefix+t)},x.staticEventScopePrefix="containerwindow-";var W,P=x;function x(t){var n=W.call(this)||this;return n.innerWindow=t,n}function Z(){}var $=function(t){this.windows=[],this.name=t};function S(){return"undefined"!=typeof window&&window.fin}u.WindowStateTracking=void 0,(L=u.WindowStateTracking||(u.WindowStateTracking={}))[L.None=0]="None",L[L.Main=1]="Main",L[L.Group=2]="Group";tt.prototype.attach=function(t){var i=this;t?(t.addListener(S()?"minimized":"minimize",function(n){return w(i,void 0,void 0,function(){return y(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(S()?"restored":"restore",function(n){return w(i,void 0,void 0,function(){return y(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 w(i,void 0,void 0,function(){var n;return y(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)})}))};var L=tt;function tt(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}t(E,O=L),E.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)})},E.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)}))})},E.prototype.onMoving=function(f){return w(this,void 0,void 0,function(){var n,e,i,o,r,s,a,u,c,d,p,h,l=this;return y(this,function(t){switch(t.label){case 0:return(n=f.sender.id,this.snappingWindow===n)?[2]:[4,(e=f.sender).getOptions()];case 1:return(s=t.sent())&&void 0!==s.snap&&!1===s.snap?[2]:[4,e.getGroup()];case 2:return(i=t.sent(),S())?(r=new v(f.innerEvent.left,f.innerEvent.top,f.innerEvent.width,f.innerEvent.height),[3,5]):[3,3];case 3:return[4,e.getBounds()];case 4:r=t.sent(),t.label=5;case 5:return o=r,0<i.length?(S()&&this.moveWindow(e,o),[2]):[4,this.container.getAllWindows()];case 6:return s=t.sent(),a=s.filter(function(t){return n!==t.id}).map(function(e){return w(l,void 0,void 0,function(){var n;return y(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(a)];case 7:for(a=t.sent(),u=!1,d=0,p=a.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});d<p.length;d++)h=p[d],(c=this.getSnapBounds(c||o,h.bounds))?(u=!0,this.showGroupingHint(h.window),this.moveWindow(f.sender,c)):this.hideGroupingHint(h.window);return!u&&S()&&this.moveWindow(f.sender,o),[2]}})})},E.prototype.moveWindow=function(n,e){return w(this,void 0,void 0,function(){return y(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]}})})},E.prototype.onMoved=function(e){var t,n=this;this.autoGrouping&&(t=Array.from(this.targetGroup,function(t){t[0];var e=t[1];return w(n,void 0,void 0,function(){var n;return y(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()},E.prototype.showGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:.75}),this.targetGroup.set(t.id,t)},E.prototype.hideGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:1}),this.targetGroup.delete(t.id)},E.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},E.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},E.prototype.getSnapBounds=function(t,n){var e,i,o,r,s,a,u,c,d,p;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)return d=t.x,p=t.y,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 v(d,p,t.width,t.height)};var O,nt=E;function E(t,n){t=O.call(this,t,n)||this;return t.autoGrouping=!0,t.snapThreshold=15,t.snapOffset=15,t.targetGroup=new Map,n&&("snapThreshold"in n&&(t.snapThreshold=n.snapThreshold),"snapOffset"in n&&(t.snapOffset=n.snapOffset),"autoGrouping"in n)&&(t.autoGrouping=n.autoGrouping),t}function et(){}var T,it=function(){},M=(u.Default=void 0,u.Default||(u.Default={})),ot={close:"unload"},rt=(t(N,T=P),Object.defineProperty(N.prototype,"id",{get:function(){return this.innerWindow[k.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"name",{get:function(){return this.innerWindow[k.windowNamePropertyKey]},enumerable:!1,configurable:!0}),N.prototype.load=function(n,t){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.location.replace(n),[2]})})},N.prototype.focus=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.focus(),[2]})})},N.prototype.show=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},N.prototype.hide=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},N.prototype.close=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.close(),[2]})})},N.prototype.minimize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.minimize(),[2]})})},N.prototype.maximize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.maximize(),[2]})})},N.prototype.restore=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.restore(),[2]})})},N.prototype.isShowing=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,!0]})})},N.prototype.getSnapshot=function(){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("getSnapshot requires an implementation.")})})},N.prototype.flash=function(t,n){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},N.prototype.getParent=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null]})})},N.prototype.setParent=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},N.prototype.getBounds=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,new v(this.innerWindow.screenX,this.innerWindow.screenY,this.innerWindow.outerWidth,this.innerWindow.outerHeight)]})})},N.prototype.setBounds=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.moveTo(n.x,n.y),this.innerWindow.resizeTo(n.width,n.height),[2]})})},N.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.innerWindow[p.windowOptionsPropertyKey]]})})},N.prototype.getState=function(){var n,e;return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null==(e=null==(n=this.nativeWindow)?void 0:n.getState)?void 0:e.call(n)]})})},N.prototype.setState=function(e){var i,o;return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return n=null==(o=null==(i=this.nativeWindow)?void 0:i.setState)?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(ot[t]||t,n)},N.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(ot[t]||t,n)},Object.defineProperty(N.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),N);function N(){return null!==T&&T.apply(this,arguments)||this}M.DefaultContainerWindow=rt,G.prototype.subscribe=function(o,r,t){var e,s;return w(this,void 0,void 0,function(){var n,i=this;return y(this,function(t){return n=new U(o,function(t){var n,e;t.origin===i.container.globalWindow.location.origin&&(n=(t=t.data).source,e=t.topic,t=t.message,n===G.messageSource)&&o===e&&r({topic:o},t)}),null!=(s=null==(e=this.container.globalWindow)?void 0:e.addEventListener)&&s.call(e,"message",n.listener),[2,n]})})},G.prototype.unsubscribe=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.container.globalWindow.removeEventListener("message",n.listener)]})})},G.prototype.publish=function(r,s,a){var u;return w(this,void 0,void 0,function(){var n,e,i,o;return y(this,function(t){if(n=this.container.globalWindow?this.container.globalWindow[k.windowsPropertyKey]||(null==(u=this.container.globalWindow.opener)?void 0:u[k.windowsPropertyKey]):[])for(e in n)i=n[e],null!=a&&a.name&&a.name!==i[k.windowNamePropertyKey]||(o=(null==a?void 0:a.targetOrigin)||this.container.globalWindow.location.origin,i.postMessage({source:G.messageSource,topic:r,message:s},o));return[2]})})},G.messageSource="desktopJS";var st=G;function G(t){this.container=t}M.DefaultMessageBus=st,t(A,at=J),A.prototype.createMessageBus=function(){return new st(this)},A.prototype.setOptions=function(t){},A.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{}]})})},A.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.globalWindow.navigator.appVersion]})})},A.prototype.getMainWindow=function(){var t;return this.mainWindow||(t=this.globalWindow[A.windowsPropertyKey].root,this.mainWindow=t?this.wrapWindow(t):null),this.mainWindow},A.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},A.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},A.prototype.wrapWindow=function(t){return new rt(t)},A.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);if(i){var o=a.newGuid();try{var r=this.globalWindow[A.windowsPropertyKey];(r[o]=i)[A.windowUuidPropertyKey]=o,i.addEventListener("beforeunload",function(){i.addEventListener("unload",function(){delete r[o]})}),i[A.windowsPropertyKey]=r}catch(t){this.log("warn","Error tracking new window, '".concat(t.message,"'"))}p.emit("window-created",{name:"window-created",windowId:o}),P.emit("window-created",{name:"window-created",windowId:o})}return i},A.prototype.createWindow=function(s,a){return w(this,void 0,void 0,function(){var n,e,i,o,r;return y(this,function(t){if(r="_blank",e=this.getWindowOptions(a)){for(i in e)n=(n||"")+i+"="+e[i]+",";e&&"target"in e&&(r=e.target)}r=this.globalWindow.open(s,r,n),o=!0;try{r[p.windowOptionsPropertyKey]=a,r[A.windowNamePropertyKey]=e.name}catch(t){o=!1,this.log("warn","Error propagating properties to new window, '".concat(t.message,"'"))}return r=this.wrapWindow(r),this.emit("window-created",{sender:this,name:"window-created",window:r,windowId:o?r.id:void 0,windowName:e.name}),[2,r]})})},A.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")},A.prototype.closeAllWindows=function(o){return void 0===o&&(o=!1),w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])i=n[e],o&&this.globalWindow===i||i.close();return[2]})})},A.prototype.getAllWindows=function(){return w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(i in n=[],e=this.globalWindow[A.windowsPropertyKey])n.push(this.wrapWindow(e[i]));return[2,n]})})},A.prototype.getWindowById=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return[2,(n=this.globalWindow[A.windowsPropertyKey][e])?this.wrapWindow(n):null]})})},A.prototype.getWindowByName=function(i){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])if(n[e][A.windowNamePropertyKey]===i)return[2,this.wrapWindow(n[e])];return[2,null]})})},A.prototype.buildLayout=function(){return w(this,void 0,void 0,function(){var a,n,e=this;return y(this,function(t){switch(t.label){case 0:return a=new $,n=[],[4,this.getAllWindows()];case 1:return t.sent().forEach(function(o){var r=o.nativeWindow;try{var s=r[p.windowOptionsPropertyKey];s&&"persist"in s&&!s.persist||n.push(w(e,void 0,void 0,function(){var n,e,i;return y(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, '".concat(t.message,"'"))}}),[4,Promise.all(n)];case 2:return t.sent(),[2,a]}})})},A.windowsPropertyKey="desktopJS-windows",A.windowUuidPropertyKey="desktopJS-uuid",A.windowNamePropertyKey="desktopJS-name",A.rootWindowUuid="root",A.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}};var at,k=A;function A(t){t=at.call(this,t)||this;return t.windowOptionsMap=A.defaultWindowOptionsMap,t.hostType="Default",t.ipc=t.createMessageBus(),!t.globalWindow||A.windowsPropertyKey in t.globalWindow||(t.globalWindow[A.windowsPropertyKey]={root:t.globalWindow},t.globalWindow[A.windowNamePropertyKey]=t.globalWindow[A.windowUuidPropertyKey]=A.rootWindowUuid),t.screen=new ut(t.globalWindow),t}M.DefaultContainer=k,K.prototype.getPrimaryDisplay=function(){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return(n=new it).scaleFactor=this.window.devicePixelRatio,n.id="Current",n.bounds=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.width,this.window.screen.height),n.workArea=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.availWidth,this.window.screen.availHeight),[2,n]})})},K.prototype.getAllDisplays=function(){return w(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.getPrimaryDisplay()];case 1:return[2,[t.sent()]]}})})},K.prototype.getMousePosition=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{x:this.window.event.screenX,y:this.window.event.screenY}]})})};var ut=K;function K(t){this.window=t}function ct(){}var j=[];u.container=void 0;function dt(){}function pt(){}u.Container=p,u.ContainerBase=C,u.ContainerNotification=R,u.ContainerRegistration=ct,u.ContainerWindow=P,u.Display=it,u.EventArgs=r,u.EventEmitter=e,u.GlobalShortcutManager=pt,u.GroupWindowManager=L,u.Guid=a,u.LayoutEventArgs=I,u.MenuItem=_,u.MessageBusOptions=z,u.MessageBusSubscription=U,u.NotificationOptions=F,u.PersistedWindow=Z,u.PersistedWindowLayout=$,u.Point=et,u.PropertyMap=V,u.Rectangle=v,u.SnapAssistWindowManager=nt,u.TrayIconDetails=dt,u.WebContainerBase=J,u.WindowEventArgs=q,u.WindowGroupEventArgs=Y,u.clearRegistry=function(){j.splice(0,j.length),u.container=void 0},u.registerContainer=function(t,n){j.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e=!1,i=n;if("boolean"==typeof t?e=t:i=t,e||!u.container)try{for(var o=0;o<j.length;o++)var r=j[o].id,s=j[o].registration,a=s.condition(i)?s:a;u.container=a?a.create(i):void 0}catch(t){console.error("Error resolving container '".concat(r,"' : ").concat(t.toString()))}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="4.0.0"}); | ||
//# sourceMappingURL=desktop.min.js.map |
@@ -9,3 +9,3 @@ import { ContainerWindowManager, ContainerWindow, PersistedWindowLayout, WindowEventArgs } from "./window"; | ||
import { GlobalShortcutManager } from "./shortcut"; | ||
export declare type ContainerEventType = "window-created" | "layout-loaded" | "layout-saved" | "layout-deleted"; | ||
export type ContainerEventType = "window-created" | "layout-loaded" | "layout-saved" | "layout-deleted"; | ||
export declare class LayoutEventArgs extends EventArgs { | ||
@@ -15,3 +15,3 @@ readonly layout?: PersistedWindowLayout; | ||
} | ||
export declare type ContainerEventArgs = EventArgs | WindowEventArgs | LayoutEventArgs; | ||
export type ContainerEventArgs = EventArgs | WindowEventArgs | LayoutEventArgs; | ||
export declare abstract class Container extends EventEmitter implements ContainerWindowManager, ContainerNotificationManager { | ||
@@ -18,0 +18,0 @@ private static readonly staticEventScopePrefix; |
@@ -1,2 +0,2 @@ | ||
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)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function w(t,s,a,u){return new(a=a||Promise)(function(e,n){function i(t){try{r(u.next(t))}catch(t){n(t)}}function o(t){try{r(u.throw(t))}catch(t){n(t)}}function r(t){var n;t.done?e(t.value):((n=t.value)instanceof a?n:new a(function(t){t(n)})).then(i,o)}r((u=u.apply(t,s||[])).next())})}function y(i,o){var r,s,a,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(e){return function(t){var n=[e,t];if(r)throw new TypeError("Generator is already executing.");for(;u=c&&n[c=0]?0:u;)try{if(r=1,s&&(a=2&n[0]?s.return:n[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,n[1])).done)return a;switch(s=0,(n=a?[2&n[0],a.value]:n)[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,s=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(!(a=0<(a=u.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){u.label=n[1];break}if(6===n[0]&&u.label<a[1]){u.label=a[1],a=n;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(n);break}a[2]&&u.ops.pop(),u.trys.pop();continue}n=o.call(i,u)}catch(t){n=[6,t],s=0}finally{r=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}}}var r=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},e=(s.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},s.prototype.registerAndWrapListener=function(t,n){t=this.wrapListener(t,n);return this.wrappedListeners.set(n,t),t},s.prototype.wrapListener=function(e,i){var o=this;return function(t){var t=new r(o,e,t),n=(o.preProcessArgs(t),i(t));return o.postProcessArgs(t),n}},s.prototype.preProcessArgs=function(t){},s.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},s.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},s.prototype.removeListener=function(t,n){t=this.listeners(t);return t&&0<=(n=t.indexOf(n))&&t.splice(n,1),this},s.prototype.listeners=function(t){return this.eventListeners[t]||[]},s.prototype.emit=function(t,n){for(var e=0,i=this.listeners(t);e<i.length;e++)(0,i[e])(n)},Object.defineProperty(s,"ipc",{set:function(t){t&&t.subscribe(s.staticEventName,function(t,n){s.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),s.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},s.removeListener=function(t,n){t=s.listeners(t);t&&0<=(n=t.indexOf(n))&&t.splice(n,1)},s.listeners=function(t){return this.staticEventListeners[t]||[]},s.emit=function(t,n,e){if(e&&e.publish)e.publish(s.staticEventName,{eventName:t,eventArgs:n});else for(var i=0,o=s.listeners(t);i<o.length;i++)(0,o[i])(n)},s.staticEventListeners=new Map,s.staticEventName="desktopJS.static-event",s);function s(){this.eventListeners=new Map,this.wrappedListeners=new Map}B.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)})};var a=B;function B(){}t(H,n=r);var n,I=H;function H(){return null!==n&&n.apply(this,arguments)||this}t(c,o=e),c.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,void 0]})})},c.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(c,"ipc",{get:function(){return c._ipc},set:function(t){e.ipc=c._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"ipc",{get:function(){return c.ipc},set:function(t){c.ipc=t},enumerable:!1,configurable:!0}),c.prototype.addListener=function(t,n){return o.prototype.addListener.call(this,t,n)},c.prototype.removeListener=function(t,n){return o.prototype.removeListener.call(this,t,n)},c.prototype.emit=function(t,n){o.prototype.emit.call(this,t,n)},c.addListener=function(t,n){e.addListener(c.staticEventScopePrefix+t,n)},c.removeListener=function(t,n){e.removeListener(c.staticEventScopePrefix+t,n)},c.emit=function(t,n){e.emit(c.staticEventScopePrefix+t,n,c.ipc)},c.listeners=function(t){return e.listeners(c.staticEventScopePrefix+t)},c.staticEventScopePrefix="container-",c.windowOptionsPropertyKey="desktopJS-options";var o,p=c;function c(){return null!==o&&o.apply(this,arguments)||this}t(h,d=p),h.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},h.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},h.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(h.layoutsPropertyKey))[t]},h.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(h.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})},h.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(h.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}))},h.prototype.loadLayout=function(d){return w(this,void 0,void 0,function(){var o,n,e,i,r,s,a,u,c=this;return y(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)||!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}),i=(t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)}),!1);u.forEach(function(t,n){!i&&0<=t.indexOf(e.id)&&(i=!0)}),i||(t=t?t.group:void 0)&&0<t.length&&u.set(e,t.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")}})})},h.prototype.saveLayout=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return[4,this.buildLayout()];case 1:return n=t.sent(),this.saveLayoutToStorage(e,n),[2,n]}})})},h.prototype.deleteLayout=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.deleteLayoutFromStorage(n)]})})},h.prototype.getLayouts=function(){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){return(n=this.storage.getItem(h.layoutsPropertyKey))?(e=JSON.parse(n),[2,Object.getOwnPropertyNames(e).map(function(t){return e[t]})]):[2]})})},h.prototype.log=function(e,i){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(e){case"debug":case"warn":case"error":n=console[e];break;default:n=console.log}return n&&n(i),[2]})})},h.layoutsPropertyKey="desktopJS-layouts";var d,C=h;function h(){var t=null!==d&&d.apply(this,arguments)||this;return t.uuid=a.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}t(l,D=C),l.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},l.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t};var D,J=l;function l(t){var e,i=D.call(this)||this;i.globalWindow=t||"undefined"!=typeof window&&window||null,i.linkHelper={href:"unknown"};try{i.linkHelper=i.globalWindow.top.document.createElement("a")}catch(t){}return i.globalWindow&&(e=i.globalWindow.open,i.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i.onOpen.apply(i,function(t,n,e){if(e||2===arguments.length)for(var i,o=0,r=n.length;o<r;o++)!i&&o in n||((i=i||Array.prototype.slice.call(n,0,o))[o]=n[o]);return t.concat(i||Array.prototype.slice.call(n))}([e],t,!1))}),i}function _(){}function z(){}function F(){}var U=function(t,n,e){this.topic=t,this.listener=n,this.options=e},R=(f.requestPermission=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return n&&n(f.permission),[2,f.permission]})})},f.permission="granted",f);function f(t,n){this.title=t,this.options=n}function V(){}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},Object.defineProperty(g.prototype,"right",{get:function(){return g.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"bottom",{get:function(){return g.getBottom(this)},enumerable:!1,configurable:!0}),g.getRight=function(t){return t.x+t.width},g.getBottom=function(t){return t.y+t.height};var v=g;function g(t,n,e,i){this.x=t,this.y=n,this.width=e,this.height=i}t(X,m=r);var m,q=X;function X(){return null!==m&&m.apply(this,arguments)||this}t(Q,b=q);var b,Y=Q;function Q(){return null!==b&&b.apply(this,arguments)||this}t(x,W=e),Object.defineProperty(x.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),x.prototype.getGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,[]]})})},x.prototype.joinGroup=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},x.prototype.leaveGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.bringToFront=function(){return this.focus()},x.prototype.getState=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.setState=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},Object.defineProperty(x.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),x.prototype.addListener=function(t,n){n=this.registerAndWrapListener(t,n);return this.attachListener(t,n),W.prototype.addListener.call(this,t,n)},x.prototype.removeListener=function(t,n){n=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,n),W.prototype.removeListener.call(this,t,n)},x.addListener=function(t,n){e.addListener(x.staticEventScopePrefix+t,n)},x.removeListener=function(t,n){e.removeListener(x.staticEventScopePrefix+t,n)},x.emit=function(t,n){e.emit(x.staticEventScopePrefix+t,n,p.ipc)},x.listeners=function(t){return e.listeners(x.staticEventScopePrefix+t)},x.staticEventScopePrefix="containerwindow-";var W,P=x;function x(t){var n=W.call(this)||this;return n.innerWindow=t,n}function Z(){}var $=function(t){this.windows=[],this.name=t};function S(){return"undefined"!=typeof window&&window.fin}u.WindowStateTracking=void 0,(L=u.WindowStateTracking||(u.WindowStateTracking={}))[L.None=0]="None",L[L.Main=1]="Main",L[L.Group=2]="Group";tt.prototype.attach=function(t){var i=this;t?(t.addListener(S()?"minimized":"minimize",function(n){return w(i,void 0,void 0,function(){return y(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(S()?"restored":"restore",function(n){return w(i,void 0,void 0,function(){return y(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 w(i,void 0,void 0,function(){var n;return y(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)})}))};var L=tt;function tt(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}t(E,O=L),E.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)})},E.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)}))})},E.prototype.onMoving=function(f){return w(this,void 0,void 0,function(){var n,e,i,o,r,s,a,u,c,d,p,h,l=this;return y(this,function(t){switch(t.label){case 0:return(n=f.sender.id,this.snappingWindow===n)?[2]:[4,(e=f.sender).getOptions()];case 1:return(s=t.sent())&&void 0!==s.snap&&!1===s.snap?[2]:[4,e.getGroup()];case 2:return(i=t.sent(),S())?(r=new v(f.innerEvent.left,f.innerEvent.top,f.innerEvent.width,f.innerEvent.height),[3,5]):[3,3];case 3:return[4,e.getBounds()];case 4:r=t.sent(),t.label=5;case 5:return o=r,0<i.length?(S()&&this.moveWindow(e,o),[2]):[4,this.container.getAllWindows()];case 6:return s=t.sent(),a=s.filter(function(t){return n!==t.id}).map(function(e){return w(l,void 0,void 0,function(){var n;return y(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(a)];case 7:for(a=t.sent(),u=!1,d=0,p=a.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});d<p.length;d++)h=p[d],(c=this.getSnapBounds(c||o,h.bounds))?(u=!0,this.showGroupingHint(h.window),this.moveWindow(f.sender,c)):this.hideGroupingHint(h.window);return!u&&S()&&this.moveWindow(f.sender,o),[2]}})})},E.prototype.moveWindow=function(n,e){return w(this,void 0,void 0,function(){return y(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]}})})},E.prototype.onMoved=function(e){var t,n=this;this.autoGrouping&&(t=Array.from(this.targetGroup,function(t){t[0];var e=t[1];return w(n,void 0,void 0,function(){var n;return y(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()},E.prototype.showGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:.75}),this.targetGroup.set(t.id,t)},E.prototype.hideGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:1}),this.targetGroup.delete(t.id)},E.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},E.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},E.prototype.getSnapBounds=function(t,n){var e,i,o,r,s,a,u,c,d,p;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)return d=t.x,p=t.y,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 v(d,p,t.width,t.height)};var O,nt=E;function E(t,n){t=O.call(this,t,n)||this;return t.autoGrouping=!0,t.snapThreshold=15,t.snapOffset=15,t.targetGroup=new Map,n&&("snapThreshold"in n&&(t.snapThreshold=n.snapThreshold),"snapOffset"in n&&(t.snapOffset=n.snapOffset),"autoGrouping"in n&&(t.autoGrouping=n.autoGrouping)),t}function et(){}var M,it=function(){},T=(u.Default=void 0,u.Default||(u.Default={})),ot={close:"unload"},rt=(t(k,M=P),Object.defineProperty(k.prototype,"id",{get:function(){return this.innerWindow[G.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"name",{get:function(){return this.innerWindow[G.windowNamePropertyKey]},enumerable:!1,configurable:!0}),k.prototype.load=function(n,t){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.location.replace(n),[2]})})},k.prototype.focus=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.focus(),[2]})})},k.prototype.show=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},k.prototype.hide=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},k.prototype.close=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.close(),[2]})})},k.prototype.minimize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.minimize(),[2]})})},k.prototype.maximize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.maximize(),[2]})})},k.prototype.restore=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.restore(),[2]})})},k.prototype.isShowing=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,!0]})})},k.prototype.getSnapshot=function(){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("getSnapshot requires an implementation.")})})},k.prototype.flash=function(t,n){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},k.prototype.getParent=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null]})})},k.prototype.setParent=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},k.prototype.getBounds=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,new v(this.innerWindow.screenX,this.innerWindow.screenY,this.innerWindow.outerWidth,this.innerWindow.outerHeight)]})})},k.prototype.setBounds=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.moveTo(n.x,n.y),this.innerWindow.resizeTo(n.width,n.height),[2]})})},k.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.innerWindow[p.windowOptionsPropertyKey]]})})},k.prototype.getState=function(){var n,e;return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null==(e=null==(n=this.nativeWindow)?void 0:n.getState)?void 0:e.call(n)]})})},k.prototype.setState=function(e){var i,o;return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return n=null==(o=null==(i=this.nativeWindow)?void 0:i.setState)?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]}})})},k.prototype.attachListener=function(t,n){this.innerWindow.addEventListener(ot[t]||t,n)},k.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(ot[t]||t,n)},Object.defineProperty(k.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),k);function k(){return null!==M&&M.apply(this,arguments)||this}T.DefaultContainerWindow=rt,N.prototype.subscribe=function(o,r,t){var e,s;return w(this,void 0,void 0,function(){var n,i=this;return y(this,function(t){return n=new U(o,function(t){var n,e;t.origin===i.container.globalWindow.location.origin&&(n=(t=t.data).source,e=t.topic,t=t.message,n===N.messageSource&&o===e&&r({topic:o},t))}),null!=(s=null==(e=this.container.globalWindow)?void 0:e.addEventListener)&&s.call(e,"message",n.listener),[2,n]})})},N.prototype.unsubscribe=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.container.globalWindow.removeEventListener("message",n.listener)]})})},N.prototype.publish=function(r,s,a){var u;return w(this,void 0,void 0,function(){var n,e,i,o;return y(this,function(t){if(n=this.container.globalWindow?this.container.globalWindow[G.windowsPropertyKey]||(null==(u=this.container.globalWindow.opener)?void 0:u[G.windowsPropertyKey]):[])for(e in n)i=n[e],null!=a&&a.name&&a.name!==i[G.windowNamePropertyKey]||(o=(null==a?void 0:a.targetOrigin)||this.container.globalWindow.location.origin,i.postMessage({source:N.messageSource,topic:r,message:s},o));return[2]})})},N.messageSource="desktopJS";var st=N;function N(t){this.container=t}T.DefaultMessageBus=st,t(A,at=J),A.prototype.createMessageBus=function(){return new st(this)},A.prototype.setOptions=function(t){},A.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{}]})})},A.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.globalWindow.navigator.appVersion]})})},A.prototype.getMainWindow=function(){var t;return this.mainWindow||(t=this.globalWindow[A.windowsPropertyKey].root,this.mainWindow=t?this.wrapWindow(t):null),this.mainWindow},A.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},A.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},A.prototype.wrapWindow=function(t){return new rt(t)},A.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);if(i){var o=a.newGuid();try{var r=this.globalWindow[A.windowsPropertyKey];(r[o]=i)[A.windowUuidPropertyKey]=o,i.addEventListener("beforeunload",function(){i.addEventListener("unload",function(){delete r[o]})}),i[A.windowsPropertyKey]=r}catch(t){this.log("warn","Error tracking new window, '".concat(t.message,"'"))}p.emit("window-created",{name:"window-created",windowId:o}),P.emit("window-created",{name:"window-created",windowId:o})}return i},A.prototype.createWindow=function(s,a){return w(this,void 0,void 0,function(){var n,e,i,o,r;return y(this,function(t){if(r="_blank",e=this.getWindowOptions(a)){for(i in e)n=(n||"")+i+"="+e[i]+",";e&&"target"in e&&(r=e.target)}r=this.globalWindow.open(s,r,n),o=!0;try{r[p.windowOptionsPropertyKey]=a,r[A.windowNamePropertyKey]=e.name}catch(t){o=!1,this.log("warn","Error propagating properties to new window, '".concat(t.message,"'"))}return r=this.wrapWindow(r),this.emit("window-created",{sender:this,name:"window-created",window:r,windowId:o?r.id:void 0,windowName:e.name}),[2,r]})})},A.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")},A.prototype.closeAllWindows=function(o){return void 0===o&&(o=!1),w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])i=n[e],o&&this.globalWindow===i||i.close();return[2]})})},A.prototype.getAllWindows=function(){return w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(i in n=[],e=this.globalWindow[A.windowsPropertyKey])n.push(this.wrapWindow(e[i]));return[2,n]})})},A.prototype.getWindowById=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return[2,(n=this.globalWindow[A.windowsPropertyKey][e])?this.wrapWindow(n):null]})})},A.prototype.getWindowByName=function(i){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])if(n[e][A.windowNamePropertyKey]===i)return[2,this.wrapWindow(n[e])];return[2,null]})})},A.prototype.buildLayout=function(){return w(this,void 0,void 0,function(){var a,n,e=this;return y(this,function(t){switch(t.label){case 0:return a=new $,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(w(e,void 0,void 0,function(){var n,e,i;return y(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, '".concat(t.message,"'"))}}),[4,Promise.all(n)];case 2:return t.sent(),[2,a]}})})},A.windowsPropertyKey="desktopJS-windows",A.windowUuidPropertyKey="desktopJS-uuid",A.windowNamePropertyKey="desktopJS-name",A.rootWindowUuid="root",A.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}};var at,G=A;function A(t){t=at.call(this,t)||this;return t.windowOptionsMap=A.defaultWindowOptionsMap,t.hostType="Default",t.ipc=t.createMessageBus(),!t.globalWindow||A.windowsPropertyKey in t.globalWindow||(t.globalWindow[A.windowsPropertyKey]={root:t.globalWindow},t.globalWindow[A.windowNamePropertyKey]=t.globalWindow[A.windowUuidPropertyKey]=A.rootWindowUuid),t.screen=new ut(t.globalWindow),t}T.DefaultContainer=G,K.prototype.getPrimaryDisplay=function(){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return(n=new it).scaleFactor=this.window.devicePixelRatio,n.id="Current",n.bounds=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.width,this.window.screen.height),n.workArea=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.availWidth,this.window.screen.availHeight),[2,n]})})},K.prototype.getAllDisplays=function(){return w(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.getPrimaryDisplay()];case 1:return[2,[t.sent()]]}})})},K.prototype.getMousePosition=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{x:this.window.event.screenX,y:this.window.event.screenY}]})})};var ut=K;function K(t){this.window=t}function ct(){}var j=[];u.container=void 0;function dt(){}function pt(){}return u.Container=p,u.ContainerBase=C,u.ContainerNotification=R,u.ContainerRegistration=ct,u.ContainerWindow=P,u.Display=it,u.EventArgs=r,u.EventEmitter=e,u.GlobalShortcutManager=pt,u.GroupWindowManager=L,u.Guid=a,u.LayoutEventArgs=I,u.MenuItem=z,u.MessageBusOptions=_,u.MessageBusSubscription=U,u.NotificationOptions=F,u.PersistedWindow=Z,u.PersistedWindowLayout=$,u.Point=et,u.PropertyMap=V,u.Rectangle=v,u.SnapAssistWindowManager=nt,u.TrayIconDetails=dt,u.WebContainerBase=J,u.WindowEventArgs=q,u.WindowGroupEventArgs=Y,u.clearRegistry=function(){j.splice(0,j.length),u.container=void 0},u.registerContainer=function(t,n){j.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e=!1,i=n;if("boolean"==typeof t?e=t:i=t,e||!u.container)try{for(var o=0;o<j.length;o++)var r=j[o].id,s=j[o].registration,a=s.condition(i)?s:a;u.container=a?a.create(i):void 0}catch(t){console.error("Error resolving container '".concat(r,"' : ").concat(t.toString()))}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="3.13.1",Object.defineProperty(u,"__esModule",{value:!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)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}))(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}i(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function w(t,s,a,u){return new(a=a||Promise)(function(e,n){function i(t){try{r(u.next(t))}catch(t){n(t)}}function o(t){try{r(u.throw(t))}catch(t){n(t)}}function r(t){var n;t.done?e(t.value):((n=t.value)instanceof a?n:new a(function(t){t(n)})).then(i,o)}r((u=u.apply(t,s||[])).next())})}function y(i,o){var r,s,a,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(e){return function(t){var n=[e,t];if(r)throw new TypeError("Generator is already executing.");for(;u=c&&n[c=0]?0:u;)try{if(r=1,s&&(a=2&n[0]?s.return:n[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,n[1])).done)return a;switch(s=0,(n=a?[2&n[0],a.value]:n)[0]){case 0:case 1:a=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,s=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(!(a=0<(a=u.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3]))u.label=n[1];else if(6===n[0]&&u.label<a[1])u.label=a[1],a=n;else{if(!(a&&u.label<a[2])){a[2]&&u.ops.pop(),u.trys.pop();continue}u.label=a[2],u.ops.push(n)}}n=o.call(i,u)}catch(t){n=[6,t],s=0}finally{r=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}}}var r=function(t,n,e){this.sender=t,this.name=n,this.innerEvent=e},e=(s.prototype.addListener=function(t,n){return(this.eventListeners[t]=this.eventListeners[t]||[]).push(n),this},s.prototype.registerAndWrapListener=function(t,n){t=this.wrapListener(t,n);return this.wrappedListeners.set(n,t),t},s.prototype.wrapListener=function(e,i){var o=this;return function(t){var t=new r(o,e,t),n=(o.preProcessArgs(t),i(t));return o.postProcessArgs(t),n}},s.prototype.preProcessArgs=function(t){},s.prototype.postProcessArgs=function(t){t&&void 0!==t.returnValue&&(t.innerEvent.returnValue=t.returnValue)},s.prototype.unwrapAndUnRegisterListener=function(t){var n=this.wrappedListeners.get(t);return n&&this.wrappedListeners.delete(t),n},s.prototype.removeListener=function(t,n){t=this.listeners(t);return t&&0<=(n=t.indexOf(n))&&t.splice(n,1),this},s.prototype.listeners=function(t){return this.eventListeners[t]||[]},s.prototype.emit=function(t,n){for(var e=0,i=this.listeners(t);e<i.length;e++)(0,i[e])(n)},Object.defineProperty(s,"ipc",{set:function(t){t&&t.subscribe(s.staticEventName,function(t,n){s.emit(n.eventName,n.eventArgs)})},enumerable:!1,configurable:!0}),s.addListener=function(t,n){(this.staticEventListeners[t]=this.staticEventListeners[t]||[]).push(n)},s.removeListener=function(t,n){t=s.listeners(t);t&&0<=(n=t.indexOf(n))&&t.splice(n,1)},s.listeners=function(t){return this.staticEventListeners[t]||[]},s.emit=function(t,n,e){if(e&&e.publish)e.publish(s.staticEventName,{eventName:t,eventArgs:n});else for(var i=0,o=s.listeners(t);i<o.length;i++)(0,o[i])(n)},s.staticEventListeners=new Map,s.staticEventName="desktopJS.static-event",s);function s(){this.eventListeners=new Map,this.wrappedListeners=new Map}B.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)})};var a=B;function B(){}t(H,n=r);var n,I=H;function H(){return null!==n&&n.apply(this,arguments)||this}t(c,o=e),c.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,void 0]})})},c.prototype.ready=function(){return Promise.resolve()},Object.defineProperty(c,"ipc",{get:function(){return c._ipc},set:function(t){e.ipc=c._ipc=t},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"ipc",{get:function(){return c.ipc},set:function(t){c.ipc=t},enumerable:!1,configurable:!0}),c.prototype.addListener=function(t,n){return o.prototype.addListener.call(this,t,n)},c.prototype.removeListener=function(t,n){return o.prototype.removeListener.call(this,t,n)},c.prototype.emit=function(t,n){o.prototype.emit.call(this,t,n)},c.addListener=function(t,n){e.addListener(c.staticEventScopePrefix+t,n)},c.removeListener=function(t,n){e.removeListener(c.staticEventScopePrefix+t,n)},c.emit=function(t,n){e.emit(c.staticEventScopePrefix+t,n,c.ipc)},c.listeners=function(t){return e.listeners(c.staticEventScopePrefix+t)},c.staticEventScopePrefix="container-",c.windowOptionsPropertyKey="desktopJS-options";var o,p=c;function c(){return null!==o&&o.apply(this,arguments)||this}t(h,d=p),h.prototype.showNotification=function(t,n){throw new TypeError("Notifications not supported by this container")},h.prototype.addTrayIcon=function(t,n,e){throw new TypeError("Tray icons are not supported by this container.")},h.prototype.getLayoutFromStorage=function(t){return JSON.parse(this.storage.getItem(h.layoutsPropertyKey))[t]},h.prototype.saveLayoutToStorage=function(t,n){var e=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{};n.name||(n.name=t),e[t]=n,this.storage.setItem(h.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})},h.prototype.deleteLayoutFromStorage=function(t){var n=JSON.parse(this.storage.getItem(h.layoutsPropertyKey))||{},e=n[t];e&&(delete n[t],this.storage.setItem(h.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}))},h.prototype.loadLayout=function(d){return w(this,void 0,void 0,function(){var o,n,e,i,r,s,a,u,c=this;return y(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)||!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}),i=(t&&t.state&&e.setState&&e.setState(t.state).catch(function(t){return c.log("error","Error invoking setState: "+t)}),!1);u.forEach(function(t,n){!i&&0<=t.indexOf(e.id)&&(i=!0)}),i||(t=t?t.group:void 0)&&0<t.length&&u.set(e,t.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")}})})},h.prototype.saveLayout=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return[4,this.buildLayout()];case 1:return n=t.sent(),this.saveLayoutToStorage(e,n),[2,n]}})})},h.prototype.deleteLayout=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.deleteLayoutFromStorage(n)]})})},h.prototype.getLayouts=function(){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){return(n=this.storage.getItem(h.layoutsPropertyKey))?(e=JSON.parse(n),[2,Object.getOwnPropertyNames(e).map(function(t){return e[t]})]):[2]})})},h.prototype.log=function(e,i){return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(e){case"debug":case"warn":case"error":n=console[e];break;default:n=console.log}return n&&n(i),[2]})})},h.layoutsPropertyKey="desktopJS-layouts";var d,C=h;function h(){var t=null!==d&&d.apply(this,arguments)||this;return t.uuid=a.newGuid(),t.storage="undefined"!=typeof window&&window?window.localStorage:void 0,t}t(l,D=C),l.prototype.onOpen=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return t.apply(this.globalWindow,n)},l.prototype.ensureAbsoluteUrl=function(t){return this.linkHelper?(this.linkHelper.href=t,this.linkHelper.href):t};var D,J=l;function l(t){var e,i=D.call(this)||this;i.globalWindow=t||"undefined"!=typeof window&&window||null,i.linkHelper={href:"unknown"};try{i.linkHelper=i.globalWindow.top.document.createElement("a")}catch(t){}return i.globalWindow&&(e=i.globalWindow.open,i.globalWindow.open=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i.onOpen.apply(i,function(t,n,e){if(e||2===arguments.length)for(var i,o=0,r=n.length;o<r;o++)!i&&o in n||((i=i||Array.prototype.slice.call(n,0,o))[o]=n[o]);return t.concat(i||Array.prototype.slice.call(n))}([e],t,!1))}),i}function z(){}function _(){}function F(){}var U=function(t,n,e){this.topic=t,this.listener=n,this.options=e},R=(f.requestPermission=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return n&&n(f.permission),[2,f.permission]})})},f.permission="granted",f);function f(t,n){this.title=t,this.options=n}function V(){}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},Object.defineProperty(g.prototype,"right",{get:function(){return g.getRight(this)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"bottom",{get:function(){return g.getBottom(this)},enumerable:!1,configurable:!0}),g.getRight=function(t){return t.x+t.width},g.getBottom=function(t){return t.y+t.height};var v=g;function g(t,n,e,i){this.x=t,this.y=n,this.width=e,this.height=i}t(X,m=r);var m,q=X;function X(){return null!==m&&m.apply(this,arguments)||this}t(Q,b=q);var b,Y=Q;function Q(){return null!==b&&b.apply(this,arguments)||this}t(x,W=e),Object.defineProperty(x.prototype,"allowGrouping",{get:function(){return!1},enumerable:!1,configurable:!0}),x.prototype.getGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,[]]})})},x.prototype.joinGroup=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},x.prototype.leaveGroup=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.bringToFront=function(){return this.focus()},x.prototype.getState=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},x.prototype.setState=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},Object.defineProperty(x.prototype,"nativeWindow",{get:function(){},enumerable:!1,configurable:!0}),x.prototype.addListener=function(t,n){n=this.registerAndWrapListener(t,n);return this.attachListener(t,n),W.prototype.addListener.call(this,t,n)},x.prototype.removeListener=function(t,n){n=this.unwrapAndUnRegisterListener(n)||n;return this.detachListener(t,n),W.prototype.removeListener.call(this,t,n)},x.addListener=function(t,n){e.addListener(x.staticEventScopePrefix+t,n)},x.removeListener=function(t,n){e.removeListener(x.staticEventScopePrefix+t,n)},x.emit=function(t,n){e.emit(x.staticEventScopePrefix+t,n,p.ipc)},x.listeners=function(t){return e.listeners(x.staticEventScopePrefix+t)},x.staticEventScopePrefix="containerwindow-";var W,P=x;function x(t){var n=W.call(this)||this;return n.innerWindow=t,n}function Z(){}var $=function(t){this.windows=[],this.name=t};function S(){return"undefined"!=typeof window&&window.fin}u.WindowStateTracking=void 0,(L=u.WindowStateTracking||(u.WindowStateTracking={}))[L.None=0]="None",L[L.Main=1]="Main",L[L.Group=2]="Group";tt.prototype.attach=function(t){var i=this;t?(t.addListener(S()?"minimized":"minimize",function(n){return w(i,void 0,void 0,function(){return y(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(S()?"restored":"restore",function(n){return w(i,void 0,void 0,function(){return y(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 w(i,void 0,void 0,function(){var n;return y(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)})}))};var L=tt;function tt(t,n){this.windowStateTracking=u.WindowStateTracking.None,this.container=t,n&&"windowStateTracking"in n&&(this.windowStateTracking=n.windowStateTracking),this.attach()}t(E,O=L),E.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)})},E.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)}))})},E.prototype.onMoving=function(f){return w(this,void 0,void 0,function(){var n,e,i,o,r,s,a,u,c,d,p,h,l=this;return y(this,function(t){switch(t.label){case 0:return(n=f.sender.id,this.snappingWindow===n)?[2]:[4,(e=f.sender).getOptions()];case 1:return(s=t.sent())&&void 0!==s.snap&&!1===s.snap?[2]:[4,e.getGroup()];case 2:return(i=t.sent(),S())?(r=new v(f.innerEvent.left,f.innerEvent.top,f.innerEvent.width,f.innerEvent.height),[3,5]):[3,3];case 3:return[4,e.getBounds()];case 4:r=t.sent(),t.label=5;case 5:return o=r,0<i.length?(S()&&this.moveWindow(e,o),[2]):[4,this.container.getAllWindows()];case 6:return s=t.sent(),a=s.filter(function(t){return n!==t.id}).map(function(e){return w(l,void 0,void 0,function(){var n;return y(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(a)];case 7:for(a=t.sent(),u=!1,d=0,p=a.filter(function(t){return!(t.options&&void 0!==t.options.snap&&!1===t.options.snap)});d<p.length;d++)h=p[d],(c=this.getSnapBounds(c||o,h.bounds))?(u=!0,this.showGroupingHint(h.window),this.moveWindow(f.sender,c)):this.hideGroupingHint(h.window);return!u&&S()&&this.moveWindow(f.sender,o),[2]}})})},E.prototype.moveWindow=function(n,e){return w(this,void 0,void 0,function(){return y(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]}})})},E.prototype.onMoved=function(e){var t,n=this;this.autoGrouping&&(t=Array.from(this.targetGroup,function(t){t[0];var e=t[1];return w(n,void 0,void 0,function(){var n;return y(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()},E.prototype.showGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:.75}),this.targetGroup.set(t.id,t)},E.prototype.hideGroupingHint=function(t){var n,e;null!=(e=null==(n=t.innerWindow)?void 0:n.updateOptions)&&e.call(n,{opacity:1}),this.targetGroup.delete(t.id)},E.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},E.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},E.prototype.getSnapBounds=function(t,n){var e,i,o,r,s,a,u,c,d,p;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)return d=t.x,p=t.y,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 v(d,p,t.width,t.height)};var O,nt=E;function E(t,n){t=O.call(this,t,n)||this;return t.autoGrouping=!0,t.snapThreshold=15,t.snapOffset=15,t.targetGroup=new Map,n&&("snapThreshold"in n&&(t.snapThreshold=n.snapThreshold),"snapOffset"in n&&(t.snapOffset=n.snapOffset),"autoGrouping"in n)&&(t.autoGrouping=n.autoGrouping),t}function et(){}var M,it=function(){},T=(u.Default=void 0,u.Default||(u.Default={})),ot={close:"unload"},rt=(t(N,M=P),Object.defineProperty(N.prototype,"id",{get:function(){return this.innerWindow[k.windowUuidPropertyKey]},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"name",{get:function(){return this.innerWindow[k.windowNamePropertyKey]},enumerable:!1,configurable:!0}),N.prototype.load=function(n,t){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.location.replace(n),[2]})})},N.prototype.focus=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.focus(),[2]})})},N.prototype.show=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},N.prototype.hide=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},N.prototype.close=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.close(),[2]})})},N.prototype.minimize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.minimize(),[2]})})},N.prototype.maximize=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.maximize(),[2]})})},N.prototype.restore=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.restore(),[2]})})},N.prototype.isShowing=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,!0]})})},N.prototype.getSnapshot=function(){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("getSnapshot requires an implementation.")})})},N.prototype.flash=function(t,n){return w(this,void 0,void 0,function(){return y(this,function(t){throw new Error("Not supported")})})},N.prototype.getParent=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null]})})},N.prototype.setParent=function(t){return w(this,void 0,void 0,function(){return y(this,function(t){return[2]})})},N.prototype.getBounds=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,new v(this.innerWindow.screenX,this.innerWindow.screenY,this.innerWindow.outerWidth,this.innerWindow.outerHeight)]})})},N.prototype.setBounds=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return this.innerWindow.moveTo(n.x,n.y),this.innerWindow.resizeTo(n.width,n.height),[2]})})},N.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.innerWindow[p.windowOptionsPropertyKey]]})})},N.prototype.getState=function(){var n,e;return w(this,void 0,void 0,function(){return y(this,function(t){return[2,null==(e=null==(n=this.nativeWindow)?void 0:n.getState)?void 0:e.call(n)]})})},N.prototype.setState=function(e){var i,o;return w(this,void 0,void 0,function(){var n;return y(this,function(t){switch(t.label){case 0:return n=null==(o=null==(i=this.nativeWindow)?void 0:i.setState)?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(ot[t]||t,n)},N.prototype.detachListener=function(t,n){this.innerWindow.removeEventListener(ot[t]||t,n)},Object.defineProperty(N.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!1,configurable:!0}),N);function N(){return null!==M&&M.apply(this,arguments)||this}T.DefaultContainerWindow=rt,G.prototype.subscribe=function(o,r,t){var e,s;return w(this,void 0,void 0,function(){var n,i=this;return y(this,function(t){return n=new U(o,function(t){var n,e;t.origin===i.container.globalWindow.location.origin&&(n=(t=t.data).source,e=t.topic,t=t.message,n===G.messageSource)&&o===e&&r({topic:o},t)}),null!=(s=null==(e=this.container.globalWindow)?void 0:e.addEventListener)&&s.call(e,"message",n.listener),[2,n]})})},G.prototype.unsubscribe=function(n){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.container.globalWindow.removeEventListener("message",n.listener)]})})},G.prototype.publish=function(r,s,a){var u;return w(this,void 0,void 0,function(){var n,e,i,o;return y(this,function(t){if(n=this.container.globalWindow?this.container.globalWindow[k.windowsPropertyKey]||(null==(u=this.container.globalWindow.opener)?void 0:u[k.windowsPropertyKey]):[])for(e in n)i=n[e],null!=a&&a.name&&a.name!==i[k.windowNamePropertyKey]||(o=(null==a?void 0:a.targetOrigin)||this.container.globalWindow.location.origin,i.postMessage({source:G.messageSource,topic:r,message:s},o));return[2]})})},G.messageSource="desktopJS";var st=G;function G(t){this.container=t}T.DefaultMessageBus=st,t(A,at=J),A.prototype.createMessageBus=function(){return new st(this)},A.prototype.setOptions=function(t){},A.prototype.getOptions=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{}]})})},A.prototype.getInfo=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,this.globalWindow.navigator.appVersion]})})},A.prototype.getMainWindow=function(){var t;return this.mainWindow||(t=this.globalWindow[A.windowsPropertyKey].root,this.mainWindow=t?this.wrapWindow(t):null),this.mainWindow},A.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},A.prototype.getWindowOptions=function(t){return u.ObjectTransform.transformProperties(t,this.windowOptionsMap)},A.prototype.wrapWindow=function(t){return new rt(t)},A.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);if(i){var o=a.newGuid();try{var r=this.globalWindow[A.windowsPropertyKey];(r[o]=i)[A.windowUuidPropertyKey]=o,i.addEventListener("beforeunload",function(){i.addEventListener("unload",function(){delete r[o]})}),i[A.windowsPropertyKey]=r}catch(t){this.log("warn","Error tracking new window, '".concat(t.message,"'"))}p.emit("window-created",{name:"window-created",windowId:o}),P.emit("window-created",{name:"window-created",windowId:o})}return i},A.prototype.createWindow=function(s,a){return w(this,void 0,void 0,function(){var n,e,i,o,r;return y(this,function(t){if(r="_blank",e=this.getWindowOptions(a)){for(i in e)n=(n||"")+i+"="+e[i]+",";e&&"target"in e&&(r=e.target)}r=this.globalWindow.open(s,r,n),o=!0;try{r[p.windowOptionsPropertyKey]=a,r[A.windowNamePropertyKey]=e.name}catch(t){o=!1,this.log("warn","Error propagating properties to new window, '".concat(t.message,"'"))}return r=this.wrapWindow(r),this.emit("window-created",{sender:this,name:"window-created",window:r,windowId:o?r.id:void 0,windowName:e.name}),[2,r]})})},A.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")},A.prototype.closeAllWindows=function(o){return void 0===o&&(o=!1),w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])i=n[e],o&&this.globalWindow===i||i.close();return[2]})})},A.prototype.getAllWindows=function(){return w(this,void 0,void 0,function(){var n,e,i;return y(this,function(t){for(i in n=[],e=this.globalWindow[A.windowsPropertyKey])n.push(this.wrapWindow(e[i]));return[2,n]})})},A.prototype.getWindowById=function(e){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return[2,(n=this.globalWindow[A.windowsPropertyKey][e])?this.wrapWindow(n):null]})})},A.prototype.getWindowByName=function(i){return w(this,void 0,void 0,function(){var n,e;return y(this,function(t){for(e in n=this.globalWindow[A.windowsPropertyKey])if(n[e][A.windowNamePropertyKey]===i)return[2,this.wrapWindow(n[e])];return[2,null]})})},A.prototype.buildLayout=function(){return w(this,void 0,void 0,function(){var a,n,e=this;return y(this,function(t){switch(t.label){case 0:return a=new $,n=[],[4,this.getAllWindows()];case 1:return t.sent().forEach(function(o){var r=o.nativeWindow;try{var s=r[p.windowOptionsPropertyKey];s&&"persist"in s&&!s.persist||n.push(w(e,void 0,void 0,function(){var n,e,i;return y(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, '".concat(t.message,"'"))}}),[4,Promise.all(n)];case 2:return t.sent(),[2,a]}})})},A.windowsPropertyKey="desktopJS-windows",A.windowUuidPropertyKey="desktopJS-uuid",A.windowNamePropertyKey="desktopJS-name",A.rootWindowUuid="root",A.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}};var at,k=A;function A(t){t=at.call(this,t)||this;return t.windowOptionsMap=A.defaultWindowOptionsMap,t.hostType="Default",t.ipc=t.createMessageBus(),!t.globalWindow||A.windowsPropertyKey in t.globalWindow||(t.globalWindow[A.windowsPropertyKey]={root:t.globalWindow},t.globalWindow[A.windowNamePropertyKey]=t.globalWindow[A.windowUuidPropertyKey]=A.rootWindowUuid),t.screen=new ut(t.globalWindow),t}T.DefaultContainer=k,K.prototype.getPrimaryDisplay=function(){return w(this,void 0,void 0,function(){var n;return y(this,function(t){return(n=new it).scaleFactor=this.window.devicePixelRatio,n.id="Current",n.bounds=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.width,this.window.screen.height),n.workArea=new v(this.window.screen.availLeft,this.window.screen.availTop,this.window.screen.availWidth,this.window.screen.availHeight),[2,n]})})},K.prototype.getAllDisplays=function(){return w(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.getPrimaryDisplay()];case 1:return[2,[t.sent()]]}})})},K.prototype.getMousePosition=function(){return w(this,void 0,void 0,function(){return y(this,function(t){return[2,{x:this.window.event.screenX,y:this.window.event.screenY}]})})};var ut=K;function K(t){this.window=t}function ct(){}var j=[];u.container=void 0;function dt(){}function pt(){}return u.Container=p,u.ContainerBase=C,u.ContainerNotification=R,u.ContainerRegistration=ct,u.ContainerWindow=P,u.Display=it,u.EventArgs=r,u.EventEmitter=e,u.GlobalShortcutManager=pt,u.GroupWindowManager=L,u.Guid=a,u.LayoutEventArgs=I,u.MenuItem=_,u.MessageBusOptions=z,u.MessageBusSubscription=U,u.NotificationOptions=F,u.PersistedWindow=Z,u.PersistedWindowLayout=$,u.Point=et,u.PropertyMap=V,u.Rectangle=v,u.SnapAssistWindowManager=nt,u.TrayIconDetails=dt,u.WebContainerBase=J,u.WindowEventArgs=q,u.WindowGroupEventArgs=Y,u.clearRegistry=function(){j.splice(0,j.length),u.container=void 0},u.registerContainer=function(t,n){j.push({id:t,registration:n})},u.resolveContainer=function(t,n){var e=!1,i=n;if("boolean"==typeof t?e=t:i=t,e||!u.container)try{for(var o=0;o<j.length;o++)var r=j[o].id,s=j[o].registration,a=s.condition(i)?s:a;u.container=a?a.create(i):void 0}catch(t){console.error("Error resolving container '".concat(r,"' : ").concat(t.toString()))}finally{u.container=u.container||new u.Default.DefaultContainer}return u.container},u.version="4.0.0",u}({}); | ||
//# sourceMappingURL=desktop.min.js.map |
@@ -14,3 +14,3 @@ import { Container } from "./container"; | ||
} | ||
export declare type WindowEventType = "window-created" | "window-joinGroup" | "window-leaveGroup" | "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore" | "beforeunload" | "state-changed"; | ||
export type WindowEventType = "window-created" | "window-joinGroup" | "window-leaveGroup" | "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore" | "beforeunload" | "state-changed"; | ||
export declare class WindowEventArgs extends EventArgs { | ||
@@ -17,0 +17,0 @@ readonly window?: ContainerWindow; |
@@ -14,3 +14,3 @@ import { Container } from "./container"; | ||
} | ||
export declare type WindowEventType = "window-created" | "window-joinGroup" | "window-leaveGroup" | "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore" | "beforeunload" | "state-changed"; | ||
export type WindowEventType = "window-created" | "window-joinGroup" | "window-leaveGroup" | "move" | "resize" | "close" | "closed" | "focus" | "blur" | "maximize" | "minimize" | "restore" | "beforeunload" | "state-changed"; | ||
export declare class WindowEventArgs extends EventArgs { | ||
@@ -17,0 +17,0 @@ readonly window?: ContainerWindow; |
@@ -5,3 +5,3 @@ { | ||
"description": "Library for abstracting common container hosting", | ||
"version": "3.13.1", | ||
"version": "4.0.0", | ||
"publishConfig": { | ||
@@ -8,0 +8,0 @@ "access": "public" |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
709282
4998