@luigi-project/client
Advanced tools
Comparing version 1.0.0-next.0 to 1.0.0-next.1
@@ -81,2 +81,3 @@ // Type definitions for Luigi Client | ||
* Adds a backdrop to block the top and side navigation. It is based on the Fundamental UI Modal, which you can use in your micro frontend to achieve the same behavior. | ||
* @memberof uxManager | ||
*/ | ||
@@ -87,2 +88,3 @@ addBackdrop: () => void; | ||
* Removes the backdrop. | ||
* @memberof uxManager | ||
*/ | ||
@@ -92,3 +94,4 @@ removeBackdrop: () => void; | ||
/** | ||
* Adds a backdrop with a loading indicator for the micro frontend frame. This overrides the {@link navigation-configuration.md#nodes loadingIndicator.enabled} setting. | ||
* Adds a backdrop with a loading indicator for the micro frontend frame. This overrides the {@link navigation-parameters-reference.md#node-parameters loadingIndicator.enabled} setting. | ||
* @memberof uxManager | ||
*/ | ||
@@ -98,3 +101,4 @@ showLoadingIndicator: () => void; | ||
/** | ||
* Removes the loading indicator. Use it after calling {@link #showLoadingIndicator showLoadingIndicator()} or to hide the indicator when you use the {@link navigation-configuration.md#nodes loadingIndicator.hideAutomatically: false} node configuration. | ||
* Removes the loading indicator. Use it after calling {@link #showLoadingIndicator showLoadingIndicator()} or to hide the indicator when you use the {@link navigation-parameters-reference.md#node-parameters loadingIndicator.hideAutomatically: false} node configuration. | ||
* @memberof uxManager | ||
*/ | ||
@@ -106,2 +110,3 @@ hideLoadingIndicator: () => void; | ||
* @param {boolean} isDirty indicates if there are any unsaved changes on the current page or in the component | ||
* @memberof uxManager | ||
*/ | ||
@@ -112,9 +117,11 @@ setDirtyStatus: (isDirty: boolean) => void; | ||
* Shows an alert. | ||
* @memberof uxManager | ||
* @param {Object} settings the settings for the alert | ||
* @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. | ||
* @param {('info'|'success'|'warning'|'error')} settings.type sets the type of the alert | ||
* @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 | ||
* @param {('info'|'success'|'warning'|'error')} settings.type sets the type of alert | ||
* @param {Object} settings.links provides links data | ||
* @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. | ||
* @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 | ||
* @param {string} settings.links.LINK_KEY.text text which replaces the link identifier in the alert content | ||
* @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. | ||
* @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 | ||
* @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` | ||
* @returns {promise} which is resolved when the alert is dismissed | ||
@@ -124,4 +131,3 @@ * @example | ||
* const settings = { | ||
* text: Ut enim ad minim veniam, {goToHome} quis nostrud exercitation ullamco {relativePath} laboris nisi ut aliquip ex ea commodo consequat. | ||
* Duis aute irure dolor {goToOtherProject}, | ||
* text: "Ut enim ad minim veniam, {goToHome} quis nostrud exercitation ullamco {relativePath}. Duis aute irure dolor {goToOtherProject}", | ||
* type: 'info', | ||
@@ -132,3 +138,4 @@ * links: { | ||
* relativePath: { text: 'relative hide side nav', url: 'hideSideNav' } | ||
* } | ||
* }, | ||
* closeAfter: 3000 | ||
* } | ||
@@ -140,3 +147,3 @@ * LuigiClient | ||
* // Logic to execute when the alert is dismissed | ||
* }); | ||
* }); | ||
*/ | ||
@@ -147,8 +154,23 @@ showAlert: (settings: AlertSettings) => Promise<void>; | ||
* Shows a confirmation modal. | ||
* @param {Object} settings the settings the confirmation modal. If no value is provided for any of the fields, a default value is set for it. | ||
* @param {string} settings.header the content of the modal header | ||
* @param {string} settings.body the content of the modal body | ||
* @param {string} settings.buttonConfirm the label for the modal confirm button | ||
* @param {string} settings.buttonDismiss the label for the modal dismiss button | ||
* @returns {promise} which is resolved when accepting the confirmation modal and rejected when dismissing it. | ||
* @memberof uxManager | ||
* @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 | ||
* @param {string} [settings.header="Confirmation"] the content of the modal header | ||
* @param {string} [settings.body="Are you sure you want to do this?"] the content of the modal body | ||
* @param {string} [settings.buttonConfirm="Yes"] the label for the modal confirm button | ||
* @param {string} [settings.buttonDismiss="No"] the label for the modal dismiss button | ||
* @returns {promise} which is resolved when accepting the confirmation modal and rejected when dismissing it | ||
* @example | ||
* import LuigiClient from '@kyma-project/luigi-client'; | ||
* const settings = { | ||
* header: "Confirmation", | ||
* body: "Are you sure you want to do this?", | ||
* buttonConfirm: "Yes", | ||
* buttonDismiss: "No" | ||
* } | ||
* LuigiClient | ||
* .uxManager() | ||
* .showConfirmationModal(settings) | ||
* .then(() => { | ||
* // Logic to execute when the confirmation modal is dismissed | ||
* }); | ||
*/ | ||
@@ -160,2 +182,3 @@ showConfirmationModal: (settings: ConfirmationModalSettings) => Promise<void>; | ||
* @returns {string} current locale | ||
* @memberof uxManager | ||
*/ | ||
@@ -166,3 +189,7 @@ getCurrentLocale: () => string; | ||
* Sets current locale to the specified one. | ||
* | ||
* **NOTE:** this must be explicitly allowed on the navigation node level by setting `clientPermissions.changeCurrentLocale` to `true`. (See {@link navigation-parameters-reference.md Node parameters}.) | ||
* | ||
* @param {string} locale locale to be set as the current locale | ||
* @memberof uxManager | ||
*/ | ||
@@ -173,4 +200,5 @@ setCurrentLocale: (locale: string) => void; | ||
* Checks if the current micro frontend is displayed inside a split view | ||
* @returns {boolean} indicating if it is loaded inside a split view | ||
* @memberof uxManager | ||
* @since 0.6.0 | ||
* @returns {boolean} indicating if it is loaded inside a split view | ||
*/ | ||
@@ -181,4 +209,5 @@ isSplitView: () => boolean; | ||
* Checks if the current micro frontend is displayed inside a modal | ||
* @returns {boolean} indicating if it is loaded inside a modal | ||
* @memberof uxManager | ||
* @since 0.6.0 | ||
* @returns {boolean} indicating if it is loaded inside a modal | ||
*/ | ||
@@ -191,3 +220,4 @@ isModal: () => boolean; | ||
* 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. | ||
* @returns {linkManager} link manager instance. | ||
* @memberof linkManager | ||
* @returns {linkManager} link manager instance | ||
* @example | ||
@@ -200,4 +230,5 @@ * LuigiClient.linkManager().fromClosestContext().navigate('/users/groups/stakeholders') | ||
* 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. | ||
* @memberof linkManager | ||
* @param {string} navigationContext | ||
* @returns {linkManager} link manager instance. | ||
* @returns {linkManager} link manager instance | ||
* @example | ||
@@ -210,3 +241,4 @@ * LuigiClient.linkManager().fromContext('project').navigate('/settings') | ||
* 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. | ||
* @param {any} goBackValue data that is passed in the **goBackContext** field to the last visited view when using preserved views. | ||
* @memberof linkManager | ||
* @param {any} goBackValue data that is passed in the **goBackContext** field to the last visited view when using preserved views | ||
* @example | ||
@@ -220,3 +252,4 @@ * LuigiClient.linkManager().goBack({ foo: 'bar' }); | ||
* Checks if there is one or more preserved views. You can use it to show a **back** button. | ||
* @returns {boolean} indicating if there is a preserved view you can return to. | ||
* @memberof linkManager | ||
* @returns {boolean} indicating if there is a preserved view you can return to | ||
*/ | ||
@@ -227,8 +260,13 @@ hasBack: () => boolean; | ||
* Navigates to the given path in the application hosted by Luigi. 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. | ||
* @memberof linkManager | ||
* @param {string} path path to be navigated to | ||
* @param {string} sessionId current Luigi **sessionId** | ||
* @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 the standard {@link #navigate navigate()} function is used instead of {@link #goBack goBack()}. | ||
* @param {Object} modalSettings opens a view in a modal. Use these settings to configure the modal's title and size. | ||
* @param {string} modalSettings.title modal title. By default, it is the node label. If there is no label, it is left empty. | ||
* @param {('l'|'m'|'s')} [modalSettings.size=l] size of the modal (optional, default `l`) | ||
* @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()} | ||
* @param {Object} modalSettings opens a view in a modal. Use these settings to configure the modal's title and size | ||
* @param {string} modalSettings.title modal title. By default, it is the node label. If there is no label, it is left empty | ||
* @param {('l'|'m'|'s')} [modalSettings.size="l"] size of the modal | ||
* @param {Object} splitViewSettings opens a view in a split view. Use these settings to configure the split view's behaviour | ||
* @param {string} splitViewSettings.title split view title. By default, it is the node label. If there is no label, it is left empty | ||
* @param {number} [splitViewSettings.size=40] height of the split view in percent | ||
* @param {boolean} [splitViewSettings.collapsed=false] creates split view but leaves it closed initially | ||
* @example | ||
@@ -246,9 +284,11 @@ * LuigiClient.linkManager().navigate('/overview') | ||
/** @lends linkManager */ | ||
/** | ||
* 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. | ||
* @memberof linkManager | ||
* @param {string} path path which existence you want to check | ||
* @returns {promise} A promise which resolves to a Boolean variable specifying whether the path exists or not. | ||
* @returns {promise} a promise which resolves to a Boolean variable specifying whether the path exists or not | ||
* @example | ||
* let pathExists; | ||
* this.luigiClient | ||
* LuigiClient | ||
* .linkManager() | ||
@@ -264,4 +304,5 @@ * .pathExists('projects/pr2') | ||
* 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. | ||
* @memberof linkManager | ||
* @param {Object} nodeParams | ||
* @returns {linkManager} link manager instance. | ||
* @returns {linkManager} link manager instance | ||
* @example | ||
@@ -277,7 +318,7 @@ * LuigiClient.linkManager().withParams({foo: "bar"}).navigate("path") | ||
* Opens a view in a modal. You can specify the modal'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 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. | ||
* @memberof linkManager | ||
* @param {string} path navigation path | ||
* @param {Object} modalSettings opens a view in a modal. Use these settings to configure the modal's title and size. | ||
* @param {string} modalSettings.title modal title. By default, it is the node label. If there is no label, it is left empty. | ||
* @param {('l'|'m'|'s')} [modalSettings.size=l] size of the modal (optional, default `l`) | ||
* @since 0.4.11 | ||
* @param {Object} [modalSettings] opens a view in a modal. Use these settings to configure the modal's title and size | ||
* @param {string} modalSettings.title modal title. By default, it is the node label. If there is no label, it is left empty | ||
* @param {('l'|'m'|'s')} [modalSettings.size="l"] size of the modal | ||
* @example | ||
@@ -306,2 +347,13 @@ * LuigiClient.linkManager().openAsModal('projects/pr1/users', {title:'Users', size:'m'}); | ||
) => SplitViewInstance; | ||
/** | ||
* Disables the navigation handling for a single navigation request | ||
* It prevents Luigi Core from handling url change after `navigate()`. | ||
* Used for auto-navigation | ||
* @since v0.7.6 | ||
* @example | ||
* LuigiClient.linkManager().withoutSync().navigate('/projects/xy/foobar'); | ||
* LuigiClient.linkManager().withoutSync().fromClosestContext().navigate('settings'); | ||
*/ | ||
withoutSync: () => this; | ||
} | ||
@@ -311,3 +363,3 @@ | ||
* Registers a listener called with the context object and the Luigi Core domain as soon as Luigi is instantiated. Defer your application bootstrap if you depend on authentication data coming from Luigi. | ||
* @param {function} initFn the function that is called once Luigi is initialized, receives current context and origin as parameters. | ||
* @param {Lifecycle~initListenerCallback} initFn the function that is called once Luigi is initialized, receives current context and origin as parameters | ||
* @memberof Lifecycle | ||
@@ -323,4 +375,10 @@ */ | ||
/** | ||
* Callback of the addInitListener | ||
* @callback Lifecycle~initListenerCallback | ||
* @param {Object} context current context data | ||
* @param {string} origin Luigi Core URL | ||
*/ | ||
/** | ||
* Removes an init listener. | ||
* @param {string} id the id that was returned by the `addInitListener` function | ||
* @param {string} id the id that was returned by the `addInitListener` function. | ||
* @memberof Lifecycle | ||
@@ -332,3 +390,3 @@ */ | ||
/** | ||
* Registers a listener called with the context object upon any navigation change. | ||
* Registers a listener called with the context object when the URL is changed. For example, you can use this when changing environments in a context switcher in order for the micro frontend to do an API call to the environment picked. | ||
* @param {function} contextUpdatedFn the listener function called each time Luigi context changes | ||
@@ -353,4 +411,9 @@ * @memberof Lifecycle | ||
/** | ||
* Registers a listener called upon microfrontend inactivity. Usually happens when micro frontends get moved to the background when using preserve view, loading new view groups or using preload. | ||
* @param {function} inactiveFn the listener function called each time the micro frontend turns into an inactive state | ||
* Registers a listener called upon micro frontend inactivity. This happens when a new micro frontend gets shown while keeping the old one cached. | ||
* Gets called when: | ||
* - navigating with **preserveView** | ||
* - navigating from or to a **viewGroup** | ||
* | ||
* Does not get called when navigating normally, or when `openAsModal` or `openAsSplitView` are used. | ||
* @param {function} inactiveFn the listener function called each time a micro frontend turns into an inactive state | ||
* @memberof Lifecycle | ||
@@ -372,4 +435,5 @@ */ | ||
* @param {string} customMessageId the custom message id | ||
* @param {Lifecycle~customMessageListenerCallback} customMessageListener the function that is called when the micro frontend receives the corresponding event. | ||
* @param {Lifecycle~customMessageListenerCallback} customMessageListener the function that is called when the micro frontend receives the corresponding event | ||
* @memberof Lifecycle | ||
* @since 0.6.2 | ||
*/ | ||
@@ -391,8 +455,9 @@ export function addCustomMessageListener( | ||
* @param {*} customMessage.MY_DATA_FIELD any other message data field | ||
* @param {string} listenerId custom message listener id to be used for unsubscribing | ||
* @param {string} listenerId custom message listener id to be used for unsubscription | ||
*/ | ||
/** | ||
* Removes a custom message listener. | ||
* @param {string} listenerId the id that was returned by the `addInitListener` function | ||
* @param {string} id the id that was returned by the `addInitListener` function | ||
* @memberof Lifecycle | ||
* @since 0.6.2 | ||
*/ | ||
@@ -403,3 +468,5 @@ export function removeCustomMessageListener(id: string): boolean; | ||
/** | ||
* @returns {string} the authorization token | ||
* Returns the currently valid access token. | ||
* @returns {string} current access token | ||
* @memberof Lifecycle | ||
*/ | ||
@@ -411,3 +478,3 @@ export function getToken(): AuthData['accessToken']; | ||
* Returns the context object. Typically it is not required as the {@link #addContextUpdateListener addContextUpdateListener()} receives the same values. | ||
* @returns {Object} current context data. | ||
* @returns {Object} current context data | ||
* @memberof Lifecycle | ||
@@ -420,3 +487,3 @@ */ | ||
* Returns the context object. It is an alias function for getEventData(). | ||
* @returns {Object} current context data. | ||
* @returns {Object} current context data | ||
* @memberof Lifecycle | ||
@@ -429,6 +496,6 @@ */ | ||
* Returns the node parameters of the active URL. | ||
* Node parameters are defined like URL query parameters but with a specific prefix allowing Luigi to pass them to the micro frontend view. The default prefix is **~** and you can use it in the following way: `https://my.luigi.app/home/products?~sort=asc~page=3`. | ||
* Node parameters are defined like URL query parameters but with a specific prefix allowing Luigi to pass them to the micro frontend view. The default prefix is **~** and you can use it in the following way: `https://my.luigi.app/home/products?~sort=asc~page=3`. | ||
* <!-- add-attribute:class:warning --> | ||
* > **NOTE:** some special characters (`<`, `>`, `"`, `'`, `/`) in node parameters are HTML-encoded. | ||
* @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}`. | ||
* @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}` | ||
* @memberof Lifecycle | ||
@@ -445,3 +512,3 @@ */ | ||
* > **NOTE:** some special characters (`<`, `>`, `"`, `'`, `/`) in path parameters are HTML-encoded. | ||
* @returns {Object} path parameters, where the object property name is the path parameter name without the prefix, and its value is the actual value of the path parameter. For example ` {productId: 1234, ...}`. | ||
* @returns {Object} path parameters, where the object property name is the path parameter name without the prefix, and its value is the actual value of the path parameter. For example ` {productId: 1234, ...}` | ||
* @memberof Lifecycle | ||
@@ -454,3 +521,3 @@ */ | ||
* Returns the current client permissions as specified in the navigation node or an empty object. For details, see [Node parameters](navigation-parameters-reference.md). | ||
* @returns {Object} client permissions as specified in the navigation node. | ||
* @returns {Object} client permissions as specified in the navigation node | ||
* @memberof Lifecycle | ||
@@ -463,3 +530,3 @@ */ | ||
* When the micro frontend is not embedded in the Luigi Core application and there is no init handshake you can set the target origin that is used in postMessage function calls by Luigi Client. | ||
* @param {string} targetOrigin target origin. | ||
* @param {string} origin target origin | ||
* @memberof Lifecycle | ||
@@ -473,3 +540,3 @@ * @since 0.7.3 | ||
* Sends a custom message to the Luigi Core application. | ||
* @param {Object} message an object containing data to be sent to the Luigi Core to further process the custom event. This object is set as an input parameter of the event handler on the Luigi Core side. | ||
* @param {Object} message an object containing data to be sent to the Luigi Core to process it further. This object is set as an input parameter of the custom message listener on the Luigi Core side | ||
* @param {string} message.id a string containing the message id | ||
@@ -481,2 +548,3 @@ * @param {*} message.MY_DATA_FIELD any other message data field | ||
* @memberof Lifecycle | ||
* @since 0.6.2 | ||
*/ | ||
@@ -488,7 +556,7 @@ export function sendCustomMessage(message: object): void; | ||
* The Link Manager allows you to navigate to another route. Use it instead of an internal router to: | ||
- Route inside micro frontends. | ||
- Provide routing inside micro frontends. | ||
- Reflect the route. | ||
- Keep the navigation state in Luigi. | ||
*/ | ||
/** @name linkManager */ | ||
* @name linkManager | ||
*/ | ||
export function linkManager(): LinkManager; | ||
@@ -499,5 +567,5 @@ export type linkManager = () => LinkManager; | ||
* Use the UX Manager to manage the appearance features in Luigi. | ||
* @name uxManager | ||
*/ | ||
/** @name uxManager */ | ||
export function uxManager(): UxManager; | ||
export type uxManager = () => UxManager; |
@@ -1,1 +0,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 o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.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 o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));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=0)}([function(e,t,n){"use strict";function i(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)}}n.r(t);var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.promises={}}var t,n,o;return t=e,(n=[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}])&&i(t.prototype,n),o&&i(t,o),e}();function r(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)}}var a=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(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),window.onunload=function(){return window.removeEventListener("message",t)}}var t,n,i;return t=e,(n=[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",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:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){this.origin?window.parent.postMessage(e,this.origin):console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}}])&&r(t.prototype,n),i&&r(t,i),e}());function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(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)}}function l(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var d=new(function(e){function t(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=l(this,c(t).call(this))).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams"],e.setCurrentContext(e.defaultContextKeys.reduce(function(e,t){return e[t]={},e},{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={};var n,i;return n=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)},a.addEventListener("luigi.init",function(t){n(t.data),i(t.data.authData),a.setLuigiCoreDomain(t.origin),e.luigiInitialized=!0,e._notifyInit(t.origin)}),a.addEventListener("luigi-client.inactive-microfrontend",function(t){e._notifyInactive(t.origin)}),a.addEventListener("luigi.auth.tokenIssued",function(e){i(e.data.authData)}),a.addEventListener("luigi.navigate",function(t){n(t.data),e.currentContext.internal.isNavigateBack||(history.replaceState(null,"",t.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"}))),e._notifyUpdate(),a.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})}),window.parent.postMessage({msg:"luigi.get-context"},"*"),e._tpcCheck(),e}var n,i,r;return 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&&f(e,t)}(t,o),n=t,(i=[{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",(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)&&a.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=a.getRandomId();return this._onInitFns[t]=e,this.luigiInitialized&&a.isFunction(e)&&e(this.currentContext.context,a.getLuigiCoreDomain()),t}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=a.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&a.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=a.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 a.addEventListener(e,function(e,n){return t(e,n)})}},{key:"removeCustomMessageListener",value:function(e){return a.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getNodeParams",value:function(){return this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){a.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=a.convertCustomMessageUserToInternal(e);a.sendPostMessageToLuigiCore(t)}}])&&u(n.prototype,i),r&&u(n,r),t}());function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(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)}}function g(e,t){return!t||"object"!==v(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=function(e){function t(e){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=g(this,y(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=[a.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 a.removeEventListener(e)})}),n}var n,i,r;return 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&&m(e,t)}(t,o),n=t,(i=[{key:"sendSplitViewEvent",value:function(e,t){a.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=a.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),function(e){return t(e.data.data)});return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return a.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}}])&&p(n.prototype,i),r&&p(n,r),t}();function b(e){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(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)}}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var P=function(e){function t(e){var n,i,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=this,n=!(o=w(t).call(this))||"object"!==b(o)&&"function"!=typeof o?C(i):o,Object.assign(C(n),e),n.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,relative:!1,link:""},n}var n,i,r;return 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&&x(e,t)}(t,o),n=t,(i=[{key:"navigate",value:function(e,t,n,i,o){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&o&&console.warn("modalSettings and splitViewSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var r="/"!==e[0],s={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:r,modal:i,splitView:o})};a.sendPostMessageToLuigiCore(s)}}},{key:"openAsModal",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,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 h(t)}},{key:"fromContext",value:function(e){return-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.context.parentNavigationContexts.length>0?(this.options.fromContext=null,this.options.fromClosestContext=!0):console.error("Navigation not possible, no parent navigationContext found."),this}},{key:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"pathExists",value:function(e){var t=Date.now(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),a.addEventListener("luigi.navigation.pathExists.answer",function(e,t){var n=e.data.data,i=this.getPromise("pathExistsPromises")||{};i[n.correlationId]&&(i[n.correlationId].resolveFn(n.pathExists),delete i[n.correlationId],this.setPromise("pathExistsPromises",i)),a.removeEventListener(t)}.bind(this));var i={msg:"luigi.navigation.pathExists",data:{id:t,link:e,relative:"/"!==e[0]}};return a.sendPostMessageToLuigiCore(i),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){a.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}}])&&k(n.prototype,i),r&&k(n,r),t}();function L(e){return(L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(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)}}function _(e,t){return!t||"object"!==L(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var S=new(function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=_(this,E(t).call(this)),a.addEventListener("luigi.current-locale-changed",function(e){var t;e.data.currentLocale&&(null===(t=d.currentContext)||void 0===t?void 0:t.internal)&&(d.currentContext.internal.currentLocale=e.data.currentLocale,d._notifyUpdate())}),e}var n,i,r;return 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)}(t,o),n=t,(i=[{key:"showLoadingIndicator",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"addBackdrop",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){a.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;a.addEventListener("luigi.ux.confirmationModal.hide",function(e,n){t.hideConfirmationModal(e.data.data),a.removeEventListener(n)}),a.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;a.addEventListener("luigi.ux.alert.hide",function(e,n){t.hideAlert(e.data.id),a.removeEventListener(n)}),e.id=a.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),a.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=this.getPromise("alerts");e&&t[e]&&(t[e].resolveFn(e),delete t[e],this.setPromise("alerts",t))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=d.currentContext)||void 0===e?void 0:null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&a.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=d.currentContext)||void 0===e?void 0:null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=d.currentContext)||void 0===e?void 0:null===(t=e.internal)||void 0===t?void 0:t.modal}}])&&O(n.prototype,i),r&&O(n,r),t}());function M(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)}}var j=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"addInitListener",value:function(e){return d.addInitListener(e)}},{key:"removeInitListener",value:function(e){return d.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return d.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return d.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return d.getToken()}},{key:"getEventData",value:function(){return d.getEventData()}},{key:"getContext",value:function(){return d.getContext()}},{key:"getNodeParams",value:function(){return d.getNodeParams()}},{key:"getPathParams",value:function(){return d.getPathParams()}},{key:"getClientPermissions",value:function(){return d.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return d.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return d.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return d.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return d.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return d.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return d.setTargetOrigin(e)}},{key:"linkManager",value:function(){return new P({currentContext:d.currentContext})}},{key:"uxManager",value:function(){return S}},{key:"lifecycleManager",value:function(){return d}}])&&M(t.prototype,n),i&&M(t,i),e}();t.default=j=new j}]).default}); | ||
!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 o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.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 o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));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=0)}([function(e,t,n){"use strict";function i(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)}}n.r(t);var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.promises={}}var t,n,o;return t=e,(n=[{key:"setPromise",value:function(e,t){this.promises[e]=t}},{key:"getPromise",value:function(e){return this.promises[e]}}])&&i(t.prototype,n),o&&i(t,o),e}();function r(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)}}var a=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(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),window.onunload=function(){return window.removeEventListener("message",t)}}var t,n,i;return t=e,(n=[{key:"convertCustomMessageInternalToUser",value:function(e){return e.data}},{key:"convertCustomMessageUserToInternal",value:function(e){return{msg:"custom",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:"getLuigiCoreDomain",value:function(){return this.origin}},{key:"setLuigiCoreDomain",value:function(e){e&&(this.origin=e)}},{key:"setTargetOrigin",value:function(e){this.setLuigiCoreDomain(e)}},{key:"sendPostMessageToLuigiCore",value:function(e){this.origin?window.parent.postMessage(e,this.origin):console.warn('There is no target origin set. You can specify the target origin by calling LuigiClient.setTargetOrigin("targetorigin") in your micro frontend.')}}])&&r(t.prototype,n),i&&r(t,i),e}());function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(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)}}function l(e,t){return!t||"object"!==s(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var d=new(function(e){function t(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(e=l(this,c(t).call(this))).luigiInitialized=!1,e.defaultContextKeys=["context","internal","nodeParams","pathParams"],e.setCurrentContext(e.defaultContextKeys.reduce(function(e,t){return e[t]={},e},{})),e._onContextUpdatedFns={},e._onInactiveFns={},e._onInitFns={},e.authData={};var n,i;return n=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)},a.addEventListener("luigi.init",function(t){n(t.data),i(t.data.authData),a.setLuigiCoreDomain(t.origin),e.luigiInitialized=!0,e._notifyInit(t.origin)}),a.addEventListener("luigi-client.inactive-microfrontend",function(t){e._notifyInactive(t.origin)}),a.addEventListener("luigi.auth.tokenIssued",function(e){i(e.data.authData)}),a.addEventListener("luigi.navigate",function(t){n(t.data),e.currentContext.internal.isNavigateBack||(history.replaceState(null,"",t.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"}))),e._notifyUpdate(),a.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})}),window.parent.postMessage({msg:"luigi.get-context"},"*"),e._tpcCheck(),e}var n,i,r;return 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&&f(e,t)}(t,o),n=t,(i=[{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",(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)&&a.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=a.getRandomId();return this._onInitFns[t]=e,this.luigiInitialized&&a.isFunction(e)&&e(this.currentContext.context,a.getLuigiCoreDomain()),t}},{key:"removeInitListener",value:function(e){return!!this._onInitFns[e]&&(this._onInitFns[e]=void 0,!0)}},{key:"addContextUpdateListener",value:function(e){var t=a.getRandomId();return this._onContextUpdatedFns[t]=e,this.luigiInitialized&&a.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=a.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 a.addEventListener(e,function(e,n){return t(e,n)})}},{key:"removeCustomMessageListener",value:function(e){return a.removeEventListener(e)}},{key:"getToken",value:function(){return this.authData.accessToken}},{key:"getEventData",value:function(){return this.currentContext.context}},{key:"getContext",value:function(){return this.getEventData()}},{key:"getNodeParams",value:function(){return this.currentContext.nodeParams}},{key:"getPathParams",value:function(){return this.currentContext.pathParams}},{key:"getClientPermissions",value:function(){return this.currentContext.internal.clientPermissions||{}}},{key:"setTargetOrigin",value:function(e){a.setTargetOrigin(e)}},{key:"sendCustomMessage",value:function(e){var t=a.convertCustomMessageUserToInternal(e);a.sendPostMessageToLuigiCore(t)}}])&&u(n.prototype,i),r&&u(n,r),t}());function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(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)}}function g(e,t){return!t||"object"!==v(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=function(e){function t(e){var n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),(n=g(this,y(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=[a.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 a.removeEventListener(e)})}),n}var n,i,r;return 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&&m(e,t)}(t,o),n=t,(i=[{key:"sendSplitViewEvent",value:function(e,t){a.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=a.addEventListener("luigi.navigation.splitview.".concat(e,".ok"),function(e){return t(e.data.data)});return this.splitView.listeners.push(n),n}},{key:"removeEventListener",value:function(e){return a.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}}])&&p(n.prototype,i),r&&p(n,r),t}();function b(e){return(b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(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)}}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(e,t){return(x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var P=function(e){function t(e){var n,i,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i=this,n=!(o=w(t).call(this))||"object"!==b(o)&&"function"!=typeof o?C(i):o,Object.assign(C(n),e),n.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,relative:!1,link:""},n}var n,i,r;return 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&&x(e,t)}(t,o),n=t,(i=[{key:"navigate",value:function(e,t,n,i,o){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&o&&console.warn("modalSettings and splitViewSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var r="/"!==e[0],s={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:r,modal:i,splitView:o})};a.sendPostMessageToLuigiCore(s)}}},{key:"openAsModal",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.navigate(e,0,!0,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 h(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:"withParams",value:function(e){return e&&Object.assign(this.options.nodeParams,e),this}},{key:"pathExists",value:function(e){var t=Date.now(),n=this.getPromise("pathExistsPromises")||{};n[t]={resolveFn:function(){},then:function(e){this.resolveFn=e}},this.setPromise("pathExistsPromises",n),a.addEventListener("luigi.navigation.pathExists.answer",function(e,t){var n=e.data.data,i=this.getPromise("pathExistsPromises")||{};i[n.correlationId]&&(i[n.correlationId].resolveFn(n.pathExists),delete i[n.correlationId],this.setPromise("pathExistsPromises",i)),a.removeEventListener(t)}.bind(this));var i={msg:"luigi.navigation.pathExists",data:{id:t,link:e,relative:"/"!==e[0]}};return a.sendPostMessageToLuigiCore(i),n[t]}},{key:"hasBack",value:function(){return!!this.currentContext.internal.modal||0!==this.currentContext.internal.viewStackSize}},{key:"goBack",value:function(e){a.sendPostMessageToLuigiCore({msg:"luigi.navigation.back",goBackContext:e&&JSON.stringify(e)})}},{key:"withoutSync",value:function(){return this.options.withoutSync=!0,this}}])&&k(n.prototype,i),r&&k(n,r),t}();function L(e){return(L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(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)}}function _(e,t){return!t||"object"!==L(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var I=new(function(e){function t(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),e=_(this,E(t).call(this)),a.addEventListener("luigi.current-locale-changed",function(e){var t;e.data.currentLocale&&(null===(t=d.currentContext)||void 0===t?void 0:t.internal)&&(d.currentContext.internal.currentLocale=e.data.currentLocale,d._notifyUpdate())}),e}var n,i,r;return 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&&S(e,t)}(t,o),n=t,(i=[{key:"showLoadingIndicator",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.show-loading-indicator"})}},{key:"hideLoadingIndicator",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.hide-loading-indicator"})}},{key:"addBackdrop",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.add-backdrop"})}},{key:"removeBackdrop",value:function(){a.sendPostMessageToLuigiCore({msg:"luigi.remove-backdrop"})}},{key:"setDirtyStatus",value:function(e){a.sendPostMessageToLuigiCore({msg:"luigi.set-page-dirty",dirty:e})}},{key:"showConfirmationModal",value:function(e){var t=this;a.addEventListener("luigi.ux.confirmationModal.hide",function(e,n){t.hideConfirmationModal(e.data.data),a.removeEventListener(n)}),a.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;a.addEventListener("luigi.ux.alert.hide",function(e,n){t.hideAlert(e.data.id),a.removeEventListener(n)}),e.id=a.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),a.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=this.getPromise("alerts");e&&t[e]&&(t[e].resolveFn(e),delete t[e],this.setPromise("alerts",t))}},{key:"getCurrentLocale",value:function(){var e,t;return null===(e=d.currentContext)||void 0===e?void 0:null===(t=e.internal)||void 0===t?void 0:t.currentLocale}},{key:"setCurrentLocale",value:function(e){e&&a.sendPostMessageToLuigiCore({msg:"luigi.ux.set-current-locale",data:{currentLocale:e}})}},{key:"isSplitView",value:function(){var e,t;return null===(e=d.currentContext)||void 0===e?void 0:null===(t=e.internal)||void 0===t?void 0:t.splitView}},{key:"isModal",value:function(){var e,t;return null===(e=d.currentContext)||void 0===e?void 0:null===(t=e.internal)||void 0===t?void 0:t.modal}}])&&O(n.prototype,i),r&&O(n,r),t}());function M(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)}}var j=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,n,i;return t=e,(n=[{key:"addInitListener",value:function(e){return d.addInitListener(e)}},{key:"removeInitListener",value:function(e){return d.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return d.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return d.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return d.getToken()}},{key:"getEventData",value:function(){return d.getEventData()}},{key:"getContext",value:function(){return d.getContext()}},{key:"getNodeParams",value:function(){return d.getNodeParams()}},{key:"getPathParams",value:function(){return d.getPathParams()}},{key:"getClientPermissions",value:function(){return d.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return d.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return d.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return d.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return d.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return d.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return d.setTargetOrigin(e)}},{key:"linkManager",value:function(){return new P({currentContext:d.currentContext})}},{key:"uxManager",value:function(){return I}},{key:"lifecycleManager",value:function(){return d}}])&&M(t.prototype,n),i&&M(t,i),e}();t.default=j=new j}]).default}); |
{ | ||
"name": "@luigi-project/client", | ||
"version": "1.0.0-next.0", | ||
"version": "1.0.0-next.1", | ||
"description": "Javascript library supporting consumers of the Luigi framework", | ||
@@ -17,4 +17,6 @@ "license": "Apache-2.0", | ||
"UI", | ||
"extensibility" | ||
"extensibility", | ||
"micro-frontends", | ||
"microfrontends" | ||
] | ||
} |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
483
0
12
45616