@openfin/core-web 0.40.2 → 0.40.5
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/platform-developer-guide.md +13 -5
- package/out/api-client.js +1 -1
- package/out/iframe-broker.js +1 -1
- package/out/{main-7ffb79c1.js → main-07021ef9.js} +1 -1
- package/out/main-ad0b29e8.js +1 -0
- package/out/shared-worker.js +1 -1
- package/package.json +5 -5
- package/out/main-6e25bc08.js +0 -1
@@ -115,6 +115,14 @@ const layoutSnapshot = {
|
|
115
115
|
|
116
116
|
The JSON structure of the underlying layout options is interchangeable, though not identical, between Desktop and Web. Web Layout Snapshots have an optional `web` property within the view `componentState` options which stores web specific properties. This `web` property is ignored on desktop.
|
117
117
|
|
118
|
+
### Layout Settings
|
119
|
+
|
120
|
+
Layouts in the web support the following [`LayoutOptions.settings`](https://cdn.openfin.co/docs/javascript/stable/interfaces/OpenFin.LayoutOptions.html#settings):
|
121
|
+
|
122
|
+
- `reorderEnabled` (Default value **true**): If true, users can re-arrange the layout by dragging items by their tabs to the desired location. Note, unlike in an OpenFin environment the dragging of items is limited to the current window.
|
123
|
+
- `hasHeaders` (Default value **true**): Turns tab headers on or off. If false, the layout will be displayed with splitters only.
|
124
|
+
- `preventSplitterResize` (Default value **false**): When true the splitters will not be draggable and the layout will not resize.
|
125
|
+
|
118
126
|
### Example: Retrieve a layoutSnapshot from both desktop and web environments
|
119
127
|
|
120
128
|
From within your OpenFin v34+ Desktop environment, retrieve the current layoutSnapshot:
|
@@ -219,11 +227,11 @@ Note that cross-tab support is experimental, browser-dependent and respects each
|
|
219
227
|
|
220
228
|
(Please note, these links work in your IDE and not on npmjs.com, we will update this soon.)
|
221
229
|
|
222
|
-
-
|
223
|
-
-
|
224
|
-
-
|
230
|
+
- [@openfin/core-web](../out/docs/@openfin/core-web/README.md)
|
231
|
+
- [@openfin/core-web/iframe-broker](../out/docs/@openfin/core-web/iframe-broker/README.md)
|
232
|
+
- [@openfin/core-web/shared-worker](../out/docs/@openfin/core-web/shared-worker/README.md)
|
225
233
|
|
226
234
|
## See Also
|
227
235
|
|
228
|
-
-
|
229
|
-
-
|
236
|
+
- [OpenFin Container Developer guide](https://developers.openfin.co/of-docs/docs/container-overview)
|
237
|
+
- [Fin API reference](https://developer.openfin.co/docs/javascript/stable)
|
package/out/api-client.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("./main-
|
1
|
+
"use strict";var e=require("./main-ad0b29e8.js");require("buffer/"),require("uuid"),require("events"),require("lodash"),exports.connect=e.connect;
|
package/out/iframe-broker.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";const e="web-broker-ports-ready",t="worker-initialize-connection",
|
1
|
+
"use strict";const e="web-broker-ports-ready",t="worker-initialize-connection",i="create-fallback-connection",r="request-fallback-connection",n=e=>`ack-${e}`,o=(...e)=>({log:(...t)=>console.log(`[${(new Date).toISOString()}]`,...(e=>e.map((e=>`[${e}]`)))(e),...t),getLogger:(...t)=>o(...e,...t)}),s=e=>window.top===e,a=(e,t)=>{try{return e.origin===t.origin}catch(e){return!1}},c="openfin/web-shared-worker";class d{static get lockApi(){return navigator.locks}constructor(e){this.name=e,this.releaseCallback=null,d.pending.add(this),this.lockAcquiredPromise=new Promise(((e,t)=>{this.lockReleasedPromise=d.lockApi.request(this.name,(()=>(d.pending.delete(this),e(),new Promise((e=>{d.held.add(this),this.releaseCallback=e}))))).catch((e=>{throw t(e),e}))}))}async acquired(){await this.lockAcquiredPromise}async release(){if(!this.releaseCallback)throw new Error(`Lock ${this.name} not acquired.`);this.releaseCallback(),this.releaseCallback=null,await this.lockReleasedPromise,d.held.delete(this)}async onReleased(e){if(!this.lockReleasedPromise)throw new Error(`Lock ${this.name} not queued.`);return this.lockReleasedPromise.then(e)}autoRelease(){this.acquired().then((()=>this.release()))}static async releaseAll(){const e=Promise.all([...this.pending].map((async e=>{await e.acquired(),await e.release()})));await Promise.all([...this.held].map((async e=>{await e.release()}))),await e}}d.pending=new Set,d.held=new Set;class l{constructor(e=100,t=2){this.pingIntervalMs=e,this.allowedMissedPings=t,this.lockSelf=async e=>{const t=new d((e=>`__OPENFIN__${e.uuid}_${e.name}`)(e));return await t.acquired(),t}}async lockProxiedConnection(e,t){let i=0;t.addEventListener("message",(e=>{"pong"===e.data.topic&&i--}));const r=await this.lockSelf(e);let n=setInterval((()=>{i>=this.allowedMissedPings?(r.release(),clearInterval(n)):(i++,t.postMessage({topic:"ping"}))}),this.pingIntervalMs);t.start()}registerProxiedConnection(e){e.addEventListener("message",(t=>{"ping"===t.data.topic&&e.postMessage({topic:"pong"})})),e.start()}}class h{constructor(e,t,o){this.workerUrl=e,this.iframeWindow=t,this.forceWorker=o,this.identityDisconnectionController=new l,this.isSharedWorkerSupported=()=>!this.forceWorker&&!!window.SharedWorker,this.state="ready",this.establishWorkerConnectionViaWindow=async(e,t)=>{if(a(this.iframeWindow,e)){const o=new MessageChannel,s=new MessageChannel;return this.identityDisconnectionController.registerProxiedConnection(s.port1),new Promise(((a,c)=>{o.port1.addEventListener("message",(e=>{e.data.topic===n(i)&&(e.data.success?a(o.port1):c(e.data.reason))})),o.port1.start();const d={topic:r,payload:{identity:t}};e.postMessage(d,location.origin,[o.port2,s.port2])}))}throw new Error("Could not connect via top level browsing context as its origin does not much the web interop broker.")},this.listenForNestedConnections=e=>{"top-window"===this.state&&a(this.iframeWindow,this.iframeWindow.parent)&&this.iframeWindow.parent.addEventListener("message",(async t=>{const{data:n}=t;if(t.origin===location.origin&&n.topic===r){const[r,...o]=t.ports;if(o.length>0&&n.payload?.identity){const[e]=o;await this.identityDisconnectionController.lockProxiedConnection(n.payload.identity,e)}const s={topic:i};e.postMessage(s,[r])}}))},this.initialize=async e=>{if("ready"!==this.state)throw new Error("Worker connection already initialized");return(e=>{const t=i=>!(!(e=>{try{return!e.origin}catch(e){return!0}})(i)&&i.origin===e.origin)||!s(i)&&t(i.parent);return!s(e)&&t(e.parent)})(this.iframeWindow)&&a(this.iframeWindow,this.iframeWindow.top)?this.state="partitioned-frame":s(this.iframeWindow.parent)?this.state="top-window":this.state="frame",this.connect(e)}}async connect(e){if("ready"===this.state)throw new Error("Must call initialize before connect");switch(this.state){case"partitioned-frame":return this.establishWorkerConnectionViaWindow(this.iframeWindow.top,e);case"top-window":{let t;return t=this.isSharedWorkerSupported()?new SharedWorker(this.workerUrl,c).port:new Worker(this.workerUrl),await this.identityDisconnectionController.lockSelf(e),this.listenForNestedConnections(t),t}case"frame":{if(!this.isSharedWorkerSupported())try{return await this.establishWorkerConnectionViaWindow(this.iframeWindow.top,e)}catch(e){throw new Error(`SharedWorker is not supported and an unexpected error occured when trying to connect via fallback mechanism: ${e.message}`,{cause:e})}await this.identityDisconnectionController.lockSelf(e);const{port:t}=new SharedWorker(this.workerUrl,c);return t}default:throw this.state,new Error(`Invalid state: ${this.state}`)}}}const w=o("@openfin/core-web/iframe-broker"),p=()=>{const e=((e,t)=>{const i=new RegExp(`^${t}<(?<meta>.*)>$`).exec(e)?.groups?.meta;if(i)try{return JSON.parse(atob(i))}catch(e){throw new Error(`Failed to decode JSON from ${i}.`)}})(window.name,"of-broker");if(!e)throw new Error("Invalid or missing identity string in iframe context. Ensure that this iframe is being renderered via the @openfin/core-web library.");return e};function g(t){const i={topic:n(e),success:!1,reason:t?.reason??"Connection Rejected"};window.parent.postMessage(i,"*")}exports.init=async i=>{try{const{sharedWorkerUrl:r}=i;await("loading"===document.readyState?new Promise((e=>{const t=()=>{e(),window.removeEventListener("DOMContentLoaded",t)};window.addEventListener("DOMContentLoaded",t)})):Promise.resolve());const o=p(),s=new h(r,window,"same-site"!==i.experimental?.crossTab),a=await s.initialize(o);w.log(`Loading ${r} in ${s.state} mode...`);const c=await(async(i,r,o)=>{const s=new MessageChannel,a=new MessageChannel,c={topic:t,payload:{identity:o}};await new Promise(((e,i)=>{r.addEventListener("message",(r=>{r.data.topic===n(t)&&(r.data.success?e():i(new Error(r.data.reason)))})),r.start?.(),r.postMessage(c,[a.port2])}));const d={topic:n(e),success:!0,payload:{identity:o}};return i.postMessage(d,"*",[s.port2,a.port1]),s.port1})(window.parent,a,o);c.start(),a.start?.(),w.log(`Port transfer complete in ${s.state} mode. Connection established with identity ${JSON.stringify(o)}. SharedWorker support=${s.isSharedWorkerSupported()}`)}catch(e){const t=new Error(`An unexpected error occured during initialization. ${e.message}`);g({reason:t.message}),console.error(t)}},exports.rejectConnections=g;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("./main-6e25bc08.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")}};
|
1
|
+
"use strict";var e=require("./main-ad0b29e8.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")}};
|