@tanstack/react-router 0.0.1-beta.82 → 0.0.1-beta.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* LICENSE.md file in the root directory of this source tree.
|
|
29
29
|
*
|
|
30
30
|
* @license MIT
|
|
31
|
-
*/const u="popstate",l="beforeunload",d=t=>(t.preventDefault(),t.returnValue=""),p=()=>{removeEventListener(l,d,{capture:!0})};function f(t){let e=t.getLocation(),r=()=>{},o=new Set,a=[],s=[];const n=()=>{if(a.length)a[0]?.(n,(()=>{a=[],p()}));else{for(;s.length;)s.shift()?.();c()}},i=t=>{s.push(t),n()},c=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(c)),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(a.push(t),1===a.length&&addEventListener(l,d,{capture:!0}),()=>{a=a.filter((e=>e!==t)),a.length||p()})}}function m(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return f({getLocation:()=>g(e(),history.state),listener:t=>(window.addEventListener(u,t),()=>{window.removeEventListener(u,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:v()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:v()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function y(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return f({getLocation:()=>g(e[r],o),listener:()=>()=>{},pushState:(t,a)=>{o={...a,key:v()},e.push(t),r++},replaceState:(t,a)=>{o={...a,key:v()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function g(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r,o):"",search:o>-1?t.substring(o):"",state:e}}function v(){return(Math.random()+1).toString(36).substring(7)}function w(t){return t[t.length-1]}function b(t,e){return"function"==typeof t?t(e):t}function S(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function _(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||L(t)&&L(r)){const e=o?t.length:Object.keys(t).length,a=o?r:Object.keys(r),s=a.length,n=o?[]:{};let i=0;for(let e=0;e<s;e++){const s=o?e:a[e];n[s]=_(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function L(t){if(!E(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!E(r)&&!!r.hasOwnProperty("isPrototypeOf")}function E(t){return"[object Object]"===Object.prototype.toString.call(t)}function P(t,e){return t===e||typeof t==typeof e&&(L(t)&&L(e)?!Object.keys(e).some((r=>!P(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>P(t,e[r])))))}function x(t){return R(t.filter(Boolean).join("/"))}function R(t){return t.replace(/\/{2,}/g,"/")}function C(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function M(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function k(t){return M(C(t))}function O(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=j(e);const a=j(r);a.forEach(((t,e)=>{if("/"===t.value)e?e===a.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===w(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return R(x([t,...o.map((t=>t.value))]))}function j(t){if(!t)return[];const e=[];if("/"===(t=R(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function A(t,e,r){return x(j(t).map((t=>["$","*"].includes(t.value)&&!r?"":"param"===t.type?e[t.value.substring(1)]??"":t.value)))}function I(t,e,r){const o=$(t,e,r);if(!r.to||o)return o??{}}function $(t,e,r){if(!e.startsWith(t))return;const o=j(e="/"!=t?e.substring(t.length):e),a=j(`${r.to??"$"}`);"/"===w(o)?.value&&o.pop();const s={};return(()=>{for(let t=0;t<Math.max(o.length,a.length);t++){const e=o[t],n=a[t],i=t===a.length-1,c=t===o.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s["*"]=x(o.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?s:void 0}function T(t,e){var r,o,a,s="";for(r in t)if(void 0!==(a=t[r]))if(Array.isArray(a))for(o=0;o<a.length;o++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a[o]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a);return(e||"")+s}function D(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function N(t){for(var e,r,o={},a=t.split("&");e=a.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],D(e.shift())):o[r]=D(e.shift());return o}const H="__root__";class B{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=H:n(this.parentRoute);let o=r?H:e.path;o&&"/"!==o&&(o=k(o));const a=e?.id||o;let s=r?H:x([this.parentRoute.id===H?"":this.parentRoute.id,a]);o===H&&(o="/"),s!==H&&(s=x(["/",s]));const i=s===H?"/":M(x([this.parentRoute.fullPath,o]));this.path=o,this.id=s,this.fullPath=i};addChildren=t=>(this.children=t,this)}class F extends B{constructor(t){super(t)}static withRouterContext=()=>t=>new F(t)}const U=q(JSON.parse),z=W(JSON.stringify);function q(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=N(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function W(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=T(e).toString();return r?`?${r}`:""}}const K=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),o=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(o.ok)return o.json();throw new Error("Failed to fetch match data")};class V{#e;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??z,parseSearch:t?.parseSearch??U,fetchServerDataFn:t?.fetchServerDataFn??K},this.__store=new c(G(),{onUpdate:t=>{this.state=t}}),this.state=this.__store.state,this.basepath="",this.update(t),this.options.Router?.(this);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.latestLocation.href!==e.href&&this.#r({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,G())))};mount=()=>(J||this.state.currentMatches.length||this.safeLoad(),()=>{});update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#e&&this.#e(),this.history=this.options.history??(J?y():m());const t=this.#o();this.__store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#e=this.history.listen((()=>{this.safeLoad({next:this.#o(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${k(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#a(r)),this};buildNext=t=>{const e=this.#s(t),r=this.matchRoutes(e.pathname);return this.#s({...t,__matches:r})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),n(!1)}))};load=async t=>{let e=Date.now();const r=e;let o;if(this.startedLoadingAt=r,this.cancelMatches(),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,latestLocation:t.next}))),o=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatches:o,pendingLocation:this.state.latestLocation})))})),await this.loadMatches(o,this.state.pendingLocation),this.startedLoadingAt!==r)return this.navigationPromise;const a=this.state.currentMatches,s=[],n=[];a.forEach((t=>{o.find((e=>e.id===t.id))?n.push(t):s.push(t)}));const i=o.filter((t=>!a.find((e=>e.id===t.id))));e=Date.now(),s.forEach((t=>{t.__onExit?.({params:t.params,search:t.state.routeSearch}),"error"===t.state.status&&this.__store.setState((t=>({...t,status:"idle",error:void 0})))})),n.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),i.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})}));const c=this.state.currentLocation;this.__store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:o,pendingLocation:void 0,pendingMatches:void 0}))),o.forEach((t=>{t.__commit()})),c.href!==this.state.currentLocation.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return n(e),e};loadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e),r};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e,{preload:!0}),r};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const o=[...this.state.currentMatches,...this.state.pendingMatches??[]],a=async s=>{let n=w(r)?.params??{};const i=this.options.filterRoutes?.(s)??s;let c=[];const h=(r,o)=>(o.some((o=>{const a=o.children;if(!o.path&&a?.length)return h([...c,o],a);const s=!("/"===o.path&&!a?.length),i=I(this.basepath,t,{to:o.fullPath,fuzzy:s,caseSensitive:o.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=o.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,o]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=A(t.path,n),a=A(t.id,n,!0),s=o.find((t=>t.id===a))||new Y(this,t,{id:a,params:n,pathname:x([this.basepath,e])});r.push(s)}));const u=w(c).children;u?.length&&a(u)};return a([this.routeTree]),r};loadMatches=async(t,e,r)=>{let o;try{await Promise.all(t.map((async(t,e)=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(r){if(Q(r))throw r;o=o??e;const a=t.route.options.onBeforeLoadError??t.route.options.onError;try{a?.(r)}catch(e){if(Q(e))throw e;return void t.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}t.__store.setState((t=>({...t,error:r,status:"error",updatedAt:Date.now()})))}})))}catch(t){if(Q(t))return void(r?.preload||this.navigate(t));throw t}const a=t.slice(0,o),s=a.map((async(t,o)=>{const s=a[o-1];t.__load({preload:r?.preload,location:e,parentMatch:s}),await t.__loadPromise,s&&await s.__loadPromise}));await Promise.all(s)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>O(this.basepath,t,R(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:a,params:s})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return n(!h),this.#r({from:c,to:i,search:r,hash:o,replace:a,params:s})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),o=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!o)return!1;const a=I(this.basepath,o.pathname,{...e,to:r.pathname});return!!a&&(e?.includeSearch??1?!!P(o.search,r.search)&&a:a)};buildLink=({from:t,to:e=".",search:r,params:o,hash:a,target:s,replace:n,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:a,replace:n},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.currentLocation.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.currentLocation.pathname===d.pathname:m,g=!i?.includeHash||this.state.currentLocation.hash===d.hash,v=!(i?.includeSearch??1)||P(this.state.currentLocation.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),this.#r(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:{...S(this.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.state.currentMatches.map((t=>({id:t.id,state:{status:t.state.status}})))}});hydrate=t=>{this.__store.setState((e=>{const r=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return r.forEach(((e,r)=>{const o=t.state.currentMatches[r];n(o&&o.id===e.id),e.__store.setState((t=>({...t,...o.state})))})),{...e,...t.state,currentMatches:r}}))};#a=t=>{const e=(t,r)=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});n(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t;const o=t.children;o?.length&&(e(o),t.children=o.map(((t,e)=>{const r=j(C(R(t.path??"/")));for(;r.length>1&&"/"===r[0]?.value;)r.shift();let o=0;return r.forEach(((t,e)=>{let r=1;for(;e--;)r*=.001;"pathname"===t.type&&"/"!==t.value?o+=1*r:"param"===t.type?o+=2*r:"wildcard"===t.type&&(o+=3*r)})),{child:t,parsed:r,index:e,score:o}})).sort(((t,e)=>t.score!==e.score?t.score-e.score:t.index-e.index)).map((t=>t.child)))}))};e([t]);const r=(t,e)=>{t.forEach((t=>{t.isRoot?n(!e):n(!e||t.parentRoute===e,(t.path,t.parentRoute?.id,e?.id)),t.children&&r(t.children,t)}))};return r([t],void 0),t};#o=t=>{let{pathname:e,search:r,hash:o,state:a}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:_(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:a,key:a?.key||"__init__"}};#s=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=O(this.basepath??"/",e,`${t.to??""}`);const o={...w(this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}))?.params};let a=!0===(t.params??!0)?o:b(t.params,o);a&&t.__matches?.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{a={...a,...t(a)}})),r=A(r,a??{});const s=t.__matches?.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean)??[],n=t.__matches?.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean)??[],i=s?.length?s?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,c=!0===t.search?i:t.search?b(t.search,i)??{}:s?.length?i:{},h=n?.length?n.reduce(((t,e)=>e(t)),c):c,u=_(this.state.latestLocation.search,h),l=this.options.stringifySearch(u);let d=!0===t.hash?this.state.latestLocation.hash:b(t.hash,this.state.latestLocation.hash);d=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.latestLocation.state:b(t.state,this.state.latestLocation.state),hash:d,href:this.history.createHref(`${r}${l}${d}`),key:t.key}};#r=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.latestLocation.href===e.href&&!e.key&&(o="replace");const a=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](a,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const J="undefined"==typeof window||!window.document.createElement;function G(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function Q(t){return!!t?.isRedirect}const X=["component","errorComponent","pendingComponent"];class Y{abortController=new AbortController;constructor(t,e,r){Object.assign(this,{route:e,router:t,id:r.id,pathname:r.pathname,params:r.params,__store:new c({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.__store.state,X.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"idle"!==this.state.status||this.#n()||this.__store.setState((t=>({...t,status:"success"})))}#n=()=>!(!this.route.options.onLoad&&!X.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:o}=this.#i({location:this.router.state.currentLocation});this.context=r,this.routeContext=o,this.__store.setState((r=>({...r,routeSearch:_(r.routeSearch,t),search:_(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#c=t=>{const e=this.parentMatch?this.parentMatch.#c(t):{search:t.location.search,routeSearch:t.location.search};try{const t=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(e.search)??{};return{routeSearch:t,search:{...e.search,...t}}}catch(t){if(Q(t))throw t;(this.route.options.onValidateSearchError??this.route.options.onError)?.(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#i=t=>{const{search:e,routeSearch:r}=this.#c(t);try{const t=this.route.options.getContext?.({parentContext:this.parentMatch?.routeContext??{},context:this.parentMatch?.context??this.router?.options.context??{},params:this.params,search:e})||{};return{routeSearch:r,search:e,context:{...this.parentMatch?.context??this.router?.options.context,...t},routeContext:t}}catch(t){throw this.route.options.onError?.(t),t}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#i(t)}catch(e){return Q(e)?void(t?.preload||this.router.navigate(e)):void this.__store.setState((t=>({...t,status:"error",error:e})))}const{routeSearch:r,search:o,context:a,routeContext:s}=e;if("pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#h=e;const n=()=>e!==this.#h?this.__loadPromise:void 0;let i;"idle"===this.state.status&&this.__store.setState((t=>({...t,status:"pending"})));const c=(async()=>{await Promise.all(X.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),h=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,routeSearch:r,search:o,signal:this.abortController.signal,preload:!!t?.preload,routeContext:s,context:a})}));try{if(await Promise.all([c,h]),i=n())return await i;this.__store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(e){if(Q(e))return void(t?.preload||this.router.navigate(e));const r=this.route.options.onLoadError??this.route.options.onError;try{r?.(e)}catch(e){return Q(e)?void(t?.preload||this.router.navigate(e)):void this.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}this.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#h=""}
|
|
31
|
+
*/const u="popstate",l="beforeunload",d=t=>(t.preventDefault(),t.returnValue=""),p=()=>{removeEventListener(l,d,{capture:!0})};function f(t){let e=t.getLocation(),r=()=>{},o=new Set,a=[],s=[];const n=()=>{if(a.length)a[0]?.(n,(()=>{a=[],p()}));else{for(;s.length;)s.shift()?.();c()}},i=t=>{s.push(t),n()},c=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(c)),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(a.push(t),1===a.length&&addEventListener(l,d,{capture:!0}),()=>{a=a.filter((e=>e!==t)),a.length||p()})}}function m(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return f({getLocation:()=>g(e(),history.state),listener:t=>(window.addEventListener(u,t),()=>{window.removeEventListener(u,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:v()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:v()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function y(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return f({getLocation:()=>g(e[r],o),listener:()=>()=>{},pushState:(t,a)=>{o={...a,key:v()},e.push(t),r++},replaceState:(t,a)=>{o={...a,key:v()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function g(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r,o):"",search:o>-1?t.substring(o):"",state:e}}function v(){return(Math.random()+1).toString(36).substring(7)}function w(t){return t[t.length-1]}function b(t,e){return"function"==typeof t?t(e):t}function S(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function _(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||L(t)&&L(r)){const e=o?t.length:Object.keys(t).length,a=o?r:Object.keys(r),s=a.length,n=o?[]:{};let i=0;for(let e=0;e<s;e++){const s=o?e:a[e];n[s]=_(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function L(t){if(!E(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!E(r)&&!!r.hasOwnProperty("isPrototypeOf")}function E(t){return"[object Object]"===Object.prototype.toString.call(t)}function P(t,e){return t===e||typeof t==typeof e&&(L(t)&&L(e)?!Object.keys(e).some((r=>!P(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>P(t,e[r])))))}function x(t){return R(t.filter(Boolean).join("/"))}function R(t){return t.replace(/\/{2,}/g,"/")}function C(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function M(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function k(t){return M(C(t))}function O(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=j(e);const a=j(r);a.forEach(((t,e)=>{if("/"===t.value)e?e===a.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===w(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return R(x([t,...o.map((t=>t.value))]))}function j(t){if(!t)return[];const e=[];if("/"===(t=R(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function A(t,e,r){return x(j(t).map((t=>["$","*"].includes(t.value)&&!r?"":"param"===t.type?e[t.value.substring(1)]??"":t.value)))}function I(t,e,r){const o=$(t,e,r);if(!r.to||o)return o??{}}function $(t,e,r){if(!e.startsWith(t))return;const o=j(e="/"!=t?e.substring(t.length):e),a=j(`${r.to??"$"}`);"/"===w(o)?.value&&o.pop();const s={};return(()=>{for(let t=0;t<Math.max(o.length,a.length);t++){const e=o[t],n=a[t],i=t===a.length-1,c=t===o.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s["*"]=x(o.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?s:void 0}function T(t,e){var r,o,a,s="";for(r in t)if(void 0!==(a=t[r]))if(Array.isArray(a))for(o=0;o<a.length;o++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a[o]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a);return(e||"")+s}function D(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function N(t){for(var e,r,o={},a=t.split("&");e=a.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],D(e.shift())):o[r]=D(e.shift());return o}const H="__root__";class B{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=H:n(this.parentRoute);let o=r?H:e.path;o&&"/"!==o&&(o=k(o));const a=e?.id||o;let s=r?H:x([this.parentRoute.id===H?"":this.parentRoute.id,a]);o===H&&(o="/"),s!==H&&(s=x(["/",s]));const i=s===H?"/":M(x([this.parentRoute.fullPath,o]));this.path=o,this.id=s,this.fullPath=i};addChildren=t=>(this.children=t,this)}class F extends B{constructor(t){super(t)}static withRouterContext=()=>t=>new F(t)}const U=q(JSON.parse),z=W(JSON.stringify);function q(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=N(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function W(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=T(e).toString();return r?`?${r}`:""}}const K=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),o=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(o.ok)return o.json();throw new Error("Failed to fetch match data")};class V{#e;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??z,parseSearch:t?.parseSearch??U,fetchServerDataFn:t?.fetchServerDataFn??K},this.__store=new c(G(),{onUpdate:t=>{this.state=t}}),this.state=this.__store.state,this.basepath="",this.update(t),this.options.Router?.(this);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.latestLocation.href!==e.href&&this.#r({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,G())))};mount=()=>(J||this.state.currentMatches.length||this.safeLoad(),()=>{});update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#e&&this.#e(),this.history=this.options.history??(J?y():m());const t=this.#o();this.__store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#e=this.history.listen((()=>{this.safeLoad({next:this.#o(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${k(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#a(r)),this};buildNext=t=>{const e=this.#s(t),r=this.matchRoutes(e.pathname);return this.#s({...t,__matches:r})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),n(!1)}))};load=async t=>{let e=Date.now();const r=e;let o;if(this.startedLoadingAt=r,this.cancelMatches(),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,latestLocation:t.next}))),o=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatches:o,pendingLocation:this.state.latestLocation})))})),await this.loadMatches(o,this.state.pendingLocation),this.startedLoadingAt!==r)return this.navigationPromise;const a=this.state.currentMatches,s=[],n=[];a.forEach((t=>{o.find((e=>e.id===t.id))?n.push(t):s.push(t)}));const i=o.filter((t=>!a.find((e=>e.id===t.id))));e=Date.now(),s.forEach((t=>{t.__onExit?.({params:t.params,search:t.state.routeSearch}),"error"===t.state.status&&this.__store.setState((t=>({...t,status:"idle",error:void 0})))})),n.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),i.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})}));const c=this.state.currentLocation;this.__store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:o,pendingLocation:void 0,pendingMatches:void 0}))),o.forEach((t=>{t.__commit()})),c.href!==this.state.currentLocation.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return n(e),e};loadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e),r};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e,{preload:!0}),r};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const o=[...this.state.currentMatches,...this.state.pendingMatches??[]],a=async s=>{let n=w(r)?.params??{};const i=this.options.filterRoutes?.(s)??s;let c=[];const h=(r,o)=>(o.some((o=>{const a=o.children;if(!o.path&&a?.length)return h([...c,o],a);const s=!("/"===o.path&&!a?.length),i=I(this.basepath,t,{to:o.fullPath,fuzzy:s,caseSensitive:o.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=o.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,o]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=A(t.path,n),a=A(t.id,n,!0),s=o.find((t=>t.id===a))||new Y(this,t,{id:a,params:n,pathname:x([this.basepath,e])});r.push(s)}));const u=w(c).children;u?.length&&a(u)};return a([this.routeTree]),r};loadMatches=async(t,e,r)=>{let o;try{await Promise.all(t.map((async(t,e)=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(r){if(Q(r))throw r;o=o??e;const a=t.route.options.onBeforeLoadError??t.route.options.onError;try{a?.(r)}catch(e){if(Q(e))throw e;return void t.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}t.__store.setState((t=>({...t,error:r,status:"error",updatedAt:Date.now()})))}})))}catch(t){if(Q(t))return void(r?.preload||this.navigate(t));throw t}const a=t.slice(0,o),s=a.map((async(t,o)=>{const s=a[o-1];t.__load({preload:r?.preload,location:e,parentMatch:s}),await t.__loadPromise,s&&await s.__loadPromise}));await Promise.all(s)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>O(this.basepath,t,R(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:a,params:s})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return n(!h),this.#r({from:c,to:i,search:r,hash:o,replace:a,params:s})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),o=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!o)return!1;const a=I(this.basepath,o.pathname,{...e,to:r.pathname});return!!a&&(e?.includeSearch??1?!!P(o.search,r.search)&&a:a)};buildLink=({from:t,to:e=".",search:r,params:o,hash:a,target:s,replace:n,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:a,replace:n},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.currentLocation.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.currentLocation.pathname===d.pathname:m,g=!i?.includeHash||this.state.currentLocation.hash===d.hash,v=!(i?.includeSearch??1)||P(this.state.currentLocation.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),this.#r(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:{...S(this.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.state.currentMatches.map((t=>({id:t.id,state:{status:t.state.status}})))}});hydrate=t=>{this.__store.setState((e=>{const r=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return r.forEach(((e,r)=>{const o=t.state.currentMatches[r];n(o&&o.id===e.id),e.__store.setState((t=>({...t,...o.state})))})),{...e,...t.state,currentMatches:r}}))};#a=t=>{const e=(t,r)=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});n(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t;const o=t.children;o?.length&&(e(o),t.children=o.map(((t,e)=>{const r=j(C(R(t.path??"/")));for(;r.length>1&&"/"===r[0]?.value;)r.shift();let o=0;return r.forEach(((t,e)=>{let r=1;for(;e--;)r*=.001;"pathname"===t.type&&"/"!==t.value?o+=1*r:"param"===t.type?o+=2*r:"wildcard"===t.type&&(o+=3*r)})),{child:t,parsed:r,index:e,score:o}})).sort(((t,e)=>t.score!==e.score?t.score-e.score:t.index-e.index)).map((t=>t.child)))}))};e([t]);const r=(t,e)=>{t.forEach((t=>{t.isRoot?n(!e):n(!e||t.parentRoute===e,(t.path,t.parentRoute?.id,e?.id)),t.children&&r(t.children,t)}))};return r([t],void 0),t};#o=t=>{let{pathname:e,search:r,hash:o,state:a}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:_(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:a,key:a?.key||"__init__"}};#s=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=O(this.basepath??"/",e,`${t.to??""}`);const o={...w(this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}))?.params};let a=!0===(t.params??!0)?o:b(t.params,o);a&&t.__matches?.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{a={...a,...t(a)}})),r=A(r,a??{});const s=t.__matches?.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean)??[],n=t.__matches?.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean)??[],i=s?.length?s?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,c=!0===t.search?i:t.search?b(t.search,i)??{}:s?.length?i:{},h=n?.length?n.reduce(((t,e)=>e(t)),c):c,u=_(this.state.latestLocation.search,h),l=this.options.stringifySearch(u);let d=!0===t.hash?this.state.latestLocation.hash:b(t.hash,this.state.latestLocation.hash);d=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.latestLocation.state:b(t.state,this.state.latestLocation.state),hash:d,href:this.history.createHref(`${r}${l}${d}`),key:t.key}};#r=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.latestLocation.href===e.href&&!e.key&&(o="replace");const a=`${e.pathname}${e.searchStr}${e.hash?`${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](a,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const J="undefined"==typeof window||!window.document.createElement;function G(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function Q(t){return!!t?.isRedirect}const X=["component","errorComponent","pendingComponent"];class Y{abortController=new AbortController;constructor(t,e,r){Object.assign(this,{route:e,router:t,id:r.id,pathname:r.pathname,params:r.params,__store:new c({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.__store.state,X.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"idle"!==this.state.status||this.#n()||this.__store.setState((t=>({...t,status:"success"})))}#n=()=>!(!this.route.options.onLoad&&!X.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:o}=this.#i({location:this.router.state.currentLocation});this.context=r,this.routeContext=o,this.__store.setState((r=>({...r,routeSearch:_(r.routeSearch,t),search:_(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#c=t=>{const e=this.parentMatch?this.parentMatch.#c(t):{search:t.location.search,routeSearch:t.location.search};try{const t=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(e.search)??{};return{routeSearch:t,search:{...e.search,...t}}}catch(t){if(Q(t))throw t;(this.route.options.onValidateSearchError??this.route.options.onError)?.(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#i=t=>{const{search:e,routeSearch:r}=this.#c(t);try{const t=this.route.options.getContext?.({parentContext:this.parentMatch?.routeContext??{},context:this.parentMatch?.context??this.router?.options.context??{},params:this.params,search:e})||{};return{routeSearch:r,search:e,context:{...this.parentMatch?.context??this.router?.options.context,...t},routeContext:t}}catch(t){throw this.route.options.onError?.(t),t}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#i(t)}catch(e){return Q(e)?void(t?.preload||this.router.navigate(e)):void this.__store.setState((t=>({...t,status:"error",error:e})))}const{routeSearch:r,search:o,context:a,routeContext:s}=e;if("pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#h=e;const n=()=>e!==this.#h?this.__loadPromise:void 0;let i;"idle"===this.state.status&&this.__store.setState((t=>({...t,status:"pending"})));const c=(async()=>{await Promise.all(X.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),h=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,routeSearch:r,search:o,signal:this.abortController.signal,preload:!!t?.preload,routeContext:s,context:a})}));try{if(await Promise.all([c,h]),i=n())return await i;this.__store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(e){if(Q(e))return void(t?.preload||this.router.navigate(e));const r=this.route.options.onLoadError??this.route.options.onError;try{r?.(e)}catch(e){return Q(e)?void(t?.preload||this.router.navigate(e)):void this.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}this.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#h=""}
|
|
32
32
|
/**
|
|
33
33
|
* react-store
|
|
34
34
|
*
|