UNPKG

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