@luigi-project/client 1.25.2-dev.20221290038 → 1.25.2-dev.20230120046

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-client.d.ts CHANGED
@@ -182,7 +182,7 @@ export declare interface UxManager {
182
182
  * @param {string} [settings.buttonDismiss="No"] the label for the modal dismiss button
183
183
  * @returns {promise} which is resolved when accepting the confirmation modal and rejected when dismissing it
184
184
  * @example
185
- * import LuigiClient from '@kyma-project/luigi-client';
185
+ * import LuigiClient from '@luigi-project/client';
186
186
  * const settings = {
187
187
  * header: "Confirmation",
188
188
  * body: "Are you sure you want to do this?",
package/luigi-client.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LuigiClient=t():e.LuigiClient=t()}(window,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}e.exports=function(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),e}},function(e,t,n){var i=n(7),r=n(5);e.exports=function(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?r(e):t}},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){var i=n(8);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t,n){var i=n(10),r=n(11),o=n(12);e.exports=function(e,t){return i(e)||r(e,t)||o()}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t){function n(t,i){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,i)}e.exports=n},function(e){e.exports=JSON.parse('{"name":"@luigi-project/client","description":"Javascript library supporting consumers of the Luigi framework","license":"Apache-2.0","main":"luigi-client.js","repository":{"type":"git","url":"ssh://github.com/SAP/luigi.git"},"publishConfig":{"tag":"luigi-client"},"keywords":["luigi","UI","extensibility","micro-frontends","microfrontends"],"version":"1.25.2-dev.20221280036"}')},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{i||null==s.return||s.return()}finally{if(r)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t,n){"use strict";n.r(t);var i=n(0),r=n.n(i),o=n(1),a=n.n(o),s=n(2),u=n.n(s),l=n(3),c=n.n(l),d=n(4),v=n.n(d),g=function(){function e(){r()(this,e),this.promises={}}return a()(e,[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}]),e}(),f=new(function(){function e(){r()(this,e),this.listeners=[],this.origin="";var t=function(e){if(e.data.msg)if("custom"===e.data.msg){var t=this.convertCustomMessageInternalToUser(e.data);this.listeners.filter((function(e){return e.name===t.id})).map((function(e){return e.eventFn(t,e.listenerId)}))}else this.listeners.filter((function(t){return t.name===e.data.msg})).map((function(t){return t.eventFn(e,t.listenerId)}))}.bind(this);window.addEventListener("message",t)}return a()(e,[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",data:e}}},{key:"convertStorageMessageToInternal",value:function(e){return{msg:"storage",data:e}}},{key:"addEventListener",value:function(e,t){var n=this.getRandomId();return this.listeners.push({name:e,eventFn:t,listenerId:n}),n}},{key:"removeEventListener",value:function(e){return!!Boolean(this.listeners.find((function(t){return t.listenerId===e})))&&(this.listeners=this.listeners.filter((function(t){return t.listenerId!==e})),!0)}},{key:"getRandomId",value:function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&"null"!==e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){if(this.origin)try{window.parent.postMessage(e,this.origin)}catch(t){console.warn("Unable to post message "+e+" to Luigi Core from origin "+this.origin+": "+t)}else console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}},{key:"hasIntent",value:function(e){return!!e&&e.toLowerCase().includes("#?intent=")}},{key:"deSanitizeParamsMap",value:function(e){var t=this;return Object.entries(e).reduce((function(e,n){return e[t.deSanitizeParam(n[0])]=t.deSanitizeParam(n[1]),e}),{})}},{key:"deSanitizeParam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return String(e).replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/")}}]),e}()),h=new(function(e){function t(){var e;return r()(this,t),(e=u()(this,c()(t).call(this))).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams","searchParams"],e.setCurrentContext(e.defaultContextKeys.reduce((function(e,t){return e[t]={},e}),{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={},e._isDeferInitDefined()||e.luigiClientInit(),e}return v()(t,e),a()(t,[{key:"_isDeferInitDefined",value:function(){return window.document.head.hasAttribute("defer-luigi-init")}},{key:"isLuigiClientInitialized",value:function(){return this.luigiInitialized}},{key:"luigiClientInit",value:function(){var e=this;if(this.luigiInitialized)console.warn("Luigi Client has been already initialized");else{var t=function(t){for(var n=0;n<e.defaultContextKeys.length;n++){var i=e.defaultContextKeys[n];try{"string"==typeof t[i]&&(t[i]=JSON.parse(t[i]))}catch(e){console.info("unable to parse luigi context data for",i,t[i],e)}}e.setCurrentContext(t)},i=function(t){t&&(e.authData=t)};f.addEventListener("luigi.init",(function(n){t(n.data),i(n.data.authData),f.setLuigiCoreDomain(n.origin),e.luigiInitialized=!0,e._notifyInit(n.origin),f.sendPostMessageToLuigiCore({msg:"luigi.init.ok"})})),f.addEventListener("luigi-client.inactive-microfrontend",(function(t){e._notifyInactive(t.origin)})),f.addEventListener("luigi.auth.tokenIssued",(function(e){i(e.data.authData)})),f.addEventListener("luigi.navigate",(function(n){if(t(n.data),!e.currentContext.internal.isNavigateBack&&!e.currentContext.withoutSync){var i=window.location.hash;history.replaceState({luigiInduced:!0},"",n.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"})),window.location.hash!==i&&window.dispatchEvent(new HashChangeEvent("hashchange"))}e.currentContext.withoutSync&&Object.assign(e.currentContext.context,{viewUrl:n.data.viewUrl?n.data.viewUrl:void 0,pathParams:n.data.pathParams?n.data.pathParams:void 0}),e._notifyUpdate(),f.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})})),window.parent.postMessage({msg:"luigi.get-context",clientVersion:n(9).version},"*"),this._tpcCheck()}}},{key:"_tpcCheck",value:function(){var e,t,n="enabled",i=document.cookie;i&&(e=i.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"==e}))),"luigiCookie=true"===e&&(t=e.split("=")[0],document.cookie=t+"=; Max-Age=-99999999;"),document.cookie="luigiCookie=true; SameSite=None; Secure",(i=document.cookie)&&(e=i.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"==e}))),"luigiCookie=true"===e?(window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:n},"*"),document.cookie=t+"=; Max-Age=-99999999;"):(n="disabled",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:n},"*"),console.warn("Third party cookies are not supported!"))}},{key:"_callAllFns",value:function(e,t,n){for(var i in e)e.hasOwnProperty(i)&&f.isFunction(e[i])&&e[i](t,n)}},{key:"_notifyInit",value:function(e){this._callAllFns(this._onInitFns,this.currentContext.context,e)}},{key:"_notifyUpdate",value:function(){this._callAllFns(this._onContextUpdatedFns,this.currentContext.context)}},{key:"_notifyInactive",value:function(){this._callAllFns(this._onInactiveFns)}},{key:"setCurrentContext",value:function(e){this.currentContext=e}},{key:"addInitListener",value:function(e){var t=f.getRandomId();return this._onInitFns[t]=e,this.luigiInitialized&&f.isFunction(e)&&e(this.currentContext.context,f.getLuigiCoreDomain()),t}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=f.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&f.isFunction(e)&&e(this.currentContext.context),t}},{key:"removeContextUpdateListener",value:function(e){return!!this._onContextUpdatedFns[e]&&(this._onContextUpdatedFns[e]=void 0,!0)}},{key:"addInactiveListener",value:function(e){var t=f.getRandomId();return this._onInactiveFns[t]=e,t}},{key:"removeInactiveListener",value:function(e){return!!this._onInactiveFns[e]&&(this._onInactiveFns[e]=void 0,!0)}},{key:"addCustomMessageListener",value:function(e,t){return f.addEventListener(e,(function(e,n){return t(e,n)}))}},{key:"removeCustomMessageListener",value:function(e){return f.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getActiveFeatureToggles",value:function(){return this.currentContext.internal.activeFeatureToggleList}},{key:"addNodeParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&f.sendPostMessageToLuigiCore({msg:"luigi.addNodeParams",data:e,keepBrowserHistory:t})}},{key:"getNodeParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e?f.deSanitizeParamsMap(this.currentContext.nodeParams):this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getCoreSearchParams",value:function(){return this.currentContext.searchParams||{}}},{key:"addCoreSearchParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&f.sendPostMessageToLuigiCore({msg:"luigi.addSearchParams",data:e,keepBrowserHistory:t})}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){f.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=f.convertCustomMessageUserToInternal(e);f.sendPostMessageToLuigiCore(t)}},{key:"getUserSettings",value:function(){return this.currentContext.internal.userSettings}},{key:"getAnchor",value:function(){return this.currentContext.internal.anchor||""}},{key:"setAnchor",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.setAnchor",anchor:e})}}]),t}(g)),p=n(6),m=n.n(p),y=n(5),k=n.n(y),C=function(e){function t(e){var n;r()(this,t),(n=u()(this,c()(t).call(this))).validSplitViewEvents=["expand","collapse","resize","close"],n.splitView={exists:!0,size:40,collapsed:!1},Object.assign(n.splitView,e);return n.splitView.listeners=[f.addEventListener("luigi.navigation.splitview.internal",(function(e){Object.assign(n.splitView,e.data.data)}))],n.on("resize",(function(e){n.splitView.size=e})),n.on("close",(function(){n.splitView.listeners.forEach((function(e){return f.removeEventListener(e)}))})),n}return v()(t,e),a()(t,[{key:"sendSplitViewEvent",value:function(e,t){f.sendPostMessageToLuigiCore({msg:"luigi.navigation.splitview.".concat(e),data:t})}},{key:"collapse",value:function(){this.sendSplitViewEvent("collapse")}},{key:"expand",value:function(){this.sendSplitViewEvent("expand")}},{key:"close",value:function(){this.sendSplitViewEvent("close")}},{key:"setSize",value:function(e){this.sendSplitViewEvent("resize",e)}},{key:"on",value:function(e,t){if(!this.validSplitViewEvents.includes(e))return console.warn(e+" is not a valid split view event"),!1;var n=f.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),(function(e){var n="number"==typeof e.data.data?e.data.data:void 0;t(n)}));return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return f.removeEventListener(e)}},{key:"exists",value:function(){return this.splitView.exists}},{key:"getSize",value:function(){return this.splitView.size}},{key:"isCollapsed",value:function(){return this.splitView.collapsed}},{key:"isExpanded",value:function(){return!this.splitView.collapsed}}]),t}(g),w=function(e){function t(e){var n;return r()(this,t),n=u()(this,c()(t).call(this)),Object.assign(k()(n),e),n.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:"",newTab:!1,preserveQueryParams:!1,anchor:"",preventContextUpdate:!1,preventHistoryEntry:!1},n}return v()(t,e),a()(t,[{key:"navigate",value:function(e,t,n,i,r,o){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&r&&o&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var a="/"!==e[0];if("/"===e&&(i||r||o))console.warn("Navigation with an absolute path prevented.");else{var s={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:a,intent:f.hasIntent(e),modal:i,splitView:r,drawer:o})};f.sendPostMessageToLuigiCore(s)}}}},{key:"updateModalPathInternalNavigation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e){var i={msg:"luigi.navigation.updateModalDataPath",params:Object.assign(this.options,{link:e,modal:t,history:n})};f.sendPostMessageToLuigiCore(i)}else console.warn("Updating path of the modal upon internal navigation prevented. No path specified.")}},{key:"navigateToIntent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="#?intent=";if(n+=e,t){var i=Object.entries(t);if(i.length>0){n+="?";for(var r=0,o=i;r<o.length;r++){var a=m()(o[r],2),s=a[0],u=a[1];n+=s+"="+u+"&"}n=n.slice(0,-1)}}this.navigate(n)}},{key:"openAsModal",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,t)}},{key:"updateModalSettings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={msg:"luigi.navigation.updateModalSettings",updatedModalSettings:e};f.sendPostMessageToLuigiCore(t)}},{key:"openAsSplitView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.navigate(e,0,!0,void 0,t),new C(t)}},{key:"openAsDrawer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,void 0,void 0,t)}},{key:"fromContext",value:function(e){return this.currentContext.context.parentNavigationContexts&&-1!==this.currentContext.context.parentNavigationContexts.indexOf(e)?this.options.fromContext=e:(this.options.errorSkipNavigation=!0,console.error("Navigation not possible, navigationContext "+e+" not found.")),this}},{key:"fromClosestContext",value:function(){return this.currentContext&&this.currentContext.context.parentNavigationContexts.length>0?(this.options.fromContext=null,this.options.fromClosestContext=!0):console.error("Navigation not possible, no parent navigationContext found."),this}},{key:"fromVirtualTreeRoot",value:function(){return this.options.fromContext=null,this.options.fromClosestContext=!1,this.options.fromVirtualTreeRoot=!0,this}},{key:"fromParent",value:function(){return this.options.fromParent=!0,this}},{key:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"withOptions",value:function(e){return f.isObject(e)?(void 0!==e.preventHistoryEntry&&(this.options.preventHistoryEntry=e.preventHistoryEntry),void 0!==e.preventContextUpdate&&(this.options.preventContextUpdate=e.preventContextUpdate),this):this}},{key:"pathExists",value:function(e){var t=f.getRandomId(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),f.addEventListener("luigi.navigation.pathExists.answer",function(e,n){var i=e.data.data,r=this.getPromise("pathExistsPromises")||{};i.correlationId===t&&(r[i.correlationId]&&(r[i.correlationId].resolveFn(i.pathExists),delete r[i.correlationId],this.setPromise("pathExistsPromises",r)),f.removeEventListener(n))}.bind(this));var i={msg:"luigi.navigation.pathExists",data:Object.assign(this.options,{id:t,link:e,intent:f.hasIntent(e),relative:"/"!==e[0]})};return f.sendPostMessageToLuigiCore(i),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}},{key:"withoutSync",value:function(){return this.options.withoutSync=!0,this}},{key:"newTab",value:function(){return this.options.newTab=!0,this}},{key:"preserveQueryParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.options.preserveQueryParams=e,this}},{key:"getCurrentRoute",value:function(){var e=this,t=f.getRandomId(),n=this.getPromise("getCurrentRoute")||{};return n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("getCurrentRoute",n),f.addEventListener("luigi.navigation.currentRoute.answer",(function(n,i){var r=n.data.data,o=e.getPromise("getCurrentRoute")||{};r.correlationId===t&&(o[r.correlationId]&&(o[r.correlationId].resolveFn(r.route),delete o[r.correlationId],e.setPromise("getCurrentRoute",o)),f.removeEventListener(i)),f.removeEventListener(i)})),f.sendPostMessageToLuigiCore({msg:"luigi.navigation.currentRoute",data:Object.assign(this.options,{id:t})}),n[t]}}]),t}(g),x=new(function(e){function t(){var e;return r()(this,t),e=u()(this,c()(t).call(this)),f.addEventListener("luigi.current-locale-changed",(function(e){var t;e.data.currentLocale&&(null===(t=h.currentContext)||void 0===t?void 0:t.internal)&&(h.currentContext.internal.currentLocale=e.data.currentLocale,h._notifyUpdate())})),e}return v()(t,e),a()(t,[{key:"showLoadingIndicator",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"closeCurrentModal",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.close-modal"})}},{key:"addBackdrop",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;f.addEventListener("luigi.ux.confirmationModal.hide",(function(e,n){t.hideConfirmationModal(e.data.data),f.removeEventListener(n)})),f.sendPostMessageToLuigiCore({msg:"luigi.ux.confirmationModal.show",data:{settings:e}});var n={};return n.promise=new Promise((function(e,t){n.resolveFn=e,n.rejectFn=t})),this.setPromise("confirmationModal",n),n.promise}},{key:"hideConfirmationModal",value:function(e){var t=this.getPromise("confirmationModal");t&&(e.confirmed?t.resolveFn():t.rejectFn(),this.setPromise("confirmationModal",void 0))}},{key:"showAlert",value:function(e){var t=this;f.addEventListener("luigi.ux.alert.hide",(function(e,n){t.hideAlert(e.data),f.removeEventListener(n)})),e.id=f.getRandomId(),(null==e?void 0:e.closeAfter)<100&&(console.warn("Message with id='".concat(e.id,"' has too small 'closeAfter' value. It needs to be at least 100ms.")),e.closeAfter=void 0),f.sendPostMessageToLuigiCore({msg:"luigi.ux.alert.show",data:{settings:e}});var n=this.getPromise("alerts")||{};return n[e.id]={},n[e.id].promise=new Promise((function(t){n[e.id].resolveFn=t})),this.setPromise("alerts",n),n[e.id].promise}},{key:"hideAlert",value:function(e){var t=e.id,n=e.dismissKey,i=this.getPromise("alerts");t&&i[t]&&(i[t].resolveFn(n||t),delete i[t],this.setPromise("alerts",i))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&f.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"isDrawer",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.drawer}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}}]),t}(g)),P=new Map,L=function(e){function t(){var e;return r()(this,t),(e=u()(this,c()(t).call(this))).storageEventProcessor=new b,f.addEventListener("storage",(function(t,n){return e.storageEventProcessor.processEvent(t,n)})),e}return v()(t,e),a()(t,[{key:"setItem",value:function(e,t){var n=this;return new Promise((function(i,r){n.storageEventProcessor.execute(i,r,"setItem",{key:e,value:t})}))}},{key:"getItem",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"getItem",{key:e})}))}},{key:"removeItem",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"removeItem",{key:e})}))}},{key:"clear",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"clear",{})}))}},{key:"has",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"has",{key:e})}))}},{key:"getAllKeys",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"getAllKeys",{})}))}}]),t}(g),b=function(){function e(){r()(this,e)}return a()(e,[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!P.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var i=P.get(n.id);"ERROR"===n.status?i.reject(n.result):i.resolve(n.result),P.delete(n.id)}catch(e){console.error(e)}}},{key:"waitForSyncResult",value:function(e){for(var t=(new Date).getTime();!syncOperation.has(e);){if((new Date).getTime()-t>1e4)throw"Storage operation is taking more than 1 second...Some problem with Luigi Core communication"}var n=syncOperation.get(e);return P.delete(e),n}},{key:"execute",value:function(e,t,n,i){var r=f.getRandomId();this.createPendingOperation(r,e,t),this.sendMessage(r,n,i)}},{key:"createPendingOperation",value:function(e,t,n){P.set(e,{resolve:t,reject:n})}},{key:"sendMessage",value:function(e,t,n){f.sendPostMessageToLuigiCore({msg:"storage",data:{id:e,operation:t,params:n}})}}]),e}(),I=new L,M=function(){function e(){r()(this,e),window!==window.top&&("true"!==window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history)),"true"!==window.document.head.getAttribute("disable-luigi-runtime-error-handling")&&window.addEventListener("error",(function(e){var t={msg:"luigi-runtime-error-handling",errorObj:{filename:e.filename,message:e.message,lineno:e.lineno,colno:e.colno,error:e.error}};f.sendPostMessageToLuigiCore(t)})))}return a()(e,[{key:"addInitListener",value:function(e){return h.addInitListener(e)}},{key:"removeInitListener",value:function(e){return h.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return h.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return h.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return h.getToken()}},{key:"getEventData",value:function(){return h.getEventData()}},{key:"getContext",value:function(){return h.getContext()}},{key:"addNodeParams",value:function(e,t){return h.addNodeParams(e,t)}},{key:"getNodeParams",value:function(e){return h.getNodeParams(e)}},{key:"getActiveFeatureToggles",value:function(){return h.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return h.getPathParams()}},{key:"getCoreSearchParams",value:function(){return h.getCoreSearchParams()}},{key:"addCoreSearchParams",value:function(e,t){return h.addCoreSearchParams(e,t)}},{key:"getClientPermissions",value:function(){return h.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return h.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return h.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return h.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return h.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return h.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return h.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return h.getUserSettings()}},{key:"isLuigiClientInitialized",value:function(){return h.isLuigiClientInitialized()}},{key:"luigiClientInit",value:function(){return h.luigiClientInit()}},{key:"getAnchor",value:function(){return h.getAnchor()}},{key:"setAnchor",value:function(e){return h.setAnchor(e)}},{key:"linkManager",value:function(){return new w({currentContext:h.currentContext})}},{key:"uxManager",value:function(){return x}},{key:"lifecycleManager",value:function(){return h}},{key:"storageManager",value:function(){return I}}]),e}();t.default=M=new M}]).default}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LuigiClient=t():e.LuigiClient=t()}(window,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=13)}([function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}e.exports=function(e,t,i){return t&&n(e.prototype,t),i&&n(e,i),e}},function(e,t,n){var i=n(7),r=n(5);e.exports=function(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?r(e):t}},function(e,t){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},n(t)}e.exports=n},function(e,t,n){var i=n(8);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}},function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},function(e,t,n){var i=n(10),r=n(11),o=n(12);e.exports=function(e,t){return i(e)||r(e,t)||o()}},function(e,t){function n(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=n=function(e){return typeof e}:e.exports=n=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(t)}e.exports=n},function(e,t){function n(t,i){return e.exports=n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(t,i)}e.exports=n},function(e){e.exports=JSON.parse('{"name":"@luigi-project/client","description":"Javascript library supporting consumers of the Luigi framework","license":"Apache-2.0","main":"luigi-client.js","repository":{"type":"git","url":"ssh://github.com/SAP/luigi.git"},"publishConfig":{"tag":"luigi-client"},"keywords":["luigi","UI","extensibility","micro-frontends","microfrontends"],"version":"1.25.2-dev.20230110044"}')},function(e,t){e.exports=function(e){if(Array.isArray(e))return e}},function(e,t){e.exports=function(e,t){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{i||null==s.return||s.return()}finally{if(r)throw o}}return n}}},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(e,t,n){"use strict";n.r(t);var i=n(0),r=n.n(i),o=n(1),a=n.n(o),s=n(2),u=n.n(s),l=n(3),c=n.n(l),d=n(4),v=n.n(d),g=function(){function e(){r()(this,e),this.promises={}}return a()(e,[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}]),e}(),f=new(function(){function e(){r()(this,e),this.listeners=[],this.origin="";var t=function(e){if(e.data.msg)if("custom"===e.data.msg){var t=this.convertCustomMessageInternalToUser(e.data);this.listeners.filter((function(e){return e.name===t.id})).map((function(e){return e.eventFn(t,e.listenerId)}))}else this.listeners.filter((function(t){return t.name===e.data.msg})).map((function(t){return t.eventFn(e,t.listenerId)}))}.bind(this);window.addEventListener("message",t)}return a()(e,[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",data:e}}},{key:"convertStorageMessageToInternal",value:function(e){return{msg:"storage",data:e}}},{key:"addEventListener",value:function(e,t){var n=this.getRandomId();return this.listeners.push({name:e,eventFn:t,listenerId:n}),n}},{key:"removeEventListener",value:function(e){return!!Boolean(this.listeners.find((function(t){return t.listenerId===e})))&&(this.listeners=this.listeners.filter((function(t){return t.listenerId!==e})),!0)}},{key:"getRandomId",value:function(){return(window.crypto||window.msCrypto).getRandomValues(new Uint32Array(1))[0]}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&"null"!==e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){if(this.origin)try{window.parent.postMessage(e,this.origin)}catch(t){console.warn("Unable to post message "+e+" to Luigi Core from origin "+this.origin+": "+t)}else console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}},{key:"hasIntent",value:function(e){return!!e&&e.toLowerCase().includes("#?intent=")}},{key:"deSanitizeParamsMap",value:function(e){var t=this;return Object.entries(e).reduce((function(e,n){return e[t.deSanitizeParam(n[0])]=t.deSanitizeParam(n[1]),e}),{})}},{key:"deSanitizeParam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return String(e).replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/")}}]),e}()),h=new(function(e){function t(){var e;return r()(this,t),(e=u()(this,c()(t).call(this))).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams","searchParams"],e.setCurrentContext(e.defaultContextKeys.reduce((function(e,t){return e[t]={},e}),{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={},e._isDeferInitDefined()||e.luigiClientInit(),e}return v()(t,e),a()(t,[{key:"_isDeferInitDefined",value:function(){return window.document.head.hasAttribute("defer-luigi-init")}},{key:"isLuigiClientInitialized",value:function(){return this.luigiInitialized}},{key:"luigiClientInit",value:function(){var e=this;if(this.luigiInitialized)console.warn("Luigi Client has been already initialized");else{var t=function(t){for(var n=0;n<e.defaultContextKeys.length;n++){var i=e.defaultContextKeys[n];try{"string"==typeof t[i]&&(t[i]=JSON.parse(t[i]))}catch(e){console.info("unable to parse luigi context data for",i,t[i],e)}}e.setCurrentContext(t)},i=function(t){t&&(e.authData=t)};f.addEventListener("luigi.init",(function(n){t(n.data),i(n.data.authData),f.setLuigiCoreDomain(n.origin),e.luigiInitialized=!0,e._notifyInit(n.origin),f.sendPostMessageToLuigiCore({msg:"luigi.init.ok"})})),f.addEventListener("luigi-client.inactive-microfrontend",(function(t){e._notifyInactive(t.origin)})),f.addEventListener("luigi.auth.tokenIssued",(function(e){i(e.data.authData)})),f.addEventListener("luigi.navigate",(function(n){if(t(n.data),!e.currentContext.internal.isNavigateBack&&!e.currentContext.withoutSync){var i=window.location.hash;history.replaceState({luigiInduced:!0},"",n.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"})),window.location.hash!==i&&window.dispatchEvent(new HashChangeEvent("hashchange"))}e.currentContext.withoutSync&&Object.assign(e.currentContext.context,{viewUrl:n.data.viewUrl?n.data.viewUrl:void 0,pathParams:n.data.pathParams?n.data.pathParams:void 0}),e._notifyUpdate(),f.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})})),window.parent.postMessage({msg:"luigi.get-context",clientVersion:n(9).version},"*"),this._tpcCheck()}}},{key:"_tpcCheck",value:function(){var e,t,n="enabled",i=document.cookie;i&&(e=i.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"==e}))),"luigiCookie=true"===e&&(t=e.split("=")[0],document.cookie=t+"=; Max-Age=-99999999;"),document.cookie="luigiCookie=true; SameSite=None; Secure",(i=document.cookie)&&(e=i.split(";").map((function(e){return e.trim()})).find((function(e){return"luigiCookie=true"==e}))),"luigiCookie=true"===e?(window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:n},"*"),document.cookie=t+"=; Max-Age=-99999999;"):(n="disabled",window.parent.postMessage({msg:"luigi.third-party-cookie",tpc:n},"*"),console.warn("Third party cookies are not supported!"))}},{key:"_callAllFns",value:function(e,t,n){for(var i in e)e.hasOwnProperty(i)&&f.isFunction(e[i])&&e[i](t,n)}},{key:"_notifyInit",value:function(e){this._callAllFns(this._onInitFns,this.currentContext.context,e)}},{key:"_notifyUpdate",value:function(){this._callAllFns(this._onContextUpdatedFns,this.currentContext.context)}},{key:"_notifyInactive",value:function(){this._callAllFns(this._onInactiveFns)}},{key:"setCurrentContext",value:function(e){this.currentContext=e}},{key:"addInitListener",value:function(e){var t=f.getRandomId();return this._onInitFns[t]=e,this.luigiInitialized&&f.isFunction(e)&&e(this.currentContext.context,f.getLuigiCoreDomain()),t}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=f.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&f.isFunction(e)&&e(this.currentContext.context),t}},{key:"removeContextUpdateListener",value:function(e){return!!this._onContextUpdatedFns[e]&&(this._onContextUpdatedFns[e]=void 0,!0)}},{key:"addInactiveListener",value:function(e){var t=f.getRandomId();return this._onInactiveFns[t]=e,t}},{key:"removeInactiveListener",value:function(e){return!!this._onInactiveFns[e]&&(this._onInactiveFns[e]=void 0,!0)}},{key:"addCustomMessageListener",value:function(e,t){return f.addEventListener(e,(function(e,n){return t(e,n)}))}},{key:"removeCustomMessageListener",value:function(e){return f.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getActiveFeatureToggles",value:function(){return this.currentContext.internal.activeFeatureToggleList}},{key:"addNodeParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&f.sendPostMessageToLuigiCore({msg:"luigi.addNodeParams",data:e,keepBrowserHistory:t})}},{key:"getNodeParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e?f.deSanitizeParamsMap(this.currentContext.nodeParams):this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getCoreSearchParams",value:function(){return this.currentContext.searchParams||{}}},{key:"addCoreSearchParams",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&f.sendPostMessageToLuigiCore({msg:"luigi.addSearchParams",data:e,keepBrowserHistory:t})}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){f.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=f.convertCustomMessageUserToInternal(e);f.sendPostMessageToLuigiCore(t)}},{key:"getUserSettings",value:function(){return this.currentContext.internal.userSettings}},{key:"getAnchor",value:function(){return this.currentContext.internal.anchor||""}},{key:"setAnchor",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.setAnchor",anchor:e})}}]),t}(g)),p=n(6),m=n.n(p),y=n(5),k=n.n(y),C=function(e){function t(e){var n;r()(this,t),(n=u()(this,c()(t).call(this))).validSplitViewEvents=["expand","collapse","resize","close"],n.splitView={exists:!0,size:40,collapsed:!1},Object.assign(n.splitView,e);return n.splitView.listeners=[f.addEventListener("luigi.navigation.splitview.internal",(function(e){Object.assign(n.splitView,e.data.data)}))],n.on("resize",(function(e){n.splitView.size=e})),n.on("close",(function(){n.splitView.listeners.forEach((function(e){return f.removeEventListener(e)}))})),n}return v()(t,e),a()(t,[{key:"sendSplitViewEvent",value:function(e,t){f.sendPostMessageToLuigiCore({msg:"luigi.navigation.splitview.".concat(e),data:t})}},{key:"collapse",value:function(){this.sendSplitViewEvent("collapse")}},{key:"expand",value:function(){this.sendSplitViewEvent("expand")}},{key:"close",value:function(){this.sendSplitViewEvent("close")}},{key:"setSize",value:function(e){this.sendSplitViewEvent("resize",e)}},{key:"on",value:function(e,t){if(!this.validSplitViewEvents.includes(e))return console.warn(e+" is not a valid split view event"),!1;var n=f.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),(function(e){var n="number"==typeof e.data.data?e.data.data:void 0;t(n)}));return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return f.removeEventListener(e)}},{key:"exists",value:function(){return this.splitView.exists}},{key:"getSize",value:function(){return this.splitView.size}},{key:"isCollapsed",value:function(){return this.splitView.collapsed}},{key:"isExpanded",value:function(){return!this.splitView.collapsed}}]),t}(g),w=function(e){function t(e){var n;return r()(this,t),n=u()(this,c()(t).call(this)),Object.assign(k()(n),e),n.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:"",newTab:!1,preserveQueryParams:!1,anchor:"",preventContextUpdate:!1,preventHistoryEntry:!1},n}return v()(t,e),a()(t,[{key:"navigate",value:function(e,t,n,i,r,o){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&r&&o&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var a="/"!==e[0];if("/"===e&&(i||r||o))console.warn("Navigation with an absolute path prevented.");else{var s={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:a,intent:f.hasIntent(e),modal:i,splitView:r,drawer:o})};f.sendPostMessageToLuigiCore(s)}}}},{key:"updateModalPathInternalNavigation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e){var i={msg:"luigi.navigation.updateModalDataPath",params:Object.assign(this.options,{link:e,modal:t,history:n})};f.sendPostMessageToLuigiCore(i)}else console.warn("Updating path of the modal upon internal navigation prevented. No path specified.")}},{key:"navigateToIntent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="#?intent=";if(n+=e,t){var i=Object.entries(t);if(i.length>0){n+="?";for(var r=0,o=i;r<o.length;r++){var a=m()(o[r],2),s=a[0],u=a[1];n+=s+"="+u+"&"}n=n.slice(0,-1)}}this.navigate(n)}},{key:"openAsModal",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,t)}},{key:"updateModalSettings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={msg:"luigi.navigation.updateModalSettings",updatedModalSettings:e};f.sendPostMessageToLuigiCore(t)}},{key:"openAsSplitView",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.navigate(e,0,!0,void 0,t),new C(t)}},{key:"openAsDrawer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,void 0,void 0,t)}},{key:"fromContext",value:function(e){return this.currentContext.context.parentNavigationContexts&&-1!==this.currentContext.context.parentNavigationContexts.indexOf(e)?this.options.fromContext=e:(this.options.errorSkipNavigation=!0,console.error("Navigation not possible, navigationContext "+e+" not found.")),this}},{key:"fromClosestContext",value:function(){return this.currentContext&&this.currentContext.context.parentNavigationContexts.length>0?(this.options.fromContext=null,this.options.fromClosestContext=!0):console.error("Navigation not possible, no parent navigationContext found."),this}},{key:"fromVirtualTreeRoot",value:function(){return this.options.fromContext=null,this.options.fromClosestContext=!1,this.options.fromVirtualTreeRoot=!0,this}},{key:"fromParent",value:function(){return this.options.fromParent=!0,this}},{key:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"withOptions",value:function(e){return f.isObject(e)?(void 0!==e.preventHistoryEntry&&(this.options.preventHistoryEntry=e.preventHistoryEntry),void 0!==e.preventContextUpdate&&(this.options.preventContextUpdate=e.preventContextUpdate),this):this}},{key:"pathExists",value:function(e){var t=f.getRandomId(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),f.addEventListener("luigi.navigation.pathExists.answer",function(e,n){var i=e.data.data,r=this.getPromise("pathExistsPromises")||{};i.correlationId===t&&(r[i.correlationId]&&(r[i.correlationId].resolveFn(i.pathExists),delete r[i.correlationId],this.setPromise("pathExistsPromises",r)),f.removeEventListener(n))}.bind(this));var i={msg:"luigi.navigation.pathExists",data:Object.assign(this.options,{id:t,link:e,intent:f.hasIntent(e),relative:"/"!==e[0]})};return f.sendPostMessageToLuigiCore(i),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}},{key:"withoutSync",value:function(){return this.options.withoutSync=!0,this}},{key:"newTab",value:function(){return this.options.newTab=!0,this}},{key:"preserveQueryParams",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.options.preserveQueryParams=e,this}},{key:"getCurrentRoute",value:function(){var e=this,t=f.getRandomId(),n=this.getPromise("getCurrentRoute")||{};return n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("getCurrentRoute",n),f.addEventListener("luigi.navigation.currentRoute.answer",(function(n,i){var r=n.data.data,o=e.getPromise("getCurrentRoute")||{};r.correlationId===t&&(o[r.correlationId]&&(o[r.correlationId].resolveFn(r.route),delete o[r.correlationId],e.setPromise("getCurrentRoute",o)),f.removeEventListener(i)),f.removeEventListener(i)})),f.sendPostMessageToLuigiCore({msg:"luigi.navigation.currentRoute",data:Object.assign(this.options,{id:t})}),n[t]}}]),t}(g),x=new(function(e){function t(){var e;return r()(this,t),e=u()(this,c()(t).call(this)),f.addEventListener("luigi.current-locale-changed",(function(e){var t;e.data.currentLocale&&(null===(t=h.currentContext)||void 0===t?void 0:t.internal)&&(h.currentContext.internal.currentLocale=e.data.currentLocale,h._notifyUpdate())})),e}return v()(t,e),a()(t,[{key:"showLoadingIndicator",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"closeCurrentModal",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.close-modal"})}},{key:"addBackdrop",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){f.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){f.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;f.addEventListener("luigi.ux.confirmationModal.hide",(function(e,n){t.hideConfirmationModal(e.data.data),f.removeEventListener(n)})),f.sendPostMessageToLuigiCore({msg:"luigi.ux.confirmationModal.show",data:{settings:e}});var n={};return n.promise=new Promise((function(e,t){n.resolveFn=e,n.rejectFn=t})),this.setPromise("confirmationModal",n),n.promise}},{key:"hideConfirmationModal",value:function(e){var t=this.getPromise("confirmationModal");t&&(e.confirmed?t.resolveFn():t.rejectFn(),this.setPromise("confirmationModal",void 0))}},{key:"showAlert",value:function(e){var t=this;f.addEventListener("luigi.ux.alert.hide",(function(e,n){t.hideAlert(e.data),f.removeEventListener(n)})),e.id=f.getRandomId(),(null==e?void 0:e.closeAfter)<100&&(console.warn("Message with id='".concat(e.id,"' has too small 'closeAfter' value. It needs to be at least 100ms.")),e.closeAfter=void 0),f.sendPostMessageToLuigiCore({msg:"luigi.ux.alert.show",data:{settings:e}});var n=this.getPromise("alerts")||{};return n[e.id]={},n[e.id].promise=new Promise((function(t){n[e.id].resolveFn=t})),this.setPromise("alerts",n),n[e.id].promise}},{key:"hideAlert",value:function(e){var t=e.id,n=e.dismissKey,i=this.getPromise("alerts");t&&i[t]&&(i[t].resolveFn(n||t),delete i[t],this.setPromise("alerts",i))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&f.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"isDrawer",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.drawer}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=h.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}}]),t}(g)),P=new Map,L=function(e){function t(){var e;return r()(this,t),(e=u()(this,c()(t).call(this))).storageEventProcessor=new b,f.addEventListener("storage",(function(t,n){return e.storageEventProcessor.processEvent(t,n)})),e}return v()(t,e),a()(t,[{key:"setItem",value:function(e,t){var n=this;return new Promise((function(i,r){n.storageEventProcessor.execute(i,r,"setItem",{key:e,value:t})}))}},{key:"getItem",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"getItem",{key:e})}))}},{key:"removeItem",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"removeItem",{key:e})}))}},{key:"clear",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"clear",{})}))}},{key:"has",value:function(e){var t=this;return new Promise((function(n,i){t.storageEventProcessor.execute(n,i,"has",{key:e})}))}},{key:"getAllKeys",value:function(){var e=this;return new Promise((function(t,n){e.storageEventProcessor.execute(t,n,"getAllKeys",{})}))}}]),t}(g),b=function(){function e(){r()(this,e)}return a()(e,[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!P.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var i=P.get(n.id);"ERROR"===n.status?i.reject(n.result):i.resolve(n.result),P.delete(n.id)}catch(e){console.error(e)}}},{key:"waitForSyncResult",value:function(e){for(var t=(new Date).getTime();!syncOperation.has(e);){if((new Date).getTime()-t>1e4)throw"Storage operation is taking more than 1 second...Some problem with Luigi Core communication"}var n=syncOperation.get(e);return P.delete(e),n}},{key:"execute",value:function(e,t,n,i){var r=f.getRandomId();this.createPendingOperation(r,e,t),this.sendMessage(r,n,i)}},{key:"createPendingOperation",value:function(e,t,n){P.set(e,{resolve:t,reject:n})}},{key:"sendMessage",value:function(e,t,n){f.sendPostMessageToLuigiCore({msg:"storage",data:{id:e,operation:t,params:n}})}}]),e}(),I=new L,M=function(){function e(){r()(this,e),window!==window.top&&("true"!==window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history)),"true"!==window.document.head.getAttribute("disable-luigi-runtime-error-handling")&&window.addEventListener("error",(function(e){var t={msg:"luigi-runtime-error-handling",errorObj:{filename:e.filename,message:e.message,lineno:e.lineno,colno:e.colno,error:e.error}};f.sendPostMessageToLuigiCore(t)})))}return a()(e,[{key:"addInitListener",value:function(e){return h.addInitListener(e)}},{key:"removeInitListener",value:function(e){return h.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return h.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return h.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return h.getToken()}},{key:"getEventData",value:function(){return h.getEventData()}},{key:"getContext",value:function(){return h.getContext()}},{key:"addNodeParams",value:function(e,t){return h.addNodeParams(e,t)}},{key:"getNodeParams",value:function(e){return h.getNodeParams(e)}},{key:"getActiveFeatureToggles",value:function(){return h.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return h.getPathParams()}},{key:"getCoreSearchParams",value:function(){return h.getCoreSearchParams()}},{key:"addCoreSearchParams",value:function(e,t){return h.addCoreSearchParams(e,t)}},{key:"getClientPermissions",value:function(){return h.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return h.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return h.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return h.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return h.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return h.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return h.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return h.getUserSettings()}},{key:"isLuigiClientInitialized",value:function(){return h.isLuigiClientInitialized()}},{key:"luigiClientInit",value:function(){return h.luigiClientInit()}},{key:"getAnchor",value:function(){return h.getAnchor()}},{key:"setAnchor",value:function(e){return h.setAnchor(e)}},{key:"linkManager",value:function(){return new w({currentContext:h.currentContext})}},{key:"uxManager",value:function(){return x}},{key:"lifecycleManager",value:function(){return h}},{key:"storageManager",value:function(){return I}}]),e}();t.default=M=new M}]).default}));
2
2
  //# sourceMappingURL=luigi-client.js.map
@@ -0,0 +1,412 @@
1
+ // Type definitions for Luigi Client web components
2
+
3
+ export declare interface ConfirmationModalSettings {
4
+ type?: string;
5
+ header?: string;
6
+ body?: string;
7
+ buttonConfirm?: string | boolean;
8
+ buttonDismiss?: string;
9
+ }
10
+
11
+ export declare interface ModalSettings {
12
+ title?: string;
13
+ size?: 'fullscreen' | 'l' | 'm' | 's';
14
+ width?: string;
15
+ height?: string;
16
+ }
17
+
18
+ export declare interface SplitViewSettings {
19
+ title?: string;
20
+ size?: number;
21
+ collapsed?: boolean;
22
+ }
23
+
24
+ export declare enum SplitViewEvents {
25
+ 'expand',
26
+ 'collapse',
27
+ 'resize',
28
+ 'close'
29
+ }
30
+
31
+ export declare interface SplitViewInstance {
32
+ collapse: () => void;
33
+ expand: () => void;
34
+ setSize: (value: number) => void;
35
+ on: (key: SplitViewEvents, callback: () => void) => string;
36
+ exists: () => boolean;
37
+ getSize: () => number;
38
+ isCollapsed: () => boolean;
39
+ isExpanded: () => boolean;
40
+ }
41
+
42
+ export declare interface DrawerSettings {
43
+ header?: any;
44
+ size?: 'l' | 'm' | 's' | 'xs';
45
+ backdrop?: boolean;
46
+ overlap?: boolean;
47
+ }
48
+
49
+ export declare interface AlertSettings {
50
+ text?: string;
51
+ type: 'info' | 'success' | 'warning' | 'error';
52
+ links?: {
53
+ [key: string]: { text: string; url?: string; dismissKey?: string };
54
+ };
55
+ closeAfter?: number;
56
+ }
57
+
58
+ export declare interface NodeParams {
59
+ [key: string]: string;
60
+ }
61
+
62
+ export declare interface UxManager {
63
+ /**
64
+ * Hides the app loading indicator.
65
+ * @memberof uxManager
66
+ */
67
+ hideAppLoadingIndicator: () => void;
68
+
69
+ /**
70
+ * Shows an alert.
71
+ * @memberof uxManager
72
+ * @param {Object} settings the settings for the alert
73
+ * @param {string} settings.text the content of the alert. To add a link to the content, you have to set up the link in the `links` object. The key(s) in the `links` object must be used in the text to reference the links, wrapped in curly brackets with no spaces. If you don't specify any text, the alert is not displayed
74
+ * @param {('info'|'success'|'warning'|'error')} settings.type sets the type of alert
75
+ * @param {Object} settings.links provides links data
76
+ * @param {Object} settings.links.LINK_KEY object containing the data for a particular link. To properly render the link in the alert message refer to the description of the **settings.text** parameter
77
+ * @param {string} settings.links.LINK_KEY.text text which replaces the link identifier in the alert content
78
+ * @param {string} settings.links.LINK_KEY.url URL to navigate when you click the link. Currently, only internal links are supported in the form of relative or absolute paths
79
+ * @param {string} settings.links.LINK_KEY.dismissKey dismissKey which represents the key of the link.
80
+ * @param {number} settings.closeAfter (optional) time in milliseconds that tells Luigi when to close the Alert automatically. If not provided, the Alert will stay on until closed manually. It has to be greater than `100`
81
+ * @returns {promise} which is resolved when the alert is dismissed
82
+ * @example
83
+ * import LuigiClient from '@luigi-project/client';
84
+ * const settings = {
85
+ * text: "Ut enim ad minim veniam, {goToHome} quis nostrud exercitation ullamco {relativePath}. Duis aute irure dolor {goToOtherProject}",
86
+ * type: 'info',
87
+ * links: {
88
+ * goToHome: { text: 'homepage', url: '/overview' },
89
+ * goToOtherProject: { text: 'other project', url: '/projects/pr2' },
90
+ * relativePath: { text: 'relative hide side nav', url: 'hideSideNav' },
91
+ * neverShowItAgain: { text: 'Never show it again', dismissKey: 'neverShowItAgain' }
92
+ * },
93
+ * closeAfter: 3000
94
+ * }
95
+ * LuigiClient
96
+ * .uxManager()
97
+ * .showAlert(settings)
98
+ * .then(() => {
99
+ * // Logic to execute when the alert is dismissed
100
+ * });
101
+ */
102
+ showAlert: (settings: AlertSettings) => Promise<Object>;
103
+
104
+ /**
105
+ * Shows a confirmation modal.
106
+ * @memberof uxManager
107
+ * @param {Object} settings the settings of the confirmation modal. If you don't provide any value for any of the fields, a default value is used
108
+ * @param {string} [settings.header="Confirmation"] the content of the modal header
109
+ * @param {string} [settings.body="Are you sure you want to do this?"] the content of the modal body
110
+ * @param {string} [settings.buttonConfirm="Yes"] the label for the modal confirm button
111
+ * @param {string} [settings.buttonDismiss="No"] the label for the modal dismiss button
112
+ * @returns {promise} which is resolved when accepting the confirmation modal and rejected when dismissing it
113
+ * @example
114
+ * import LuigiClient from '@kyma-project/luigi-client';
115
+ * const settings = {
116
+ * header: "Confirmation",
117
+ * body: "Are you sure you want to do this?",
118
+ * buttonConfirm: "Yes",
119
+ * buttonDismiss: "No"
120
+ * }
121
+ * LuigiClient
122
+ * .uxManager()
123
+ * .showConfirmationModal(settings)
124
+ * .then(() => {
125
+ * // Logic to execute when the confirmation modal is dismissed
126
+ * });
127
+ */
128
+ showConfirmationModal: (settings: ConfirmationModalSettings) => Promise<void>;
129
+
130
+ /**
131
+ * Set the document title
132
+ * @memberof UX
133
+ * @param {string} documentTitle
134
+ * @since 1.4.0
135
+ * @example LuigiClient.uxManager().setDocumentTitle('Luigi');
136
+ */
137
+ setDocumentTitle: (documentTitle: string) => void;
138
+
139
+ /**
140
+ * Get the document title
141
+ * @memberof UX
142
+ * @since 1.4.0
143
+ * @returns a string, which is displayed in the tab.
144
+ * @example LuigiClient.uxManager().getDocumentTitle();
145
+ */
146
+ getDocumentTitle: () => string;
147
+
148
+ /**
149
+ * Set the collapsed state of the left side navigation
150
+ * @memberof UX
151
+ * @param {boolean} state
152
+ * @since 1.5.0
153
+ */
154
+ collapseLeftSideNav: (state: boolean) => void;
155
+
156
+ /**
157
+ * Open user settings dialog
158
+ * @memberof UX
159
+ * @since 1.7.1
160
+ */
161
+ openUserSettings: () => void;
162
+
163
+ /**
164
+ * Close user settings dialog
165
+ * @memberof UX
166
+ * @since 1.7.1
167
+ */
168
+ closeUserSettings: () => void;
169
+ }
170
+
171
+ export declare interface LinkManager {
172
+ /**
173
+ * Refreshes top navigation badge counters by rendering the navigation again.
174
+ * @memberof linkManager
175
+ * @example
176
+ * LuigiClient.linkManager().updateTopNavigation();
177
+ */
178
+ updateTopNavigation: () => void;
179
+
180
+ /**
181
+ * Navigates to the given path in the application. It contains either a full absolute path or a relative path without a leading slash that uses the active route as a base. This is the standard navigation.
182
+ * @memberof LuigiNavigation
183
+ * @param {string} path path to be navigated to
184
+ * @param {boolean} preserveView preserve a view by setting it to `true`. It keeps the current view opened in the background and opens the new route in a new frame. Use the {@link #goBack goBack()} function to navigate back. You can use this feature across different levels. Preserved views are discarded as soon as you use the standard {@link #navigate navigate()} function instead of {@link #goBack goBack()}
185
+ * @param {Object} modalSettings opens a view in a modal. Use these settings to configure the modal's title and size
186
+ * @param {string} modalSettings.title modal title. By default, it is the node label. If there is no label, it is left empty
187
+ * @param {('fullscreen'|'l'|'m'|'s')} [modalSettings.size="l"] size of the modal
188
+ * @param {string} modalSettings.width lets you specify a precise width for the modal. Allowed units are 'px', '%', 'rem', 'em', 'vh' and 'vw'.
189
+ * @param {string} modalSettings.height lets you specify a precise height for the modal. Allowed units are 'px', '%', 'rem', 'em', 'vh' and 'vw'.
190
+ * @param {Object} splitViewSettings opens a view in a split view. Use these settings to configure the split view's behaviour
191
+ * @param {string} splitViewSettings.title split view title. By default, it is the node label. If there is no label, it is left empty
192
+ * @param {number} [splitViewSettings.size=40] height of the split view in percent
193
+ * @param {boolean} [splitViewSettings.collapsed=false] opens split view in collapsed state
194
+ * @param {Object} drawerSettings opens a view in a drawer. Use these settings to configure if the drawer has a header, backdrop and size.
195
+ * @param {any} drawerSettings.header By default, the header is visible. The default title is the node label, but the header could also be an object with a `title` attribute allowing you to specify your own title. An 'x' icon is displayed to close the drawer view.
196
+ * @param {boolean} drawerSettings.backdrop By default, it is set to `false`. If it is set to `true` the rest of the screen has a backdrop.
197
+ * @param {('l'|'m'|'s'|'xs')} [drawerSettings.size="s"] size of the drawer
198
+ * @example
199
+ * LuigiClient.linkManager().navigate('/overview')
200
+ * LuigiClient.linkManager().navigate('users/groups/stakeholders')
201
+ * LuigiClient.linkManager().navigate('/settings', null, true) // preserve view
202
+ */
203
+ navigate: (
204
+ path: string,
205
+ preserveView?: boolean,
206
+ modalSettings?: ModalSettings,
207
+ splitViewSettings?: SplitViewSettings,
208
+ drawerSettings?: DrawerSettings
209
+ ) => void;
210
+
211
+ /**
212
+ * Opens a view in a modal. You can specify the modal's title and size. If you do not specify the title, it is the node label. If there is no node label, the title remains empty. The default size of the modal is `l`, which means 80%. You can also use `m` (60%) and `s` (40%) to set the modal size. Optionally, use it in combination with any of the navigation functions.
213
+ * @memberof linkManager
214
+ * @param {string} path navigation path
215
+ * @param {Object} [modalSettings] opens a view in a modal. Use these settings to configure the modal's title and size
216
+ * @param {string} modalSettings.title modal title. By default, it is the node label. If there is no label, it is left empty
217
+ * @param {('fullscreen'|'l'|'m'|'s')} [modalSettings.size="l"] size of the modal
218
+ * @param {string} modalSettings.width lets you specify a precise width for the modal. Allowed units are 'px', '%', 'rem', 'em', 'vh' and 'vw'.
219
+ * @param {string} modalSettings.height lets you specify a precise height for the modal. Allowed units are 'px', '%', 'rem', 'em', 'vh' and 'vw'.
220
+ * @param {Function} onCloseCallback callback function called upon closing the openened modal
221
+ * @example
222
+ * LuigiClient.linkManager().openAsModal('projects/pr1/users', {title:'Users', size:'m'});
223
+ */
224
+ openAsModal: (nodepath: string, modalSettings?: ModalSettings, onCloseCallback?: Function) => void;
225
+
226
+ /**
227
+ * Opens a view in a split view. You can specify the split view's title and size. If you don't specify the title, it is the node label. If there is no node label, the title remains empty. The default size of the split view is 40, which means 40% height of the split view.
228
+ * @memberof linkManager
229
+ * @param {string} path navigation path
230
+ * @param {Object} splitViewSettings opens a view in a split view. Use these settings to configure the split view's behaviour
231
+ * @param {string} splitViewSettings.title split view title. By default, it is the node label. If there is no label, it is left empty
232
+ * @param {number} [splitViewSettings.size=40] height of the split view in percent
233
+ * @param {boolean} [splitViewSettings.collapsed=false] opens split view in collapsed state
234
+ * @returns {Object} an instance of the SplitView. It provides functions to control its behavior.
235
+ * @see {@link https://docs.luigi-project.io/docs/luigi-client-api?section=splitview|SplitView Client} for further documentation. These methods from the Client SplitView are also implemented for Luigi Core: `close`, `collapse`, `expand`, `isCollapsed`, `isExpanded`, `exists`
236
+ *
237
+ * @since 0.7.6
238
+ * @example
239
+ * LuigiClient.linkManager().openAsSplitView('projects/pr1/users', {title:'Users', size:'40'});
240
+ */
241
+ openAsSplitView: (path: string, splitViewSettings?: SplitViewSettings) => SplitViewInstance;
242
+
243
+ /**
244
+ * Opens a view in a drawer. You can specify if the drawer has a header, if a backdrop is active in the background and configure the size of the drawer. By default the header is shown. The backdrop is not visible and has to be activated. The size of the drawer is by default set to `s` which means 25% of the micro frontend size. You can also use `l`(75%), `m`(50%) or `xs`(15.5%). Optionally, use it in combination with any of the navigation functions.
245
+ * @memberof linkManager
246
+ * @param {string} path navigation path
247
+ * @param {Object} [drawerSettings] opens a view in a drawer. Use these settings to configure if the drawer has a header, backdrop and size.
248
+ * @param {any} drawerSettings.header By default, the header is visible. Title is node label and 'x' is displayed to close the drawer view. The header could also be an object with a `title` attribute to specify an own title for the drawer component.
249
+ * @param {boolean} drawerSettings.backdrop By default, it is set to `false`. If it is set to `true` the rest of the screen has a backdrop.
250
+ * @param {('l'|'m'|'s'|'xs')} [drawerSettings.size="s"] size of the drawer
251
+ * @since 1.6.0
252
+ * @example
253
+ * LuigiClient.linkManager().openAsDrawer('projects/pr1/drawer', {header:true, backdrop:true, size:'s'});
254
+ * LuigiClient.linkManager().openAsDrawer('projects/pr1/drawer', {header:{title:'My drawer component'}, backdrop:true, size:'xs'});
255
+ */
256
+ openAsDrawer: (nodepath: string, drawerSettings?: DrawerSettings) => void;
257
+
258
+ /**
259
+ * Sets the current navigation context to that of a specific parent node which has the {@link navigation-configuration.md navigationContext} field declared in the navigation configuration. This navigation context is then used by the `navigate` function.
260
+ * @memberof linkManager
261
+ * @param {string} navigationContext
262
+ * @returns {linkManager} link manager instance
263
+ * @example
264
+ * LuigiClient.linkManager().fromContext('project').navigate('/settings')
265
+ */
266
+ fromContext: (navigationContext: string) => this;
267
+
268
+ /**
269
+ * Sets the current navigation context which is then used by the `navigate` function. This has to be a parent navigation context, it is not possible to use the child navigation contexts.
270
+ * @memberof linkManager
271
+ * @returns {linkManager} link manager instance
272
+ * @example
273
+ * LuigiClient.linkManager().fromClosestContext().navigate('/users/groups/stakeholders')
274
+ */
275
+ fromClosestContext: () => this;
276
+
277
+ /**
278
+ * Sets the current navigation base to the parent node that is defined as virtualTree. This method works only when the currently active micro frontend is inside a virtualTree.
279
+ * @memberof linkManager
280
+ * @returns {linkManager} link manager instance
281
+ * @since 1.0.1
282
+ * @example
283
+ * LuigiClient.linkManager().fromVirtualTreeRoot().navigate('/users/groups/stakeholders')
284
+ */
285
+ fromVirtualTreeRoot: () => this;
286
+
287
+ /**
288
+ * Sends node parameters to the route. The parameters are used by the `navigate` function. Use it optionally in combination with any of the navigation functions and receive it as part of the context object in Luigi Client.
289
+ * @memberof linkManager
290
+ * @param {Object} nodeParams
291
+ * @returns {linkManager} link manager instance
292
+ * @example
293
+ * LuigiClient.linkManager().withParams({foo: "bar"}).navigate("path")
294
+ *
295
+ * // Can be chained with context setting functions such as:
296
+ * LuigiClient.linkManager().fromContext("currentTeam").withParams({foo: "bar"}).navigate("path")
297
+ */
298
+ withParams: (nodeParams: NodeParams) => this;
299
+
300
+ /** @lends linkManager */
301
+ /**
302
+ * Checks if the path you can navigate to exists in the main application. For example, you can use this helper method conditionally to display a DOM element like a button.
303
+ * @memberof linkManager
304
+ * @param {string} path path which existence you want to check
305
+ * @returns {promise} a promise which resolves to a Boolean variable specifying whether the path exists or not
306
+ * @example
307
+ * let pathExists;
308
+ * LuigiClient
309
+ * .linkManager()
310
+ * .pathExists('projects/pr2')
311
+ * .then(
312
+ * (pathExists) => { }
313
+ * );
314
+ */
315
+ pathExists: (path: string) => Promise<boolean>;
316
+
317
+ /**
318
+ * Discards the active view and navigates back to the last visited view. Works with preserved views, and also acts as the substitute of the browser **back** button. **goBackContext** is only available when using preserved views.
319
+ * @memberof linkManager
320
+ * @param {any} goBackValue data that is passed in the **goBackContext** field to the last visited view when using preserved views
321
+ * @example
322
+ * LuigiClient.linkManager().goBack({ foo: 'bar' });
323
+ * LuigiClient.linkManager().goBack(true);
324
+ */
325
+ goBack: (goBackValue: any) => this;
326
+
327
+ /**
328
+ * Checks if there is one or more preserved views. You can use it to show a **back** button.
329
+ * @memberof linkManager
330
+ * @returns {boolean} indicating if there is a preserved view you can return to
331
+ */
332
+ hasBack: () => boolean;
333
+ }
334
+
335
+ export declare class LuigiElement extends HTMLElement {
336
+ constructor(options?: Options);
337
+ /**
338
+ * Override to return the html template string defining the web component view.
339
+ *
340
+ * @param {*} ctx The context object passed by luigi core
341
+ */
342
+ render(ctx?: Object): string;
343
+ /**
344
+ * Override to execute logic after an attribute of this web component has changed.
345
+ */
346
+ update(): void;
347
+ /**
348
+ * Override to execute logic when a new context object is set.
349
+ *
350
+ * @param {*} ctx The new context object passed by luigi core
351
+ */
352
+ onContextUpdate(ctx: Object): void;
353
+ /**
354
+ * Override to execute logic after initialization of the web component, i.e.
355
+ * after internal rendering and all context data set.
356
+ *
357
+ * @param {*} ctx The context object passed by luigi core
358
+ */
359
+ afterInit(ctx: Object): void;
360
+
361
+ /**
362
+ * Query selector operating on shadow root.
363
+ *
364
+ * @see ParentNode.querySelector
365
+ */
366
+ querySelector(selector: string): any;
367
+
368
+ /**
369
+ * LuigiClient instance
370
+ */
371
+ LuigiClient: LuigiClient;
372
+
373
+ /**
374
+ * Context object
375
+ * @returns {Object} context object
376
+ */
377
+ get context(): Object;
378
+ }
379
+
380
+ export declare interface Options {
381
+ /**
382
+ *
383
+ *if `true` shadowRoot mode is "open" otherwise shadowRoot mode is "closed".
384
+ */
385
+ openShadow: boolean;
386
+ }
387
+
388
+ /**
389
+ * Html string processing according to luigi functionality.
390
+ * Also useful in combination with LitElement VS Code plugins.
391
+ *
392
+ * @param {String} literal The literal to process.
393
+ * @returns {String} Returns the processed literal.
394
+ */
395
+ export declare const html: (strings: TemplateStringsArray, ...keys: unknown[]) => string;
396
+
397
+ export interface LuigiClient {
398
+ /**
399
+ * @returns {Object} node parameters, where the object property name is the node parameter name without the prefix, and its value is the value of the node parameter. For example `{sort: 'asc', page: 3}`
400
+ * @memberof LuigiClient
401
+ */
402
+ getActiveFeatureToggles: () => Array<String>;
403
+ /**
404
+ * Gets the current locale.
405
+ * @returns {string} current locale
406
+ * @memberof LuigiClient
407
+ */
408
+ getCurrentLocale: () => string;
409
+ linkManager: () => LinkManager;
410
+ uxManager: () => UxManager;
411
+ publishEvent: (event: Event) => void;
412
+ }
package/package.json CHANGED
@@ -17,5 +17,5 @@
17
17
  "micro-frontends",
18
18
  "microfrontends"
19
19
  ],
20
- "version": "1.25.2-dev.20221290038"
20
+ "version": "1.25.2-dev.20230120046"
21
21
  }