New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@luigi-project/client

Package Overview
Dependencies
Maintainers
2
Versions
1448
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luigi-project/client - npm Package Compare versions

Comparing version 1.7.1-dev.20201219 to 1.7.1-dev.20201220

2

luigi-client.js

@@ -1,2 +0,2 @@

!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=9)}([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(6),o=n(5);e.exports=function(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?o(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(7);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){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","version":"1.7.1-dev.20201218","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"]}')},function(e,t,n){"use strict";n.r(t);var i=n(0),o=n.n(i),r=n(1),s=n.n(r),a=n(2),u=n.n(a),l=n(3),c=n.n(l),d=n(4),v=n.n(d),g=function(){function e(){o()(this,e),this.promises={}}return s()(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(){o()(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 s()(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:"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.')}}]),e}()),p=new(function(e){function t(){var e;o()(this,t),(e=u()(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 i,r;return i=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)},r=function(t){t&&(e.authData=t)},f.addEventListener("luigi.init",(function(t){i(t.data),r(t.data.authData),f.setLuigiCoreDomain(t.origin),e.luigiInitialized=!0,e._notifyInit(t.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){r(e.data.authData)})),f.addEventListener("luigi.navigate",(function(t){i(t.data),e.currentContext.internal.isNavigateBack||(history.replaceState({luigiInduced:!0},"",t.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"}))),e._notifyUpdate(),f.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})})),window.parent.postMessage({msg:"luigi.get-context",clientVersion:n(8).version},"*"),e._tpcCheck(),e}return v()(t,e),s()(t,[{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)&&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:"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){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}}]),t}(g)),h=n(5),m=n.n(h),y=function(e){function t(e){var n;o()(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),s()(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){return t(e.data.data)}));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),k=function(e){function t(e){var n;return o()(this,t),n=u()(this,c()(t).call(this)),Object.assign(m()(n),e),n.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:""},n}return v()(t,e),s()(t,[{key:"navigate",value:function(e,t,n,i,o,r){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&o&&r&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var s="/"!==e[0],a=e.toLowerCase().includes("?intent="),u={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:s,intent:a,modal:i,splitView:o,drawer:r})};f.sendPostMessageToLuigiCore(u)}}},{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 y(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:"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),f.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)),f.removeEventListener(t)}.bind(this));var i={msg:"luigi.navigation.pathExists",data:{id:t,link: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}}]),t}(g),C=new(function(e){function t(){var e;return o()(this,t),e=u()(this,c()(t).call(this)),f.addEventListener("luigi.current-locale-changed",(function(e){var t;e.data.currentLocale&&(null===(t=p.currentContext)||void 0===t?void 0:t.internal)&&(p.currentContext.internal.currentLocale=e.data.currentLocale,p._notifyUpdate())})),e}return v()(t,e),s()(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.id),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=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=p.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=p.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=p.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=p.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}}]),t}(g)),x=new Map,w=function(e){function t(){var e;return o()(this,t),(e=u()(this,c()(t).call(this))).storageEventProcessor=new P,f.addEventListener("storage",(function(t,n){return e.storageEventProcessor.processEvent(t,n)})),e}return v()(t,e),s()(t,[{key:"setItem",value:function(e,t){var n=this;return new Promise((function(i,o){n.storageEventProcessor.execute(i,o,"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),P=function(){function e(){o()(this,e)}return s()(e,[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!x.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var i=x.get(n.id);"ERROR"===n.status?i.reject(n.result):i.resolve(n.result),x.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 x.delete(e),n}},{key:"execute",value:function(e,t,n,i){var o=f.getRandomId();this.createPendingOperation(o,e,t),this.sendMessage(o,n,i)}},{key:"createPendingOperation",value:function(e,t,n){x.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}(),L=new w,b=function(){function e(){o()(this,e),window!==window.top&&"true"!=window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history))}return s()(e,[{key:"addInitListener",value:function(e){return p.addInitListener(e)}},{key:"removeInitListener",value:function(e){return p.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return p.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return p.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return p.getToken()}},{key:"getEventData",value:function(){return p.getEventData()}},{key:"getContext",value:function(){return p.getContext()}},{key:"getNodeParams",value:function(){return p.getNodeParams()}},{key:"getActiveFeatureToggles",value:function(){return p.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return p.getPathParams()}},{key:"getClientPermissions",value:function(){return p.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return p.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return p.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return p.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return p.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return p.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return p.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return p.getUserSettings()}},{key:"linkManager",value:function(){return new k({currentContext:p.currentContext})}},{key:"uxManager",value:function(){return C}},{key:"lifecycleManager",value:function(){return p}},{key:"storageManager",value:function(){return L}}]),e}();t.default=b=new b}]).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=9)}([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(6),o=n(5);e.exports=function(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?o(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(7);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){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","version":"1.7.1-dev.20201219","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"]}')},function(e,t,n){"use strict";n.r(t);var i=n(0),o=n.n(i),r=n(1),s=n.n(r),a=n(2),u=n.n(a),l=n(3),c=n.n(l),d=n(4),v=n.n(d),g=function(){function e(){o()(this,e),this.promises={}}return s()(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(){o()(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 s()(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:"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.')}}]),e}()),p=new(function(e){function t(){var e;o()(this,t),(e=u()(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 i,r;return i=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)},r=function(t){t&&(e.authData=t)},f.addEventListener("luigi.init",(function(t){i(t.data),r(t.data.authData),f.setLuigiCoreDomain(t.origin),e.luigiInitialized=!0,e._notifyInit(t.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){r(e.data.authData)})),f.addEventListener("luigi.navigate",(function(t){i(t.data),e.currentContext.internal.isNavigateBack||(history.replaceState({luigiInduced:!0},"",t.data.viewUrl),window.dispatchEvent(new PopStateEvent("popstate",{state:"luiginavigation"}))),e._notifyUpdate(),f.sendPostMessageToLuigiCore({msg:"luigi.navigate.ok"})})),window.parent.postMessage({msg:"luigi.get-context",clientVersion:n(8).version},"*"),e._tpcCheck(),e}return v()(t,e),s()(t,[{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)&&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:"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){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}}]),t}(g)),h=n(5),m=n.n(h),y=function(e){function t(e){var n;o()(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),s()(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){return t(e.data.data)}));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),k=function(e){function t(e){var n;return o()(this,t),n=u()(this,c()(t).call(this)),Object.assign(m()(n),e),n.options={preserveView:!1,nodeParams:{},errorSkipNavigation:!1,fromContext:null,fromClosestContext:!1,fromVirtualTreeRoot:!1,fromParent:!1,relative:!1,link:""},n}return v()(t,e),s()(t,[{key:"navigate",value:function(e,t,n,i,o,r){if(this.options.errorSkipNavigation)this.options.errorSkipNavigation=!1;else{i&&o&&r&&console.warn("modalSettings, splitViewSettings and drawerSettings cannot be used together. Only modal setting will be taken into account."),this.options.preserveView=n;var s="/"!==e[0],a=e.toLowerCase().includes("?intent="),u={msg:"luigi.navigation.open",sessionId:t,params:Object.assign(this.options,{link:e,relative:s,intent:a,modal:i,splitView:o,drawer:r})};f.sendPostMessageToLuigiCore(u)}}},{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 y(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:"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),f.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)),f.removeEventListener(t)}.bind(this));var i={msg:"luigi.navigation.pathExists",data:{id:t,link: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}}]),t}(g),C=new(function(e){function t(){var e;return o()(this,t),e=u()(this,c()(t).call(this)),f.addEventListener("luigi.current-locale-changed",(function(e){var t;e.data.currentLocale&&(null===(t=p.currentContext)||void 0===t?void 0:t.internal)&&(p.currentContext.internal.currentLocale=e.data.currentLocale,p._notifyUpdate())})),e}return v()(t,e),s()(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.id),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=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=p.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=p.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=p.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.modal}},{key:"getCurrentTheme",value:function(){var e,t;return null===(e=p.currentContext)||void 0===e||null===(t=e.internal)||void 0===t?void 0:t.currentTheme}}]),t}(g)),x=new Map,w=function(e){function t(){var e;return o()(this,t),(e=u()(this,c()(t).call(this))).storageEventProcessor=new P,f.addEventListener("storage",(function(t,n){return e.storageEventProcessor.processEvent(t,n)})),e}return v()(t,e),s()(t,[{key:"setItem",value:function(e,t){var n=this;return new Promise((function(i,o){n.storageEventProcessor.execute(i,o,"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),P=function(){function e(){o()(this,e)}return s()(e,[{key:"processEvent",value:function(e,t){try{var n=e.data.data;if(!x.has(n.id))return void console.log("Impossible to find Promise method for message "+n.id);var i=x.get(n.id);"ERROR"===n.status?i.reject(n.result):i.resolve(n.result),x.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 x.delete(e),n}},{key:"execute",value:function(e,t,n,i){var o=f.getRandomId();this.createPendingOperation(o,e,t),this.sendMessage(o,n,i)}},{key:"createPendingOperation",value:function(e,t,n){x.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}(),L=new w,b=function(){function e(){o()(this,e),window!==window.top&&"true"!=window.document.head.getAttribute("disable-luigi-history-handling")&&(history.pushState=history.replaceState.bind(history))}return s()(e,[{key:"addInitListener",value:function(e){return p.addInitListener(e)}},{key:"removeInitListener",value:function(e){return p.removeInitListener(e)}},{key:"addContextUpdateListener",value:function(e){return p.addContextUpdateListener(e)}},{key:"removeContextUpdateListener",value:function(e){return p.removeContextUpdateListener(e)}},{key:"getToken",value:function(){return p.getToken()}},{key:"getEventData",value:function(){return p.getEventData()}},{key:"getContext",value:function(){return p.getContext()}},{key:"getNodeParams",value:function(){return p.getNodeParams()}},{key:"getActiveFeatureToggles",value:function(){return p.getActiveFeatureToggles()}},{key:"getPathParams",value:function(){return p.getPathParams()}},{key:"getClientPermissions",value:function(){return p.getClientPermissions()}},{key:"sendCustomMessage",value:function(e){return p.sendCustomMessage(e)}},{key:"addCustomMessageListener",value:function(e,t){return p.addCustomMessageListener(e,t)}},{key:"removeCustomMessageListener",value:function(e){return p.removeCustomMessageListener(e)}},{key:"addInactiveListener",value:function(e,t){return p.addInactiveListener(e,t)}},{key:"removeInactiveListener",value:function(e){return p.removeInactiveListener(e)}},{key:"setTargetOrigin",value:function(e){return p.setTargetOrigin(e)}},{key:"getUserSettings",value:function(){return p.getUserSettings()}},{key:"linkManager",value:function(){return new k({currentContext:p.currentContext})}},{key:"uxManager",value:function(){return C}},{key:"lifecycleManager",value:function(){return p}},{key:"storageManager",value:function(){return L}}]),e}();t.default=b=new b}]).default}));
//# sourceMappingURL=luigi-client.js.map
{
"name": "@luigi-project/client",
"version": "1.7.1-dev.20201219",
"version": "1.7.1-dev.20201220",
"description": "Javascript library supporting consumers of the Luigi framework",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc