single-spa
Advanced tools
Comparing version 4.3.1 to 4.3.2
@@ -1,2 +0,2 @@ | ||
var t=Object.freeze({get start(){return Dt},get ensureJQuerySupport(){return ft},get setBootstrapMaxTime(){return D},get setMountMaxTime(){return U},get setUnmountMaxTime(){return C},get setUnloadMaxTime(){return L},get registerApplication(){return Et},get getMountedApps(){return wt},get getAppStatus(){return yt},get unloadApplication(){return At},get checkActivityFunctions(){return Pt},get getAppNames(){return gt},get declareChildApplication(){return bt},get unloadChildApplication(){return Tt},get navigateToUrl(){return nt},get triggerAppChange(){return xt},get addErrorHandler(){return c},get removeErrorHandler(){return s},get mountRootParcel(){return Q},get NOT_LOADED(){return l},get LOADING_SOURCE_CODE(){return p},get NOT_BOOTSTRAPPED(){return m},get BOOTSTRAPPING(){return d},get NOT_MOUNTED(){return h},get MOUNTING(){return v},get UPDATING(){return g},get MOUNTED(){return w},get UNMOUNTING(){return y},get SKIP_BECAUSE_BROKEN(){return E}}),n=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent;var e=function(){try{var t=new n("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?n:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e};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 o(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function i(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.forEach(function(n){o(t,n,e[n])})}return t}var a=[];function u(t,n){var e=f(t,n);a.length?a.forEach(function(t){return t(e)}):setTimeout(function(){throw e})}function c(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");a.push(t)}function s(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");var n=!1;return a=a.filter(function(e){var r=e===t;return n=n||r,!r}),n}function f(t,n){var e,r=n.unmountThisParcel?"Parcel":"Application",o="".concat(r," '").concat(n.name,"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message}catch(t){}e=t}else{console.warn("While ".concat(n.status,", '").concat(n.name,"' rejected its lifecycle function promise with a non-Error. This will cause stack traces to not be accurate."));try{e=new Error(o+JSON.stringify(t))}catch(n){e=t}}return e.appName=n.name,e.name=n.name,e}var l="NOT_LOADED",p="LOADING_SOURCE_CODE",m="NOT_BOOTSTRAPPED",d="BOOTSTRAPPING",h="NOT_MOUNTED",v="MOUNTING",w="MOUNTED",g="UPDATING",y="UNMOUNTING",b="UNLOADING",E="SKIP_BECAUSE_BROKEN";function P(t){return t.status===w}function O(t){return!P(t)}function T(t){return t.status!==l&&t.status!==p}function A(t){return!T(t)}function N(t){try{return t.activeWhen(window.location)}catch(n){u(n,t),t.status=E}}function S(t){try{return!t.activeWhen(window.location)}catch(n){u(n,t),t.status=E}}function j(t){return t!==E&&(!t||t.status!==E)}function x(t){return t.name}var _={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}};function D(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("bootstrap max time must be a positive integer number of milliseconds");_.bootstrap={millis:t,dieOnTimeout:n}}function U(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("mount max time must be a positive integer number of milliseconds");_.mount={millis:t,dieOnTimeout:n}}function C(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unmount max time must be a positive integer number of milliseconds");_.unmount={millis:t,dieOnTimeout:n}}function L(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unload max time must be a positive integer number of milliseconds");_.unload={millis:t,dieOnTimeout:n}}function I(t,n,e){var r=1e3;return new Promise(function(o,i){var a=!1,u=!1;function c(t){if(!a)if(!0===t)u=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!u){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r<e.millis&&setTimeout(function(){return c(o+1)},r)}}t.then(function(t){a=!0,o(t)}).catch(function(t){a=!0,i(t)}),setTimeout(function(){return c(1)},r),setTimeout(function(){return c(!0)},e.millis)})}function M(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i({},_,t)}function B(t,n){for(var e=0;e<t.length;e++)if(n(t[e]))return t[e];return null}function G(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!B(n,function(t){return"function"!=typeof t})));var n}function R(t,n){return 0===(t=Array.isArray(t)?t:[t]).length&&(t=[function(){return Promise.resolve()}]),function(e){return new Promise(function(r,o){!function i(a){var u=t[a](e);k(u)?u.then(function(){a===t.length-1?r():i(a+1)}).catch(o):o("".concat(n," at index ").concat(a," did not return a promise"))}(0)})}}function k(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}function q(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==m?t:(t.status=d,I(t.bootstrap(X(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=h,t}).catch(function(e){if(t.status=E,n)throw f(e,t);return u(e,t),t}))})}function W(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){if(t.status!==w)return t;t.status=y;var e=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(e).then(r,function(e){return r().then(function(){var r=new Error(e.message);if(n){var o=f(r,t);throw t.status=E,o}u(r,t),t.status=E})}).then(function(){return t});function r(){return I(t.unmount(X(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=h}).catch(function(e){if(n){var r=f(e,t);throw t.status=E,r}u(e,t),t.status=E})}})}var F=!1,K=!1;function $(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==h?t:(F||(window.dispatchEvent(new e("single-spa:before-first-mount")),F=!0),I(t.mount(X(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=w,K||(window.dispatchEvent(new e("single-spa:first-mount")),K=!0),t}).catch(function(e){return t.status=w,W(t).then(r,r);function r(){if(n){var r=f(e,t);throw t.status=E,r}return u(e,t),t.status=E,t}}))})}var H=0,J={parcels:{}};function Q(){return V.apply(J,arguments)}function V(t,n){var e=this;if(!t||"object"!==r(t)&&"function"!=typeof t)throw new Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw new Error("Parcel name must be a string, if provided");if("object"!==r(n))throw new Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw new Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var o,i=H++,a="function"==typeof t,u=a?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:a?p:m,customProps:n,parentName:e.name,unmountThisParcel:function(){if(c.status!==w)throw new Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return W(c,!0).then(function(t){return c.parentName&&delete e.parcels[c.id],t}).then(function(t){return l(t),t}).catch(function(t){throw c.status=E,d(t),t})}};e.parcels[i]=c;var s=u();if(!s||"function"!=typeof s.then)throw new Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var l,d,v=(s=s.then(function(t){if(!t)throw new Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!G(t.bootstrap))throw new Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!G(t.mount))throw new Error("Parcel ".concat(n," must have a valid mount function"));if(!G(t.unmount))throw new Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!G(t.update))throw new Error("Parcel ".concat(n," provided an invalid update function"));var e=R(t.bootstrap),r=R(t.mount),a=R(t.unmount);c.status=m,c.name=n,c.bootstrap=e,c.mount=r,c.unmount=a,c.timeouts=M(t.timeouts),t.update&&(c.update=R(t.update),o.update=function(t){return c.customProps=t,z(function(t){return Promise.resolve().then(function(){if(t.status!==w)throw new Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=g,I(t.update(X(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=w,t}).catch(function(n){var e=f(n,t);throw t.status=E,e})})}(c))})})).then(function(){return q(c,!0)}),y=v.then(function(){return $(c,!0)}),b=new Promise(function(t,n){l=t,d=n});return o={mount:function(){return z(Promise.resolve().then(function(){if(c.status!==h)throw new Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return e.parcels[i]=c,$(c)}))},unmount:function(){return z(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:z(s),bootstrapPromise:z(v),mountPromise:z(y),unmountPromise:z(b)}}function z(t){return t.then(function(){return null})}function X(n){var e=i({},n.customProps,{name:n.name,mountParcel:V.bind(n),singleSpa:t});return n.unmountThisParcel&&(e.unmountSelf=n.unmountThisParcel),e}function Y(t){return Promise.resolve().then(function(){return t.status!==l?t:(t.status=p,Promise.resolve().then(function(){var e=t.loadImpl(X(t));if(!k(e))throw new Error("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return e.then(function(e){var o;return"object"!==r(n=e)&&(o="does not export anything"),G(n.bootstrap)||(o="does not export a bootstrap function or array of functions"),G(n.mount)||(o="does not export a mount function or array of functions"),G(n.unmount)||(o="does not export an unmount function or array of functions"),o?(u(o,t),t.status=E,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=i({},t.devtools.overlays,n.devtools.overlays)),t.status=m,t.bootstrap=R(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=R(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=R(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=R(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=M(n.timeouts),t)})}).catch(function(n){return u(n,t),t.status=E,t}));var n})}var Z={hashchange:[],popstate:[]},tt=["hashchange","popstate"];function nt(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 new Error("singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag");n=t.currentTarget.href,t.preventDefault()}var r=ct(window.location.href),o=ct(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else!function(t,n){return n===t||n==="/"+t}(o.path,r.path)?window.history.pushState(null,null,n):window.location.hash="#"+o.anchor}function et(t){var n=this;if(t){var e=t[0].type;tt.indexOf(e)>=0&&Z[e].forEach(function(e){e.apply(n,t)})}}function rt(){xt([],arguments)}window.addEventListener("hashchange",rt),window.addEventListener("popstate",rt);var ot=window.addEventListener,it=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&tt.indexOf(t)>=0)||B(Z[t],function(t){return t===n}))return ot.apply(this,arguments);Z[t].push(n)},window.removeEventListener=function(t,n){if(!("function"==typeof n&&tt.indexOf(t)>=0))return it.apply(this,arguments);Z[t]=Z[t].filter(function(t){return t!==n})};var at=window.history.pushState;window.history.pushState=function(t){var n=at.apply(this,arguments);return rt(new PopStateEvent("popstate",{state:t})),n};var ut=window.history.replaceState;function ct(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}window.history.replaceState=function(t){var n=ut.apply(this,arguments);return rt(new PopStateEvent("popstate",{state:t})),n},window.singleSpaNavigate=nt;var st=!1;function ft(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!st){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return lt.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return lt.call(this,e,window.removeEventListener,t,n,arguments)},st=!0}}function lt(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){tt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}var pt={};function mt(t){return Promise.resolve().then(function(){var n=pt[t.name];return n?t.status===l?(dt(t,n),t):t.status===b?n.promise.then(function(){return t}):t.status!==h?t:(t.status=b,I(t.unload(X(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return dt(t,n),t}).catch(function(e){return function(t,n,e){delete pt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,u(e,t),t.status=E,n.reject(e)}(t,n,e),t})):t})}function dt(t,n){delete pt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=l,n.resolve()}function ht(t,n,e,r){pt[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(pt[t.name],"promise",{get:n})}var vt=[];function wt(){return vt.filter(P).map(x)}function gt(){return vt.map(x)}function yt(t){var n=B(vt,function(n){return n.name===t});return n?n.status:null}function bt(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),Et(t,n,e)}function Et(t,n,e){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw new Error("The first argument must be a non-empty string 'appName'");if(-1!==gt().indexOf(t))throw new Error("There is already an app declared with name ".concat(t));if("object"!==r(i)||Array.isArray(i))throw new Error("customProps must be an object");if(!n)throw new Error("The application or loading function is required");if(o="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof e)throw new Error("The activeWhen argument must be a function");vt.push({name:t,loadImpl:o,activeWhen:e,status:l,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),ft(),xt()}function Pt(t){for(var n=[],e=0;e<vt.length;e++)vt[e].activeWhen(t)&&n.push(vt[e].name);return n}function Ot(){return vt.filter(j).filter(A).filter(N)}function Tt(t,n){return console.warn('unloadChildApplication is deprecated and will be removed in the next major version, use "unloadApplication" instead'),At(t,n)}function At(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw new Error("unloadApplication requires a string 'appName'");var e=B(vt,function(n){return n.name===t});if(!e)throw new Error("Could not unload application '".concat(t,"' because no such application has been declared"));var r,o=function(t){return pt[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){ht(e,function(){return i},t,n)});return i}return o?(r=o.promise,Nt(e,o.resolve,o.reject)):r=new Promise(function(t,n){ht(e,function(){return r},t,n),Nt(e,t,n)}),r}function Nt(t,n,e){W(t).then(mt).then(function(){n(),setTimeout(function(){xt()})}).catch(e)}var St=!1,jt=[];function xt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;if(St)return new Promise(function(t,e){jt.push({resolve:t,reject:e,eventArguments:n})});St=!0;var r=!0;return _t?Promise.resolve().then(function(){window.dispatchEvent(new e("single-spa:before-routing-event",a()));var n=Object.keys(pt).map(function(t){return pt[t].app}).filter(O).map(mt),u=vt.filter(j).filter(P).filter(S).map(W).map(function(t){return t.then(mt)}),c=u.concat(n);c.length>0&&(r=!1);var s=Promise.all(c),f=Ot(),l=f.map(function(t){return Y(t).then(q).then(function(t){return s.then(function(){return $(t)})})});l.length>0&&(r=!1);var p=vt.filter(j).filter(O).filter(T).filter(N).filter(function(t){return f.indexOf(t)<0}).map(function(t){return q(t).then(function(){return s}).then(function(){return $(t)})});return p.length>0&&(r=!1),s.catch(function(t){throw i(),t}).then(function(){return i(),Promise.all(l.concat(p)).catch(function(n){throw t.forEach(function(t){return t.reject(n)}),n}).then(function(){return o(!1)})})}):Promise.resolve().then(function(){var t=Ot().map(Y);return t.length>0&&(r=!1),Promise.all(t).then(o).catch(function(t){throw i(),t})});function o(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=wt();n&&i(),t.forEach(function(t){return t.resolve(o)});try{var u=r?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new e(u,a())),window.dispatchEvent(new e("single-spa:routing-event",a()))}catch(t){setTimeout(function(){throw t})}if(St=!1,jt.length>0){var c=jt;jt=[],xt(c)}return o}function i(){t.forEach(function(t){et(t.eventArguments)}),et(n)}function a(){var t={detail:{}};return n&&n[0]&&(t.detail.originalEvent=n[0]),t}}var _t=!1;function Dt(){_t=!0,xt()}setTimeout(function(){_t||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var Ut={getRawAppData:function(){return[].concat(vt)},reroute:xt,NOT_LOADED:l,toLoadPromise:Y,toBootstrapPromise:q};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Ut);export{d as BOOTSTRAPPING,p as LOADING_SOURCE_CODE,w as MOUNTED,v as MOUNTING,m as NOT_BOOTSTRAPPED,l as NOT_LOADED,h as NOT_MOUNTED,E as SKIP_BECAUSE_BROKEN,y as UNMOUNTING,g as UPDATING,c as addErrorHandler,Pt as checkActivityFunctions,bt as declareChildApplication,ft as ensureJQuerySupport,gt as getAppNames,yt as getAppStatus,wt as getMountedApps,Q as mountRootParcel,nt as navigateToUrl,Et as registerApplication,s as removeErrorHandler,D as setBootstrapMaxTime,U as setMountMaxTime,L as setUnloadMaxTime,C as setUnmountMaxTime,Dt as start,xt as triggerAppChange,At as unloadApplication,Tt as unloadChildApplication}; | ||
var t=Object.freeze({get start(){return Ut},get ensureJQuerySupport(){return lt},get setBootstrapMaxTime(){return D},get setMountMaxTime(){return U},get setUnmountMaxTime(){return C},get setUnloadMaxTime(){return L},get registerApplication(){return Pt},get getMountedApps(){return gt},get getAppStatus(){return bt},get unloadApplication(){return Nt},get checkActivityFunctions(){return Ot},get getAppNames(){return yt},get declareChildApplication(){return Et},get unloadChildApplication(){return At},get navigateToUrl(){return nt},get triggerAppChange(){return _t},get addErrorHandler(){return c},get removeErrorHandler(){return s},get mountRootParcel(){return Q},get NOT_LOADED(){return l},get LOADING_SOURCE_CODE(){return p},get NOT_BOOTSTRAPPED(){return m},get BOOTSTRAPPING(){return d},get NOT_MOUNTED(){return h},get MOUNTING(){return v},get UPDATING(){return g},get MOUNTED(){return w},get UNMOUNTING(){return y},get SKIP_BECAUSE_BROKEN(){return E}}),n=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent;var e=function(){try{var t=new n("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?n:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e};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 o(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function i(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.forEach(function(n){o(t,n,e[n])})}return t}var a=[];function u(t,n){var e=f(t,n);a.length?a.forEach(function(t){return t(e)}):setTimeout(function(){throw e})}function c(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");a.push(t)}function s(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");var n=!1;return a=a.filter(function(e){var r=e===t;return n=n||r,!r}),n}function f(t,n){var e,r=n.unmountThisParcel?"Parcel":"Application",o="".concat(r," '").concat(n.name,"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message}catch(t){}e=t}else{console.warn("While ".concat(n.status,", '").concat(n.name,"' rejected its lifecycle function promise with a non-Error. This will cause stack traces to not be accurate."));try{e=new Error(o+JSON.stringify(t))}catch(n){e=t}}return e.appName=n.name,e.name=n.name,e}var l="NOT_LOADED",p="LOADING_SOURCE_CODE",m="NOT_BOOTSTRAPPED",d="BOOTSTRAPPING",h="NOT_MOUNTED",v="MOUNTING",w="MOUNTED",g="UPDATING",y="UNMOUNTING",b="UNLOADING",E="SKIP_BECAUSE_BROKEN";function P(t){return t.status===w}function O(t){return!P(t)}function T(t){return t.status!==l&&t.status!==p}function A(t){return!T(t)}function N(t){try{return t.activeWhen(window.location)}catch(n){u(n,t),t.status=E}}function S(t){try{return!t.activeWhen(window.location)}catch(n){u(n,t),t.status=E}}function j(t){return t!==E&&(!t||t.status!==E)}function x(t){return t.name}var _={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}};function D(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("bootstrap max time must be a positive integer number of milliseconds");_.bootstrap={millis:t,dieOnTimeout:n}}function U(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("mount max time must be a positive integer number of milliseconds");_.mount={millis:t,dieOnTimeout:n}}function C(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unmount max time must be a positive integer number of milliseconds");_.unmount={millis:t,dieOnTimeout:n}}function L(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unload max time must be a positive integer number of milliseconds");_.unload={millis:t,dieOnTimeout:n}}function I(t,n,e){var r=1e3;return new Promise(function(o,i){var a=!1,u=!1;function c(t){if(!a)if(!0===t)u=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!u){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r<e.millis&&setTimeout(function(){return c(o+1)},r)}}t.then(function(t){a=!0,o(t)}).catch(function(t){a=!0,i(t)}),setTimeout(function(){return c(1)},r),setTimeout(function(){return c(!0)},e.millis)})}function M(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i({},_,t)}function B(t,n){for(var e=0;e<t.length;e++)if(n(t[e]))return t[e];return null}function G(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!B(n,function(t){return"function"!=typeof t})));var n}function R(t,n){return 0===(t=Array.isArray(t)?t:[t]).length&&(t=[function(){return Promise.resolve()}]),function(e){return new Promise(function(r,o){!function i(a){var u=t[a](e);k(u)?u.then(function(){a===t.length-1?r():i(a+1)}).catch(o):o("".concat(n," at index ").concat(a," did not return a promise"))}(0)})}}function k(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}function q(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==m?t:(t.status=d,I(t.bootstrap(X(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=h,t}).catch(function(e){if(t.status=E,n)throw f(e,t);return u(e,t),t}))})}function W(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){if(t.status!==w)return t;t.status=y;var e=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(e).then(r,function(e){return r().then(function(){var r=new Error(e.message);if(n){var o=f(r,t);throw t.status=E,o}u(r,t),t.status=E})}).then(function(){return t});function r(){return I(t.unmount(X(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=h}).catch(function(e){if(n){var r=f(e,t);throw t.status=E,r}u(e,t),t.status=E})}})}var F=!1,K=!1;function $(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==h?t:(F||(window.dispatchEvent(new e("single-spa:before-first-mount")),F=!0),I(t.mount(X(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=w,K||(window.dispatchEvent(new e("single-spa:first-mount")),K=!0),t}).catch(function(e){return t.status=w,W(t).then(r,r);function r(){if(n){var r=f(e,t);throw t.status=E,r}return u(e,t),t.status=E,t}}))})}var H=0,J={parcels:{}};function Q(){return V.apply(J,arguments)}function V(t,n){var e=this;if(!t||"object"!==r(t)&&"function"!=typeof t)throw new Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw new Error("Parcel name must be a string, if provided");if("object"!==r(n))throw new Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw new Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var o,i=H++,a="function"==typeof t,u=a?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:a?p:m,customProps:n,parentName:e.name,unmountThisParcel:function(){if(c.status!==w)throw new Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return W(c,!0).then(function(t){return c.parentName&&delete e.parcels[c.id],t}).then(function(t){return l(t),t}).catch(function(t){throw c.status=E,d(t),t})}};e.parcels[i]=c;var s=u();if(!s||"function"!=typeof s.then)throw new Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var l,d,v=(s=s.then(function(t){if(!t)throw new Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!G(t.bootstrap))throw new Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!G(t.mount))throw new Error("Parcel ".concat(n," must have a valid mount function"));if(!G(t.unmount))throw new Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!G(t.update))throw new Error("Parcel ".concat(n," provided an invalid update function"));var e=R(t.bootstrap),r=R(t.mount),a=R(t.unmount);c.status=m,c.name=n,c.bootstrap=e,c.mount=r,c.unmount=a,c.timeouts=M(t.timeouts),t.update&&(c.update=R(t.update),o.update=function(t){return c.customProps=t,z(function(t){return Promise.resolve().then(function(){if(t.status!==w)throw new Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=g,I(t.update(X(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=w,t}).catch(function(n){var e=f(n,t);throw t.status=E,e})})}(c))})})).then(function(){return q(c,!0)}),y=v.then(function(){return $(c,!0)}),b=new Promise(function(t,n){l=t,d=n});return o={mount:function(){return z(Promise.resolve().then(function(){if(c.status!==h)throw new Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return e.parcels[i]=c,$(c)}))},unmount:function(){return z(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:z(s),bootstrapPromise:z(v),mountPromise:z(y),unmountPromise:z(b)}}function z(t){return t.then(function(){return null})}function X(n){var e=i({},n.customProps,{name:n.name,mountParcel:V.bind(n),singleSpa:t});return n.unmountThisParcel&&(e.unmountSelf=n.unmountThisParcel),e}function Y(t){return Promise.resolve().then(function(){return t.status!==l?t:(t.status=p,Promise.resolve().then(function(){var e=t.loadImpl(X(t));if(!k(e))throw new Error("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return e.then(function(e){var o;return"object"!==r(n=e)&&(o="does not export anything"),G(n.bootstrap)||(o="does not export a bootstrap function or array of functions"),G(n.mount)||(o="does not export a mount function or array of functions"),G(n.unmount)||(o="does not export an unmount function or array of functions"),o?(u(o,t),t.status=E,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=i({},t.devtools.overlays,n.devtools.overlays)),t.status=m,t.bootstrap=R(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=R(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=R(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=R(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=M(n.timeouts),t)})}).catch(function(n){return u(n,t),t.status=E,t}));var n})}var Z={hashchange:[],popstate:[]},tt=["hashchange","popstate"];function nt(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 new Error("singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag");n=t.currentTarget.href,t.preventDefault()}var r=st(window.location.href),o=st(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else!function(t,n){return n===t||n==="/"+t}(o.path,r.path)?window.history.pushState(null,null,n):window.location.hash="#"+o.anchor}function et(t){var n=this;if(t){var e=t[0].type;tt.indexOf(e)>=0&&Z[e].forEach(function(e){e.apply(n,t)})}}function rt(){_t([],arguments)}window.addEventListener("hashchange",rt),window.addEventListener("popstate",rt);var ot=window.addEventListener,it=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&tt.indexOf(t)>=0)||B(Z[t],function(t){return t===n}))return ot.apply(this,arguments);Z[t].push(n)},window.removeEventListener=function(t,n){if(!("function"==typeof n&&tt.indexOf(t)>=0))return it.apply(this,arguments);Z[t]=Z[t].filter(function(t){return t!==n})};var at=window.history.pushState;window.history.pushState=function(t){var n=at.apply(this,arguments);return rt(ct(t)),n};var ut=window.history.replaceState;function ct(t){try{return new PopStateEvent("popstate",{state:t})}catch(e){var n=document.createEvent("PopStateEvent");return n.initPopStateEvent("popstate",!1,!1,t),n}}function st(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}window.history.replaceState=function(t){var n=ut.apply(this,arguments);return rt(ct(t)),n},window.singleSpaNavigate=nt;var ft=!1;function lt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!ft){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return pt.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return pt.call(this,e,window.removeEventListener,t,n,arguments)},ft=!0}}function pt(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){tt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}var mt={};function dt(t){return Promise.resolve().then(function(){var n=mt[t.name];return n?t.status===l?(ht(t,n),t):t.status===b?n.promise.then(function(){return t}):t.status!==h?t:(t.status=b,I(t.unload(X(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return ht(t,n),t}).catch(function(e){return function(t,n,e){delete mt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,u(e,t),t.status=E,n.reject(e)}(t,n,e),t})):t})}function ht(t,n){delete mt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=l,n.resolve()}function vt(t,n,e,r){mt[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(mt[t.name],"promise",{get:n})}var wt=[];function gt(){return wt.filter(P).map(x)}function yt(){return wt.map(x)}function bt(t){var n=B(wt,function(n){return n.name===t});return n?n.status:null}function Et(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),Pt(t,n,e)}function Pt(t,n,e){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw new Error("The first argument must be a non-empty string 'appName'");if(-1!==yt().indexOf(t))throw new Error("There is already an app declared with name ".concat(t));if("object"!==r(i)||Array.isArray(i))throw new Error("customProps must be an object");if(!n)throw new Error("The application or loading function is required");if(o="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof e)throw new Error("The activeWhen argument must be a function");wt.push({name:t,loadImpl:o,activeWhen:e,status:l,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),lt(),_t()}function Ot(t){for(var n=[],e=0;e<wt.length;e++)wt[e].activeWhen(t)&&n.push(wt[e].name);return n}function Tt(){return wt.filter(j).filter(A).filter(N)}function At(t,n){return console.warn('unloadChildApplication is deprecated and will be removed in the next major version, use "unloadApplication" instead'),Nt(t,n)}function Nt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw new Error("unloadApplication requires a string 'appName'");var e=B(wt,function(n){return n.name===t});if(!e)throw new Error("Could not unload application '".concat(t,"' because no such application has been declared"));var r,o=function(t){return mt[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){vt(e,function(){return i},t,n)});return i}return o?(r=o.promise,St(e,o.resolve,o.reject)):r=new Promise(function(t,n){vt(e,function(){return r},t,n),St(e,t,n)}),r}function St(t,n,e){W(t).then(dt).then(function(){n(),setTimeout(function(){_t()})}).catch(e)}var jt=!1,xt=[];function _t(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;if(jt)return new Promise(function(t,e){xt.push({resolve:t,reject:e,eventArguments:n})});jt=!0;var r=!0;return Dt?Promise.resolve().then(function(){window.dispatchEvent(new e("single-spa:before-routing-event",a()));var n=Object.keys(mt).map(function(t){return mt[t].app}).filter(O).map(dt),u=wt.filter(j).filter(P).filter(S).map(W).map(function(t){return t.then(dt)}),c=u.concat(n);c.length>0&&(r=!1);var s=Promise.all(c),f=Tt(),l=f.map(function(t){return Y(t).then(q).then(function(t){return s.then(function(){return $(t)})})});l.length>0&&(r=!1);var p=wt.filter(j).filter(O).filter(T).filter(N).filter(function(t){return f.indexOf(t)<0}).map(function(t){return q(t).then(function(){return s}).then(function(){return $(t)})});return p.length>0&&(r=!1),s.catch(function(t){throw i(),t}).then(function(){return i(),Promise.all(l.concat(p)).catch(function(n){throw t.forEach(function(t){return t.reject(n)}),n}).then(function(){return o(!1)})})}):Promise.resolve().then(function(){var t=Tt().map(Y);return t.length>0&&(r=!1),Promise.all(t).then(o).catch(function(t){throw i(),t})});function o(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=gt();n&&i(),t.forEach(function(t){return t.resolve(o)});try{var u=r?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new e(u,a())),window.dispatchEvent(new e("single-spa:routing-event",a()))}catch(t){setTimeout(function(){throw t})}if(jt=!1,xt.length>0){var c=xt;xt=[],_t(c)}return o}function i(){t.forEach(function(t){et(t.eventArguments)}),et(n)}function a(){var t={detail:{}};return n&&n[0]&&(t.detail.originalEvent=n[0]),t}}var Dt=!1;function Ut(){Dt=!0,_t()}setTimeout(function(){Dt||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var Ct={getRawAppData:function(){return[].concat(wt)},reroute:_t,NOT_LOADED:l,toLoadPromise:Y,toBootstrapPromise:q};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Ct);export{d as BOOTSTRAPPING,p as LOADING_SOURCE_CODE,w as MOUNTED,v as MOUNTING,m as NOT_BOOTSTRAPPED,l as NOT_LOADED,h as NOT_MOUNTED,E as SKIP_BECAUSE_BROKEN,y as UNMOUNTING,g as UPDATING,c as addErrorHandler,Ot as checkActivityFunctions,Et as declareChildApplication,lt as ensureJQuerySupport,yt as getAppNames,bt as getAppStatus,gt as getMountedApps,Q as mountRootParcel,nt as navigateToUrl,Pt as registerApplication,s as removeErrorHandler,D as setBootstrapMaxTime,U as setMountMaxTime,L as setUnloadMaxTime,C as setUnmountMaxTime,Ut as start,_t as triggerAppChange,Nt as unloadApplication,At as unloadChildApplication}; | ||
//# sourceMappingURL=single-spa.min.js.map |
@@ -1,2 +0,2 @@ | ||
System.register([],function(t,n){"use strict";return{execute:function(){t({addErrorHandler:s,checkActivityFunctions:Tt,declareChildApplication:Et,ensureJQuerySupport:ft,getAppNames:yt,getAppStatus:bt,getMountedApps:gt,mountRootParcel:V,navigateToUrl:et,registerApplication:Ot,removeErrorHandler:l,setBootstrapMaxTime:j,setMountMaxTime:C,setUnloadMaxTime:I,setUnmountMaxTime:M,start:jt,triggerAppChange:Dt,unloadApplication:Nt,unloadChildApplication:At});var n=Object.freeze({get start(){return jt},get ensureJQuerySupport(){return ft},get setBootstrapMaxTime(){return j},get setMountMaxTime(){return C},get setUnmountMaxTime(){return M},get setUnloadMaxTime(){return I},get registerApplication(){return Ot},get getMountedApps(){return gt},get getAppStatus(){return bt},get unloadApplication(){return Nt},get checkActivityFunctions(){return Tt},get getAppNames(){return yt},get declareChildApplication(){return Et},get unloadChildApplication(){return At},get navigateToUrl(){return et},get triggerAppChange(){return Dt},get addErrorHandler(){return s},get removeErrorHandler(){return l},get mountRootParcel(){return V},get NOT_LOADED(){return p},get LOADING_SOURCE_CODE(){return m},get NOT_BOOTSTRAPPED(){return d},get BOOTSTRAPPING(){return h},get NOT_MOUNTED(){return v},get MOUNTING(){return w},get UPDATING(){return y},get MOUNTED(){return g},get UNMOUNTING(){return b},get SKIP_BECAUSE_BROKEN(){return O}}),e=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent;var r=function(){try{var t=new e("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?e:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e};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)}function i(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function a(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.forEach(function(n){i(t,n,e[n])})}return t}var u=[];function c(t,n){var e=f(t,n);u.length?u.forEach(function(t){return t(e)}):setTimeout(function(){throw e})}function s(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");u.push(t)}function l(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");var n=!1;return u=u.filter(function(e){var r=e===t;return n=n||r,!r}),n}function f(t,n){var e,r=n.unmountThisParcel?"Parcel":"Application",o="".concat(r," '").concat(n.name,"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message}catch(t){}e=t}else{console.warn("While ".concat(n.status,", '").concat(n.name,"' rejected its lifecycle function promise with a non-Error. This will cause stack traces to not be accurate."));try{e=new Error(o+JSON.stringify(t))}catch(n){e=t}}return e.appName=n.name,e.name=n.name,e}var p=t("NOT_LOADED","NOT_LOADED"),m=t("LOADING_SOURCE_CODE","LOADING_SOURCE_CODE"),d=t("NOT_BOOTSTRAPPED","NOT_BOOTSTRAPPED"),h=t("BOOTSTRAPPING","BOOTSTRAPPING"),v=t("NOT_MOUNTED","NOT_MOUNTED"),w=t("MOUNTING","MOUNTING"),g=t("MOUNTED","MOUNTED"),y=t("UPDATING","UPDATING"),b=t("UNMOUNTING","UNMOUNTING"),E="UNLOADING",O=t("SKIP_BECAUSE_BROKEN","SKIP_BECAUSE_BROKEN");function T(t){return t.status===g}function P(t){return!T(t)}function A(t){return t.status!==p&&t.status!==m}function N(t){return!A(t)}function S(t){try{return t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function U(t){try{return!t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function _(t){return t!==O&&(!t||t.status!==O)}function D(t){return t.name}var x={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}};function j(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("bootstrap max time must be a positive integer number of milliseconds");x.bootstrap={millis:t,dieOnTimeout:n}}function C(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("mount max time must be a positive integer number of milliseconds");x.mount={millis:t,dieOnTimeout:n}}function M(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unmount max time must be a positive integer number of milliseconds");x.unmount={millis:t,dieOnTimeout:n}}function I(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unload max time must be a positive integer number of milliseconds");x.unload={millis:t,dieOnTimeout:n}}function L(t,n,e){var r=1e3;return new Promise(function(o,i){var a=!1,u=!1;function c(t){if(!a)if(!0===t)u=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!u){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r<e.millis&&setTimeout(function(){return c(o+1)},r)}}t.then(function(t){a=!0,o(t)}).catch(function(t){a=!0,i(t)}),setTimeout(function(){return c(1)},r),setTimeout(function(){return c(!0)},e.millis)})}function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a({},x,t)}function G(t,n){for(var e=0;e<t.length;e++)if(n(t[e]))return t[e];return null}function R(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!G(n,function(t){return"function"!=typeof t})));var n}function k(t,n){return 0===(t=Array.isArray(t)?t:[t]).length&&(t=[function(){return Promise.resolve()}]),function(e){return new Promise(function(r,o){!function i(a){var u=t[a](e);q(u)?u.then(function(){a===t.length-1?r():i(a+1)}).catch(o):o("".concat(n," at index ").concat(a," did not return a promise"))}(0)})}}function q(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}function W(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==d?t:(t.status=h,L(t.bootstrap(Y(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=v,t}).catch(function(e){if(t.status=O,n)throw f(e,t);return c(e,t),t}))})}function K(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){if(t.status!==g)return t;t.status=b;var e=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(e).then(r,function(e){return r().then(function(){var r=new Error(e.message);if(n){var o=f(r,t);throw t.status=O,o}c(r,t),t.status=O})}).then(function(){return t});function r(){return L(t.unmount(Y(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=v}).catch(function(e){if(n){var r=f(e,t);throw t.status=O,r}c(e,t),t.status=O})}})}var F=!1,H=!1;function $(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==v?t:(F||(window.dispatchEvent(new r("single-spa:before-first-mount")),F=!0),L(t.mount(Y(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,H||(window.dispatchEvent(new r("single-spa:first-mount")),H=!0),t}).catch(function(e){return t.status=g,K(t).then(r,r);function r(){if(n){var r=f(e,t);throw t.status=O,r}return c(e,t),t.status=O,t}}))})}var J=0,Q={parcels:{}};function V(){return z.apply(Q,arguments)}function z(t,n){var e=this;if(!t||"object"!==o(t)&&"function"!=typeof t)throw new Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw new Error("Parcel name must be a string, if provided");if("object"!==o(n))throw new Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw new Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var r,i=J++,a="function"==typeof t,u=a?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:a?m:d,customProps:n,parentName:e.name,unmountThisParcel:function(){if(c.status!==g)throw new Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return K(c,!0).then(function(t){return c.parentName&&delete e.parcels[c.id],t}).then(function(t){return l(t),t}).catch(function(t){throw c.status=O,p(t),t})}};e.parcels[i]=c;var s=u();if(!s||"function"!=typeof s.then)throw new Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var l,p,h=(s=s.then(function(t){if(!t)throw new Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!R(t.bootstrap))throw new Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!R(t.mount))throw new Error("Parcel ".concat(n," must have a valid mount function"));if(!R(t.unmount))throw new Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!R(t.update))throw new Error("Parcel ".concat(n," provided an invalid update function"));var e=k(t.bootstrap),o=k(t.mount),a=k(t.unmount);c.status=d,c.name=n,c.bootstrap=e,c.mount=o,c.unmount=a,c.timeouts=B(t.timeouts),t.update&&(c.update=k(t.update),r.update=function(t){return c.customProps=t,X(function(t){return Promise.resolve().then(function(){if(t.status!==g)throw new Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=y,L(t.update(Y(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,t}).catch(function(n){var e=f(n,t);throw t.status=O,e})})}(c))})})).then(function(){return W(c,!0)}),w=h.then(function(){return $(c,!0)}),b=new Promise(function(t,n){l=t,p=n});return r={mount:function(){return X(Promise.resolve().then(function(){if(c.status!==v)throw new Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return e.parcels[i]=c,$(c)}))},unmount:function(){return X(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:X(s),bootstrapPromise:X(h),mountPromise:X(w),unmountPromise:X(b)}}function X(t){return t.then(function(){return null})}function Y(t){var e=a({},t.customProps,{name:t.name,mountParcel:z.bind(t),singleSpa:n});return t.unmountThisParcel&&(e.unmountSelf=t.unmountThisParcel),e}function Z(t){return Promise.resolve().then(function(){return t.status!==p?t:(t.status=m,Promise.resolve().then(function(){var e=t.loadImpl(Y(t));if(!q(e))throw new Error("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return e.then(function(e){var r;return"object"!==o(n=e)&&(r="does not export anything"),R(n.bootstrap)||(r="does not export a bootstrap function or array of functions"),R(n.mount)||(r="does not export a mount function or array of functions"),R(n.unmount)||(r="does not export an unmount function or array of functions"),r?(c(r,t),t.status=O,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=a({},t.devtools.overlays,n.devtools.overlays)),t.status=d,t.bootstrap=k(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=k(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=k(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=k(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=B(n.timeouts),t)})}).catch(function(n){return c(n,t),t.status=O,t}));var n})}var tt={hashchange:[],popstate:[]},nt=["hashchange","popstate"];function et(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 new Error("singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag");n=t.currentTarget.href,t.preventDefault()}var r=st(window.location.href),o=st(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else!function(t,n){return n===t||n==="/"+t}(o.path,r.path)?window.history.pushState(null,null,n):window.location.hash="#"+o.anchor}function rt(t){var n=this;if(t){var e=t[0].type;nt.indexOf(e)>=0&&tt[e].forEach(function(e){e.apply(n,t)})}}function ot(){Dt([],arguments)}window.addEventListener("hashchange",ot),window.addEventListener("popstate",ot);var it=window.addEventListener,at=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0)||G(tt[t],function(t){return t===n}))return it.apply(this,arguments);tt[t].push(n)},window.removeEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0))return at.apply(this,arguments);tt[t]=tt[t].filter(function(t){return t!==n})};var ut=window.history.pushState;window.history.pushState=function(t){var n=ut.apply(this,arguments);return ot(new PopStateEvent("popstate",{state:t})),n};var ct=window.history.replaceState;function st(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}window.history.replaceState=function(t){var n=ct.apply(this,arguments);return ot(new PopStateEvent("popstate",{state:t})),n},window.singleSpaNavigate=et;var lt=!1;function ft(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!lt){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return pt.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return pt.call(this,e,window.removeEventListener,t,n,arguments)},lt=!0}}function pt(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){nt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}var mt={};function dt(t){return Promise.resolve().then(function(){var n=mt[t.name];return n?t.status===p?(ht(t,n),t):t.status===E?n.promise.then(function(){return t}):t.status!==v?t:(t.status=E,L(t.unload(Y(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return ht(t,n),t}).catch(function(e){return function(t,n,e){delete mt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,c(e,t),t.status=O,n.reject(e)}(t,n,e),t})):t})}function ht(t,n){delete mt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=p,n.resolve()}function vt(t,n,e,r){mt[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(mt[t.name],"promise",{get:n})}var wt=[];function gt(){return wt.filter(T).map(D)}function yt(){return wt.map(D)}function bt(t){var n=G(wt,function(n){return n.name===t});return n?n.status:null}function Et(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),Ot(t,n,e)}function Ot(t,n,e){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw new Error("The first argument must be a non-empty string 'appName'");if(-1!==yt().indexOf(t))throw new Error("There is already an app declared with name ".concat(t));if("object"!==o(i)||Array.isArray(i))throw new Error("customProps must be an object");if(!n)throw new Error("The application or loading function is required");if(r="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof e)throw new Error("The activeWhen argument must be a function");wt.push({name:t,loadImpl:r,activeWhen:e,status:p,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),ft(),Dt()}function Tt(t){for(var n=[],e=0;e<wt.length;e++)wt[e].activeWhen(t)&&n.push(wt[e].name);return n}function Pt(){return wt.filter(_).filter(N).filter(S)}function At(t,n){return console.warn('unloadChildApplication is deprecated and will be removed in the next major version, use "unloadApplication" instead'),Nt(t,n)}function Nt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw new Error("unloadApplication requires a string 'appName'");var e=G(wt,function(n){return n.name===t});if(!e)throw new Error("Could not unload application '".concat(t,"' because no such application has been declared"));var r,o=function(t){return mt[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){vt(e,function(){return i},t,n)});return i}return o?(r=o.promise,St(e,o.resolve,o.reject)):r=new Promise(function(t,n){vt(e,function(){return r},t,n),St(e,t,n)}),r}function St(t,n,e){K(t).then(dt).then(function(){n(),setTimeout(function(){Dt()})}).catch(e)}var Ut=!1,_t=[];function Dt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;if(Ut)return new Promise(function(t,e){_t.push({resolve:t,reject:e,eventArguments:n})});Ut=!0;var e=!0;return xt?Promise.resolve().then(function(){window.dispatchEvent(new r("single-spa:before-routing-event",a()));var n=Object.keys(mt).map(function(t){return mt[t].app}).filter(P).map(dt),u=wt.filter(_).filter(T).filter(U).map(K).map(function(t){return t.then(dt)}),c=u.concat(n);c.length>0&&(e=!1);var s=Promise.all(c),l=Pt(),f=l.map(function(t){return Z(t).then(W).then(function(t){return s.then(function(){return $(t)})})});f.length>0&&(e=!1);var p=wt.filter(_).filter(P).filter(A).filter(S).filter(function(t){return l.indexOf(t)<0}).map(function(t){return W(t).then(function(){return s}).then(function(){return $(t)})});return p.length>0&&(e=!1),s.catch(function(t){throw i(),t}).then(function(){return i(),Promise.all(f.concat(p)).catch(function(n){throw t.forEach(function(t){return t.reject(n)}),n}).then(function(){return o(!1)})})}):Promise.resolve().then(function(){var t=Pt().map(Z);return t.length>0&&(e=!1),Promise.all(t).then(o).catch(function(t){throw i(),t})});function o(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=gt();n&&i(),t.forEach(function(t){return t.resolve(o)});try{var u=e?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new r(u,a())),window.dispatchEvent(new r("single-spa:routing-event",a()))}catch(t){setTimeout(function(){throw t})}if(Ut=!1,_t.length>0){var c=_t;_t=[],Dt(c)}return o}function i(){t.forEach(function(t){rt(t.eventArguments)}),rt(n)}function a(){var t={detail:{}};return n&&n[0]&&(t.detail.originalEvent=n[0]),t}}var xt=!1;function jt(){xt=!0,Dt()}setTimeout(function(){xt||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var Ct={getRawAppData:function(){return[].concat(wt)},reroute:Dt,NOT_LOADED:p,toLoadPromise:Z,toBootstrapPromise:W};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Ct)}}}); | ||
System.register([],function(t,n){"use strict";return{execute:function(){t({addErrorHandler:s,checkActivityFunctions:Pt,declareChildApplication:Ot,ensureJQuerySupport:pt,getAppNames:bt,getAppStatus:Et,getMountedApps:yt,mountRootParcel:V,navigateToUrl:et,registerApplication:Tt,removeErrorHandler:f,setBootstrapMaxTime:j,setMountMaxTime:C,setUnloadMaxTime:I,setUnmountMaxTime:M,start:Ct,triggerAppChange:xt,unloadApplication:St,unloadChildApplication:Nt});var n=Object.freeze({get start(){return Ct},get ensureJQuerySupport(){return pt},get setBootstrapMaxTime(){return j},get setMountMaxTime(){return C},get setUnmountMaxTime(){return M},get setUnloadMaxTime(){return I},get registerApplication(){return Tt},get getMountedApps(){return yt},get getAppStatus(){return Et},get unloadApplication(){return St},get checkActivityFunctions(){return Pt},get getAppNames(){return bt},get declareChildApplication(){return Ot},get unloadChildApplication(){return Nt},get navigateToUrl(){return et},get triggerAppChange(){return xt},get addErrorHandler(){return s},get removeErrorHandler(){return f},get mountRootParcel(){return V},get NOT_LOADED(){return p},get LOADING_SOURCE_CODE(){return m},get NOT_BOOTSTRAPPED(){return d},get BOOTSTRAPPING(){return h},get NOT_MOUNTED(){return v},get MOUNTING(){return w},get UPDATING(){return y},get MOUNTED(){return g},get UNMOUNTING(){return b},get SKIP_BECAUSE_BROKEN(){return O}}),e=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent;var r=function(){try{var t=new e("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?e:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e};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)}function i(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function a(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.forEach(function(n){i(t,n,e[n])})}return t}var u=[];function c(t,n){var e=l(t,n);u.length?u.forEach(function(t){return t(e)}):setTimeout(function(){throw e})}function s(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");u.push(t)}function f(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");var n=!1;return u=u.filter(function(e){var r=e===t;return n=n||r,!r}),n}function l(t,n){var e,r=n.unmountThisParcel?"Parcel":"Application",o="".concat(r," '").concat(n.name,"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message}catch(t){}e=t}else{console.warn("While ".concat(n.status,", '").concat(n.name,"' rejected its lifecycle function promise with a non-Error. This will cause stack traces to not be accurate."));try{e=new Error(o+JSON.stringify(t))}catch(n){e=t}}return e.appName=n.name,e.name=n.name,e}var p=t("NOT_LOADED","NOT_LOADED"),m=t("LOADING_SOURCE_CODE","LOADING_SOURCE_CODE"),d=t("NOT_BOOTSTRAPPED","NOT_BOOTSTRAPPED"),h=t("BOOTSTRAPPING","BOOTSTRAPPING"),v=t("NOT_MOUNTED","NOT_MOUNTED"),w=t("MOUNTING","MOUNTING"),g=t("MOUNTED","MOUNTED"),y=t("UPDATING","UPDATING"),b=t("UNMOUNTING","UNMOUNTING"),E="UNLOADING",O=t("SKIP_BECAUSE_BROKEN","SKIP_BECAUSE_BROKEN");function T(t){return t.status===g}function P(t){return!T(t)}function A(t){return t.status!==p&&t.status!==m}function N(t){return!A(t)}function S(t){try{return t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function U(t){try{return!t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function _(t){return t!==O&&(!t||t.status!==O)}function D(t){return t.name}var x={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}};function j(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("bootstrap max time must be a positive integer number of milliseconds");x.bootstrap={millis:t,dieOnTimeout:n}}function C(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("mount max time must be a positive integer number of milliseconds");x.mount={millis:t,dieOnTimeout:n}}function M(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unmount max time must be a positive integer number of milliseconds");x.unmount={millis:t,dieOnTimeout:n}}function I(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unload max time must be a positive integer number of milliseconds");x.unload={millis:t,dieOnTimeout:n}}function L(t,n,e){var r=1e3;return new Promise(function(o,i){var a=!1,u=!1;function c(t){if(!a)if(!0===t)u=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!u){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r<e.millis&&setTimeout(function(){return c(o+1)},r)}}t.then(function(t){a=!0,o(t)}).catch(function(t){a=!0,i(t)}),setTimeout(function(){return c(1)},r),setTimeout(function(){return c(!0)},e.millis)})}function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a({},x,t)}function G(t,n){for(var e=0;e<t.length;e++)if(n(t[e]))return t[e];return null}function R(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!G(n,function(t){return"function"!=typeof t})));var n}function k(t,n){return 0===(t=Array.isArray(t)?t:[t]).length&&(t=[function(){return Promise.resolve()}]),function(e){return new Promise(function(r,o){!function i(a){var u=t[a](e);q(u)?u.then(function(){a===t.length-1?r():i(a+1)}).catch(o):o("".concat(n," at index ").concat(a," did not return a promise"))}(0)})}}function q(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}function W(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==d?t:(t.status=h,L(t.bootstrap(Y(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=v,t}).catch(function(e){if(t.status=O,n)throw l(e,t);return c(e,t),t}))})}function K(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){if(t.status!==g)return t;t.status=b;var e=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(e).then(r,function(e){return r().then(function(){var r=new Error(e.message);if(n){var o=l(r,t);throw t.status=O,o}c(r,t),t.status=O})}).then(function(){return t});function r(){return L(t.unmount(Y(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=v}).catch(function(e){if(n){var r=l(e,t);throw t.status=O,r}c(e,t),t.status=O})}})}var F=!1,H=!1;function $(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==v?t:(F||(window.dispatchEvent(new r("single-spa:before-first-mount")),F=!0),L(t.mount(Y(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,H||(window.dispatchEvent(new r("single-spa:first-mount")),H=!0),t}).catch(function(e){return t.status=g,K(t).then(r,r);function r(){if(n){var r=l(e,t);throw t.status=O,r}return c(e,t),t.status=O,t}}))})}var J=0,Q={parcels:{}};function V(){return z.apply(Q,arguments)}function z(t,n){var e=this;if(!t||"object"!==o(t)&&"function"!=typeof t)throw new Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw new Error("Parcel name must be a string, if provided");if("object"!==o(n))throw new Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw new Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var r,i=J++,a="function"==typeof t,u=a?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:a?m:d,customProps:n,parentName:e.name,unmountThisParcel:function(){if(c.status!==g)throw new Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return K(c,!0).then(function(t){return c.parentName&&delete e.parcels[c.id],t}).then(function(t){return f(t),t}).catch(function(t){throw c.status=O,p(t),t})}};e.parcels[i]=c;var s=u();if(!s||"function"!=typeof s.then)throw new Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var f,p,h=(s=s.then(function(t){if(!t)throw new Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!R(t.bootstrap))throw new Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!R(t.mount))throw new Error("Parcel ".concat(n," must have a valid mount function"));if(!R(t.unmount))throw new Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!R(t.update))throw new Error("Parcel ".concat(n," provided an invalid update function"));var e=k(t.bootstrap),o=k(t.mount),a=k(t.unmount);c.status=d,c.name=n,c.bootstrap=e,c.mount=o,c.unmount=a,c.timeouts=B(t.timeouts),t.update&&(c.update=k(t.update),r.update=function(t){return c.customProps=t,X(function(t){return Promise.resolve().then(function(){if(t.status!==g)throw new Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=y,L(t.update(Y(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,t}).catch(function(n){var e=l(n,t);throw t.status=O,e})})}(c))})})).then(function(){return W(c,!0)}),w=h.then(function(){return $(c,!0)}),b=new Promise(function(t,n){f=t,p=n});return r={mount:function(){return X(Promise.resolve().then(function(){if(c.status!==v)throw new Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return e.parcels[i]=c,$(c)}))},unmount:function(){return X(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:X(s),bootstrapPromise:X(h),mountPromise:X(w),unmountPromise:X(b)}}function X(t){return t.then(function(){return null})}function Y(t){var e=a({},t.customProps,{name:t.name,mountParcel:z.bind(t),singleSpa:n});return t.unmountThisParcel&&(e.unmountSelf=t.unmountThisParcel),e}function Z(t){return Promise.resolve().then(function(){return t.status!==p?t:(t.status=m,Promise.resolve().then(function(){var e=t.loadImpl(Y(t));if(!q(e))throw new Error("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return e.then(function(e){var r;return"object"!==o(n=e)&&(r="does not export anything"),R(n.bootstrap)||(r="does not export a bootstrap function or array of functions"),R(n.mount)||(r="does not export a mount function or array of functions"),R(n.unmount)||(r="does not export an unmount function or array of functions"),r?(c(r,t),t.status=O,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=a({},t.devtools.overlays,n.devtools.overlays)),t.status=d,t.bootstrap=k(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=k(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=k(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=k(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=B(n.timeouts),t)})}).catch(function(n){return c(n,t),t.status=O,t}));var n})}var tt={hashchange:[],popstate:[]},nt=["hashchange","popstate"];function et(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 new Error("singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag");n=t.currentTarget.href,t.preventDefault()}var r=ft(window.location.href),o=ft(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else!function(t,n){return n===t||n==="/"+t}(o.path,r.path)?window.history.pushState(null,null,n):window.location.hash="#"+o.anchor}function rt(t){var n=this;if(t){var e=t[0].type;nt.indexOf(e)>=0&&tt[e].forEach(function(e){e.apply(n,t)})}}function ot(){xt([],arguments)}window.addEventListener("hashchange",ot),window.addEventListener("popstate",ot);var it=window.addEventListener,at=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0)||G(tt[t],function(t){return t===n}))return it.apply(this,arguments);tt[t].push(n)},window.removeEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0))return at.apply(this,arguments);tt[t]=tt[t].filter(function(t){return t!==n})};var ut=window.history.pushState;window.history.pushState=function(t){var n=ut.apply(this,arguments);return ot(st(t)),n};var ct=window.history.replaceState;function st(t){try{return new PopStateEvent("popstate",{state:t})}catch(e){var n=document.createEvent("PopStateEvent");return n.initPopStateEvent("popstate",!1,!1,t),n}}function ft(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}window.history.replaceState=function(t){var n=ct.apply(this,arguments);return ot(st(t)),n},window.singleSpaNavigate=et;var lt=!1;function pt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!lt){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return mt.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return mt.call(this,e,window.removeEventListener,t,n,arguments)},lt=!0}}function mt(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){nt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}var dt={};function ht(t){return Promise.resolve().then(function(){var n=dt[t.name];return n?t.status===p?(vt(t,n),t):t.status===E?n.promise.then(function(){return t}):t.status!==v?t:(t.status=E,L(t.unload(Y(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return vt(t,n),t}).catch(function(e){return function(t,n,e){delete dt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,c(e,t),t.status=O,n.reject(e)}(t,n,e),t})):t})}function vt(t,n){delete dt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=p,n.resolve()}function wt(t,n,e,r){dt[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(dt[t.name],"promise",{get:n})}var gt=[];function yt(){return gt.filter(T).map(D)}function bt(){return gt.map(D)}function Et(t){var n=G(gt,function(n){return n.name===t});return n?n.status:null}function Ot(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),Tt(t,n,e)}function Tt(t,n,e){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw new Error("The first argument must be a non-empty string 'appName'");if(-1!==bt().indexOf(t))throw new Error("There is already an app declared with name ".concat(t));if("object"!==o(i)||Array.isArray(i))throw new Error("customProps must be an object");if(!n)throw new Error("The application or loading function is required");if(r="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof e)throw new Error("The activeWhen argument must be a function");gt.push({name:t,loadImpl:r,activeWhen:e,status:p,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),pt(),xt()}function Pt(t){for(var n=[],e=0;e<gt.length;e++)gt[e].activeWhen(t)&&n.push(gt[e].name);return n}function At(){return gt.filter(_).filter(N).filter(S)}function Nt(t,n){return console.warn('unloadChildApplication is deprecated and will be removed in the next major version, use "unloadApplication" instead'),St(t,n)}function St(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw new Error("unloadApplication requires a string 'appName'");var e=G(gt,function(n){return n.name===t});if(!e)throw new Error("Could not unload application '".concat(t,"' because no such application has been declared"));var r,o=function(t){return dt[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){wt(e,function(){return i},t,n)});return i}return o?(r=o.promise,Ut(e,o.resolve,o.reject)):r=new Promise(function(t,n){wt(e,function(){return r},t,n),Ut(e,t,n)}),r}function Ut(t,n,e){K(t).then(ht).then(function(){n(),setTimeout(function(){xt()})}).catch(e)}var _t=!1,Dt=[];function xt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;if(_t)return new Promise(function(t,e){Dt.push({resolve:t,reject:e,eventArguments:n})});_t=!0;var e=!0;return jt?Promise.resolve().then(function(){window.dispatchEvent(new r("single-spa:before-routing-event",a()));var n=Object.keys(dt).map(function(t){return dt[t].app}).filter(P).map(ht),u=gt.filter(_).filter(T).filter(U).map(K).map(function(t){return t.then(ht)}),c=u.concat(n);c.length>0&&(e=!1);var s=Promise.all(c),f=At(),l=f.map(function(t){return Z(t).then(W).then(function(t){return s.then(function(){return $(t)})})});l.length>0&&(e=!1);var p=gt.filter(_).filter(P).filter(A).filter(S).filter(function(t){return f.indexOf(t)<0}).map(function(t){return W(t).then(function(){return s}).then(function(){return $(t)})});return p.length>0&&(e=!1),s.catch(function(t){throw i(),t}).then(function(){return i(),Promise.all(l.concat(p)).catch(function(n){throw t.forEach(function(t){return t.reject(n)}),n}).then(function(){return o(!1)})})}):Promise.resolve().then(function(){var t=At().map(Z);return t.length>0&&(e=!1),Promise.all(t).then(o).catch(function(t){throw i(),t})});function o(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=yt();n&&i(),t.forEach(function(t){return t.resolve(o)});try{var u=e?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new r(u,a())),window.dispatchEvent(new r("single-spa:routing-event",a()))}catch(t){setTimeout(function(){throw t})}if(_t=!1,Dt.length>0){var c=Dt;Dt=[],xt(c)}return o}function i(){t.forEach(function(t){rt(t.eventArguments)}),rt(n)}function a(){var t={detail:{}};return n&&n[0]&&(t.detail.originalEvent=n[0]),t}}var jt=!1;function Ct(){jt=!0,xt()}setTimeout(function(){jt||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var Mt={getRawAppData:function(){return[].concat(gt)},reroute:xt,NOT_LOADED:p,toLoadPromise:Z,toBootstrapPromise:W};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Mt)}}}); | ||
//# sourceMappingURL=single-spa.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).singleSpa={})}(this,function(t){"use strict";var n=Object.freeze({get start(){return jt},get ensureJQuerySupport(){return lt},get setBootstrapMaxTime(){return j},get setMountMaxTime(){return C},get setUnmountMaxTime(){return M},get setUnloadMaxTime(){return I},get registerApplication(){return Ot},get getMountedApps(){return gt},get getAppStatus(){return bt},get unloadApplication(){return Nt},get checkActivityFunctions(){return Tt},get getAppNames(){return yt},get declareChildApplication(){return Et},get unloadChildApplication(){return At},get navigateToUrl(){return et},get triggerAppChange(){return xt},get addErrorHandler(){return s},get removeErrorHandler(){return f},get mountRootParcel(){return V},get NOT_LOADED(){return p},get LOADING_SOURCE_CODE(){return m},get NOT_BOOTSTRAPPED(){return d},get BOOTSTRAPPING(){return h},get NOT_MOUNTED(){return v},get MOUNTING(){return w},get UPDATING(){return y},get MOUNTED(){return g},get UNMOUNTING(){return b},get SKIP_BECAUSE_BROKEN(){return O}}),e=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent;var r=function(){try{var t=new e("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?e:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e};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)}function i(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function a(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.forEach(function(n){i(t,n,e[n])})}return t}var u=[];function c(t,n){var e=l(t,n);u.length?u.forEach(function(t){return t(e)}):setTimeout(function(){throw e})}function s(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");u.push(t)}function f(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");var n=!1;return u=u.filter(function(e){var r=e===t;return n=n||r,!r}),n}function l(t,n){var e,r=n.unmountThisParcel?"Parcel":"Application",o="".concat(r," '").concat(n.name,"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message}catch(t){}e=t}else{console.warn("While ".concat(n.status,", '").concat(n.name,"' rejected its lifecycle function promise with a non-Error. This will cause stack traces to not be accurate."));try{e=new Error(o+JSON.stringify(t))}catch(n){e=t}}return e.appName=n.name,e.name=n.name,e}var p="NOT_LOADED",m="LOADING_SOURCE_CODE",d="NOT_BOOTSTRAPPED",h="BOOTSTRAPPING",v="NOT_MOUNTED",w="MOUNTING",g="MOUNTED",y="UPDATING",b="UNMOUNTING",E="UNLOADING",O="SKIP_BECAUSE_BROKEN";function T(t){return t.status===g}function P(t){return!T(t)}function A(t){return t.status!==p&&t.status!==m}function N(t){return!A(t)}function S(t){try{return t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function U(t){try{return!t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function _(t){return t!==O&&(!t||t.status!==O)}function x(t){return t.name}var D={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}};function j(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("bootstrap max time must be a positive integer number of milliseconds");D.bootstrap={millis:t,dieOnTimeout:n}}function C(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("mount max time must be a positive integer number of milliseconds");D.mount={millis:t,dieOnTimeout:n}}function M(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unmount max time must be a positive integer number of milliseconds");D.unmount={millis:t,dieOnTimeout:n}}function I(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unload max time must be a positive integer number of milliseconds");D.unload={millis:t,dieOnTimeout:n}}function L(t,n,e){var r=1e3;return new Promise(function(o,i){var a=!1,u=!1;function c(t){if(!a)if(!0===t)u=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!u){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r<e.millis&&setTimeout(function(){return c(o+1)},r)}}t.then(function(t){a=!0,o(t)}).catch(function(t){a=!0,i(t)}),setTimeout(function(){return c(1)},r),setTimeout(function(){return c(!0)},e.millis)})}function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a({},D,t)}function G(t,n){for(var e=0;e<t.length;e++)if(n(t[e]))return t[e];return null}function R(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!G(n,function(t){return"function"!=typeof t})));var n}function k(t,n){return 0===(t=Array.isArray(t)?t:[t]).length&&(t=[function(){return Promise.resolve()}]),function(e){return new Promise(function(r,o){!function i(a){var u=t[a](e);q(u)?u.then(function(){a===t.length-1?r():i(a+1)}).catch(o):o("".concat(n," at index ").concat(a," did not return a promise"))}(0)})}}function q(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}function W(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==d?t:(t.status=h,L(t.bootstrap(Y(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=v,t}).catch(function(e){if(t.status=O,n)throw l(e,t);return c(e,t),t}))})}function K(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){if(t.status!==g)return t;t.status=b;var e=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(e).then(r,function(e){return r().then(function(){var r=new Error(e.message);if(n){var o=l(r,t);throw t.status=O,o}c(r,t),t.status=O})}).then(function(){return t});function r(){return L(t.unmount(Y(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=v}).catch(function(e){if(n){var r=l(e,t);throw t.status=O,r}c(e,t),t.status=O})}})}var F=!1,H=!1;function $(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==v?t:(F||(window.dispatchEvent(new r("single-spa:before-first-mount")),F=!0),L(t.mount(Y(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,H||(window.dispatchEvent(new r("single-spa:first-mount")),H=!0),t}).catch(function(e){return t.status=g,K(t).then(r,r);function r(){if(n){var r=l(e,t);throw t.status=O,r}return c(e,t),t.status=O,t}}))})}var J=0,Q={parcels:{}};function V(){return z.apply(Q,arguments)}function z(t,n){var e=this;if(!t||"object"!==o(t)&&"function"!=typeof t)throw new Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw new Error("Parcel name must be a string, if provided");if("object"!==o(n))throw new Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw new Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var r,i=J++,a="function"==typeof t,u=a?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:a?m:d,customProps:n,parentName:e.name,unmountThisParcel:function(){if(c.status!==g)throw new Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return K(c,!0).then(function(t){return c.parentName&&delete e.parcels[c.id],t}).then(function(t){return f(t),t}).catch(function(t){throw c.status=O,p(t),t})}};e.parcels[i]=c;var s=u();if(!s||"function"!=typeof s.then)throw new Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var f,p,h=(s=s.then(function(t){if(!t)throw new Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!R(t.bootstrap))throw new Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!R(t.mount))throw new Error("Parcel ".concat(n," must have a valid mount function"));if(!R(t.unmount))throw new Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!R(t.update))throw new Error("Parcel ".concat(n," provided an invalid update function"));var e=k(t.bootstrap),o=k(t.mount),a=k(t.unmount);c.status=d,c.name=n,c.bootstrap=e,c.mount=o,c.unmount=a,c.timeouts=B(t.timeouts),t.update&&(c.update=k(t.update),r.update=function(t){return c.customProps=t,X(function(t){return Promise.resolve().then(function(){if(t.status!==g)throw new Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=y,L(t.update(Y(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,t}).catch(function(n){var e=l(n,t);throw t.status=O,e})})}(c))})})).then(function(){return W(c,!0)}),w=h.then(function(){return $(c,!0)}),b=new Promise(function(t,n){f=t,p=n});return r={mount:function(){return X(Promise.resolve().then(function(){if(c.status!==v)throw new Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return e.parcels[i]=c,$(c)}))},unmount:function(){return X(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:X(s),bootstrapPromise:X(h),mountPromise:X(w),unmountPromise:X(b)}}function X(t){return t.then(function(){return null})}function Y(t){var e=a({},t.customProps,{name:t.name,mountParcel:z.bind(t),singleSpa:n});return t.unmountThisParcel&&(e.unmountSelf=t.unmountThisParcel),e}function Z(t){return Promise.resolve().then(function(){return t.status!==p?t:(t.status=m,Promise.resolve().then(function(){var e=t.loadImpl(Y(t));if(!q(e))throw new Error("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return e.then(function(e){var r;return"object"!==o(n=e)&&(r="does not export anything"),R(n.bootstrap)||(r="does not export a bootstrap function or array of functions"),R(n.mount)||(r="does not export a mount function or array of functions"),R(n.unmount)||(r="does not export an unmount function or array of functions"),r?(c(r,t),t.status=O,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=a({},t.devtools.overlays,n.devtools.overlays)),t.status=d,t.bootstrap=k(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=k(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=k(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=k(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=B(n.timeouts),t)})}).catch(function(n){return c(n,t),t.status=O,t}));var n})}var tt={hashchange:[],popstate:[]},nt=["hashchange","popstate"];function et(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 new Error("singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag");n=t.currentTarget.href,t.preventDefault()}var r=st(window.location.href),o=st(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else!function(t,n){return n===t||n==="/"+t}(o.path,r.path)?window.history.pushState(null,null,n):window.location.hash="#"+o.anchor}function rt(t){var n=this;if(t){var e=t[0].type;nt.indexOf(e)>=0&&tt[e].forEach(function(e){e.apply(n,t)})}}function ot(){xt([],arguments)}window.addEventListener("hashchange",ot),window.addEventListener("popstate",ot);var it=window.addEventListener,at=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0)||G(tt[t],function(t){return t===n}))return it.apply(this,arguments);tt[t].push(n)},window.removeEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0))return at.apply(this,arguments);tt[t]=tt[t].filter(function(t){return t!==n})};var ut=window.history.pushState;window.history.pushState=function(t){var n=ut.apply(this,arguments);return ot(new PopStateEvent("popstate",{state:t})),n};var ct=window.history.replaceState;function st(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}window.history.replaceState=function(t){var n=ct.apply(this,arguments);return ot(new PopStateEvent("popstate",{state:t})),n},window.singleSpaNavigate=et;var ft=!1;function lt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!ft){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return pt.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return pt.call(this,e,window.removeEventListener,t,n,arguments)},ft=!0}}function pt(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){nt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}var mt={};function dt(t){return Promise.resolve().then(function(){var n=mt[t.name];return n?t.status===p?(ht(t,n),t):t.status===E?n.promise.then(function(){return t}):t.status!==v?t:(t.status=E,L(t.unload(Y(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return ht(t,n),t}).catch(function(e){return function(t,n,e){delete mt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,c(e,t),t.status=O,n.reject(e)}(t,n,e),t})):t})}function ht(t,n){delete mt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=p,n.resolve()}function vt(t,n,e,r){mt[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(mt[t.name],"promise",{get:n})}var wt=[];function gt(){return wt.filter(T).map(x)}function yt(){return wt.map(x)}function bt(t){var n=G(wt,function(n){return n.name===t});return n?n.status:null}function Et(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),Ot(t,n,e)}function Ot(t,n,e){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw new Error("The first argument must be a non-empty string 'appName'");if(-1!==yt().indexOf(t))throw new Error("There is already an app declared with name ".concat(t));if("object"!==o(i)||Array.isArray(i))throw new Error("customProps must be an object");if(!n)throw new Error("The application or loading function is required");if(r="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof e)throw new Error("The activeWhen argument must be a function");wt.push({name:t,loadImpl:r,activeWhen:e,status:p,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),lt(),xt()}function Tt(t){for(var n=[],e=0;e<wt.length;e++)wt[e].activeWhen(t)&&n.push(wt[e].name);return n}function Pt(){return wt.filter(_).filter(N).filter(S)}function At(t,n){return console.warn('unloadChildApplication is deprecated and will be removed in the next major version, use "unloadApplication" instead'),Nt(t,n)}function Nt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw new Error("unloadApplication requires a string 'appName'");var e=G(wt,function(n){return n.name===t});if(!e)throw new Error("Could not unload application '".concat(t,"' because no such application has been declared"));var r,o=function(t){return mt[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){vt(e,function(){return i},t,n)});return i}return o?(r=o.promise,St(e,o.resolve,o.reject)):r=new Promise(function(t,n){vt(e,function(){return r},t,n),St(e,t,n)}),r}function St(t,n,e){K(t).then(dt).then(function(){n(),setTimeout(function(){xt()})}).catch(e)}var Ut=!1,_t=[];function xt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;if(Ut)return new Promise(function(t,e){_t.push({resolve:t,reject:e,eventArguments:n})});Ut=!0;var e=!0;return Dt?Promise.resolve().then(function(){window.dispatchEvent(new r("single-spa:before-routing-event",a()));var n=Object.keys(mt).map(function(t){return mt[t].app}).filter(P).map(dt),u=wt.filter(_).filter(T).filter(U).map(K).map(function(t){return t.then(dt)}),c=u.concat(n);c.length>0&&(e=!1);var s=Promise.all(c),f=Pt(),l=f.map(function(t){return Z(t).then(W).then(function(t){return s.then(function(){return $(t)})})});l.length>0&&(e=!1);var p=wt.filter(_).filter(P).filter(A).filter(S).filter(function(t){return f.indexOf(t)<0}).map(function(t){return W(t).then(function(){return s}).then(function(){return $(t)})});return p.length>0&&(e=!1),s.catch(function(t){throw i(),t}).then(function(){return i(),Promise.all(l.concat(p)).catch(function(n){throw t.forEach(function(t){return t.reject(n)}),n}).then(function(){return o(!1)})})}):Promise.resolve().then(function(){var t=Pt().map(Z);return t.length>0&&(e=!1),Promise.all(t).then(o).catch(function(t){throw i(),t})});function o(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=gt();n&&i(),t.forEach(function(t){return t.resolve(o)});try{var u=e?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new r(u,a())),window.dispatchEvent(new r("single-spa:routing-event",a()))}catch(t){setTimeout(function(){throw t})}if(Ut=!1,_t.length>0){var c=_t;_t=[],xt(c)}return o}function i(){t.forEach(function(t){rt(t.eventArguments)}),rt(n)}function a(){var t={detail:{}};return n&&n[0]&&(t.detail.originalEvent=n[0]),t}}var Dt=!1;function jt(){Dt=!0,xt()}setTimeout(function(){Dt||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var Ct={getRawAppData:function(){return[].concat(wt)},reroute:xt,NOT_LOADED:p,toLoadPromise:Z,toBootstrapPromise:W};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Ct),t.BOOTSTRAPPING=h,t.LOADING_SOURCE_CODE=m,t.MOUNTED=g,t.MOUNTING=w,t.NOT_BOOTSTRAPPED=d,t.NOT_LOADED=p,t.NOT_MOUNTED=v,t.SKIP_BECAUSE_BROKEN=O,t.UNMOUNTING=b,t.UPDATING=y,t.addErrorHandler=s,t.checkActivityFunctions=Tt,t.declareChildApplication=Et,t.ensureJQuerySupport=lt,t.getAppNames=yt,t.getAppStatus=bt,t.getMountedApps=gt,t.mountRootParcel=V,t.navigateToUrl=et,t.registerApplication=Ot,t.removeErrorHandler=f,t.setBootstrapMaxTime=j,t.setMountMaxTime=C,t.setUnloadMaxTime=I,t.setUnmountMaxTime=M,t.start=jt,t.triggerAppChange=xt,t.unloadApplication=Nt,t.unloadChildApplication=At,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).singleSpa={})}(this,function(t){"use strict";var n=Object.freeze({get start(){return Ct},get ensureJQuerySupport(){return pt},get setBootstrapMaxTime(){return j},get setMountMaxTime(){return C},get setUnmountMaxTime(){return M},get setUnloadMaxTime(){return I},get registerApplication(){return Pt},get getMountedApps(){return yt},get getAppStatus(){return Et},get unloadApplication(){return St},get checkActivityFunctions(){return Tt},get getAppNames(){return bt},get declareChildApplication(){return Ot},get unloadChildApplication(){return Nt},get navigateToUrl(){return et},get triggerAppChange(){return Dt},get addErrorHandler(){return s},get removeErrorHandler(){return f},get mountRootParcel(){return V},get NOT_LOADED(){return p},get LOADING_SOURCE_CODE(){return m},get NOT_BOOTSTRAPPED(){return d},get BOOTSTRAPPING(){return h},get NOT_MOUNTED(){return v},get MOUNTING(){return w},get UPDATING(){return y},get MOUNTED(){return g},get UNMOUNTING(){return b},get SKIP_BECAUSE_BROKEN(){return O}}),e=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent;var r=function(){try{var t=new e("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?e:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e};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)}function i(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function a(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{},r=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(e).filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.forEach(function(n){i(t,n,e[n])})}return t}var u=[];function c(t,n){var e=l(t,n);u.length?u.forEach(function(t){return t(e)}):setTimeout(function(){throw e})}function s(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");u.push(t)}function f(t){if("function"!=typeof t)throw new Error("a single-spa error handler must be a function");var n=!1;return u=u.filter(function(e){var r=e===t;return n=n||r,!r}),n}function l(t,n){var e,r=n.unmountThisParcel?"Parcel":"Application",o="".concat(r," '").concat(n.name,"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message}catch(t){}e=t}else{console.warn("While ".concat(n.status,", '").concat(n.name,"' rejected its lifecycle function promise with a non-Error. This will cause stack traces to not be accurate."));try{e=new Error(o+JSON.stringify(t))}catch(n){e=t}}return e.appName=n.name,e.name=n.name,e}var p="NOT_LOADED",m="LOADING_SOURCE_CODE",d="NOT_BOOTSTRAPPED",h="BOOTSTRAPPING",v="NOT_MOUNTED",w="MOUNTING",g="MOUNTED",y="UPDATING",b="UNMOUNTING",E="UNLOADING",O="SKIP_BECAUSE_BROKEN";function P(t){return t.status===g}function T(t){return!P(t)}function A(t){return t.status!==p&&t.status!==m}function N(t){return!A(t)}function S(t){try{return t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function U(t){try{return!t.activeWhen(window.location)}catch(n){c(n,t),t.status=O}}function _(t){return t!==O&&(!t||t.status!==O)}function x(t){return t.name}var D={bootstrap:{millis:4e3,dieOnTimeout:!1},mount:{millis:3e3,dieOnTimeout:!1},unmount:{millis:3e3,dieOnTimeout:!1},unload:{millis:3e3,dieOnTimeout:!1}};function j(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("bootstrap max time must be a positive integer number of milliseconds");D.bootstrap={millis:t,dieOnTimeout:n}}function C(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("mount max time must be a positive integer number of milliseconds");D.mount={millis:t,dieOnTimeout:n}}function M(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unmount max time must be a positive integer number of milliseconds");D.unmount={millis:t,dieOnTimeout:n}}function I(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("number"!=typeof t||t<=0)throw new Error("unload max time must be a positive integer number of milliseconds");D.unload={millis:t,dieOnTimeout:n}}function L(t,n,e){var r=1e3;return new Promise(function(o,i){var a=!1,u=!1;function c(t){if(!a)if(!0===t)u=!0,e.dieOnTimeout?i("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds")):console.error("".concat(n," did not resolve or reject for ").concat(e.millis," milliseconds -- we're no longer going to warn you about it."));else if(!u){var o=t,s=o*r;console.warn("".concat(n," did not resolve or reject within ").concat(s," milliseconds")),s+r<e.millis&&setTimeout(function(){return c(o+1)},r)}}t.then(function(t){a=!0,o(t)}).catch(function(t){a=!0,i(t)}),setTimeout(function(){return c(1)},r),setTimeout(function(){return c(!0)},e.millis)})}function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a({},D,t)}function G(t,n){for(var e=0;e<t.length;e++)if(n(t[e]))return t[e];return null}function R(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!G(n,function(t){return"function"!=typeof t})));var n}function k(t,n){return 0===(t=Array.isArray(t)?t:[t]).length&&(t=[function(){return Promise.resolve()}]),function(e){return new Promise(function(r,o){!function i(a){var u=t[a](e);q(u)?u.then(function(){a===t.length-1?r():i(a+1)}).catch(o):o("".concat(n," at index ").concat(a," did not return a promise"))}(0)})}}function q(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}function W(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==d?t:(t.status=h,L(t.bootstrap(Y(t)),"Bootstrapping appOrParcel '".concat(t.name,"'"),t.timeouts.bootstrap).then(function(){return t.status=v,t}).catch(function(e){if(t.status=O,n)throw l(e,t);return c(e,t),t}))})}function K(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){if(t.status!==g)return t;t.status=b;var e=Object.keys(t.parcels).map(function(n){return t.parcels[n].unmountThisParcel()});return Promise.all(e).then(r,function(e){return r().then(function(){var r=new Error(e.message);if(n){var o=l(r,t);throw t.status=O,o}c(r,t),t.status=O})}).then(function(){return t});function r(){return L(t.unmount(Y(t)),"Unmounting application ".concat(t.name,"'"),t.timeouts.unmount).then(function(){t.status=v}).catch(function(e){if(n){var r=l(e,t);throw t.status=O,r}c(e,t),t.status=O})}})}var F=!1,H=!1;function $(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Promise.resolve().then(function(){return t.status!==v?t:(F||(window.dispatchEvent(new r("single-spa:before-first-mount")),F=!0),L(t.mount(Y(t)),"Mounting application '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,H||(window.dispatchEvent(new r("single-spa:first-mount")),H=!0),t}).catch(function(e){return t.status=g,K(t).then(r,r);function r(){if(n){var r=l(e,t);throw t.status=O,r}return c(e,t),t.status=O,t}}))})}var J=0,Q={parcels:{}};function V(){return z.apply(Q,arguments)}function z(t,n){var e=this;if(!t||"object"!==o(t)&&"function"!=typeof t)throw new Error("Cannot mount parcel without a config object or config loading function");if(t.name&&"string"!=typeof t.name)throw new Error("Parcel name must be a string, if provided");if("object"!==o(n))throw new Error("Parcel ".concat(name," has invalid customProps -- must be an object"));if(!n.domElement)throw new Error("Parcel ".concat(name," cannot be mounted without a domElement provided as a prop"));var r,i=J++,a="function"==typeof t,u=a?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:a?m:d,customProps:n,parentName:e.name,unmountThisParcel:function(){if(c.status!==g)throw new Error("Cannot unmount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return K(c,!0).then(function(t){return c.parentName&&delete e.parcels[c.id],t}).then(function(t){return f(t),t}).catch(function(t){throw c.status=O,p(t),t})}};e.parcels[i]=c;var s=u();if(!s||"function"!=typeof s.then)throw new Error("When mounting a parcel, the config loading function must return a promise that resolves with the parcel config");var f,p,h=(s=s.then(function(t){if(!t)throw new Error("When mounting a parcel, the config loading function returned a promise that did not resolve with a parcel config");var n=t.name||"parcel-".concat(i);if(!R(t.bootstrap))throw new Error("Parcel ".concat(n," must have a valid bootstrap function"));if(!R(t.mount))throw new Error("Parcel ".concat(n," must have a valid mount function"));if(!R(t.unmount))throw new Error("Parcel ".concat(n," must have a valid unmount function"));if(t.update&&!R(t.update))throw new Error("Parcel ".concat(n," provided an invalid update function"));var e=k(t.bootstrap),o=k(t.mount),a=k(t.unmount);c.status=d,c.name=n,c.bootstrap=e,c.mount=o,c.unmount=a,c.timeouts=B(t.timeouts),t.update&&(c.update=k(t.update),r.update=function(t){return c.customProps=t,X(function(t){return Promise.resolve().then(function(){if(t.status!==g)throw new Error("Cannot update parcel '".concat(t.name,"' because it is not mounted"));return t.status=y,L(t.update(Y(t)),"Updating parcel '".concat(t.name,"'"),t.timeouts.mount).then(function(){return t.status=g,t}).catch(function(n){var e=l(n,t);throw t.status=O,e})})}(c))})})).then(function(){return W(c,!0)}),w=h.then(function(){return $(c,!0)}),b=new Promise(function(t,n){f=t,p=n});return r={mount:function(){return X(Promise.resolve().then(function(){if(c.status!==v)throw new Error("Cannot mount parcel '".concat(name,"' -- it is in a ").concat(c.status," status"));return e.parcels[i]=c,$(c)}))},unmount:function(){return X(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:X(s),bootstrapPromise:X(h),mountPromise:X(w),unmountPromise:X(b)}}function X(t){return t.then(function(){return null})}function Y(t){var e=a({},t.customProps,{name:t.name,mountParcel:z.bind(t),singleSpa:n});return t.unmountThisParcel&&(e.unmountSelf=t.unmountThisParcel),e}function Z(t){return Promise.resolve().then(function(){return t.status!==p?t:(t.status=m,Promise.resolve().then(function(){var e=t.loadImpl(Y(t));if(!q(e))throw new Error("single-spa loading function did not return a promise. Check the second argument to registerApplication('".concat(t.name,"', loadingFunction, activityFunction)"));return e.then(function(e){var r;return"object"!==o(n=e)&&(r="does not export anything"),R(n.bootstrap)||(r="does not export a bootstrap function or array of functions"),R(n.mount)||(r="does not export a mount function or array of functions"),R(n.unmount)||(r="does not export an unmount function or array of functions"),r?(c(r,t),t.status=O,t):(n.devtools&&n.devtools.overlays&&(t.devtools.overlays=a({},t.devtools.overlays,n.devtools.overlays)),t.status=d,t.bootstrap=k(n.bootstrap,"App '".concat(t.name,"' bootstrap function")),t.mount=k(n.mount,"App '".concat(t.name,"' mount function")),t.unmount=k(n.unmount,"App '".concat(t.name,"' unmount function")),t.unload=k(n.unload||[],"App '".concat(t.name,"' unload function")),t.timeouts=B(n.timeouts),t)})}).catch(function(n){return c(n,t),t.status=O,t}));var n})}var tt={hashchange:[],popstate:[]},nt=["hashchange","popstate"];function et(t){var n,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 new Error("singleSpaNavigate must be either called with a string url, with an <a> tag as its context, or with an event whose currentTarget is an <a> tag");n=t.currentTarget.href,t.preventDefault()}var r=ft(window.location.href),o=ft(n);if(0===n.indexOf("#"))window.location.hash="#"+o.anchor;else if(r.host!==o.host&&o.host){if(e.isTestingEnv)return{wouldHaveReloadedThePage:!0};window.location.href=n}else!function(t,n){return n===t||n==="/"+t}(o.path,r.path)?window.history.pushState(null,null,n):window.location.hash="#"+o.anchor}function rt(t){var n=this;if(t){var e=t[0].type;nt.indexOf(e)>=0&&tt[e].forEach(function(e){e.apply(n,t)})}}function ot(){Dt([],arguments)}window.addEventListener("hashchange",ot),window.addEventListener("popstate",ot);var it=window.addEventListener,at=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0)||G(tt[t],function(t){return t===n}))return it.apply(this,arguments);tt[t].push(n)},window.removeEventListener=function(t,n){if(!("function"==typeof n&&nt.indexOf(t)>=0))return at.apply(this,arguments);tt[t]=tt[t].filter(function(t){return t!==n})};var ut=window.history.pushState;window.history.pushState=function(t){var n=ut.apply(this,arguments);return ot(st(t)),n};var ct=window.history.replaceState;function st(t){try{return new PopStateEvent("popstate",{state:t})}catch(e){var n=document.createEvent("PopStateEvent");return n.initPopStateEvent("popstate",!1,!1,t),n}}function ft(t){for(var n={strictMode:!0,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},e=n.parser.strict.exec(t),r={},o=14;o--;)r[n.key[o]]=e[o]||"";return r[n.q.name]={},r[n.key[12]].replace(n.q.parser,function(t,e,o){e&&(r[n.q.name][e]=o)}),r}window.history.replaceState=function(t){var n=ct.apply(this,arguments);return ot(st(t)),n},window.singleSpaNavigate=et;var lt=!1;function pt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!lt){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return mt.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return mt.call(this,e,window.removeEventListener,t,n,arguments)},lt=!0}}function mt(t,n,e,r,o){return"string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach(function(t){nt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""))}),""===e.trim()?this:t.apply(this,o))}var dt={};function ht(t){return Promise.resolve().then(function(){var n=dt[t.name];return n?t.status===p?(vt(t,n),t):t.status===E?n.promise.then(function(){return t}):t.status!==v?t:(t.status=E,L(t.unload(Y(t)),"Unloading application '".concat(t.name,"'"),t.timeouts.unload).then(function(){return vt(t,n),t}).catch(function(e){return function(t,n,e){delete dt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,c(e,t),t.status=O,n.reject(e)}(t,n,e),t})):t})}function vt(t,n){delete dt[t.name],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=p,n.resolve()}function wt(t,n,e,r){dt[t.name]={app:t,resolve:e,reject:r},Object.defineProperty(dt[t.name],"promise",{get:n})}var gt=[];function yt(){return gt.filter(P).map(x)}function bt(){return gt.map(x)}function Et(t){var n=G(gt,function(n){return n.name===t});return n?n.status:null}function Ot(t,n,e){return console.warn('declareChildApplication is deprecated and will be removed in the next major version, use "registerApplication" instead'),Pt(t,n,e)}function Pt(t,n,e){var r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if("string"!=typeof t||0===t.length)throw new Error("The first argument must be a non-empty string 'appName'");if(-1!==bt().indexOf(t))throw new Error("There is already an app declared with name ".concat(t));if("object"!==o(i)||Array.isArray(i))throw new Error("customProps must be an object");if(!n)throw new Error("The application or loading function is required");if(r="function"!=typeof n?function(){return Promise.resolve(n)}:n,"function"!=typeof e)throw new Error("The activeWhen argument must be a function");gt.push({name:t,loadImpl:r,activeWhen:e,status:p,parcels:{},devtools:{overlays:{options:{},selectors:[]}},customProps:i}),pt(),Dt()}function Tt(t){for(var n=[],e=0;e<gt.length;e++)gt[e].activeWhen(t)&&n.push(gt[e].name);return n}function At(){return gt.filter(_).filter(N).filter(S)}function Nt(t,n){return console.warn('unloadChildApplication is deprecated and will be removed in the next major version, use "unloadApplication" instead'),St(t,n)}function St(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw new Error("unloadApplication requires a string 'appName'");var e=G(gt,function(n){return n.name===t});if(!e)throw new Error("Could not unload application '".concat(t,"' because no such application has been declared"));var r,o=function(t){return dt[t]}(e.name);if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise(function(t,n){wt(e,function(){return i},t,n)});return i}return o?(r=o.promise,Ut(e,o.resolve,o.reject)):r=new Promise(function(t,n){wt(e,function(){return r},t,n),Ut(e,t,n)}),r}function Ut(t,n,e){K(t).then(ht).then(function(){n(),setTimeout(function(){Dt()})}).catch(e)}var _t=!1,xt=[];function Dt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;if(_t)return new Promise(function(t,e){xt.push({resolve:t,reject:e,eventArguments:n})});_t=!0;var e=!0;return jt?Promise.resolve().then(function(){window.dispatchEvent(new r("single-spa:before-routing-event",a()));var n=Object.keys(dt).map(function(t){return dt[t].app}).filter(T).map(ht),u=gt.filter(_).filter(P).filter(U).map(K).map(function(t){return t.then(ht)}),c=u.concat(n);c.length>0&&(e=!1);var s=Promise.all(c),f=At(),l=f.map(function(t){return Z(t).then(W).then(function(t){return s.then(function(){return $(t)})})});l.length>0&&(e=!1);var p=gt.filter(_).filter(T).filter(A).filter(S).filter(function(t){return f.indexOf(t)<0}).map(function(t){return W(t).then(function(){return s}).then(function(){return $(t)})});return p.length>0&&(e=!1),s.catch(function(t){throw i(),t}).then(function(){return i(),Promise.all(l.concat(p)).catch(function(n){throw t.forEach(function(t){return t.reject(n)}),n}).then(function(){return o(!1)})})}):Promise.resolve().then(function(){var t=At().map(Z);return t.length>0&&(e=!1),Promise.all(t).then(o).catch(function(t){throw i(),t})});function o(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],o=yt();n&&i(),t.forEach(function(t){return t.resolve(o)});try{var u=e?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new r(u,a())),window.dispatchEvent(new r("single-spa:routing-event",a()))}catch(t){setTimeout(function(){throw t})}if(_t=!1,xt.length>0){var c=xt;xt=[],Dt(c)}return o}function i(){t.forEach(function(t){rt(t.eventArguments)}),rt(n)}function a(){var t={detail:{}};return n&&n[0]&&(t.detail.originalEvent=n[0]),t}}var jt=!1;function Ct(){jt=!0,Dt()}setTimeout(function(){jt||console.warn("singleSpa.start() has not been called, ".concat(5e3,"ms after single-spa was loaded. Before start() is called, apps can be declared and loaded, but not bootstrapped or mounted. See https://github.com/CanopyTax/single-spa/blob/master/docs/single-spa-api.md#start"))},5e3);var Mt={getRawAppData:function(){return[].concat(gt)},reroute:Dt,NOT_LOADED:p,toLoadPromise:Z,toBootstrapPromise:W};window&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Mt),t.BOOTSTRAPPING=h,t.LOADING_SOURCE_CODE=m,t.MOUNTED=g,t.MOUNTING=w,t.NOT_BOOTSTRAPPED=d,t.NOT_LOADED=p,t.NOT_MOUNTED=v,t.SKIP_BECAUSE_BROKEN=O,t.UNMOUNTING=b,t.UPDATING=y,t.addErrorHandler=s,t.checkActivityFunctions=Tt,t.declareChildApplication=Ot,t.ensureJQuerySupport=pt,t.getAppNames=bt,t.getAppStatus=Et,t.getMountedApps=yt,t.mountRootParcel=V,t.navigateToUrl=et,t.registerApplication=Pt,t.removeErrorHandler=f,t.setBootstrapMaxTime=j,t.setMountMaxTime=C,t.setUnloadMaxTime=I,t.setUnmountMaxTime=M,t.start=Ct,t.triggerAppChange=Dt,t.unloadApplication=St,t.unloadChildApplication=Nt,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=single-spa.min.js.map |
{ | ||
"name": "single-spa", | ||
"version": "4.3.1", | ||
"version": "4.3.2", | ||
"description": "Multiple applications, one page", | ||
@@ -5,0 +5,0 @@ "main": "lib/umd/single-spa.min.js", |
@@ -7,4 +7,2 @@ | ||
[![Sauce Test Status](https://saucelabs.com/browser-matrix/joeldenning.svg)](https://saucelabs.com/u/joeldenning) | ||
# single-spa | ||
@@ -11,0 +9,0 @@ |
@@ -102,6 +102,3 @@ import { reroute } from './reroute.js'; | ||
// https://github.com/CanopyTax/single-spa/issues/224 and https://github.com/CanopyTax/single-spa-angular/issues/49 | ||
// We need a popstate event even though the browser doesn't do one by default when you call pushState, so that | ||
// all the applications can reroute. | ||
urlReroute(new PopStateEvent('popstate', {state})); | ||
urlReroute(createPopStateEvent(state)); | ||
@@ -114,7 +111,19 @@ return result; | ||
const result = originalReplaceState.apply(this, arguments); | ||
urlReroute(createPopStateEvent(state)); | ||
return result; | ||
} | ||
function createPopStateEvent(state) { | ||
// https://github.com/CanopyTax/single-spa/issues/224 and https://github.com/CanopyTax/single-spa-angular/issues/49 | ||
// We need a popstate event even though the browser doesn't do one by default when you call replaceState, so that | ||
// all the applications can reroute. | ||
urlReroute(new PopStateEvent('popstate', {state})); | ||
return result; | ||
try { | ||
return new PopStateEvent('popstate', {state}); | ||
} catch (err) { | ||
// IE 11 compatibility https://github.com/CanopyTax/single-spa/issues/299 | ||
// https://docs.microsoft.com/en-us/openspecs/ie_standards/ms-html5e/bd560f47-b349-4d2c-baa8-f1560fb489dd | ||
const evt = document.createEvent('PopStateEvent'); | ||
evt.initPopStateEvent('popstate', false, false, state); | ||
return evt; | ||
} | ||
} | ||
@@ -121,0 +130,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
329308
1530
51