single-spa
Version:
The router for easy microfrontends
4 lines (3 loc) • 21.3 kB
JavaScript
/* single-spa@6.0.3 - SystemJS ES5 - prod */
System.register([],(function(t){"use strict";return{execute:function(){t({addErrorHandler:c,checkActivityFunctions:Ut,ensureJQuerySupport:vt,getAppNames:At,getAppStatus:Nt,getMountedApps:bt,mountRootParcel:k,navigateToUrl:it,patchHistoryApi:pt,pathToActiveWhen:Rt,registerApplication:_t,removeErrorHandler:s,setBootstrapMaxTime:V,setMountMaxTime:q,setUnloadMaxTime:X,setUnmountMaxTime:z,start:kt,triggerAppChange:Bt,unloadApplication:Mt,unregisterApplication:Dt});var n=Object.freeze({__proto__:null,get start(){return kt},get ensureJQuerySupport(){return vt},get setBootstrapMaxTime(){return V},get setMountMaxTime(){return q},get setUnmountMaxTime(){return z},get setUnloadMaxTime(){return X},get registerApplication(){return _t},get unregisterApplication(){return Dt},get getMountedApps(){return bt},get getAppStatus(){return Nt},get unloadApplication(){return Mt},get checkActivityFunctions(){return Ut},get getAppNames(){return At},get pathToActiveWhen(){return Rt},get navigateToUrl(){return it},get patchHistoryApi(){return pt},get triggerAppChange(){return Bt},get addErrorHandler(){return c},get removeErrorHandler(){return s},get mountRootParcel(){return k},get NOT_LOADED(){return p},get LOADING_SOURCE_CODE(){return h},get NOT_BOOTSTRAPPED(){return m},get BOOTSTRAPPING(){return v},get NOT_MOUNTED(){return d},get MOUNTING(){return w},get UPDATING(){return E},get LOAD_ERROR(){return T},get MOUNTED(){return g},get UNLOADING(){return O},get UNMOUNTING(){return y},get SKIP_BECAUSE_BROKEN(){return P}});function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function e(t,n,r){return n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t}var o=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent,i=function(){try{var t=new o("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?o:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var r=document.createEvent("CustomEvent");return n?r.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):r.initCustomEvent(t,!1,!1,void 0),r}:function(t,n){var r=document.createEventObject();return r.type=t,n?(r.bubbles=Boolean(n.bubbles),r.cancelable=Boolean(n.cancelable),r.detail=n.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r},u=[];function a(t,n,r){var e=l(t,n,r);u.length?u.forEach((function(t){return t(e)})):setTimeout((function(){throw e}))}function c(t){if("function"!=typeof t)throw Error(f(28,!1));u.push(t)}function s(t){if("function"!=typeof t)throw Error(f(29,!1));var n=!1;return u=u.filter((function(r){var e=r===t;return n=n||e,!e})),n}function f(t,n){for(var r=arguments.length,e=new Array(r>2?r-2:0),o=2;o<r;o++)e[o-2]=arguments[o];return"single-spa minified message #".concat(t,": ").concat(n?n+" ":"","See https://single-spa.js.org/error/?code=").concat(t).concat(e.length?"&arg=".concat(e.join("&arg=")):"")}function l(t,n,r){var e,o="".concat(_(n)," '").concat(N(n),"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message}catch(t){}e=t}else{console.warn(f(30,!1,n.status,N(n)));try{e=Error(o+JSON.stringify(t))}catch(n){e=t}}return e.appOrParcelName=N(n),n.status=r,e}var p=t("NOT_LOADED","NOT_LOADED"),h=t("LOADING_SOURCE_CODE","LOADING_SOURCE_CODE"),m=t("NOT_BOOTSTRAPPED","NOT_BOOTSTRAPPED"),v=t("BOOTSTRAPPING","BOOTSTRAPPING"),d=t("NOT_MOUNTED","NOT_MOUNTED"),w=t("MOUNTING","MOUNTING"),g=t("MOUNTED","MOUNTED"),E=t("UPDATING","UPDATING"),y=t("UNMOUNTING","UNMOUNTING"),O=t("UNLOADING","UNLOADING"),T=t("LOAD_ERROR","LOAD_ERROR"),P=t("SKIP_BECAUSE_BROKEN","SKIP_BECAUSE_BROKEN");function b(t){return t.status===g}function A(t){try{return t.activeWhen(window.location)}catch(n){return a(n,t,P),!1}}function N(t){return t.name}function S(t){return Boolean(t.unmountThisParcel)}function _(t){return S(t)?"parcel":"application"}function U(){for(var t=arguments.length-1;t>0;t--)for(var n in arguments[t])"__proto__"!==n&&(arguments[t-1][n]=arguments[t][n]);return arguments[0]}function D(t,n){for(var r=0;r<t.length;r++)if(n(t[r]))return t[r];return null}function M(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!D(n,(function(t){return"function"!=typeof t}))));var n}function L(t,n){var r=t[n]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[function(){return Promise.resolve()}]);var e=_(t),o=N(t);return function(t){return r.reduce((function(r,i,u){return r.then((function(){var r=i(t);return j(r)?r:Promise.reject(f(15,!1,e,o,n,u))}))}),Promise.resolve())}}function j(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}var R=[];function I(t,n){return Promise.resolve().then((function(){return t.status!==m?t:(t.status=v,t.bootstrap?Y(t,"bootstrap").then(r).catch((function(r){if(n)throw l(r,t,P);return a(r,t,P),t})):Promise.resolve().then(r))}));function r(){return t.status=d,t}}function x(t,n){return Promise.resolve().then((function(){if(t.status!==g)return t;t.status=y;var r=Object.keys(t.parcels).map((function(n){return t.parcels[n].unmountThisParcel()}));return Promise.all(r).then(e,(function(r){return e().then((function(){var e=Error(r.message);if(n)throw l(e,t,P);a(e,t,P)}))})).then((function(){return t}));function e(){return Y(t,"unmount").then((function(){t.status=d}),(function(r){if(n)throw l(r,t,P);a(r,t,P)}))}}))}var G=!1,B=!1;function C(t,n){return Promise.resolve().then((function(){return t.status!==d?t:(G||(window.dispatchEvent(new i("single-spa:before-first-mount")),G=!0),t.status=w,Y(t,"mount").then((function(){return t.status=g,B||(window.dispatchEvent(new i("single-spa:first-mount")),B=!0),t})).catch((function(r){return t.status=g,x(t,!0).then(e,e);function e(){if(n)throw l(r,t,P);return a(r,t,P),t}})))}))}var W=0,$={parcels:{}};function k(){return H.apply($,arguments)}function H(t,n){var e=this;if(!t||"object"!==r(t)&&"function"!=typeof t)throw Error(f(2,!1));if(t.name&&"string"!=typeof t.name)throw Error(f(3,!1,r(t.name)));var o=W++,i=t.name||"parcel-".concat(o);if("object"!==r(n))throw Error(f(4,!1,i,r(n)));if(!n.domElement)throw Error(f(5,!1,i));var u,a="function"==typeof t,c=a?t:function(){return Promise.resolve(t)},s={id:o,parcels:{},status:a?h:m,customProps:n,parentName:N(e),unmountThisParcel:function(){return O.then((function(){if(s.status!==g)throw Error(f(6,!1,i,s.status));return x(s,!0)})).then((function(t){return s.parentName&&delete e.parcels[s.id],t})).then((function(t){return v(t),t})).catch((function(t){throw s.status=P,w(t),t}))}};e.parcels[o]=s;var p=c();if(!p||"function"!=typeof p.then)throw Error(f(7,!1));var v,w,y=(p=p.then((function(t){if(!t)throw Error(f(8,!1));if(i=t.name||"parcel-".concat(o),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!M(t.bootstrap))throw Error(f(9,!1,i));if(!M(t.mount))throw Error(f(10,!1,i));if(!M(t.unmount))throw Error(f(11,!1,i));if(t.update&&!M(t.update))throw Error(f(12,!1,i));var n=L(t,"bootstrap"),r=L(t,"mount"),e=L(t,"unmount");s.status=m,s.name=i,s.bootstrap=n,s.mount=r,s.unmount=e,s.timeouts=Z(t.timeouts),t.update&&(s.update=L(t,"update"),u.update=function(t){return s.customProps=t,K((n=s,Promise.resolve().then((function(){if(n.status!==g)throw Error(f(32,!1,N(n)));return n.status=E,Y(n,"update").then((function(){return n.status=g,n})).catch((function(t){throw l(t,n,P)}))}))));var n})}))).then((function(){return I(s,!0)})),O=y.then((function(){return C(s,!0)})),T=new Promise((function(t,n){v=t,w=n}));return u={mount:function(){return K(Promise.resolve().then((function(){if(s.status!==d)throw Error(f(13,!1,i,s.status));return e.parcels[o]=s,C(s)})))},unmount:function(){return K(s.unmountThisParcel())},getStatus:function(){return s.status},loadPromise:K(p),bootstrapPromise:K(y),mountPromise:K(O),unmountPromise:K(T)}}function K(t){return t.then((function(){return null}))}function F(t){var e=N(t),o="function"==typeof t.customProps?t.customProps(e,window.location):t.customProps;("object"!==r(o)||null===o||Array.isArray(o))&&(o={},console.warn(f(40,!1),e,o));var i=U({},o,{name:e,mountParcel:H.bind(t),singleSpa:n});return S(t)&&(i.unmountSelf=t.unmountThisParcel),i}var J=1e3,Q={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:J},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:J},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:J},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:J},update:{millis:3e3,dieOnTimeout:!1,warningMillis:J}};function V(t,n,r){if("number"!=typeof t||t<=0)throw Error(f(16,!1));Q.bootstrap={millis:t,dieOnTimeout:n,warningMillis:r||J}}function q(t,n,r){if("number"!=typeof t||t<=0)throw Error(f(17,!1));Q.mount={millis:t,dieOnTimeout:n,warningMillis:r||J}}function z(t,n,r){if("number"!=typeof t||t<=0)throw Error(f(18,!1));Q.unmount={millis:t,dieOnTimeout:n,warningMillis:r||J}}function X(t,n,r){if("number"!=typeof t||t<=0)throw Error(f(19,!1));Q.unload={millis:t,dieOnTimeout:n,warningMillis:r||J}}function Y(t,n){var r=t.timeouts[n],e=r.warningMillis,o=_(t);return new Promise((function(i,u){var a=!1,c=!1;t[n](F(t)).then((function(t){a=!0,i(t)})).catch((function(t){a=!0,u(t)})),setTimeout((function(){return l(1)}),e),setTimeout((function(){return l(!0)}),r.millis);var s=f(31,!1,n,o,N(t),r.millis);function l(t){if(!a)if(!0===t)c=!0,r.dieOnTimeout?u(Error(s)):console.error(s);else if(!c){var n=t,o=n*e;console.warn(s),o+e<r.millis&&setTimeout((function(){return l(n+1)}),e)}}}))}function Z(t){var n={};for(var r in Q)n[r]=U({},Q[r],t&&t[r]||{});return n}function tt(t){return Promise.resolve().then((function(){return t.loadPromise?t.loadPromise:t.status!==p&&t.status!==T?t:(t.status=h,t.loadPromise=Promise.resolve().then((function(){var o=t.loadApp(F(t));if(!j(o))throw e=!0,Error(f(33,!1,N(t)));return o.then((function(e){var o;t.loadErrorTime=null,"object"!==r(n=e)&&(o=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!M(n.bootstrap)&&(o=35),M(n.mount)||(o=36),M(n.unmount)||(o=37);var i=_(n);if(o){var u;try{u=JSON.stringify(n)}catch(t){}return console.error(f(o,!1,i,N(t),u),n),a(void 0,t,P),t}return n.devtools&&n.devtools.overlays&&(t.devtools.overlays=U({},t.devtools.overlays,n.devtools.overlays)),t.status=m,t.bootstrap=L(n,"bootstrap"),t.mount=L(n,"mount"),t.unmount=L(n,"unmount"),t.unload=L(n,"unload"),t.timeouts=Z(n.timeouts),delete t.loadPromise,t}))})).catch((function(n){var r;return delete t.loadPromise,e?r=P:(r=T,t.loadErrorTime=(new Date).getTime()),a(n,t,r),t})));var n,e}))}var nt,rt="undefined"!=typeof window,et={hashchange:[],popstate:[]},ot=["hashchange","popstate"];function it(t){var n;if("string"==typeof t)n=t;else if(this&&this.href)n=this.href;else{if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error(f(14,!1));n=t.currentTarget.href,t.preventDefault()}var r=ht(window.location.href),e=ht(n);0===n.indexOf("#")?window.location.hash=e.hash:r.host!==e.host&&e.host?window.location.href=n:e.pathname===r.pathname&&e.search===r.search?window.location.hash=e.hash:window.history.pushState(null,null,n)}function ut(t){var n=this;if(t){var r=t[0].type;ot.indexOf(r)>=0&&et[r].forEach((function(r){try{r.apply(n,t)}catch(t){setTimeout((function(){throw t}))}}))}}function at(){Ct([],arguments)}function ct(t,n){return function(){var r=window.location.href,e=t.apply(this,arguments),o=window.location.href;return nt&&r===o||window.dispatchEvent(st(window.history.state,n)),e}}function st(t,n){var r;try{r=new PopStateEvent("popstate",{state:t})}catch(n){(r=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,t)}return r.singleSpa=!0,r.singleSpaTrigger=n,r}var ft=null,lt=!1;function pt(t){if(lt)throw Error(f(43,!1));nt=!t||!t.hasOwnProperty("urlRerouteOnly")||t.urlRerouteOnly,lt=!0,ft=window.history.replaceState,window.addEventListener("hashchange",at),window.addEventListener("popstate",at);var n=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(t,r){if(!("function"==typeof r&&ot.indexOf(t)>=0)||D(et[t],(function(t){return t===r})))return n.apply(this,arguments);et[t].push(r)},window.removeEventListener=function(t,n){return"function"==typeof n&&ot.indexOf(t)>=0&&(et[t]=et[t].filter((function(t){return t!==n}))),r.apply(this,arguments)},window.history.pushState=ct(window.history.pushState,"pushState"),window.history.replaceState=ct(ft,"replaceState")}function ht(t){var n=document.createElement("a");return n.href=t,n}rt&&(window.singleSpaNavigate?console.warn(f(41,!1)):window.singleSpaNavigate=it);var mt=!1;function vt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!mt){var n=t.fn.on,r=t.fn.off;t.fn.on=function(t,r){return dt.call(this,n,window.addEventListener,t,r,arguments)},t.fn.off=function(t,n){return dt.call(this,r,window.removeEventListener,t,n,arguments)},mt=!0}}function dt(t,n,r,e,o){return"string"!=typeof r?t.apply(this,o):(r.split(/\s+/).forEach((function(t){ot.indexOf(t)>=0&&(n(t,e),r=r.replace(t,""))})),""===r.trim()?this:t.apply(this,o))}var wt={};function gt(t){return Promise.resolve().then((function(){var n=wt[N(t)];if(!n)return t;if(t.status===p)return Et(t,n),t;if(t.status===O)return n.promise.then((function(){return t}));if(t.status!==d&&t.status!==T)return t;var r=t.status===T?Promise.resolve():Y(t,"unload");return t.status=O,r.then((function(){return Et(t,n),t})).catch((function(r){return function(t,n,r){delete wt[N(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,a(r,t,P),n.reject(r)}(t,n,r),t}))}))}function Et(t,n){delete wt[N(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=p,n.resolve()}function yt(t,n,r,e){wt[N(t)]={app:t,resolve:r,reject:e},Object.defineProperty(wt[N(t)],"promise",{get:n})}function Ot(t){return wt[t]}var Tt=[];function Pt(){var t=[],n=[],r=[],e=[],o=(new Date).getTime();return Tt.forEach((function(i){var u=i.status!==P&&A(i);switch(i.status){case T:u&&o-i.loadErrorTime>=200&&r.push(i);break;case p:case h:u&&r.push(i);break;case m:case d:!u&&Ot(N(i))?t.push(i):u&&e.push(i);break;case g:u||n.push(i)}})),{appsToUnload:t,appsToUnmount:n,appsToLoad:r,appsToMount:e}}function bt(){return Tt.filter(b).map(N)}function At(){return Tt.map(N)}function Nt(t){var n=D(Tt,(function(n){return N(n)===t}));return n?n.status:null}var St=!1;function _t(t,n,e,o){var i=function(t,n,e,o){var i,u={name:null,loadApp:null,activeWhen:null,customProps:null};return"object"===r(t)?(function(t){if(Array.isArray(t)||null===t)throw Error(f(39,!1));var n=["name","app","activeWhen","customProps"],e=Object.keys(t).reduce((function(t,r){return n.indexOf(r)>=0?t:t.concat(r)}),[]);if(0!==e.length)throw Error(f(38,!1,n.join(", "),e.join(", ")));if("string"!=typeof t.name||0===t.name.length)throw Error(f(20,!1));if("object"!==r(t.app)&&"function"!=typeof t.app)throw Error(f(20,!1));var o=function(t){return"string"==typeof t||"function"==typeof t};if(!(o(t.activeWhen)||Array.isArray(t.activeWhen)&&t.activeWhen.every(o)))throw Error(f(24,!1));if(!jt(t.customProps))throw Error(f(22,!1))}(t),u.name=t.name,u.loadApp=t.app,u.activeWhen=t.activeWhen,u.customProps=t.customProps):(function(t,n,r,e){if("string"!=typeof t||0===t.length)throw Error(f(20,!1));if(!n)throw Error(f(23,!1));if("function"!=typeof r)throw Error(f(24,!1));if(!jt(e))throw Error(f(22,!1))}(t,n,e,o),u.name=t,u.loadApp=n,u.activeWhen=e,u.customProps=o),u.loadApp="function"!=typeof(i=u.loadApp)?function(){return Promise.resolve(i)}:i,u.customProps=function(t){return t||{}}(u.customProps),u.activeWhen=function(t){var n=Array.isArray(t)?t:[t];return n=n.map((function(t){return"function"==typeof t?t:Rt(t)})),function(t){return n.some((function(n){return n(t)}))}}(u.activeWhen),u}(t,n,e,o);if(Ht()||St||(St=!0,setTimeout((function(){Ht()||console.warn(f(1,!1))}),5e3)),-1!==At().indexOf(i.name))throw Error(f(21,!1,i.name));Tt.push(U({loadErrorTime:null,status:p,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},i)),rt&&(vt(),Ct())}function Ut(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location;return Tt.filter((function(n){return n.activeWhen(t)})).map(N)}function Dt(t){if(0===Tt.filter((function(n){return N(n)===t})).length)throw Error(f(25,!1,t));return(rt?Mt(t,{waitForUnmount:!1}):Promise.resolve()).then((function(){var n=Tt.map(N).indexOf(t);Tt.splice(n,1)}))}function Mt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw Error(f(26,!1));var r=D(Tt,(function(n){return N(n)===t}));if(!r)throw Error(f(27,!1,t));var e,o=Ot(N(r));if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise((function(t,n){yt(r,(function(){return i}),t,n)}));return i}return o?(e=o.promise,Lt(r,o.resolve,o.reject)):e=new Promise((function(t,n){yt(r,(function(){return e}),t,n),Lt(r,t,n)})),e}function Lt(t,n,r){Promise.resolve().then((function(){if(D(Ut(),(function(n){return n===N(t)})))return Bt()})).then((function(){return x(t).then(gt).then((function(){n(),setTimeout((function(){Ct()}))}))})).catch(r)}function jt(t){return!t||"function"==typeof t||"object"===r(t)&&null!==t&&!Array.isArray(t)}function Rt(t,n){var r=function(t,n){var r=0,e=!1,o="^";"/"!==t[0]&&(t="/"+t);for(var i=0;i<t.length;i++){var u=t[i];(!e&&":"===u||e&&"/"===u)&&a(i)}return a(t.length),new RegExp(o,"i");function a(i){var u=t.slice(r,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=e?"[^/]+/?":u,i===t.length)if(e)n&&(o+="$");else{var a=n?"":".*";o="/"===o.charAt(o.length-1)?"".concat(o).concat(a,"$"):"".concat(o,"(/").concat(a,")?(#.*)?$")}e=!e,r=i}}(t,n);return function(t){var n=t.origin;n||(n="".concat(t.protocol,"//").concat(t.host));var e=t.href.replace(n,"").replace(t.search,"").split("?")[0];return r.test(e)}}var It=!1,xt=[],Gt=rt&&window.location.href;function Bt(){return Ct()}function Ct(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(It)return new Promise((function(t,r){xt.push({resolve:t,reject:r,eventArguments:n})}));var o,u=Pt(),a=u.appsToUnload,c=u.appsToUnmount,s=u.appsToLoad,l=u.appsToMount,h=[],m=Gt,v=Gt=window.location.href;return Ht()?(It=!0,o=a.concat(s,c,l),y()):(o=s,E());function w(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n="function"==typeof(null==t?void 0:t.then)?t:Promise.resolve(t);h.push(n.catch((function(t){return console.warn(Error(f(42,!1))),console.warn(t),!1})))}function E(){return Promise.resolve().then((function(){var t=s.map(tt);return Promise.all(t).then(T).then((function(){return[]})).catch((function(t){throw T(),t})).finally((function(){}))}))}function y(){return Promise.resolve().then((function(){return A(0===o.length?"before-no-app-change":"before-app-change",b(!0)),A("before-routing-event",b(!0,{cancelNavigation:w})),Promise.all(h).then((function(r){if(r.some((function(t){return t})))return ft.call(window.history,history.state,"",m.substring(location.origin.length)),Gt=location.href,It=!1,Ct(t,n,!0);var e=a.map(gt),o=c.map(x).map((function(t){return t.then(gt)})).concat(e),i=Promise.all(o);i.then((function(){A("before-mount-routing-event",b(!0))}),(function(t){throw t}));var u=s.map((function(t){return tt(t).then((function(t){return Wt(t,i)}))})),f=l.filter((function(t){return s.indexOf(t)<0})).map((function(t){return Wt(t,i)}));return i.catch((function(t){throw T(),t})).then((function(){return T(),Promise.all(u.concat(f)).catch((function(n){throw t.forEach((function(t){return t.reject(n)})),n})).then(O).then((function(){}),(function(t){throw t}))}))}))}))}function O(){var n=bt();t.forEach((function(t){return t.resolve(n)}));try{A(0===o.length?"no-app-change":"app-change",b()),A("routing-event",b())}catch(t){setTimeout((function(){throw t}))}if(It=!1,xt.length>0){var r=xt;xt=[],Ct(r)}return n}function T(){r||(t.forEach((function(t){ut(t.eventArguments)})),ut(n))}function b(){var t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1?arguments[1]:void 0,u={},f=(e(t={},g,[]),e(t,d,[]),e(t,p,[]),e(t,P,[]),t);r?(s.concat(l).forEach((function(t,n){w(t,g)})),a.forEach((function(t){w(t,p)})),c.forEach((function(t){w(t,d)}))):o.forEach((function(t){w(t)}));var h={detail:{newAppStatuses:u,appsByNewStatus:f,totalAppChanges:o.length,originalEvent:null==n?void 0:n[0],oldUrl:m,newUrl:v}};return i&&U(h.detail,i),h;function w(t,n){var r=N(t);n=n||Nt(r),u[r]=n,(f[n]=f[n]||[]).push(r)}}function A(t,n){r||window.dispatchEvent(new i("single-spa:".concat(t),n))}}function Wt(t,n){return A(t)?I(t).then((function(t){return n.then((function(){return A(t)?C(t):t}))})):n.then((function(){return t}))}var $t=!1;function kt(t){$t=!0,rt&&(pt(t),Ct())}function Ht(){return $t}var Kt={getRawAppData:function(){return[].concat(Tt)},reroute:Ct,NOT_LOADED:p,toLoadPromise:tt,toBootstrapPromise:I,unregisterApplication:Dt,getProfilerData:function(){return R}};rt&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Kt)}}}));
//# sourceMappingURL=single-spa.min.js.map