@tanstack/react-router
Advanced tools
Comparing version 0.0.1-beta.71 to 0.0.1-beta.72
@@ -10,3 +10,3 @@ { | ||
{ | ||
"uid": "48bd-109", | ||
"uid": "7ba6-109", | ||
"name": "\u0000rollupPluginBabelHelpers.js" | ||
@@ -19,7 +19,7 @@ }, | ||
"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
"uid": "48bd-111" | ||
"uid": "7ba6-111" | ||
}, | ||
{ | ||
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js", | ||
"uid": "48bd-113" | ||
"uid": "7ba6-113" | ||
} | ||
@@ -33,15 +33,15 @@ ] | ||
"name": "store/build/esm/index.js", | ||
"uid": "48bd-115" | ||
"uid": "7ba6-115" | ||
}, | ||
{ | ||
"name": "router/build/esm/index.js", | ||
"uid": "48bd-117" | ||
"uid": "7ba6-117" | ||
}, | ||
{ | ||
"name": "react-store/build/esm/index.js", | ||
"uid": "48bd-119" | ||
"uid": "7ba6-119" | ||
}, | ||
{ | ||
"name": "react-router/src/index.tsx", | ||
"uid": "48bd-121" | ||
"uid": "7ba6-121" | ||
} | ||
@@ -56,50 +56,50 @@ ] | ||
"nodeParts": { | ||
"48bd-109": { | ||
"7ba6-109": { | ||
"renderedLength": 429, | ||
"gzipLength": 238, | ||
"brotliLength": 0, | ||
"mainUid": "48bd-108" | ||
"mainUid": "7ba6-108" | ||
}, | ||
"48bd-111": { | ||
"7ba6-111": { | ||
"renderedLength": 181, | ||
"gzipLength": 129, | ||
"brotliLength": 0, | ||
"mainUid": "48bd-110" | ||
"mainUid": "7ba6-110" | ||
}, | ||
"48bd-113": { | ||
"7ba6-113": { | ||
"renderedLength": 44, | ||
"gzipLength": 62, | ||
"brotliLength": 0, | ||
"mainUid": "48bd-112" | ||
"mainUid": "7ba6-112" | ||
}, | ||
"48bd-115": { | ||
"7ba6-115": { | ||
"renderedLength": 1288, | ||
"gzipLength": 497, | ||
"brotliLength": 0, | ||
"mainUid": "48bd-114" | ||
"mainUid": "7ba6-114" | ||
}, | ||
"48bd-117": { | ||
"renderedLength": 46374, | ||
"gzipLength": 11002, | ||
"7ba6-117": { | ||
"renderedLength": 46930, | ||
"gzipLength": 11106, | ||
"brotliLength": 0, | ||
"mainUid": "48bd-116" | ||
"mainUid": "7ba6-116" | ||
}, | ||
"48bd-119": { | ||
"7ba6-119": { | ||
"renderedLength": 1571, | ||
"gzipLength": 594, | ||
"brotliLength": 0, | ||
"mainUid": "48bd-118" | ||
"mainUid": "7ba6-118" | ||
}, | ||
"48bd-121": { | ||
"7ba6-121": { | ||
"renderedLength": 12514, | ||
"gzipLength": 3242, | ||
"brotliLength": 0, | ||
"mainUid": "48bd-120" | ||
"mainUid": "7ba6-120" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"48bd-108": { | ||
"7ba6-108": { | ||
"id": "\u0000rollupPluginBabelHelpers.js", | ||
"moduleParts": { | ||
"index.production.js": "48bd-109" | ||
"index.production.js": "7ba6-109" | ||
}, | ||
@@ -109,10 +109,10 @@ "imported": [], | ||
{ | ||
"uid": "48bd-120" | ||
"uid": "7ba6-120" | ||
} | ||
] | ||
}, | ||
"48bd-110": { | ||
"7ba6-110": { | ||
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
"moduleParts": { | ||
"index.production.js": "48bd-111" | ||
"index.production.js": "7ba6-111" | ||
}, | ||
@@ -122,10 +122,10 @@ "imported": [], | ||
{ | ||
"uid": "48bd-116" | ||
"uid": "7ba6-116" | ||
} | ||
] | ||
}, | ||
"48bd-112": { | ||
"7ba6-112": { | ||
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js", | ||
"moduleParts": { | ||
"index.production.js": "48bd-113" | ||
"index.production.js": "7ba6-113" | ||
}, | ||
@@ -135,10 +135,10 @@ "imported": [], | ||
{ | ||
"uid": "48bd-116" | ||
"uid": "7ba6-116" | ||
} | ||
] | ||
}, | ||
"48bd-114": { | ||
"7ba6-114": { | ||
"id": "/packages/store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "48bd-115" | ||
"index.production.js": "7ba6-115" | ||
}, | ||
@@ -148,20 +148,20 @@ "imported": [], | ||
{ | ||
"uid": "48bd-116" | ||
"uid": "7ba6-116" | ||
} | ||
] | ||
}, | ||
"48bd-116": { | ||
"7ba6-116": { | ||
"id": "/packages/router/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "48bd-117" | ||
"index.production.js": "7ba6-117" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "48bd-110" | ||
"uid": "7ba6-110" | ||
}, | ||
{ | ||
"uid": "48bd-112" | ||
"uid": "7ba6-112" | ||
}, | ||
{ | ||
"uid": "48bd-114" | ||
"uid": "7ba6-114" | ||
} | ||
@@ -171,14 +171,14 @@ ], | ||
{ | ||
"uid": "48bd-120" | ||
"uid": "7ba6-120" | ||
} | ||
] | ||
}, | ||
"48bd-118": { | ||
"7ba6-118": { | ||
"id": "/packages/react-store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "48bd-119" | ||
"index.production.js": "7ba6-119" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "48bd-123" | ||
"uid": "7ba6-123" | ||
} | ||
@@ -188,23 +188,23 @@ ], | ||
{ | ||
"uid": "48bd-120" | ||
"uid": "7ba6-120" | ||
} | ||
] | ||
}, | ||
"48bd-120": { | ||
"7ba6-120": { | ||
"id": "/packages/react-router/src/index.tsx", | ||
"moduleParts": { | ||
"index.production.js": "48bd-121" | ||
"index.production.js": "7ba6-121" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "48bd-108" | ||
"uid": "7ba6-108" | ||
}, | ||
{ | ||
"uid": "48bd-122" | ||
"uid": "7ba6-122" | ||
}, | ||
{ | ||
"uid": "48bd-116" | ||
"uid": "7ba6-116" | ||
}, | ||
{ | ||
"uid": "48bd-118" | ||
"uid": "7ba6-118" | ||
} | ||
@@ -215,3 +215,3 @@ ], | ||
}, | ||
"48bd-122": { | ||
"7ba6-122": { | ||
"id": "react", | ||
@@ -222,3 +222,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "48bd-120" | ||
"uid": "7ba6-120" | ||
} | ||
@@ -228,3 +228,3 @@ ], | ||
}, | ||
"48bd-123": { | ||
"7ba6-123": { | ||
"id": "use-sync-external-store/shim/with-selector", | ||
@@ -235,3 +235,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "48bd-118" | ||
"uid": "7ba6-118" | ||
} | ||
@@ -238,0 +238,0 @@ ], |
@@ -31,3 +31,3 @@ /** | ||
* @license MIT | ||
*/const h="popstate";function u(t){let e=t.getLocation(),r=()=>{},a=new Set;const o=()=>{e=t.getLocation(),a.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===a.size&&(r=t.listener(o)),a.add(e),()=>{a.delete(e),0===a.size&&r()}),push:(e,r)=>{t.pushState(e,r),o()},replace:(e,r)=>{t.replaceState(e,r),o()},go:e=>{t.go(e),o()},back:()=>{t.back(),o()},forward:()=>{t.forward(),o()}}}function l(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return u({getLocation:()=>d(e(),history.state),listener:t=>(window.addEventListener(h,t),()=>{window.removeEventListener(h,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:f()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:f()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function p(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,a={};return u({getLocation:()=>d(e[r],a),listener:()=>()=>{},pushState:(t,o)=>{a={...o,key:f()},e.push(t),r++},replaceState:(t,o)=>{a={...o,key:f()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t)})}function d(t,e){let r=t.indexOf("#"),a=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?a>0?Math.min(r,a):r:a>0?a:t.length),hash:r>-1?t.substring(r,a):"",search:a>-1?t.substring(a):"",state:e}}function f(){return(Math.random()+1).toString(36).substring(7)}function m(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function g(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function v(t,e){if(t===e)return t;const r=e,a=Array.isArray(t)&&Array.isArray(r);if(a||S(t)&&S(r)){const e=a?t.length:Object.keys(t).length,o=a?r:Object.keys(r),s=o.length,n=a?[]:{};let i=0;for(let e=0;e<s;e++){const s=a?e:o[e];n[s]=v(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function S(t){if(!w(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!w(r)&&!!r.hasOwnProperty("isPrototypeOf")}function w(t){return"[object Object]"===Object.prototype.toString.call(t)}function b(t,e){return t===e||typeof t==typeof e&&(S(t)&&S(e)?!Object.keys(e).some((r=>!b(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>b(t,e[r])))))}function L(t){return E(t.filter(Boolean).join("/"))}function E(t){return t.replace(/\/{2,}/g,"/")}function P(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function x(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function C(t){return x(P(t))}function R(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let a=_(e);const o=_(r);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&a.push(t):a=[t];else if(".."===t.value)a.length>1&&"/"===m(a)?.value&&a.pop(),a.pop();else{if("."===t.value)return;a.push(t)}}));return E(L([t,...a.map((t=>t.value))]))}function _(t){if(!t)return[];const e=[];if("/"===(t=E(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 M(t,e,r){return L(_(t).map((t=>["$","*"].includes(t.value)&&!r?"":"param"===t.type?e[t.value.substring(1)]??"":t.value)))}function k(t,e,r){const a=O(t,e,r);if(!r.to||a)return a??{}}function O(t,e,r){if(!e.startsWith(t))return;const a=_(e="/"!=t?e.substring(t.length):e),o=_(`${r.to??"$"}`);"/"===m(a)?.value&&a.pop();const s={};return(()=>{for(let t=0;t<Math.max(a.length,o.length);t++){const e=a[t],n=o[t],i=t===o.length-1,c=t===a.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s["*"]=L(a.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 j(t,e){var r,a,o,s="";for(r in t)if(void 0!==(o=t[r]))if(Array.isArray(o))for(a=0;a<o.length;a++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(o[a]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(e||"")+s}function I(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function $(t){for(var e,r,a={},o=t.split("&");e=o.shift();)void 0!==a[r=(e=e.split("=")).shift()]?a[r]=[].concat(a[r],I(e.shift())):a[r]=I(e.shift());return a}const A="__root__";class T{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,a=this.options?.getParentRoute?.();r?this.path=A:n(a);let o=r?A:e.path;o&&"/"!==o&&(o=C(o));const s=e?.id||o;let i=r?A:L([a.id===A?"":a.id,s]);o===A&&(o="/"),i!==A&&(i=L(["/",i]));const c=i===A?"/":x(L([a.fullPath,o]));this.path=o,this.id=i,this.fullPath=c};addChildren=t=>(this.children=t,this);generate=t=>{n(!1)}}class D extends T{constructor(t){super(t)}static withRouterContext=()=>t=>new D(t)}const F=B(JSON.parse),N=H(JSON.stringify);function B(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=$(e);for(let e in r){const a=r[e];if("string"==typeof a)try{r[e]=t(a)}catch(t){}}return r}}function H(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const a=e[r];if(void 0===a||void 0===a)delete e[r];else if(a&&"object"==typeof a&&null!==a)try{e[r]=t(a)}catch(t){}}));const r=j(e).toString();return r?`?${r}`:""}}const U=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),a=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(a.ok)return a.json();throw new Error("Failed to fetch match data")};class z{#e;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??N,parseSearch:t?.parseSearch??F,fetchServerDataFn:t?.fetchServerDataFn??U},this.store=new c(W(),{onUpdate:t=>{this.state=t}}),this.state=this.store.state,this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,W())))};mount=()=>(q||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??(q?p():l());const t=this.#r();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#e=this.history.listen((()=>{this.safeLoad({next:this.#r(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${C(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#a(r)),this};buildNext=t=>{const e=this.#o(t),r=this.matchRoutes(e.pathname),a=r.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),o=r.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#o({...t,__preSearchFilters:a,__postSearchFilters:o})};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 a;if(this.startedLoadingAt=r,this.cancelMatches(),this.store.batch((()=>{t?.next&&this.store.setState((e=>({...e,latestLocation:t.next}))),a=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:a,pendingLocation:this.state.latestLocation})))})),await this.loadMatches(a,this.state.pendingLocation),this.startedLoadingAt!==r)return this.navigationPromise;const o=this.state.currentMatches,s=[],n=[];o.forEach((t=>{a.find((e=>e.id===t.id))?n.push(t):s.push(t)}));const i=a.filter((t=>!o.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:a,pendingLocation:void 0,pendingMatches:void 0}))),a.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 a=[...this.state.currentMatches,...this.state.pendingMatches??[]],o=async s=>{let n=m(r)?.params??{};const i=this.options.filterRoutes?.(s)??s;let c=[];const h=(r,a)=>(a.some((a=>{const o=a.children;if(!a.path&&o?.length)return h([...c,a],o);const s=!("/"===a.path&&!o?.length),i=k(this.basepath,t,{to:a.fullPath,fuzzy:s,caseSensitive:a.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=a.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,a]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=M(t.path,n),o=M(t.id,n,!0),s=a.find((t=>t.id===o))||new V(this,t,{id:o,params:n,pathname:L([this.basepath,e])});r.push(s)}));const u=m(c).children;u?.length&&o(u)};return o([this.routeTree]),r};loadMatches=async(t,e,r)=>{await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(e){throw r?.preload||t.route.options.onBeforeLoadError?.(e),t.route.options.onError?.(e),e}})));const a=t.map((async(a,o)=>{const s=t[o-1];a.__load({preload:r?.preload,location:e,parentMatch:s}),await a.__loadPromise,s&&await s.__loadPromise}));await Promise.all(a)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>R(this.basepath,t,E(e));navigate=async({from:t,to:e="",search:r,hash:a,replace:o,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.#s({from:c,to:i,search:r,hash:a,replace:o,params:s})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),a=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!a)return!1;const o=k(this.basepath,a.pathname,{...e,to:r.pathname});return!!o&&(e?.includeSearch??1?!!b(a.search,r.search)&&o:o)};buildLink=({from:t,to:e=".",search:r,params:a,hash:o,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:a,hash:o,replace:n},p=this.buildNext(l);c=c??this.options.defaultPreload;const d=h??this.options.defaultPreloadDelay??0,f=this.state.currentLocation.pathname.split("/"),m=p.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.currentLocation.pathname===p.pathname:m,g=!i?.includeHash||this.state.currentLocation.hash===p.hash,v=!(i?.includeSearch??1)||b(this.state.currentLocation.search,p.search);return{type:"internal",next:p,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.#s(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! ☝️")}))}),d)}},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:{...g(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 a=t.state.currentMatches[r];n(a&&a.id===e.id),e.store.setState((t=>({...t,...a.state})))})),{...e,...t.state,currentMatches:r}}))};#a=t=>{const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(this.routesById[t.id])throw new Error;this.routesById[t.id]=t;const a=t.children;a?.length&&(e(a),t.children=a.map(((t,e)=>{const r=_(P(E(t.path??"/")));for(;r.length>1&&"/"===r[0]?.value;)r.shift();let a=0;return r.forEach(((t,e)=>{let r=1;for(;e--;)r*=.001;"pathname"===t.type&&"/"!==t.value?a+=1*r:"param"===t.type?a+=2*r:"wildcard"===t.type&&(a+=3*r)})),{child:t,parsed:r,index:e,score:a}})).sort(((t,e)=>t.score!==e.score?t.score-e.score:t.index-e.index)).map((t=>t.child)))}))};return e([t]),t};#r=t=>{let{pathname:e,search:r,hash:a,state:o}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,s),hash:a.split("#").reverse()[0]??"",href:`${e}${r}${a}`,state:o,key:o?.key||"__init__"}};#o=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=R(this.basepath??"/",e,`${t.to??""}`);const a=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),o=this.matchRoutes(r),s={...m(a)?.params};let n=!0===(t.params??!0)?s:y(t.params,s);n&&o.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},n,t(n))})),r=M(r,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,c=!0===t.search?i:t.search?y(t.search,i)??{}:t.__preSearchFilters?.length?i:{},h=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),c):c,u=v(this.state.latestLocation.search,h),l=this.options.stringifySearch(u);let p=!0===t.hash?this.state.latestLocation.hash:y(t.hash,this.state.latestLocation.hash);return p=p?`#${p}`:"",{pathname:r,search:u,searchStr:l,state:this.state.latestLocation.state,hash:p,href:`${r}${l}${p}`,key:t.key}};#s=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let a="replace";t.replace||(a="push");this.state.latestLocation.href===e.href&&!e.key&&(a="replace");const o=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===a?"push":"replace"](o,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const q="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function K(t){return!!t?.isRedirect}const J=["component","errorComponent","pendingComponent"];class V{abortController=new AbortController;onLoaderDataListeners=new Set;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,J.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&&!J.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:a}=this.#i({location:this.router.state.currentLocation});this.context=r,this.routeContext=a,this.store.setState((r=>({...r,routeSearch:v(r.routeSearch,t),search:v(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(K(t))throw t;this.route.options.onValidateSearchError?.(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),a=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,...a},routeContext:a}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#i(t)}catch(t){return K(t)?void this.router.navigate(t):(this.route.options.onError?.(t),void this.store.setState((e=>({...e,status:"error",error:t}))))}const{routeSearch:r,search:a,context:o,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(J.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:a,signal:this.abortController.signal,preload:!!t?.preload,routeContext:s,context:o})}));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(t){if(K(t))return void this.router.navigate(t);this.route.options.onLoadError?.(t),this.route.options.onError?.(t),this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#h=""} | ||
*/const h="popstate";function u(t){let e=t.getLocation(),r=()=>{},a=new Set;const o=()=>{e=t.getLocation(),a.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===a.size&&(r=t.listener(o)),a.add(e),()=>{a.delete(e),0===a.size&&r()}),push:(e,r)=>{t.pushState(e,r),o()},replace:(e,r)=>{t.replaceState(e,r),o()},go:e=>{t.go(e),o()},back:()=>{t.back(),o()},forward:()=>{t.forward(),o()},createHref:e=>t.createHref(e)}}function l(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return u({getLocation:()=>d(e(),history.state),listener:t=>(window.addEventListener(h,t),()=>{window.removeEventListener(h,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:f()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:f()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function p(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,a={};return u({getLocation:()=>d(e[r],a),listener:()=>()=>{},pushState:(t,o)=>{a={...o,key:f()},e.push(t),r++},replaceState:(t,o)=>{a={...o,key:f()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function d(t,e){let r=t.indexOf("#"),a=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?a>0?Math.min(r,a):r:a>0?a:t.length),hash:r>-1?t.substring(r,a):"",search:a>-1?t.substring(a):"",state:e}}function f(){return(Math.random()+1).toString(36).substring(7)}function m(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function g(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function v(t,e){if(t===e)return t;const r=e,a=Array.isArray(t)&&Array.isArray(r);if(a||S(t)&&S(r)){const e=a?t.length:Object.keys(t).length,o=a?r:Object.keys(r),s=o.length,n=a?[]:{};let i=0;for(let e=0;e<s;e++){const s=a?e:o[e];n[s]=v(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function S(t){if(!b(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!b(r)&&!!r.hasOwnProperty("isPrototypeOf")}function b(t){return"[object Object]"===Object.prototype.toString.call(t)}function w(t,e){return t===e||typeof t==typeof e&&(S(t)&&S(e)?!Object.keys(e).some((r=>!w(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>w(t,e[r])))))}function L(t){return E(t.filter(Boolean).join("/"))}function E(t){return t.replace(/\/{2,}/g,"/")}function P(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function x(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function C(t){return x(P(t))}function R(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let a=_(e);const o=_(r);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&a.push(t):a=[t];else if(".."===t.value)a.length>1&&"/"===m(a)?.value&&a.pop(),a.pop();else{if("."===t.value)return;a.push(t)}}));return E(L([t,...a.map((t=>t.value))]))}function _(t){if(!t)return[];const e=[];if("/"===(t=E(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 M(t,e,r){return L(_(t).map((t=>["$","*"].includes(t.value)&&!r?"":"param"===t.type?e[t.value.substring(1)]??"":t.value)))}function k(t,e,r){const a=O(t,e,r);if(!r.to||a)return a??{}}function O(t,e,r){if(!e.startsWith(t))return;const a=_(e="/"!=t?e.substring(t.length):e),o=_(`${r.to??"$"}`);"/"===m(a)?.value&&a.pop();const s={};return(()=>{for(let t=0;t<Math.max(a.length,o.length);t++){const e=a[t],n=o[t],i=t===o.length-1,c=t===a.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s["*"]=L(a.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 j(t,e){var r,a,o,s="";for(r in t)if(void 0!==(o=t[r]))if(Array.isArray(o))for(a=0;a<o.length;a++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(o[a]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(e||"")+s}function I(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function $(t){for(var e,r,a={},o=t.split("&");e=o.shift();)void 0!==a[r=(e=e.split("=")).shift()]?a[r]=[].concat(a[r],I(e.shift())):a[r]=I(e.shift());return a}const A="__root__";class T{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,a=this.options?.getParentRoute?.();r?this.path=A:n(a);let o=r?A:e.path;o&&"/"!==o&&(o=C(o));const s=e?.id||o;let i=r?A:L([a.id===A?"":a.id,s]);o===A&&(o="/"),i!==A&&(i=L(["/",i]));const c=i===A?"/":x(L([a.fullPath,o]));this.path=o,this.id=i,this.fullPath=c};addChildren=t=>(this.children=t,this);generate=t=>{n(!1)}}class D extends T{constructor(t){super(t)}static withRouterContext=()=>t=>new D(t)}const N=H(JSON.parse),F=B(JSON.stringify);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=$(e);for(let e in r){const a=r[e];if("string"==typeof a)try{r[e]=t(a)}catch(t){}}return r}}function B(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const a=e[r];if(void 0===a||void 0===a)delete e[r];else if(a&&"object"==typeof a&&null!==a)try{e[r]=t(a)}catch(t){}}));const r=j(e).toString();return r?`?${r}`:""}}const U=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),a=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(a.ok)return a.json();throw new Error("Failed to fetch match data")};class z{#e;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??F,parseSearch:t?.parseSearch??N,fetchServerDataFn:t?.fetchServerDataFn??U},this.store=new c(W(),{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,W())))};mount=()=>(q||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??(q?p():l());const t=this.#a();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#e=this.history.listen((()=>{this.safeLoad({next:this.#a(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${C(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#o(r)),this};buildNext=t=>{const e=this.#s(t),r=this.matchRoutes(e.pathname),a=r.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),o=r.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#s({...t,__preSearchFilters:a,__postSearchFilters:o})};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 a;if(this.startedLoadingAt=r,this.cancelMatches(),this.store.batch((()=>{t?.next&&this.store.setState((e=>({...e,latestLocation:t.next}))),a=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:a,pendingLocation:this.state.latestLocation})))})),await this.loadMatches(a,this.state.pendingLocation),this.startedLoadingAt!==r)return this.navigationPromise;const o=this.state.currentMatches,s=[],n=[];o.forEach((t=>{a.find((e=>e.id===t.id))?n.push(t):s.push(t)}));const i=a.filter((t=>!o.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:a,pendingLocation:void 0,pendingMatches:void 0}))),a.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 a=[...this.state.currentMatches,...this.state.pendingMatches??[]],o=async s=>{let n=m(r)?.params??{};const i=this.options.filterRoutes?.(s)??s;let c=[];const h=(r,a)=>(a.some((a=>{const o=a.children;if(!a.path&&o?.length)return h([...c,a],o);const s=!("/"===a.path&&!o?.length),i=k(this.basepath,t,{to:a.fullPath,fuzzy:s,caseSensitive:a.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=a.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,a]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=M(t.path,n),o=M(t.id,n,!0),s=a.find((t=>t.id===o))||new V(this,t,{id:o,params:n,pathname:L([this.basepath,e])});r.push(s)}));const u=m(c).children;u?.length&&o(u)};return o([this.routeTree]),r};loadMatches=async(t,e,r)=>{await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(e){throw r?.preload||t.route.options.onBeforeLoadError?.(e),t.route.options.onError?.(e),e}})));const a=t.map((async(a,o)=>{const s=t[o-1];a.__load({preload:r?.preload,location:e,parentMatch:s}),await a.__loadPromise,s&&await s.__loadPromise}));await Promise.all(a)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>R(this.basepath,t,E(e));navigate=async({from:t,to:e="",search:r,hash:a,replace:o,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:a,replace:o,params:s})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),a=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!a)return!1;const o=k(this.basepath,a.pathname,{...e,to:r.pathname});return!!o&&(e?.includeSearch??1?!!w(a.search,r.search)&&o:o)};buildLink=({from:t,to:e=".",search:r,params:a,hash:o,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:a,hash:o,replace:n},p=this.buildNext(l);c=c??this.options.defaultPreload;const d=h??this.options.defaultPreloadDelay??0,f=this.state.currentLocation.pathname.split("/"),m=p.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.currentLocation.pathname===p.pathname:m,g=!i?.includeHash||this.state.currentLocation.hash===p.hash,v=!(i?.includeSearch??1)||w(this.state.currentLocation.search,p.search);return{type:"internal",next:p,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! ☝️")}))}),d)}},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:{...g(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 a=t.state.currentMatches[r];n(a&&a.id===e.id),e.store.setState((t=>({...t,...a.state})))})),{...e,...t.state,currentMatches:r}}))};#o=t=>{const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(this.routesById[t.id])throw new Error;this.routesById[t.id]=t;const a=t.children;a?.length&&(e(a),t.children=a.map(((t,e)=>{const r=_(P(E(t.path??"/")));for(;r.length>1&&"/"===r[0]?.value;)r.shift();let a=0;return r.forEach(((t,e)=>{let r=1;for(;e--;)r*=.001;"pathname"===t.type&&"/"!==t.value?a+=1*r:"param"===t.type?a+=2*r:"wildcard"===t.type&&(a+=3*r)})),{child:t,parsed:r,index:e,score:a}})).sort(((t,e)=>t.score!==e.score?t.score-e.score:t.index-e.index)).map((t=>t.child)))}))};return e([t]),t};#a=t=>{let{pathname:e,search:r,hash:a,state:o}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,s),hash:a.split("#").reverse()[0]??"",href:`${e}${r}${a}`,state:o,key:o?.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=R(this.basepath??"/",e,`${t.to??""}`);const a=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),o=this.matchRoutes(r),s={...m(a)?.params};let n=!0===(t.params??!0)?s:y(t.params,s);n&&o.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},n,t(n))})),r=M(r,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,c=!0===t.search?i:t.search?y(t.search,i)??{}:t.__preSearchFilters?.length?i:{},h=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),c):c,u=v(this.state.latestLocation.search,h),l=this.options.stringifySearch(u);let p=!0===t.hash?this.state.latestLocation.hash:y(t.hash,this.state.latestLocation.hash);p=p?`#${p}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.latestLocation.state:y(t.state,this.state.latestLocation.state),hash:p,href:this.history.createHref(`${r}${l}${p}`),key:t.key}};#r=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let a="replace";t.replace||(a="push");this.state.latestLocation.href===e.href&&!e.key&&(a="replace");const o=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===a?"push":"replace"](o,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const q="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function K(t){return!!t?.isRedirect}const J=["component","errorComponent","pendingComponent"];class V{abortController=new AbortController;onLoaderDataListeners=new Set;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,J.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&&!J.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:a}=this.#i({location:this.router.state.currentLocation});this.context=r,this.routeContext=a,this.store.setState((r=>({...r,routeSearch:v(r.routeSearch,t),search:v(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(K(t))throw t;this.route.options.onValidateSearchError?.(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),a=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,...a},routeContext:a}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#i(t)}catch(t){return K(t)?void this.router.navigate(t):(this.route.options.onError?.(t),void this.store.setState((e=>({...e,status:"error",error:t}))))}const{routeSearch:r,search:a,context:o,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(J.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:a,signal:this.abortController.signal,preload:!!t?.preload,routeContext:s,context:o})}));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(t){if(K(t))return void this.router.navigate(t);this.route.options.onLoadError?.(t),this.route.options.onError?.(t),this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#h=""} | ||
/** | ||
@@ -42,3 +42,3 @@ * react-store | ||
* @license MIT | ||
*/function G(t,e=(t=>t),a){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,a?Q:void 0)}function Q(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let a=0;a<r.length;a++)if(!Object.prototype.hasOwnProperty.call(e,r[a])||!Object.is(t[r[a]],e[r[a]]))return!1;return!0}function X(t){const e=et(),{type:r,children:a,target:s,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:p,to:d=".",preload:f,preloadDelay:m,replace:g,style:v,className:S,onClick:w,onFocus:b,onMouseEnter:L,onMouseLeave:E,onTouchStart:P,...x}=t,C=e.buildLink(t);if("external"===C.type){const{href:t}=C;return{href:t}}const{handleClick:R,handleFocus:_,handleEnter:M,handleLeave:k,handleTouchStart:O,isActive:j,next:I}=C,$=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},A=j?y(n,{})??{}:{},T=j?{}:y(i,{})??{};return{...A,...T,...x,href:h?void 0:I.href,onClick:$([w,t=>{o.startTransition?o.startTransition((()=>{R(t)})):R(t)}]),onFocus:$([b,_]),onMouseEnter:$([L,M]),onMouseLeave:$([E,k]),onTouchStart:$([P,O]),target:s,style:{...v,...A.style,...T.style},className:[S,A.className,T.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}const Y=o.forwardRef(((t,e)=>{const r=X(t);return o.createElement("a",s({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const Z=o.createContext(null),tt=o.createContext(null);function et(){const t=o.useContext(tt);return G(t.router.store),t.router}function rt(){return o.useContext(Z)}function at(t){const e=et(),r=rt()[0],a=t?.from?e.state.currentMatches.find((e=>e.route.id===t?.from)):r;return n(a,t?.from&&t.from),(t?.strict??1)&&n(r.route.id==a?.route.id,(a?.route.id,r.route.id,a?.route.id,a?.route.id)),G(a.store,(e=>t?.track?.(a)??a),t?.shallow),a}function ot(){const t=et();return o.useCallback((e=>{const{pending:r,caseSensitive:a,...o}=e;return t.matchRoute(o,{pending:r,caseSensitive:a})}),[])}function st(){const t=rt().slice(1),e=t[0];return e?o.createElement(nt,{matches:t,match:e}):null}function nt({matches:t,match:e}){const r=et();G(e.store,(t=>[t.status,t.error]),!0);const a=o.useCallback((()=>null),[]),s=o.useCallback((t=>{if("error"===t.match.state.status)throw t.match.state.error;if("success"===t.match.state.status)return o.createElement(t.match.component??r.options.defaultComponent??st);if("pending"===t.match.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??a,c=e.errorComponent??r.options.defaultErrorComponent,h=e.route.options.wrapInSuspense??1?o.Suspense:it,u=c?ct:it;return o.createElement(Z.Provider,{value:t},o.createElement(h,{fallback:o.createElement(i,null)},o.createElement(u,{key:e.route.id,errorComponent:c,onCatch:()=>{e.id}},o.createElement(s,{match:e}))))}function it(t){return o.createElement(o.Fragment,null,t.children)}class ct extends o.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),console.error(t),this.setState({error:t,info:e})}render(){return o.createElement(ht,s({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ht(t){const[e,r]=o.useState(t.errorState),a=et(),s=t.errorComponent??ut,n=o.useRef("");return o.useEffect((()=>{e&&a.state.currentLocation.key!==n.current&&r({}),n.current=a.state.currentLocation.key}),[e,a.state.currentLocation.key]),o.useEffect((()=>{t.errorState.error&&r(t.errorState)}),[t.errorState.error]),t.errorState.error&&e.error?o.createElement(s,e):t.children}function ut({error:t}){return o.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},o.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),o.createElement("div",{style:{height:".5rem"}}),o.createElement("div",null,o.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red",overflow:"auto"}},t.message?o.createElement("code",null,t.message):null)))}t.ErrorComponent=ut,t.Link=Y,t.MatchRoute=function(t){const e=ot()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Navigate=function(t){const e=et();return o.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=st,t.ReactRouter=class extends z{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=D,t.Route=T,t.RouteMatch=V,t.Router=z,t.RouterProvider=function({router:t,...e}){t.update(e);const r=G(t.store,(t=>t.currentMatches));return o.useEffect(t.mount,[t]),o.createElement(tt.Provider,{value:{router:t}},o.createElement(Z.Provider,{value:[void 0,...r]},o.createElement(ct,{errorComponent:ut,onCatch:()=>{}},o.createElement(st,null))))},t.cleanPath=E,t.createBrowserHistory=l,t.createHashHistory=function(){return l({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=p,t.decode=$,t.defaultFetchServerDataFn=U,t.defaultParseSearch=F,t.defaultStringifySearch=N,t.encode=j,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=n,t.isPlainObject=S,t.isRedirect=K,t.joinPaths=L,t.last=m,t.lazy=function(t){const e=o.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=O,t.matchPathname=k,t.matchesContext=Z,t.parsePathname=_,t.parseSearchWith=B,t.partialDeepEqual=b,t.pick=g,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=v,t.resolvePath=R,t.rootRouteId=A,t.routerContext=tt,t.stringifySearchWith=H,t.trimPath=C,t.trimPathLeft=P,t.trimPathRight=x,t.useLinkProps=X,t.useMatch=at,t.useMatchRoute=ot,t.useMatches=rt,t.useNavigate=function(t){const e=et();return o.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=function(t){const e=et();return G(e.store,(e=>{const r=m(e.currentMatches)?.params;return t?.track?.(r)??r}),!0),m(e.state.currentMatches)?.params},t.useRoute=function(t){const e=et().getRoute(t);return n(e),e},t.useRouter=function(t,e){const r=et();return G(r.store,t,e),r},t.useRouterContext=et,t.useSearch=function(t){const e=at(t);return G(e.store,(e=>t?.track?.(e.search)??e.search),!0),e.state.search},t.useStore=G,t.warning=i,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
*/function G(t,e=(t=>t),a){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,a?Q:void 0)}function Q(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let a=0;a<r.length;a++)if(!Object.prototype.hasOwnProperty.call(e,r[a])||!Object.is(t[r[a]],e[r[a]]))return!1;return!0}function X(t){const e=et(),{type:r,children:a,target:s,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:p,to:d=".",preload:f,preloadDelay:m,replace:g,style:v,className:S,onClick:b,onFocus:w,onMouseEnter:L,onMouseLeave:E,onTouchStart:P,...x}=t,C=e.buildLink(t);if("external"===C.type){const{href:t}=C;return{href:t}}const{handleClick:R,handleFocus:_,handleEnter:M,handleLeave:k,handleTouchStart:O,isActive:j,next:I}=C,$=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},A=j?y(n,{})??{}:{},T=j?{}:y(i,{})??{};return{...A,...T,...x,href:h?void 0:I.href,onClick:$([b,t=>{o.startTransition?o.startTransition((()=>{R(t)})):R(t)}]),onFocus:$([w,_]),onMouseEnter:$([L,M]),onMouseLeave:$([E,k]),onTouchStart:$([P,O]),target:s,style:{...v,...A.style,...T.style},className:[S,A.className,T.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}const Y=o.forwardRef(((t,e)=>{const r=X(t);return o.createElement("a",s({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const Z=o.createContext(null),tt=o.createContext(null);function et(){const t=o.useContext(tt);return G(t.router.store),t.router}function rt(){return o.useContext(Z)}function at(t){const e=et(),r=rt()[0],a=t?.from?e.state.currentMatches.find((e=>e.route.id===t?.from)):r;return n(a,t?.from&&t.from),(t?.strict??1)&&n(r.route.id==a?.route.id,(a?.route.id,r.route.id,a?.route.id,a?.route.id)),G(a.store,(e=>t?.track?.(a)??a),t?.shallow),a}function ot(){const t=et();return o.useCallback((e=>{const{pending:r,caseSensitive:a,...o}=e;return t.matchRoute(o,{pending:r,caseSensitive:a})}),[])}function st(){const t=rt().slice(1),e=t[0];return e?o.createElement(nt,{matches:t,match:e}):null}function nt({matches:t,match:e}){const r=et();G(e.store,(t=>[t.status,t.error]),!0);const a=o.useCallback((()=>null),[]),s=o.useCallback((t=>{if("error"===t.match.state.status)throw t.match.state.error;if("success"===t.match.state.status)return o.createElement(t.match.component??r.options.defaultComponent??st);if("pending"===t.match.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??a,c=e.errorComponent??r.options.defaultErrorComponent,h=e.route.options.wrapInSuspense??1?o.Suspense:it,u=c?ct:it;return o.createElement(Z.Provider,{value:t},o.createElement(h,{fallback:o.createElement(i,null)},o.createElement(u,{key:e.route.id,errorComponent:c,onCatch:()=>{e.id}},o.createElement(s,{match:e}))))}function it(t){return o.createElement(o.Fragment,null,t.children)}class ct extends o.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),console.error(t),this.setState({error:t,info:e})}render(){return o.createElement(ht,s({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ht(t){const[e,r]=o.useState(t.errorState),a=et(),s=t.errorComponent??ut,n=o.useRef("");return o.useEffect((()=>{e&&a.state.currentLocation.key!==n.current&&r({}),n.current=a.state.currentLocation.key}),[e,a.state.currentLocation.key]),o.useEffect((()=>{t.errorState.error&&r(t.errorState)}),[t.errorState.error]),t.errorState.error&&e.error?o.createElement(s,e):t.children}function ut({error:t}){return o.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},o.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),o.createElement("div",{style:{height:".5rem"}}),o.createElement("div",null,o.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red",overflow:"auto"}},t.message?o.createElement("code",null,t.message):null)))}t.ErrorComponent=ut,t.Link=Y,t.MatchRoute=function(t){const e=ot()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Navigate=function(t){const e=et();return o.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=st,t.ReactRouter=class extends z{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=D,t.Route=T,t.RouteMatch=V,t.Router=z,t.RouterProvider=function({router:t,...e}){t.update(e);const r=G(t.store,(t=>t.currentMatches));return o.useEffect(t.mount,[t]),o.createElement(tt.Provider,{value:{router:t}},o.createElement(Z.Provider,{value:[void 0,...r]},o.createElement(ct,{errorComponent:ut,onCatch:()=>{}},o.createElement(st,null))))},t.cleanPath=E,t.createBrowserHistory=l,t.createHashHistory=function(){return l({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=p,t.decode=$,t.defaultFetchServerDataFn=U,t.defaultParseSearch=N,t.defaultStringifySearch=F,t.encode=j,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=n,t.isPlainObject=S,t.isRedirect=K,t.joinPaths=L,t.last=m,t.lazy=function(t){const e=o.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=O,t.matchPathname=k,t.matchesContext=Z,t.parsePathname=_,t.parseSearchWith=H,t.partialDeepEqual=w,t.pick=g,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=v,t.resolvePath=R,t.rootRouteId=A,t.routerContext=tt,t.stringifySearchWith=B,t.trimPath=C,t.trimPathLeft=P,t.trimPathRight=x,t.useLinkProps=X,t.useMatch=at,t.useMatchRoute=ot,t.useMatches=rt,t.useNavigate=function(t){const e=et();return o.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=function(t){const e=et();return G(e.store,(e=>{const r=m(e.currentMatches)?.params;return t?.track?.(r)??r}),!0),m(e.state.currentMatches)?.params},t.useRoute=function(t){const e=et().getRoute(t);return n(e),e},t.useRouter=function(t,e){const r=et();return G(r.store,t,e),r},t.useRouterContext=et,t.useSearch=function(t){const e=at(t);return G(e.store,(e=>t?.track?.(e.search)??e.search),!0),e.state.search},t.useStore=G,t.warning=i,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/react-router", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.71", | ||
"version": "0.0.1-beta.72", | ||
"license": "MIT", | ||
@@ -44,3 +44,3 @@ "repository": "tanstack/router", | ||
"@babel/runtime": "^7.16.7", | ||
"@tanstack/router": "0.0.1-beta.71", | ||
"@tanstack/router": "0.0.1-beta.72", | ||
"@tanstack/react-store": "0.0.1-beta.62" | ||
@@ -47,0 +47,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
617557
4133
+ Added@tanstack/router@0.0.1-beta.72(transitive)
- Removed@tanstack/router@0.0.1-beta.71(transitive)