@luigi-project/core 2.7.2-dev.20231150028 → 2.7.2-dev.20231180025
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.
- package/luigi.js +1 -1
- package/package.json +1 -1
package/luigi.js
CHANGED
|
@@ -23,7 +23,7 @@ Invalid Children:`,t),null):(t.some(s=>{if(s.pathSegment===e||s.pathSegment&&s.p
|
|
|
23
23
|
}
|
|
24
24
|
${n}
|
|
25
25
|
</style>
|
|
26
|
-
`,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 g_=i=>{const e=i.use;if(e){if(e==="grid")return new qw(i);if(e.createCompoundContainer||e.createCompoundItemContainer||e.attachCompoundItem)return new zw(i)}else return new hr(i);return new hr(i)},Ff=(i,e,t,n)=>{e.eventListeners&&e.eventListeners.forEach(l=>{const r=l.source+"."+l.name,s=i[r],o={wcElementId:t,wcElement:n,action:l.action,converter:l.dataConverter};s?s.push(o):i[r]=[o]})},Gw=i=>Object.entries(i).reduce((e,t)=>(e[Uf(t[0])]=Uf(t[1]),e),{}),Uf=(i="")=>String(i).replaceAll("<","<").replaceAll(">",">").replaceAll(""",'"').replaceAll("'","'").replaceAll("/","/");class Kw{constructor(){}dynamicImport(e){return import(
|
|
26
|
+
`,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 g_=i=>{const e=i.use;if(e){if(e==="grid")return new qw(i);if(e.createCompoundContainer||e.createCompoundItemContainer||e.attachCompoundItem)return new zw(i)}else return new hr(i);return new hr(i)},Ff=(i,e,t,n)=>{e.eventListeners&&e.eventListeners.forEach(l=>{const r=l.source+"."+l.name,s=i[r],o={wcElementId:t,wcElement:n,action:l.action,converter:l.dataConverter};s?s.push(o):i[r]=[o]})},Gw=i=>Object.entries(i).reduce((e,t)=>(e[Uf(t[0])]=Uf(t[1]),e),{}),Uf=(i="")=>String(i).replaceAll("<","<").replaceAll(">",">").replaceAll(""",'"').replaceAll("'","'").replaceAll("/","/");class Kw{constructor(){}dynamicImport(e){return import(e)}attachWC(e,t,n,l,r,s,o){if(n&&n.contains(t)){const f=document.createElement(e);s&&f.setAttribute("nodeId",s),f.setAttribute("lui_web_component",!0),this.initWC(f,e,n,r,l,s,o),n.replaceChild(f,t)}}initWC(e,t,n,l,r,s,o){const f=r.context;e.extendedContext=r,e.extendedContext.currentNode&&(e.extendedContext.clientPermissions=e.extendedContext.currentNode.clientPermissions);const g={linkManager:window.Luigi.navigation,uxManager:window.Luigi.ux,getCurrentLocale:()=>window.Luigi.i18n().getCurrentLocale(),publishEvent:_=>{n.eventBus&&n.eventBus.onPublishEvent(_,s,t)},getActiveFeatureToggleList:()=>window.Luigi.featureToggles().getActiveFeatureToggleList(),getActiveFeatureToggles:()=>window.Luigi.featureToggles().getActiveFeatureToggleList(),getPathParams:()=>{var _;return(_=e.extendedContext)!=null&&_.pathParams?e.extendedContext.pathParams:{}},getCoreSearchParams:()=>{const _={clientPermissions:e.extendedContext.clientPermissions};return me.prepareSearchParamsForClient(_)},getClientPermissions:()=>{var _;return(_=e.extendedContext)!=null&&_.clientPermissions?e.extendedContext.clientPermissions:{}},addNodeParams:(_,p)=>{o||window.Luigi.routing().addNodeParams(_,p)},getNodeParams:_=>{var b;if(o)return{};const p=(b=e.extendedContext)!=null&&b.nodeParams?e.extendedContext.nodeParams:{};return _?Gw(p):e.extendedContext.nodeParams},setAnchor:_=>{o||window.Luigi.routing().setAnchor(_)},getAnchor:()=>window.Luigi.routing().getAnchor(),getUserSettings:async()=>await this.getUserSettingsForWc(n._luigi_node)};if(e.__postProcess){const _=new URL(document.baseURI).origin===new URL(l,document.baseURI).origin?new URL(l,document.baseURI):new URL("./",l);e.__postProcess(f,g,_.origin+_.pathname)}else e.context=f,e.nodeParams=r.nodeParams,e.LuigiClient=g;const h=re.getConfigValue("settings.webcomponentCreationInterceptor");ne.isFunction(h)&&h(e,r.currentNode,r,s,o)}generateWCId(e){let t="",n=new URL(e,encodeURI(location.href)).href;for(let l=0;l<n.length;l++)t+=n.charCodeAt(l).toString(16);return"luigi-wc-"+t}registerWCFromUrl(e,t){const n=me.getI18nViewUrl(e);return new Promise((l,r)=>{this.checkWCUrl(n)?this.dynamicImport(n).then(s=>{try{if(!window.customElements.get(t)){let o=s.default;if(!HTMLElement.isPrototypeOf(o)){let f=Object.keys(s);for(let g=0;g<f.length&&(o=s[f[g]],!HTMLElement.isPrototypeOf(o));g++);}window.customElements.define(t,o)}l()}catch(o){r(o)}}).catch(s=>r(s)):(console.warn(`View URL '${n}' not allowed to be included`),r(`View URL '${n}' not allowed`))})}includeSelfRegisteredWCFromUrl(e,t,n){if(this.checkWCUrl(t)){window.Luigi._registerWebcomponent||(window.Luigi._registerWebcomponent=(r,s)=>{const o=this.generateWCId(r);window.customElements.get(o)||window.customElements.define(o,s)});let l=document.createElement("script");l.setAttribute("src",t),e.webcomponent.type==="module"&&l.setAttribute("type","module"),l.setAttribute("defer",!0),l.addEventListener("load",()=>{n()}),document.body.appendChild(l)}else console.warn(`View URL '${t}' not allowed to be included`)}checkWCUrl(e){if(e.indexOf("://")>0||e.trim().indexOf("//")===0){if(new URL(e).host===window.location.host)return!0;const n=re.getConfigValue("navigation.validWebcomponentUrls");if(n&&n.length>0)for(let l of n)try{if(new RegExp(l).test(e))return!0}catch(r){console.error(r)}return!1}return!0}renderWebComponent(e,t,n,l,r,s){var _;const o=n.context,f=me.substituteViewUrl(e,{context:o}),g=((_=l==null?void 0:l.webcomponent)==null?void 0:_.tagName)||this.generateWCId(f),h=document.createElement("div");t.appendChild(h),t._luigi_node=l,window.customElements.get(g)?this.attachWC(g,h,t,n,f,r,s):window.luigiWCFn?window.luigiWCFn(f,g,h,()=>{this.attachWC(g,h,t,n,f,r,s)}):l.webcomponent&&l.webcomponent.selfRegistered?this.includeSelfRegisteredWCFromUrl(l,f,()=>{this.attachWC(g,h,t,n,f,r,s)}):this.registerWCFromUrl(f,g).then(()=>{this.attachWC(g,h,t,n,f,r,s)})}createCompoundContainerAsync(e,t,n){return new Promise((l,r)=>{var s,o;if(e.viewUrl)try{const f=((s=n==null?void 0:n.webcomponent)==null?void 0:s.tagName)||this.generateWCId(e.viewUrl),g=document.createElement(f);(o=n==null?void 0:n.webcomponent)!=null&&o.selfRegistered?this.includeSelfRegisteredWCFromUrl(n,e.viewUrl,()=>{this.initWC(g,f,g,e.viewUrl,t,"_root"),l(g)}):this.registerWCFromUrl(e.viewUrl,f).then(()=>{this.initWC(g,f,g,e.viewUrl,t,"_root"),l(g)})}catch(f){r(f)}else l(e.createCompoundContainer())})}renderWebComponentCompound(e,t,n){const l=n.context;let r;return t._luigi_node=e,e.webcomponent&&e.viewUrl?(r=new hr,r.viewUrl=me.substituteViewUrl(e.viewUrl,{context:l}),r.createCompoundItemContainer=s=>{var o=document.createElement("div");return s&&s.slot&&o.setAttribute("slot",s.slot),o}):e.compound.renderer&&(r=g_(e.compound.renderer)),r=r||new hr,new Promise(s=>{this.createCompoundContainerAsync(r,n,e).then(o=>{const f={};o.eventBus={listeners:f,onPublishEvent:(g,h,_)=>{const p=f[h+"."+g.type]||[];p.push(...f["*."+g.type]||[]),p.forEach(b=>{const v=b.wcElement||o.querySelector("[nodeId="+b.wcElementId+"]");v?v.dispatchEvent(new CustomEvent(b.action,{detail:b.converter?b.converter(g.detail):g.detail})):console.debug("Could not find event target",b)})}},e.compound.children.forEach((g,h)=>{const _={...l,...g.context},p=r.createCompoundItemContainer(g.layoutConfig);p.eventBus=o.eventBus,r.attachCompoundItem(o,p);const b=g.id||"gen_"+h;this.renderWebComponent(g.viewUrl,p,{context:_},g,b,!0),Ff(f,g,b)}),t.appendChild(o),Ff(f,e.compound,"_root",o),s(o)})})}getUserSettingsForWc(e){return new Promise((t,n)=>{if(e.userSettingsGroup){const l=e.userSettingsGroup;re.readUserSettings().then(r=>{const o=l&&typeof r=="object"&&r!==null?r[l]:null;t(o)})}else n(null)})}}const cr=new Kw;var Yr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Dl={exports:{}};/**
|
|
27
27
|
* @license
|
|
28
28
|
* Lodash <https://lodash.com/>
|
|
29
29
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
package/package.json
CHANGED