@luigi-project/container
Advanced tools
Comparing version 1.0.0-rc3 to 1.0.0-rc4
@@ -1,2 +0,2 @@ | ||
function e(){}function t(e){return e()}function n(){return Object.create(null)}function o(e){e.forEach(t)}function r(e){return"function"==typeof e}function i(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let s,a;function c(e,t){return s||(s=document.createElement("a")),s.href=t,e===s.href}function u(e,t,n){e.insertBefore(t,n||null)}function l(e){e.parentNode&&e.parentNode.removeChild(e)}function d(e){return document.createElement(e)}function m(){return e="",document.createTextNode(e);var e}function h(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function p(e){const t={};for(const n of e)t[n.name]=n.value;return t}function g(e){a=e}function f(){if(!a)throw new Error("Function called outside component initialization");return a}function w(e){f().$$.on_mount.push(e)}const C=[],b=[],$=[],v=[],_=Promise.resolve();let x=!1;function y(e){$.push(e)}const E=new Set;let W=0;function I(){const e=a;do{for(;W<C.length;){const e=C[W];W++,g(e),U(e.$$)}for(g(null),C.length=0,W=0;b.length;)b.pop()();for(let e=0;e<$.length;e+=1){const t=$[e];E.has(t)||(E.add(t),t())}$.length=0}while(C.length);for(;v.length;)v.pop()();x=!1,E.clear(),g(e)}function U(e){if(null!==e.fragment){e.update(),o(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(y)}}const R=new Set;function k(e,t){-1===e.$$.dirty[0]&&(C.push(e),x||(x=!0,_.then(I)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function L(i,s,c,u,d,m,h,p=[-1]){const f=a;g(i);const w=i.$$={fragment:null,ctx:[],props:m,update:e,not_equal:d,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(s.context||(f?f.$$.context:[])),callbacks:n(),dirty:p,skip_bound:!1,root:s.target||f.$$.root};h&&h(w.root);let C=!1;if(w.ctx=c?c(i,s.props||{},((e,t,...n)=>{const o=n.length?n[0]:t;return w.ctx&&d(w.ctx[e],w.ctx[e]=o)&&(!w.skip_bound&&w.bound[e]&&w.bound[e](o),C&&k(i,e)),t})):[],w.update(),C=!0,o(w.before_update),w.fragment=!!u&&u(w.ctx),s.target){if(s.hydrate){const e=function(e){return Array.from(e.childNodes)}(s.target);w.fragment&&w.fragment.l(e),e.forEach(l)}else w.fragment&&w.fragment.c();s.intro&&((b=i.$$.fragment)&&b.i&&(R.delete(b),b.i($))),function(e,n,i,s){const{fragment:a,after_update:c}=e.$$;a&&a.m(n,i),s||y((()=>{const n=e.$$.on_mount.map(t).filter(r);e.$$.on_destroy?e.$$.on_destroy.push(...n):o(n),e.$$.on_mount=[]})),c.forEach(y)}(i,s.target,s.anchor,s.customElement),I()}var b,$;g(f)}let M;"function"==typeof HTMLElement&&(M=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:e}=this.$$;this.$$.on_disconnect=e.map(t).filter(r);for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}disconnectedCallback(){o(this.$$.on_disconnect)}$destroy(){!function(e,t){const n=e.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=e}$on(t,n){if(!r(n))return e;const o=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return o.push(n),()=>{const e=o.indexOf(n);-1!==e&&o.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}});class A{constructor(){}isVisible(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}sendCustomMessageToIframe(e,t){if(e.iframe.contentWindow){const n=new URL(e.iframe.src);e.iframe.contentWindow.postMessage({msg:"custom",data:t},n.origin)}else console.error("Message target could not be resolved")}dispatch(e,t,n,o){let r=new CustomEvent(e,{detail:n});r.luigiCallback=e=>{o&&o(e)},t.dispatchEvent(r)}getTargetContainer(e){let t;return globalThis.__luigi_container_manager.container.forEach((n=>{var o;(null===(o=n.iframeHandle)||void 0===o?void 0:o.iframe)&&n.iframeHandle.iframe.contentWindow===e.source&&(t=n)})),t}getContainerManager(){return globalThis.__luigi_container_manager||(globalThis.__luigi_container_manager={container:[],messageListener:e=>{var t,n,o,r,i;const s=this.getTargetContainer(e),a=null===(n=null===(t=null==s?void 0:s.iframeHandle)||void 0===t?void 0:t.iframe)||void 0===n?void 0:n.contentWindow;if(a===e.source&&(0===(null===(r=null===(o=e.data)||void 0===o?void 0:o.msg)||void 0===r?void 0:r.indexOf("luigi."))||"custom"===(null===(i=e.data)||void 0===i?void 0:i.msg))){const t=e.data.msg;switch(t){case"custom":this.dispatch("custom-message",s,e.data.data);break;case"luigi.get-context":a.postMessage({msg:"luigi.init",context:s.context||{},internal:{}},"*");break;case"luigi.navigation.open":this.dispatch("navigation-request",s,e.data.params);break;case"luigi.ux.alert.show":this.dispatch("alert-request",s,e.data.params);break;case"luigi.init.ok":this.dispatch("initialized",s,e.data.params);break;case"luigi.third-party-cookie":break;default:console.warn("Functionality not yet implemented: ",t)}}}},window.addEventListener("message",globalThis.__luigi_container_manager.messageListener)),globalThis.__luigi_container_manager}registerContainer(e){this.getContainerManager().container.push(e)}}class O{constructor(e){e?(this.rendererObject=e,this.config=e.config||{}):this.config={}}createCompoundContainer(){return document.createElement("div")}createCompoundItemContainer(e){return document.createElement("div")}attachCompoundItem(e,t){e.appendChild(t)}}class T extends O{constructor(e){super(e||{use:{}}),e&&e.use&&e.use.extends&&(this.superRenderer=j({use:e.use.extends,config:e.config}))}createCompoundContainer(){return this.rendererObject.use.createCompoundContainer?this.rendererObject.use.createCompoundContainer(this.config,this.superRenderer):this.superRenderer?this.superRenderer.createCompoundContainer():super.createCompoundContainer()}createCompoundItemContainer(e){return this.rendererObject.use.createCompoundItemContainer?this.rendererObject.use.createCompoundItemContainer(e,this.config,this.superRenderer):this.superRenderer?this.superRenderer.createCompoundItemContainer(e):super.createCompoundItemContainer(e)}attachCompoundItem(e,t){this.rendererObject.use.attachCompoundItem?this.rendererObject.use.attachCompoundItem(e,t,this.superRenderer):this.superRenderer?this.superRenderer.attachCompoundItem(e,t):super.attachCompoundItem(e,t)}}class P extends O{createCompoundContainer(){const e="__lui_compound_"+(new Date).getTime(),t=document.createElement("div");t.classList.add(e);let n="";return this.config.layouts&&this.config.layouts.forEach((t=>{if(t.minWidth||t.maxWidth){let o="@media only screen ";null!=t.minWidth&&(o+=`and (min-width: ${t.minWidth}px) `),null!=t.maxWidth&&(o+=`and (max-width: ${t.maxWidth}px) `),o+=`{\n .${e} {\n grid-template-columns: ${t.columns||"auto"};\n grid-template-rows: ${t.rows||"auto"};\n grid-gap: ${t.gap||"0"};\n }\n }\n `,n+=o}})),t.innerHTML=`\n <style scoped>\n .${e} {\n display: grid;\n grid-template-columns: ${this.config.columns||"auto"};\n grid-template-rows: ${this.config.rows||"auto"};\n grid-gap: ${this.config.gap||"0"};\n min-height: ${this.config.minHeight||"auto"};\n }\n ${n}\n </style>\n `,t}createCompoundItemContainer(e){const t=e||{},n=document.createElement("div");return n.setAttribute("style",`grid-row: ${t.row||"auto"}; grid-column: ${t.column||"auto"}`),n}}const j=e=>{const t=e.use;return t?"grid"===t?new P(e):t.createCompoundContainer||t.createCompoundItemContainer||t.attachCompoundItem?new T(e):new O(e):new O(e)},H=(e,t,n,o)=>{(null==t?void 0:t.eventListeners)&&t.eventListeners.forEach((t=>{const r=t.source+"."+t.name,i=e[r],s={wcElementId:n,wcElement:o,action:t.action,converter:t.dataConverter};i?i.push(s):e[r]=[s]}))};class S{constructor(){this.containerService=new A}dynamicImport(e){return import( /* webpackIgnore: true */e)}processViewUrl(e,t){return e}attachWC(e,t,n,o,r,i){if(n&&n.contains(t)){const s=document.createElement(e);i&&s.setAttribute("nodeId",i),this.initWC(s,e,n,r,o,i),n.replaceChild(s,t),n._luigi_node&&(n._luigi_mfe_webcomponent=s)}}createClientAPI(e,t,n){return{linkManager:()=>{},uxManager:()=>({showAlert:e=>{},showConfirmationModal:async e=>new Promise(((e,t)=>{e(!0)}))}),getCurrentLocale:()=>{},publishEvent:e=>{}}}initWC(e,t,n,o,r,i){const s=this.createClientAPI(n,i,t);if(e.__postProcess){const t=new URL(document.baseURI).origin===new URL(o,document.baseURI).origin?new URL("./",new URL(o,document.baseURI)):new URL("./",o);e.__postProcess(r,s,t.origin+t.pathname)}else e.context=r,e.LuigiClient=s}generateWCId(e){let t="";for(let n=0;n<e.length;n++)t+=e.charCodeAt(n).toString(16);return"luigi-wc-"+t}registerWCFromUrl(e,t){const n=this.processViewUrl(e);return new Promise(((e,o)=>{this.checkWCUrl(n)?this.dynamicImport(n).then((n=>{try{if(!window.customElements.get(t)){let e=n.default;if(!HTMLElement.isPrototypeOf(e)){let t=Object.keys(n);for(let o=0;o<t.length&&(e=n[t[o]],!HTMLElement.isPrototypeOf(e));o++);}window.customElements.define(t,e)}e(1)}catch(e){o(e)}})).catch((e=>o(e))):(console.warn(`View URL '${n}' not allowed to be included`),o(`View URL '${n}' not allowed`))}))}includeSelfRegisteredWCFromUrl(e,t,n){if(this.checkWCUrl(t)){this.containerService.getContainerManager()._registerWebcomponent||(this.containerService.getContainerManager()._registerWebcomponent=(e,t)=>{window.customElements.define(this.generateWCId(e),t)});let o=document.createElement("script");o.setAttribute("src",t),"module"===e.webcomponent.type&&o.setAttribute("type","module"),o.setAttribute("defer","true"),o.addEventListener("load",(()=>{n()})),document.body.appendChild(o)}else console.warn(`View URL '${t}' not allowed to be included`)}checkWCUrl(e){return!0}renderWebComponent(e,t,n,o,r){const i=this.processViewUrl(e,{context:n}),s=o.webcomponent&&o.webcomponent.tagName?o.webcomponent.tagName:this.generateWCId(i),a=document.createElement("div");t.appendChild(a),t._luigi_node=o,window.customElements.get(s)?this.attachWC(s,a,t,n,i,r):window.luigiWCFn?window.luigiWCFn(i,s,a,(()=>{this.attachWC(s,a,t,n,i,r)})):o.webcomponent&&o.webcomponent.selfRegistered?this.includeSelfRegisteredWCFromUrl(o,i,(()=>{this.attachWC(s,a,t,n,i,r)})):this.registerWCFromUrl(i,s).then((()=>{this.attachWC(s,a,t,n,i,r)}))}createCompoundContainerAsync(e,t){return new Promise(((n,o)=>{if(e.viewUrl)try{const o=this.generateWCId(e.viewUrl);this.registerWCFromUrl(e.viewUrl,o).then((()=>{const r=document.createElement(o);this.initWC(r,o,r,e.viewUrl,t,"_root"),n(r)}))}catch(e){o(e)}else n(e.createCompoundContainer())}))}renderWebComponentCompound(e,t,n){var o;let r;return e.webcomponent&&e.viewUrl?(r=new O,r.viewUrl=this.processViewUrl(e.viewUrl,{context:n}),r.createCompoundItemContainer=e=>{var t=document.createElement("div");return e&&e.slot&&t.setAttribute("slot",e.slot),t}):(null===(o=e.compound)||void 0===o?void 0:o.renderer)&&(r=j(e.compound.renderer)),r=r||new O,new Promise((o=>{this.createCompoundContainerAsync(r,n).then((i=>{var s;const a={};i.eventBus={listeners:a,onPublishEvent:(e,t,n)=>{const o=a[t+"."+e.type]||[];o.push(...a["*."+e.type]||[]),o.forEach((t=>{const n=t.wcElement||i.querySelector("[nodeId="+t.wcElementId+"]");n?n.dispatchEvent(new CustomEvent(t.action,{detail:t.converter?t.converter(e.detail):e.detail})):console.debug("Could not find event target",t)}))}},null===(s=e.compound)||void 0===s||s.children.forEach(((e,t)=>{const o=Object.assign(Object.assign({},n),e.context),s=r.createCompoundItemContainer(e.layoutConfig);s.eventBus=i.eventBus,r.attachCompoundItem(i,s);const c=e.id||"gen_"+t;this.renderWebComponent(e.viewUrl,s,o,e,c),H(a,e,c)})),t.appendChild(i),H(a,e.compound,"_root",i),o(i)}))}))}}function q(e){let t,n=!e[5](),o=n&&function(e){let t,n;return{c(){t=d("iframe"),c(t.src,n=e[0])||h(t,"src",n),h(t,"title",e[1])},m(n,o){u(n,t,o),e[8](t)},p(e,o){1&o&&!c(t.src,n=e[0])&&h(t,"src",n),2&o&&h(t,"title",e[1])},d(n){n&&l(t),e[8](null)}}}(e);return{c(){o&&o.c(),t=m()},m(e,n){o&&o.m(e,n),u(e,t,n)},p(e,t){n&&o.p(e,t)},d(e){o&&o.d(e),e&&l(t)}}}function F(t){let n,o=!t[4]&&q(t);return{c(){n=d("main"),o&&o.c(),this.c=e,h(n,"class",t[5]()?void 0:"lui-isolated")},m(e,r){u(e,n,r),o&&o.m(n,null),t[9](n)},p(e,[t]){e[4]?o&&(o.d(1),o=null):o?o.p(e,t):(o=q(e),o.c(),o.m(n,null))},i:e,o:e,d(e){e&&l(n),o&&o.d(),t[9](null)}}}function N(e,t,n){let o,{viewurl:r}=t,{context:i}=t,{label:s}=t,{webcomponent:a}=t,c={};const u=new A,l=new S;l.createClientAPI=(e,t,n)=>({linkManager:()=>({navigate:e=>{h("navigation-request",{link:e})}}),uxManager:()=>({showAlert:e=>{h("alert-request",e)},showConfirmationModal:async e=>new Promise(((t,n)=>{h("confirmation-request",e,(e=>{e?t(e):n()}))}))}),getCurrentLocale:()=>{},publishEvent:e=>{}});const d=f();d.iframeHandle=c;let m=!!d.attributes["defer-init"];function h(e,t,n){u.dispatch(e,d,t,n)}function p(){return!!a}var g;return d.init=()=>{n(4,m=!1)},d.sendCustomMessage=(e,t)=>{if(p()&&o._luigi_mfe_webcomponent)u.dispatch(e,o._luigi_mfe_webcomponent,t);else{const n=Object.assign({},t);n.id&&console.warn('Property "id" is reserved and can not be used in custom message data'),n.id=e,u.sendCustomMessageToIframe(c,n)}},u.registerContainer(d),w((async()=>{const e=i?JSON.parse(i):{};p()&&(n(3,o.innerHTML="",o),l.renderWebComponent(r,o,e,{}))})),g=async()=>{},f().$$.on_destroy.push(g),e.$$set=e=>{"viewurl"in e&&n(0,r=e.viewurl),"context"in e&&n(6,i=e.context),"label"in e&&n(1,s=e.label),"webcomponent"in e&&n(7,a=e.webcomponent)},[r,s,c,o,m,p,i,a,function(e){b[e?"unshift":"push"]((()=>{c.iframe=e,n(2,c)}))},function(e){b[e?"unshift":"push"]((()=>{o=e,n(3,o)}))}]}class V extends M{constructor(e){super(),this.shadowRoot.innerHTML="<style>main,iframe{width:100%;height:100%;border:none}main.lui-isolated{line-height:0}</style>",L(this,{target:this.shadowRoot,props:p(this.attributes),customElement:!0},N,F,i,{viewurl:0,context:6,label:1,webcomponent:7},null),e&&(e.target&&u(e.target,this,e.anchor),e.props&&(this.$set(e.props),I()))}static get observedAttributes(){return["viewurl","context","label","webcomponent"]}get viewurl(){return this.$$.ctx[0]}set viewurl(e){this.$$set({viewurl:e}),I()}get context(){return this.$$.ctx[6]}set context(e){this.$$set({context:e}),I()}get label(){return this.$$.ctx[1]}set label(e){this.$$set({label:e}),I()}get webcomponent(){return this.$$.ctx[7]}set webcomponent(e){this.$$set({webcomponent:e}),I()}}function B(t){let n;return{c(){n=d("main"),this.c=e},m(e,o){u(e,n,o),t[2](n)},p:e,i:e,o:e,d(e){e&&l(n),t[2](null)}}}function z(e,t,n){let o,{context:r}=t,i=!1;const s=new A,a=new S;a.createClientAPI=(e,t,n)=>({linkManager:()=>{},uxManager:()=>({showAlert:e=>{u("alert-request",e,{})},showConfirmationModal:async e=>new Promise(((t,n)=>{u("confirmation-request",e,(e=>{e?t(e):n()}))}))}),getCurrentLocale:()=>{},publishEvent:o=>{e&&e.eventBus&&e.eventBus.onPublishEvent(o,t,n)}});const c=f();function u(e,t,n){s.dispatch(e,c,t,n)}return c.attributes["defer-init"],c.init=()=>{if(!c.compoundConfig||i)return;const e={compound:c.compoundConfig};a.renderWebComponentCompound(e,o,r).then((e=>{})),i=!0},s.registerContainer(c),w((async()=>{!r||JSON.parse(r)})),e.$$set=e=>{"context"in e&&n(1,r=e.context)},[o,r,function(e){b[e?"unshift":"push"]((()=>{o=e,n(0,o)}))}]}class J extends M{constructor(e){super(),this.shadowRoot.innerHTML="<style>main{width:100%;height:100%;border:none}</style>",L(this,{target:this.shadowRoot,props:p(this.attributes),customElement:!0},z,B,i,{context:1},null),e&&(e.target&&u(e.target,this,e.anchor),e.props&&(this.$set(e.props),I()))}static get observedAttributes(){return["context"]}get context(){return this.$$.ctx[1]}set context(e){this.$$set({context:e}),I()}}customElements.get("luigi-container")||customElements.define("luigi-container",V),customElements.get("luigi-compound-container")||customElements.define("luigi-compound-container",J);export{J as LuigiCompoundContainer,V as LuigiContainer}; | ||
function e(){}function t(e){return e()}function n(){return Object.create(null)}function o(e){e.forEach(t)}function i(e){return"function"==typeof e}function r(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let s,a;function c(e,t){return s||(s=document.createElement("a")),s.href=t,e===s.href}function u(e,t,n){e.insertBefore(t,n||null)}function d(e){e.parentNode&&e.parentNode.removeChild(e)}function l(e){return document.createElement(e)}function E(){return e="",document.createTextNode(e);var e}function _(e,t,n){null==n?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function h(e){const t={};for(const n of e)t[n.name]=n.value;return t}function m(e){a=e}function T(){if(!a)throw new Error("Function called outside component initialization");return a}function p(e){T().$$.on_mount.push(e)}const g=[],R=[],C=[],f=[],A=Promise.resolve();let S=!1;function I(e){C.push(e)}const w=new Set;let O=0;function U(){const e=a;do{for(;O<g.length;){const e=g[O];O++,m(e),b(e.$$)}for(m(null),g.length=0,O=0;R.length;)R.pop()();for(let e=0;e<C.length;e+=1){const t=C[e];w.has(t)||(w.add(t),t())}C.length=0}while(g.length);for(;f.length;)f.pop()();S=!1,w.clear(),m(e)}function b(e){if(null!==e.fragment){e.update(),o(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(I)}}const N=new Set;function $(e,t){-1===e.$$.dirty[0]&&(g.push(e),S||(S=!0,A.then(U)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function v(r,s,c,u,l,E,_,h=[-1]){const T=a;m(r);const p=r.$$={fragment:null,ctx:[],props:E,update:e,not_equal:l,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(s.context||(T?T.$$.context:[])),callbacks:n(),dirty:h,skip_bound:!1,root:s.target||T.$$.root};_&&_(p.root);let g=!1;if(p.ctx=c?c(r,s.props||{},((e,t,...n)=>{const o=n.length?n[0]:t;return p.ctx&&l(p.ctx[e],p.ctx[e]=o)&&(!p.skip_bound&&p.bound[e]&&p.bound[e](o),g&&$(r,e)),t})):[],p.update(),g=!0,o(p.before_update),p.fragment=!!u&&u(p.ctx),s.target){if(s.hydrate){const e=function(e){return Array.from(e.childNodes)}(s.target);p.fragment&&p.fragment.l(e),e.forEach(d)}else p.fragment&&p.fragment.c();s.intro&&((R=r.$$.fragment)&&R.i&&(N.delete(R),R.i(C))),function(e,n,r,s){const{fragment:a,after_update:c}=e.$$;a&&a.m(n,r),s||I((()=>{const n=e.$$.on_mount.map(t).filter(i);e.$$.on_destroy?e.$$.on_destroy.push(...n):o(n),e.$$.on_mount=[]})),c.forEach(I)}(r,s.target,s.anchor,s.customElement),U()}var R,C;m(T)}let D;var L,Q;"function"==typeof HTMLElement&&(D=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:e}=this.$$;this.$$.on_disconnect=e.map(t).filter(i);for(const e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(e,t,n){this[e]=n}disconnectedCallback(){o(this.$$.on_disconnect)}$destroy(){!function(e,t){const n=e.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=e}$on(t,n){if(!i(n))return e;const o=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return o.push(n),()=>{const e=o.indexOf(n);-1!==e&&o.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}),function(e){e.CUSTOM_MESSAGE="custom-message",e.GET_CONTEXT_REQUEST="get-context-request",e.NAVIGATION_REQUEST="navigation-request",e.ALERT_REQUEST="show-alert-request",e.INITIALIZED="initialized",e.ADD_SEARCH_PARAMS_REQUEST="add-search-params-request",e.ADD_NODE_PARAMS_REQUEST="add-node-params-request",e.SHOW_CONFIRMATION_MODAL_REQUEST="show-confirmation-modal-request",e.SHOW_LOADING_INDICATOR_REQUEST="show-loading-indicator-request",e.HIDE_LOADING_INDICATOR_REQUEST="hide-loading-indicator-request",e.SET_CURRENT_LOCALE_REQUEST="set-current-locale-request",e.LOCAL_STORAGE_SET_REQUEST="set-storage-request",e.RUNTIME_ERROR_HANDLING_REQUEST="runtime-error-handling-request",e.SET_ANCHOR_LINK_REQUEST="set-anchor-request",e.SET_THIRD_PARTY_COOKIES_REQUEST="set-third-party-cookies-request",e.BACK_NAVIGATION_REQUEST="navigate-back-request",e.GET_CURRENT_ROUTE_REQUEST="get-current-route-request",e.NAVIGATION_COMPLETED_REPORT="report-navigation-completed-request",e.UPDATE_MODAL_PATH_DATA_REQUEST="update-modal-path-data-requesst",e.CHECK_PATH_EXISTS_REQUEST="check-path-exists-request",e.SET_DIRTY_STATUS_REQUEST="set-dirty-status-request"}(L||(L={})),function(e){e.CUSTOM_MESSAGE="custom",e.GET_CONTEXT="luigi.get-context",e.SEND_CONTEXT="luigi.init",e.CONTEXT_RECEIVED="luigi.init.ok",e.NAVIGATION_REQUEST="luigi.navigation.open",e.ALERT_REQUEST="luigi.ux.alert.show",e.INITIALIZED="luigi.init.ok",e.ADD_SEARCH_PARAMS_REQUEST="luigi.addSearchParams",e.ADD_NODE_PARAMS_REQUEST="luigi.addNodeParams",e.SHOW_CONFIRMATION_MODAL_REQUEST="luigi.ux.confirmationModal.show",e.SHOW_LOADING_INDICATOR_REQUEST="luigi.show-loading-indicator",e.HIDE_LOADING_INDICATOR_REQUEST="luigi.hide-loading-indicator",e.SET_CURRENT_LOCALE_REQUEST="luigi.ux.set-current-locale",e.LOCAL_STORAGE_SET_REQUEST="storage",e.RUNTIME_ERROR_HANDLING_REQUEST="luigi-runtime-error-handling",e.SET_ANCHOR_LINK_REQUEST="luigi.setAnchor",e.SET_THIRD_PARTY_COOKIES_REQUEST="luigi.third-party-cookie",e.BACK_NAVIGATION_REQUEST="luigi.navigation.back",e.GET_CURRENT_ROUTE_REQUEST="luigi.navigation.currentRoute",e.REPORT_TOKEN_ISSUED_REQUEST="luigi.auth.tokenIssued",e.NAVIGATION_COMPLETED_REPORT="luigi.navigate.ok",e.UPDATE_MODAL_PATH_DATA_REQUEST="luigi.navigation.updateModalDataPath",e.CHECK_PATH_EXISTS_REQUEST="luigi.navigation.pathExists",e.SET_DIRTY_STATUS_REQUEST="luigi.set-page-dirty"}(Q||(Q={}));const M=new class{isFunction(e){return e&&"[object Function]"==={}.toString.call(e)}};var y;!function(e){e.SEND_CONTEXT_TO_MICROFRONTEND="sendContextToMicrofrontend"}(y||(y={}));class x{constructor(){}isVisible(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}sendCustomMessageToIframe(e,t){if(e.iframe.contentWindow){const n=new URL(e.iframe.src);e.iframe.contentWindow.postMessage({msg:"custom",data:t},n.origin)}else console.error("Message target could not be resolved")}dispatch(e,t,n,o,i){let r=new CustomEvent(e,{detail:n});o&&M.isFunction(o)&&i&&(r[i]=e=>{o(e)}),t.dispatchEvent(r)}getTargetContainer(e){let t;return globalThis.__luigi_container_manager.container.forEach((n=>{var o;(null===(o=n.iframeHandle)||void 0===o?void 0:o.iframe)&&n.iframeHandle.iframe.contentWindow===e.source&&(t=n)})),t}getContainerManager(){return globalThis.__luigi_container_manager||(globalThis.__luigi_container_manager={container:[],messageListener:e=>{var t,n;const o=this.getTargetContainer(e),i=null===(n=null===(t=null==o?void 0:o.iframeHandle)||void 0===t?void 0:t.iframe)||void 0===n?void 0:n.contentWindow;if(i===e.source){const t=e.data.msg;switch(t){case Q.CUSTOM_MESSAGE:this.dispatch(L.CUSTOM_MESSAGE,o,e.data.data);break;case Q.GET_CONTEXT:this.dispatch(L.GET_CONTEXT_REQUEST,o,e.data,(e=>{console.log("Callback called: Received data from Core sending inside MF",e),i.postMessage({msg:Q.SEND_CONTEXT,context:e},"*")}),y.SEND_CONTEXT_TO_MICROFRONTEND);break;case Q.NAVIGATION_REQUEST:this.dispatch(L.NAVIGATION_REQUEST,o,e.data.params);break;case Q.ALERT_REQUEST:this.dispatch(L.ALERT_REQUEST,o,e.data.params);break;case Q.INITIALIZED:this.dispatch(L.INITIALIZED,o,e.data.params);break;case Q.ADD_SEARCH_PARAMS_REQUEST:this.dispatch(L.ADD_SEARCH_PARAMS_REQUEST,o,{data:e.data.data,keepBrowserHistory:e.data.keepBrowserHistory});break;case Q.ADD_NODE_PARAMS_REQUEST:this.dispatch(L.ADD_NODE_PARAMS_REQUEST,o,{data:e.data.data,keepBrowserHistory:e.data.keepBrowserHistory});break;case Q.SHOW_CONFIRMATION_MODAL_REQUEST:this.dispatch(L.SHOW_CONFIRMATION_MODAL_REQUEST,o,e.data.data);break;case Q.SHOW_LOADING_INDICATOR_REQUEST:this.dispatch(L.SHOW_LOADING_INDICATOR_REQUEST,o,e);break;case Q.HIDE_LOADING_INDICATOR_REQUEST:this.dispatch(L.HIDE_LOADING_INDICATOR_REQUEST,o,e);break;case Q.SET_CURRENT_LOCALE_REQUEST:this.dispatch(L.SET_CURRENT_LOCALE_REQUEST,o,e);break;case Q.LOCAL_STORAGE_SET_REQUEST:this.dispatch(L.LOCAL_STORAGE_SET_REQUEST,o,e);break;case Q.RUNTIME_ERROR_HANDLING_REQUEST:this.dispatch(L.RUNTIME_ERROR_HANDLING_REQUEST,o,e);break;case Q.SET_ANCHOR_LINK_REQUEST:this.dispatch(L.SET_ANCHOR_LINK_REQUEST,o,e);break;case Q.SET_THIRD_PARTY_COOKIES_REQUEST:this.dispatch(L.SET_THIRD_PARTY_COOKIES_REQUEST,o,e);break;case Q.BACK_NAVIGATION_REQUEST:this.dispatch(L.BACK_NAVIGATION_REQUEST,o,e);break;case Q.GET_CURRENT_ROUTE_REQUEST:this.dispatch(L.GET_CURRENT_ROUTE_REQUEST,o,e);break;case Q.NAVIGATION_COMPLETED_REPORT:this.dispatch(L.NAVIGATION_COMPLETED_REPORT,o,e);break;case Q.UPDATE_MODAL_PATH_DATA_REQUEST:this.dispatch(L.UPDATE_MODAL_PATH_DATA_REQUEST,o,e);break;case Q.CHECK_PATH_EXISTS_REQUEST:this.dispatch(L.CHECK_PATH_EXISTS_REQUEST,o,e);break;case Q.SET_DIRTY_STATUS_REQUEST:this.dispatch(L.SET_DIRTY_STATUS_REQUEST,o,e);break;case"luigi.third-party-cookie":break;default:console.warn("Functionality not yet implemented: ",t)}}}},window.addEventListener("message",globalThis.__luigi_container_manager.messageListener)),globalThis.__luigi_container_manager}registerContainer(e){this.getContainerManager().container.push(e)}}class H{constructor(e){e?(this.rendererObject=e,this.config=e.config||{}):this.config={}}createCompoundContainer(){return document.createElement("div")}createCompoundItemContainer(e){return document.createElement("div")}attachCompoundItem(e,t){e.appendChild(t)}}class k extends H{constructor(e){super(e||{use:{}}),e&&e.use&&e.use.extends&&(this.superRenderer=W({use:e.use.extends,config:e.config}))}createCompoundContainer(){return this.rendererObject.use.createCompoundContainer?this.rendererObject.use.createCompoundContainer(this.config,this.superRenderer):this.superRenderer?this.superRenderer.createCompoundContainer():super.createCompoundContainer()}createCompoundItemContainer(e){return this.rendererObject.use.createCompoundItemContainer?this.rendererObject.use.createCompoundItemContainer(e,this.config,this.superRenderer):this.superRenderer?this.superRenderer.createCompoundItemContainer(e):super.createCompoundItemContainer(e)}attachCompoundItem(e,t){this.rendererObject.use.attachCompoundItem?this.rendererObject.use.attachCompoundItem(e,t,this.superRenderer):this.superRenderer?this.superRenderer.attachCompoundItem(e,t):super.attachCompoundItem(e,t)}}class P extends H{createCompoundContainer(){const e="__lui_compound_"+(new Date).getTime(),t=document.createElement("div");t.classList.add(e);let n="";return this.config.layouts&&this.config.layouts.forEach((t=>{if(t.minWidth||t.maxWidth){let o="@media only screen ";null!=t.minWidth&&(o+=`and (min-width: ${t.minWidth}px) `),null!=t.maxWidth&&(o+=`and (max-width: ${t.maxWidth}px) `),o+=`{\n .${e} {\n grid-template-columns: ${t.columns||"auto"};\n grid-template-rows: ${t.rows||"auto"};\n grid-gap: ${t.gap||"0"};\n }\n }\n `,n+=o}})),t.innerHTML=`\n <style scoped>\n .${e} {\n display: grid;\n grid-template-columns: ${this.config.columns||"auto"};\n grid-template-rows: ${this.config.rows||"auto"};\n grid-gap: ${this.config.gap||"0"};\n min-height: ${this.config.minHeight||"auto"};\n }\n ${n}\n </style>\n `,t}createCompoundItemContainer(e){const t=e||{},n=document.createElement("div");return n.setAttribute("style",`grid-row: ${t.row||"auto"}; grid-column: ${t.column||"auto"}`),n}}const W=e=>{const t=e.use;return t?"grid"===t?new P(e):t.createCompoundContainer||t.createCompoundItemContainer||t.attachCompoundItem?new k(e):new H(e):new H(e)},G=(e,t,n,o)=>{(null==t?void 0:t.eventListeners)&&t.eventListeners.forEach((t=>{const i=t.source+"."+t.name,r=e[i],s={wcElementId:n,wcElement:o,action:t.action,converter:t.dataConverter};r?r.push(s):e[i]=[s]}))};class q{constructor(){this.containerService=new x}dynamicImport(e){return import( /* webpackIgnore: true */e)}processViewUrl(e,t){return e}attachWC(e,t,n,o,i,r){if(n&&n.contains(t)){const s=document.createElement(e);r&&s.setAttribute("nodeId",r),this.initWC(s,e,n,i,o,r),n.replaceChild(s,t),n._luigi_node&&(n._luigi_mfe_webcomponent=s)}}createClientAPI(e,t,n){return{linkManager:()=>{},uxManager:()=>({showAlert:e=>{},showConfirmationModal:async e=>new Promise(((e,t)=>{e(!0)}))}),getCurrentLocale:()=>{},publishEvent:e=>{}}}initWC(e,t,n,o,i,r){const s=this.createClientAPI(n,r,t);if(e.__postProcess){const t=new URL(document.baseURI).origin===new URL(o,document.baseURI).origin?new URL("./",new URL(o,document.baseURI)):new URL("./",o);e.__postProcess(i,s,t.origin+t.pathname)}else e.context=i,e.LuigiClient=s}generateWCId(e){let t="";for(let n=0;n<e.length;n++)t+=e.charCodeAt(n).toString(16);return"luigi-wc-"+t}registerWCFromUrl(e,t){const n=this.processViewUrl(e);return new Promise(((e,o)=>{this.checkWCUrl(n)?this.dynamicImport(n).then((n=>{try{if(!window.customElements.get(t)){let e=n.default;if(!HTMLElement.isPrototypeOf(e)){let t=Object.keys(n);for(let o=0;o<t.length&&(e=n[t[o]],!HTMLElement.isPrototypeOf(e));o++);}window.customElements.define(t,e)}e(1)}catch(e){o(e)}})).catch((e=>o(e))):(console.warn(`View URL '${n}' not allowed to be included`),o(`View URL '${n}' not allowed`))}))}includeSelfRegisteredWCFromUrl(e,t,n){if(this.checkWCUrl(t)){this.containerService.getContainerManager()._registerWebcomponent||(this.containerService.getContainerManager()._registerWebcomponent=(e,t)=>{window.customElements.define(this.generateWCId(e),t)});let o=document.createElement("script");o.setAttribute("src",t),"module"===e.webcomponent.type&&o.setAttribute("type","module"),o.setAttribute("defer","true"),o.addEventListener("load",(()=>{n()})),document.body.appendChild(o)}else console.warn(`View URL '${t}' not allowed to be included`)}checkWCUrl(e){return!0}renderWebComponent(e,t,n,o,i){const r=this.processViewUrl(e,{context:n}),s=o.webcomponent&&o.webcomponent.tagName?o.webcomponent.tagName:this.generateWCId(r),a=document.createElement("div");t.appendChild(a),t._luigi_node=o,window.customElements.get(s)?this.attachWC(s,a,t,n,r,i):window.luigiWCFn?window.luigiWCFn(r,s,a,(()=>{this.attachWC(s,a,t,n,r,i)})):o.webcomponent&&o.webcomponent.selfRegistered?this.includeSelfRegisteredWCFromUrl(o,r,(()=>{this.attachWC(s,a,t,n,r,i)})):this.registerWCFromUrl(r,s).then((()=>{this.attachWC(s,a,t,n,r,i)}))}createCompoundContainerAsync(e,t){return new Promise(((n,o)=>{if(e.viewUrl)try{const o=this.generateWCId(e.viewUrl);this.registerWCFromUrl(e.viewUrl,o).then((()=>{const i=document.createElement(o);this.initWC(i,o,i,e.viewUrl,t,"_root"),n(i)}))}catch(e){o(e)}else n(e.createCompoundContainer())}))}renderWebComponentCompound(e,t,n){var o;let i;return e.webcomponent&&e.viewUrl?(i=new H,i.viewUrl=this.processViewUrl(e.viewUrl,{context:n}),i.createCompoundItemContainer=e=>{var t=document.createElement("div");return e&&e.slot&&t.setAttribute("slot",e.slot),t}):(null===(o=e.compound)||void 0===o?void 0:o.renderer)&&(i=W(e.compound.renderer)),i=i||new H,new Promise((o=>{this.createCompoundContainerAsync(i,n).then((r=>{var s;const a={};r.eventBus={listeners:a,onPublishEvent:(e,t,n)=>{const o=a[t+"."+e.type]||[];o.push(...a["*."+e.type]||[]),o.forEach((t=>{const n=t.wcElement||r.querySelector("[nodeId="+t.wcElementId+"]");n?n.dispatchEvent(new CustomEvent(t.action,{detail:t.converter?t.converter(e.detail):e.detail})):console.debug("Could not find event target",t)}))}},null===(s=e.compound)||void 0===s||s.children.forEach(((e,t)=>{const o=Object.assign(Object.assign({},n),e.context),s=i.createCompoundItemContainer(e.layoutConfig);s.eventBus=r.eventBus,i.attachCompoundItem(r,s);const c=e.id||"gen_"+t;this.renderWebComponent(e.viewUrl,s,o,e,c),G(a,e,c)})),t.appendChild(r),G(a,e.compound,"_root",r),o(r)}))}))}}function V(e){let t,n=!e[5](),o=n&&function(e){let t,n;return{c(){t=l("iframe"),c(t.src,n=e[0])||_(t,"src",n),_(t,"title",e[1])},m(n,o){u(n,t,o),e[8](t)},p(e,o){1&o&&!c(t.src,n=e[0])&&_(t,"src",n),2&o&&_(t,"title",e[1])},d(n){n&&d(t),e[8](null)}}}(e);return{c(){o&&o.c(),t=E()},m(e,n){o&&o.m(e,n),u(e,t,n)},p(e,t){n&&o.p(e,t)},d(e){o&&o.d(e),e&&d(t)}}}function F(t){let n,o=!t[4]&&V(t);return{c(){n=l("main"),o&&o.c(),this.c=e,_(n,"class",t[5]()?void 0:"lui-isolated")},m(e,i){u(e,n,i),o&&o.m(n,null),t[9](n)},p(e,[t]){e[4]?o&&(o.d(1),o=null):o?o.p(e,t):(o=V(e),o.c(),o.m(n,null))},i:e,o:e,d(e){e&&d(n),o&&o.d(),t[9](null)}}}function K(e,t,n){let o,{viewurl:i}=t,{context:r}=t,{label:s}=t,{webcomponent:a}=t,c={};const u=new x,d=new q;d.createClientAPI=(e,t,n)=>({linkManager:()=>({navigate:e=>{_("navigation-request",{link:e})}}),uxManager:()=>({showAlert:e=>{_("alert-request",e)},showConfirmationModal:async e=>new Promise(((t,n)=>{_("confirmation-request",e,(e=>{e?t(e):n()}))}))}),getCurrentLocale:()=>{},publishEvent:e=>{}});const l=T();l.iframeHandle=c;let E=!!l.attributes["defer-init"];function _(e,t,n){u.dispatch(e,l,t,n)}function h(){return!!a}var m;return l.init=()=>{n(4,E=!1)},l.sendCustomMessage=(e,t)=>{if(h()&&o._luigi_mfe_webcomponent)u.dispatch(e,o._luigi_mfe_webcomponent,t);else{const n=Object.assign({},t);n.id&&console.warn('Property "id" is reserved and can not be used in custom message data'),n.id=e,u.sendCustomMessageToIframe(c,n)}},u.registerContainer(l),p((async()=>{const e=r?JSON.parse(r):{};h()&&(n(3,o.innerHTML="",o),d.renderWebComponent(i,o,e,{}))})),m=async()=>{},T().$$.on_destroy.push(m),e.$$set=e=>{"viewurl"in e&&n(0,i=e.viewurl),"context"in e&&n(6,r=e.context),"label"in e&&n(1,s=e.label),"webcomponent"in e&&n(7,a=e.webcomponent)},[i,s,c,o,E,h,r,a,function(e){R[e?"unshift":"push"]((()=>{c.iframe=e,n(2,c)}))},function(e){R[e?"unshift":"push"]((()=>{o=e,n(3,o)}))}]}class j extends D{constructor(e){super(),this.shadowRoot.innerHTML="<style>main,iframe{width:100%;height:100%;border:none}main.lui-isolated{line-height:0}</style>",v(this,{target:this.shadowRoot,props:h(this.attributes),customElement:!0},K,F,r,{viewurl:0,context:6,label:1,webcomponent:7},null),e&&(e.target&&u(e.target,this,e.anchor),e.props&&(this.$set(e.props),U()))}static get observedAttributes(){return["viewurl","context","label","webcomponent"]}get viewurl(){return this.$$.ctx[0]}set viewurl(e){this.$$set({viewurl:e}),U()}get context(){return this.$$.ctx[6]}set context(e){this.$$set({context:e}),U()}get label(){return this.$$.ctx[1]}set label(e){this.$$set({label:e}),U()}get webcomponent(){return this.$$.ctx[7]}set webcomponent(e){this.$$set({webcomponent:e}),U()}}function B(t){let n;return{c(){n=l("main"),this.c=e},m(e,o){u(e,n,o),t[2](n)},p:e,i:e,o:e,d(e){e&&d(n),t[2](null)}}}function X(e,t,n){let o,{context:i}=t,r=!1;const s=new x,a=new q;a.createClientAPI=(e,t,n)=>({linkManager:()=>{},uxManager:()=>({showAlert:e=>{u("alert-request",e,{})},showConfirmationModal:async e=>new Promise(((t,n)=>{u("confirmation-request",e,(e=>{e?t(e):n()}))}))}),getCurrentLocale:()=>{},publishEvent:o=>{e&&e.eventBus&&e.eventBus.onPublishEvent(o,t,n)}});const c=T();function u(e,t,n){s.dispatch(e,c,t,n)}return c.attributes["defer-init"],c.init=()=>{if(!c.compoundConfig||r)return;const e={compound:c.compoundConfig};a.renderWebComponentCompound(e,o,i).then((e=>{})),r=!0},s.registerContainer(c),p((async()=>{!i||JSON.parse(i)})),e.$$set=e=>{"context"in e&&n(1,i=e.context)},[o,i,function(e){R[e?"unshift":"push"]((()=>{o=e,n(0,o)}))}]}class Y extends D{constructor(e){super(),this.shadowRoot.innerHTML="<style>main{width:100%;height:100%;border:none}</style>",v(this,{target:this.shadowRoot,props:h(this.attributes),customElement:!0},X,B,r,{context:1},null),e&&(e.target&&u(e.target,this,e.anchor),e.props&&(this.$set(e.props),U()))}static get observedAttributes(){return["context"]}get context(){return this.$$.ctx[1]}set context(e){this.$$set({context:e}),U()}}var Z=L;customElements.get("luigi-container")||customElements.define("luigi-container",j),customElements.get("luigi-compound-container")||customElements.define("luigi-compound-container",Y);export{Y as LuigiCompoundContainer,j as LuigiContainer,Z as default}; | ||
//# sourceMappingURL=bundle.js.map |
@@ -22,3 +22,3 @@ { | ||
], | ||
"version": "1.0.0-rc3" | ||
"version": "1.0.0-rc4" | ||
} |
Sorry, the diff of this file is not supported yet
131329
89