@openfin/core-web 0.38.59 → 0.38.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";var e=require("./main-23566e62.js"),t=require("golden-layout"),i=require("uuid");require("buffer/"),require("events"),require("lodash");var o={},n={};Object.defineProperty(n,"__esModule",{value:!0}),n.mapValuesAsync=n.mapEntriesAsync=void 0;const s=(e,[t,i])=>({...e,[t]:i});async function r(e,t){return(await Promise.all(t.map((async([t,i])=>[t,await e(i,t)])))).reduce(s,{})}n.mapEntriesAsync=r,n.mapValuesAsync=async function(e,t){let i;return i=t instanceof Map?[...t.entries()]:Object.entries(t),r(e,i)};var a,l,c,u,h=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldSet||function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},d=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldGet||function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};Object.defineProperty(o,"__esModule",{value:!0});var m=o.DefaultLayoutManager=void 0;const y=n;class f{constructor(e){l.set(this,void 0),c.set(this,new Map),h(this,l,e,"f")}size(){return d(this,c,"f").size}async applyLayoutSnapshot({layouts:e}){if(Object.keys(e).length>1)throw new Error("[LayoutManager] Tried to call applyLayoutSnapshot with more than 1 layout. When implementing multiple layouts via overridden LayoutManager class, you must override and fully implement the applyLayoutSnapshot method without calling super.applyLayoutSnapshot().");const[[t,i]]=Object.entries(e);await f.createLayout(this,{layoutName:t,layout:i})}async showLayout({layoutName:e}){}async getLayoutSnapshot(){return{layouts:await(0,y.mapValuesAsync)((e=>e.getFrameSnapshot()),d(this,c,"f"))}}async removeLayout({layoutName:e}){}getLayoutIdentityForView(e){const t=[...d(this,c,"f").values()].find((t=>t.getCurrentViews().some((t=>t.name===e.name&&t.uuid===e.uuid))));return t?.identity??void 0}isLayoutVisible({layoutName:e}){return d(f,a,"m",u).call(f,this,e).isVisible()}resolveLayoutIdentity(e){if(e&&"layoutName"in e)return e;const t=[...d(this,c,"f").values()];if(1===t.length)return t[0].identity;const i=t.find((e=>e.isVisible()));return i?.identity??void 0}static async resolveLayout(e,t){const i=e.resolveLayoutIdentity(t);if(void 0===i||!("layoutName"in i))throw new Error("[layout-manager] resolveLayout: Could not resolve the layout identity. Make sure you include 'layoutName' in the identity object.");return d(f,a,"m",u).call(f,e,i.layoutName)}static async handleSharedView(e,t,i){await(0,y.mapValuesAsync)((async e=>{if(e.identity.layoutName!==t.layoutName){const t=e.getCurrentViews().find((e=>e.name===i.name));t&&await e.onViewDetached({viewIdentity:t,target:null}).catch(console.error)}}),d(e,c,"f"))}static async handleLastViewRemoved(e,t){await e.removeLayout(t),await d(e,l,"f").handleLastViewRemoved(e)}static async destroyLayout(e,{layoutName:t}){await d(f,a,"m",u).call(f,e,t).destroy(),d(e,c,"f").delete(t)}static async createLayout(e,t){const{layoutName:i}=t;if(d(e,c,"f").has(i))throw new Error(`Layout name ${i} already exists`);await d(e,l,"f").createLayout(t,e)}static registerLayout(e,t,i){d(e,c,"f").set(t,i)}static getAllLayouts(e){return[...d(e,c,"f").values()]}static setInitialSnapshot(e,t){d(e,l,"f").setInitialSnapshot(t)}static createClosedConstructor(...e){return class extends f{constructor(){super(...e)}}}}m=o.DefaultLayoutManager=f,a=f,l=new WeakMap,c=new WeakMap,u=function(e,t){const i=d(e,c,"f").get(t);if(!i)throw new Error(`[layout-manager] getLayoutByName: Could not locate layout with name '${t}'`);return i};var p={};Object.defineProperty(p,"__esModule",{value:!0});var w=p.BaseLayout=void 0;w=p.BaseLayout=class{};var v={};Object.defineProperty(v,"__esModule",{value:!0});var g=v.DOMEmitter=void 0;g=v.DOMEmitter=class{constructor(e){this.container=e}dispatchLocalEvent(e,t){const i={...t,type:e,tabSelector:`tab-${t.name}`,containerSelector:`container-${t.name}`,topic:"openfin-DOM-event"};this.container.dispatchEvent(new CustomEvent(e,{detail:i}))}};var b={};Object.defineProperty(b,"__esModule",{value:!0});var C=b.isVisible=void 0;C=b.isVisible=e=>(0!==e.offsetWidth||0!==e.offsetHeight)&&"hidden"!==window.getComputedStyle(e).visibility&&e.offsetTop>=0&&e.offsetLeft>=0&&e.offsetTop<=window.innerHeight&&e.offsetLeft<=window.innerWidth;const E="initial_",L={show:"top",popout:!1,maximise:!1,close:"close-tab-unused"},S={headerHeight:31},V={hasHeaders:!0,reorderEnabled:!0},_={popoutWholeStack:!1,constrainDragToContainer:!1,constrainDragToHeaders:!1,preventDragout:!1,showMaximiseIcon:!1,showPopoutIcon:!1,showCloseIcon:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,selectionEnabled:!1};var M,N;class A{constructor(t){this.layout=t,M.set(this,void 0),N.set(this,void 0),this.handleResize=e=>{e.forEach((e=>{const t=this.layout.viewComponentsByContainerElement.get(e.target);t&&t.resize(t.container.element.getBoundingClientRect())}))},this.handleMutation=()=>{const e=document.body.classList.contains("lm_dragging");this.layout.viewComponentsByContainerElement.forEach((t=>{const i=t.container.tab.element;i&&i.className.includes("lm_dragging")&&t.hide(),e?this.layout.handleDragStart():this.layout.handleDragEnd()}))},e.__classPrivateFieldSet(this,M,new ResizeObserver(this.handleResize),"f"),e.__classPrivateFieldSet(this,N,new MutationObserver(this.handleMutation),"f")}observeDragging(){const t=this.layout.layout.rootItem;if(!t)throw new Error("Root item not found in layout.");e.__classPrivateFieldGet(this,N,"f")?.observe(t.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]})}destroy(){e.__classPrivateFieldGet(this,M,"f").disconnect(),e.__classPrivateFieldGet(this,N,"f").disconnect()}observeContainer(t){e.__classPrivateFieldGet(this,M,"f").observe(t)}unobserveContainer(t){e.__classPrivateFieldGet(this,M,"f").unobserve(t)}}function P(e=[],t){for(const i of e)"component"===i.type?Object.keys(t).forEach((e=>{e in i&&(i.componentState={[`${E}${e}`]:i[e],...i.componentState}),i[e]=t[e]})):P(i.content,t)}function $(e=[],t,i){for(const o of e)if("component"===o.type)Object.keys(t).forEach((e=>{if(`${E}${e}`in o.componentState)return o[e]=o.componentState[`${E}${e}`],void delete o.componentState[`${E}${e}`];o[e]=t[e]}));else{if(o.size&&("row"===i||"column"===i)){o["row"===i?"width":"height"]=o.size?.includes(".")?parseFloat(o.size):parseInt(o.size)}$(o.content,t,o.type)}}function x(e){if(e.root){e.root.content&&$([e.root],{componentName:"view",isClosable:!0});const t=e.root;e.content=[t],delete e.root}return e}M=new WeakMap,N=new WeakMap;const k=t=>class extends t{connectedCallback(){if(!this.name||!this.uuid)throw new Error("<of-view> Name or uuid attribute missing");if(!this.src)throw new Error("<of-view> missing 'src' attribute.");this.#e||(this.#e=document.createElement("iframe"),this.#e.src=this.src,this.#e.style.height="100%",this.#e.style.width="100%",this.#e.style.border="none",this.forceFrameName?this.#e.setAttribute("name",this.forceFrameName):this.#e.setAttribute("name",e.encodeOptions({brokerUrl:this.brokerUrl,name:this.name,uuid:this.uuid,providerId:this.providerId,contextGroup:this.contextGroup},"of-frame")),this.#e.setAttribute("id",this.name),this.appendChild(this.#e))}#e;get brokerUrl(){return this.getAttribute("of-broker")}set brokerUrl(e){e&&this.setAttribute("of-broker",e)}get name(){return this.getAttribute("of-name")}set name(e){e&&this.setAttribute("of-name",e)}get forceFrameName(){return this.getAttribute("forceFrameName")}set forceFrameName(e){e&&this.setAttribute("forceFrameName",e)}get uuid(){return this.getAttribute("of-uuid")}set uuid(e){e&&this.setAttribute("of-uuid",e)}get src(){return this.getAttribute("src")}set src(e){e&&this.setAttribute("src",e)}get providerId(){return this.getAttribute("of-provider-id")}set providerId(e){e&&this.setAttribute("of-provider-id",e)}get contextGroup(){return this.getAttribute("of-context-group")}set contextGroup(e){e&&this.setAttribute("of-context-group",e)}static get observedAttributes(){return["name"]}};class F{static create(e){const t=document.createElement("of-view");return Object.entries(e).forEach((([e,i])=>{t.setAttribute(e,i)})),t}}customElements.define("of-view",k(HTMLElement));class I{constructor(e,t,o,{brokerUrl:n,interopConfig:s},r){this.container=e,this.config=t,this.ofView=null;const{url:a,web:l,interop:c}=t||{},u=`internal-generated-view-${i.v4()}`;if(this.identity={uuid:o,name:u},this.container.element.setAttribute("of-name",u),this.container.element.id=`container-${u}`,void 0===a)return void this.handleUrlMissing();const h=this.updateTitleIfNotSet(a),d={"of-broker":n,"of-uuid":o,"of-name":u,src:a};l?.frameName&&(d.forceFrameName=l.frameName);const m=c?.currentContextGroup??s?.currentContextGroup;m&&(d["of-context-group"]=m),s?.providerId&&(d["of-provider-id"]=s?.providerId),this.ofView=F.create(d),this.ofView.title=h??`Iframe: ${a}`,r.appendChild(this.ofView),this.ofView.style.position="absolute"}updateTitleIfNotSet(e){return"view"===this.container.parent.title&&this.container.parent.setTitle(e),this.container.parent.title}handleUrlMissing(){const e=document.createElement("div");e.setAttribute("style","padding: 20px");e.innerText="No URL provided",this.container.element.appendChild(e)}destroy(){this.ofView?.remove(),this.ofView=null}resize(e){this.ofView&&(this.ofView.style.position="absolute",this.ofView.style.height=`${e.height}px`,this.ofView.style.width=`${e.width}px`,this.ofView.style.inset=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`,this.ofView.style.display="block")}hide(){this.ofView&&(this.ofView.style.display="none")}}class j extends w{static overrideConfig(e){const t={...V,...e.settings,..._};return t.reorderEnabled&&P(e.content,{isClosable:!0}),{dimensions:S,...e,settings:t,header:{...L,show:!1!==e.settings?.hasHeaders&&L.show}}}constructor(e,i,o,{options:n}){super(),this.identity=e,this.container=i,this.initialConfig=o,this.viewComponentsByContainerElement=new Map,this.createViewComponent=(e,t)=>{const i=new I(e,t,this.identity.uuid,this.options,this.iframeContainer);return t&&!1===t[`${E}isClosable`]&&this.stylesheet.insertRule(`#tab-${i.identity.name} .lm_close_tab { display: none; }`),this.viewComponentsByContainerElement.set(e.element,i),this.resizeController.observeContainer(e.element),i},this.iframeContainer=document.createElement("div"),this.iframeContainer.id=`openfin-layout-iframe-container-${this.identity.layoutName}`,this.container.setAttribute("data-openfin-layout-name",this.identity.layoutName),this.domEmitter=new g(i),this.stylesheet=new CSSStyleSheet,this.stylesheet.insertRule(".lm_close { display: none; }"),document.adoptedStyleSheets.push(this.stylesheet),this.layout=new t.GoldenLayout(this.container),this.layout.resizeWithContainerAutomatically=!0,this.options=n,this.layout.registerComponent("view",this.createViewComponent),this.setupListeners(),this.resizeController=new A(this),this.layout.loadLayout(j.overrideConfig(o));const s=document.createElement("div");s.attachShadow({mode:"open",delegatesFocus:!1}).appendChild(this.iframeContainer),this.container.appendChild(s),this.initialConfig.settings?.preventSplitterResize&&this.preventPointerEvents(),this.resizeController.observeDragging()}preventPointerEvents(){const e=`\n [data-openfin-layout-name='${this.identity.layoutName}'] .lm_splitter {\n pointer-events: none;\n }\n `;this.stylesheet.insertRule(e)}addView(e){throw new Error("Method not implemented.")}replaceView({viewToReplace:e,newView:t}){throw new Error("Method not implemented.")}replaceLayout(e){throw new Error("Method not implemented.")}closeView(e){throw new Error("Method not implemented.")}applyPreset(e){throw new Error("Method not implemented.")}getCurrentViews(){throw new Error("Method not implemented.")}async getFrameSnapshot(){return x(t.LayoutConfig.fromResolved(this.layout.toConfig()))}isVisible(){return C(this.container)}async onViewDetached(){throw new Error("Method not implemented.")}async destroy(){this.layout.destroy(),this.iframeContainer.remove(),this.resizeController.destroy(),document.adoptedStyleSheets=document.adoptedStyleSheets.filter((e=>e!==this.stylesheet)),this.viewComponentsByContainerElement.clear()}setupListeners(){this.container.addEventListener("mousedown",(e=>{e.target instanceof HTMLElement&&e.target.classList.contains("lm_drag_handle")&&this.handleDragStart()})),this.layout.on("tabCreated",(e=>{const t=e.componentItem.container.element.getAttribute("of-name")??i.v4(),o={name:t,uuid:t};e.element.id=`tab-${t}`,this.domEmitter.dispatchLocalEvent("tab-created",o)})),this.layout.on("itemCreated",(({target:e})=>{const t=e;if(!t.isComponent)return;const o=t.element.querySelector("[of-name]")?.getAttribute("of-name")??i.v4(),n={name:o,uuid:o};this.domEmitter.dispatchLocalEvent("container-created",n)})),this.layout.on("itemDestroyed",(e=>{const t=e.target;if(!t.isComponent)return;const i=t.component;this.removeViewComponent(i)}))}handleDragStart(){this.iframeContainer.style.pointerEvents="none"}handleDragEnd(){this.iframeContainer.style.pointerEvents=""}removeViewComponent(e){if(e.config&&!1===e.config[`${E}isClosable`]){const t=[...this.stylesheet.cssRules].findIndex((t=>t.cssText.includes(`#tab-${e.identity.name}`)));this.stylesheet.deleteRule(t)}e.destroy(),this.viewComponentsByContainerElement.delete(e.container.element),this.resizeController.unobserveContainer(e.container.element)}}class G{constructor(e,t,i){this.windowIdentity=e,this.connectConfig=t,this.fallbackContainer=i}async createLayout(e,t){if(!("container"in e)&&!this.fallbackContainer)throw new Error("Container property is not optional in web");const{layout:i,layoutName:o}=e,n=e.container??this.fallbackContainer,s={...this.windowIdentity,layoutName:o},r=new j(s,n,i,this.connectConfig);m.registerLayout(t,o,r),this.fallbackContainer=null}async getLayoutSnapshot(e){return e.getLayoutSnapshot()}async handleLastViewRemoved(e){throw new Error("Method not implemented.")}}var O;const T=e=>e;O=new WeakMap,exports.WebLayoutEntryPoint=class{constructor(t){O.set(this,void 0),this.initLayoutManager=async(t,i,{container:o,layoutManagerOverride:n})=>{const s=n??T,r=new G(i.me,e.__classPrivateFieldGet(this,O,"f"),o);return new(s(m.createClosedConstructor(r)))},this.applyLayoutSnapshot=async(t,i,o)=>{await i.applyLayoutSnapshot(e.__classPrivateFieldGet(this,O,"f").platform.layoutSnapshot)},this.createLayout=async(e,t)=>m.createLayout(e,t),this.destroyLayout=async(e,t)=>m.destroyLayout(e,t),e.__classPrivateFieldSet(this,O,t,"f")}};