Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@tanstack/react-router

Package Overview
Dependencies
Maintainers
1
Versions
620
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/react-router - npm Package Compare versions

Comparing version 0.0.1-beta.63 to 0.0.1-beta.64

1

build/cjs/index.js

@@ -74,3 +74,2 @@ /**

preloadDelay,
preloadMaxAge,
replace,

@@ -77,0 +76,0 @@ // element props

@@ -66,3 +66,2 @@ /**

preloadDelay,
preloadMaxAge,
replace,

@@ -69,0 +68,0 @@ // element props

100

build/stats-react.json

@@ -10,3 +10,3 @@ {

{
"uid": "cf24-103",
"uid": "8d6c-103",
"name": "\u0000rollupPluginBabelHelpers.js"

@@ -16,3 +16,3 @@ },

"name": "node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "cf24-105"
"uid": "8d6c-105"
},

@@ -24,15 +24,15 @@ {

"name": "store/build/esm/index.js",
"uid": "cf24-107"
"uid": "8d6c-107"
},
{
"name": "router/build/esm/index.js",
"uid": "cf24-109"
"uid": "8d6c-109"
},
{
"name": "react-store/build/esm/index.js",
"uid": "cf24-111"
"uid": "8d6c-111"
},
{
"name": "react-router/src/index.tsx",
"uid": "cf24-113"
"uid": "8d6c-113"
}

@@ -47,44 +47,44 @@ ]

"nodeParts": {
"cf24-103": {
"8d6c-103": {
"renderedLength": 429,
"gzipLength": 238,
"brotliLength": 0,
"mainUid": "cf24-102"
"mainUid": "8d6c-102"
},
"cf24-105": {
"8d6c-105": {
"renderedLength": 181,
"gzipLength": 129,
"brotliLength": 0,
"mainUid": "cf24-104"
"mainUid": "8d6c-104"
},
"cf24-107": {
"8d6c-107": {
"renderedLength": 1288,
"gzipLength": 497,
"brotliLength": 0,
"mainUid": "cf24-106"
"mainUid": "8d6c-106"
},
"cf24-109": {
"renderedLength": 44953,
"gzipLength": 10850,
"8d6c-109": {
"renderedLength": 45412,
"gzipLength": 10895,
"brotliLength": 0,
"mainUid": "cf24-108"
"mainUid": "8d6c-108"
},
"cf24-111": {
"8d6c-111": {
"renderedLength": 1571,
"gzipLength": 594,
"brotliLength": 0,
"mainUid": "cf24-110"
"mainUid": "8d6c-110"
},
"cf24-113": {
"renderedLength": 12098,
"gzipLength": 3161,
"8d6c-113": {
"renderedLength": 12077,
"gzipLength": 3154,
"brotliLength": 0,
"mainUid": "cf24-112"
"mainUid": "8d6c-112"
}
},
"nodeMetas": {
"cf24-102": {
"8d6c-102": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "cf24-103"
"index.production.js": "8d6c-103"
},

@@ -94,10 +94,10 @@ "imported": [],

{
"uid": "cf24-112"
"uid": "8d6c-112"
}
]
},
"cf24-104": {
"8d6c-104": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "cf24-105"
"index.production.js": "8d6c-105"
},

@@ -107,10 +107,10 @@ "imported": [],

{
"uid": "cf24-108"
"uid": "8d6c-108"
}
]
},
"cf24-106": {
"8d6c-106": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "cf24-107"
"index.production.js": "8d6c-107"
},

@@ -120,17 +120,17 @@ "imported": [],

{
"uid": "cf24-108"
"uid": "8d6c-108"
}
]
},
"cf24-108": {
"8d6c-108": {
"id": "/packages/router/build/esm/index.js",
"moduleParts": {
"index.production.js": "cf24-109"
"index.production.js": "8d6c-109"
},
"imported": [
{
"uid": "cf24-104"
"uid": "8d6c-104"
},
{
"uid": "cf24-106"
"uid": "8d6c-106"
}

@@ -140,14 +140,14 @@ ],

{
"uid": "cf24-112"
"uid": "8d6c-112"
}
]
},
"cf24-110": {
"8d6c-110": {
"id": "/packages/react-store/build/esm/index.js",
"moduleParts": {
"index.production.js": "cf24-111"
"index.production.js": "8d6c-111"
},
"imported": [
{
"uid": "cf24-115"
"uid": "8d6c-115"
}

@@ -157,23 +157,23 @@ ],

{
"uid": "cf24-112"
"uid": "8d6c-112"
}
]
},
"cf24-112": {
"8d6c-112": {
"id": "/packages/react-router/src/index.tsx",
"moduleParts": {
"index.production.js": "cf24-113"
"index.production.js": "8d6c-113"
},
"imported": [
{
"uid": "cf24-102"
"uid": "8d6c-102"
},
{
"uid": "cf24-114"
"uid": "8d6c-114"
},
{
"uid": "cf24-108"
"uid": "8d6c-108"
},
{
"uid": "cf24-110"
"uid": "8d6c-110"
}

@@ -184,3 +184,3 @@ ],

},
"cf24-114": {
"8d6c-114": {
"id": "react",

@@ -191,3 +191,3 @@ "moduleParts": {},

{
"uid": "cf24-112"
"uid": "8d6c-112"
}

@@ -197,3 +197,3 @@ ],

},
"cf24-115": {
"8d6c-115": {
"id": "use-sync-external-store/shim/with-selector",

@@ -204,3 +204,3 @@ "moduleParts": {},

{
"uid": "cf24-110"
"uid": "8d6c-110"
}

@@ -207,0 +207,0 @@ ],

@@ -31,3 +31,3 @@ /**

* @license MIT
*/const c="popstate";function h(t){let e=t.getLocation(),r=()=>{},s=new Set;const a=()=>{e=t.getLocation(),s.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===s.size&&(r=t.listener(a)),s.add(e),()=>{s.delete(e),0===s.size&&r()}),push:(e,r)=>{t.pushState(e,r),a()},replace:(e,r)=>{t.replaceState(e,r),a()},go:e=>{t.go(e),a()},back:()=>{t.back(),a()},forward:()=>{t.forward(),a()}}}function u(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return h({getLocation:()=>d(e(),history.state),listener:t=>(window.addEventListener(c,t),()=>{window.removeEventListener(c,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:p()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:p()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function l(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,s={};return h({getLocation:()=>d(e[r],s),listener:()=>()=>{},pushState:(t,a)=>{s={...a,key:p()},e.push(t),r++},replaceState:(t,a)=>{s={...a,key:p()},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("#"),s=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?s>0?Math.min(r,s):r:s>0?s:t.length),hash:r>-1?t.substring(r,s):"",search:s>-1?t.substring(s):"",state:e}}function p(){return(Math.random()+1).toString(36).substring(7)}function f(t){return t[t.length-1]}function m(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0}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,s=Array.isArray(t)&&Array.isArray(r);if(s||w(t)&&w(r)){const e=s?t.length:Object.keys(t).length,a=s?r:Object.keys(r),o=a.length,n=s?[]:{};let i=0;for(let e=0;e<o;e++){const o=s?e:a[e];n[o]=v(t[o],r[o]),n[o]===t[o]&&i++}return e===o&&i===e?t:n}return r}function w(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 S(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!S(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>S(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 R(t){return x(P(t))}function C(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let s=_(e);const a=_(r);a.forEach(((t,e)=>{if("/"===t.value)e?e===a.length-1&&s.push(t):s=[t];else if(".."===t.value)s.length>1&&"/"===f(s)?.value&&s.pop(),s.pop();else{if("."===t.value)return;s.push(t)}}));return E(L([t,...s.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.startsWith("*")?{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=>"*"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function k(t,e,r){const s=O(t,e,r);if(!r.to||s)return s??{}}function O(t,e,r){if(!e.startsWith(t))return;const s=_(e="/"!=t?e.substring(t.length):e),a=_(`${r.to??"*"}`),o={};return(()=>{for(let t=0;t<Math.max(s.length,a.length);t++){const e=s[t],n=a[t],i=t===a.length-1,c=t===s.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(o["*"]=L(s.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)&&(o[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?o:void 0}function j(t,e){var r,s,a,o="";for(r in t)if(void 0!==(a=t[r]))if(Array.isArray(a))for(s=0;s<a.length;s++)o&&(o+="&"),o+=encodeURIComponent(r)+"="+encodeURIComponent(a[s]);else o&&(o+="&"),o+=encodeURIComponent(r)+"="+encodeURIComponent(a);return(e||"")+o}function A(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,s={},a=t.split("&");e=a.shift();)void 0!==s[r=(e=e.split("=")).shift()]?s[r]=[].concat(s[r],A(e.shift())):s[r]=A(e.shift());return s}const F="__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,s=this.options?.getParentRoute?.();r?this.path=F:n(s);let a=r?F:e.path;a&&"/"!==a&&(a=R(a));const o=e?.id||a;let i=r?F:L([s.id===F?"":s.id,o]);a===F&&(a="/"),i!==F&&(i=L(["/",i]));const c=i===F?"/":x(L([s.fullPath,a]));this.path=a,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 I=["component","errorComponent","pendingComponent"];class N{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 i({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.store.state,this.#e()||this.store.setState((t=>({...t,status:"success"})))}#e=()=>!(!this.route.options.onLoad&&!I.some((t=>this.route.options[t]?.preload)));__init=t=>{this.parentMatch=t.parentMatch;const e=this.parentMatch?.state.search??this.router.state.latestLocation.search;try{let t=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(e)??{};this.store.setState((r=>({...r,routeSearch:t,search:{...e,...t}}))),I.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)}));const r=this.parentMatch;this.routeContext=this.route.options.getContext?.({parentContext:r?.routeContext,context:r?.context,params:this.params,search:this.state.search})||{},this.context=r?{...r.context,...this.routeContext}:{...this.router?.options.context,...this.routeContext}}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",void this.store.setState((t=>({...t,status:"error",error:e})))}};cancel=()=>{this.abortController?.abort()};load=async t=>{"pending"!==this.state.status&&await this.fetch(t)};#r="";fetch=async t=>(this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#r=e;const r=()=>e!==this.#r?this.__loadPromise:void 0;let s;this.store.batch((()=>{"idle"===this.state.status&&this.store.setState((t=>({...t,status:"pending"})))}));const a=(async()=>{await Promise.all(I.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),o=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,search:this.state.search,signal:this.abortController.signal,preload:!!t?.preload,routeContext:this.routeContext,context:this.context})}));try{if(await a,await o,s=r())return await s;this.store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(t){this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise)}const B=U(JSON.parse),H=z(JSON.stringify);function U(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=$(e);for(let e in r){const s=r[e];if("string"==typeof s)try{r[e]=t(s)}catch(t){}}return r}}function z(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const s=e[r];if(void 0===s||void 0===s)delete e[r];else if(s&&"object"==typeof s&&null!==s)try{e[r]=t(s)}catch(t){}}));const r=j(e).toString();return r?`?${r}`:""}}const q=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),s=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(s.ok)return s.json();throw new Error("Failed to fetch match data")};class W{#s;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??H,parseSearch:t?.parseSearch??B,fetchServerDataFn:t?.fetchServerDataFn??q},this.store=new i(G(),{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,G())))};mount=()=>{if(!K){this.state.currentMatches.length||this.load();const t="visibilitychange",e="focus";return window.addEventListener&&(window.addEventListener(t,this.#a,!1),window.addEventListener(e,this.#a,!1)),()=>{window.removeEventListener&&(window.removeEventListener(t,this.#a),window.removeEventListener(e,this.#a))}}return()=>{}};update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#s&&this.#s(),this.history=this.options.history??(K?l():u());const t=this.#o();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#s=this.history.listen((()=>{this.load({next:this.#o(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${R(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#n(r)),this};buildNext=t=>{const e=this.#i(t),r=this.matchRoutes(e.pathname),s=r.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),a=r.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#i({...t,__preSearchFilters:s,__postSearchFilters:a})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};load=async t=>{let e=Date.now();const r=e;let s;this.startedLoadingAt=r,this.cancelMatches(),this.store.batch((()=>{t?.next&&this.store.setState((e=>({...e,latestLocation:t.next}))),s=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:s,pendingLocation:this.state.latestLocation})))}));try{await this.loadMatches(s)}catch(t){console.warn(t),n(!1)}if(this.startedLoadingAt!==r)return this.navigationPromise;const a=this.state.currentMatches,o=[],i=[];a.forEach((t=>{s.find((e=>e.id===t.id))?i.push(t):o.push(t)}));const c=s.filter((t=>!a.find((e=>e.id===t.id))));e=Date.now(),o.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})))})),i.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),c.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})})),this.store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:s,pendingLocation:void 0,pendingMatches:void 0}))),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),r};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,{preload:!0}),r};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const s=[...this.state.currentMatches,...this.state.pendingMatches??[]],a=async o=>{let n=f(r)?.params??{};const i=this.options.filterRoutes?.(o)??o;let c=[];const h=(r,s)=>(s.some((s=>{const a=s.children;if(!s.path&&a?.length)return h([...c,s],a);const o=!("/"===s.path&&!a?.length),i=k(this.basepath,t,{to:s.fullPath,fuzzy:o,caseSensitive:s.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=s.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,s]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=M(t.path,n),a=M(t.id,n,!0),o=s.find((t=>t.id===a))||new N(this,t,{id:a,params:n,pathname:L([this.basepath,e])});r.push(o)}));const u=f(c).children;u?.length&&a(u)};return a([this.routeTree]),r};loadMatches=async(t,e)=>{J(t),await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(r){throw e?.preload||t.route.options.onLoadError?.(r),r}})));const r=t.map((async(r,s)=>{const a=t[1];r.state.search,r.load({preload:e?.preload}),"success"!==r.state.status&&r.__loadPromise&&await r.__loadPromise,a&&await a.__loadPromise}));await Promise.all(r)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>C(this.basepath,t,E(e));navigate=async({from:t,to:e="",search:r,hash:s,replace:a,params:o})=>{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.#c({from:c,to:i,search:r,hash:s,replace:a,params:o})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),s=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!s)return!1;const a=k(this.basepath,s.pathname,{...e,to:r.pathname});return!!a&&(e?.includeSearch??1?(console.log(s.search,r.search,S(s.search,r.search)),!!S(s.search,r.search)&&a):a)};buildLink=({from:t,to:e=".",search:r,params:s,hash:a,target:o,replace:n,activeOptions:i,preload:c,preloadMaxAge:h,preloadGcMaxAge:u,preloadDelay:l,disabled:d})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const p={from:t,to:e,search:r,params:s,hash:a,replace:n},f=this.buildNext(p);c=c??this.options.defaultPreload;const m=l??this.options.defaultPreloadDelay??0,y=this.state.currentLocation.pathname.split("/"),g=f.pathname.split("/").every(((t,e)=>t===y[e])),v=i?.exact?this.state.currentLocation.pathname===f.pathname:g,w=!i?.includeHash||this.state.currentLocation.hash===f.hash,b=!(i?.includeSearch??1)||S(this.state.currentLocation.search,f.search);return{type:"internal",next:f,handleFocus:t=>{c&&this.preloadRoute(p).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{d||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||o&&"_self"!==o||0!==t.button||(t.preventDefault(),this.#c(p))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(p).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),m)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:v&&w&&b,disabled:d}};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 s=t.state.currentMatches[r];n(s&&s.id===e.id),e.store.setState((t=>({...t,...s.state})))})),J(r),{...e,...t.state,currentMatches:r}}))};#n=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 s=t.children;s?.length&&e(s)}))};return e([t]),t};#o=t=>{let{pathname:e,search:r,hash:s,state:a}=this.history.location;const o=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,o),hash:s.split("#").reverse()[0]??"",href:`${e}${r}${s}`,state:a,key:a?.key||"__init__"}};#a=()=>{this.load()};#i=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=C(this.basepath??"/",e,`${t.to??""}`);const s=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),a=this.matchRoutes(r),o={...f(s)?.params};let n=!0===(t.params??!0)?o:y(t.params,o);n&&a.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 d=!0===t.hash?this.state.latestLocation.hash:y(t.hash,this.state.latestLocation.hash);return d=d?`#${d}`:"",{pathname:r,search:u,searchStr:l,state:this.state.latestLocation.state,hash:d,href:`${r}${l}${d}`,key:t.key}};#c=t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let s="replace";t.replace||(s="push");this.state.latestLocation.href===e.href&&!e.key&&(s="replace");const a=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===s?"push":"replace"](a,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const K="undefined"==typeof window||!window.document.createElement;function G(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function J(t){t.forEach(((e,r)=>{const s=t[r-1];e.__init({parentMatch:s})}))}
*/const c="popstate";function h(t){let e=t.getLocation(),r=()=>{},s=new Set;const a=()=>{e=t.getLocation(),s.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===s.size&&(r=t.listener(a)),s.add(e),()=>{s.delete(e),0===s.size&&r()}),push:(e,r)=>{t.pushState(e,r),a()},replace:(e,r)=>{t.replaceState(e,r),a()},go:e=>{t.go(e),a()},back:()=>{t.back(),a()},forward:()=>{t.forward(),a()}}}function u(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return h({getLocation:()=>d(e(),history.state),listener:t=>(window.addEventListener(c,t),()=>{window.removeEventListener(c,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:p()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:p()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function l(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,s={};return h({getLocation:()=>d(e[r],s),listener:()=>()=>{},pushState:(t,a)=>{s={...a,key:p()},e.push(t),r++},replaceState:(t,a)=>{s={...a,key:p()},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("#"),s=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?s>0?Math.min(r,s):r:s>0?s:t.length),hash:r>-1?t.substring(r,s):"",search:s>-1?t.substring(s):"",state:e}}function p(){return(Math.random()+1).toString(36).substring(7)}function f(t){return t[t.length-1]}function m(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0}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,s=Array.isArray(t)&&Array.isArray(r);if(s||w(t)&&w(r)){const e=s?t.length:Object.keys(t).length,a=s?r:Object.keys(r),o=a.length,n=s?[]:{};let i=0;for(let e=0;e<o;e++){const o=s?e:a[e];n[o]=v(t[o],r[o]),n[o]===t[o]&&i++}return e===o&&i===e?t:n}return r}function w(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 S(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!S(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>S(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 R(t){return x(P(t))}function _(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let s=C(e);const a=C(r);a.forEach(((t,e)=>{if("/"===t.value)e?e===a.length-1&&s.push(t):s=[t];else if(".."===t.value)s.length>1&&"/"===f(s)?.value&&s.pop(),s.pop();else{if("."===t.value)return;s.push(t)}}));return E(L([t,...s.map((t=>t.value))]))}function C(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.startsWith("*")?{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(C(t).map((t=>"*"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function k(t,e,r){const s=O(t,e,r);if(!r.to||s)return s??{}}function O(t,e,r){if(!e.startsWith(t))return;const s=C(e="/"!=t?e.substring(t.length):e),a=C(`${r.to??"*"}`),o={};return(()=>{for(let t=0;t<Math.max(s.length,a.length);t++){const e=s[t],n=a[t],i=t===a.length-1,c=t===s.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(o["*"]=L(s.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)&&(o[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?o:void 0}function j(t,e){var r,s,a,o="";for(r in t)if(void 0!==(a=t[r]))if(Array.isArray(a))for(s=0;s<a.length;s++)o&&(o+="&"),o+=encodeURIComponent(r)+"="+encodeURIComponent(a[s]);else o&&(o+="&"),o+=encodeURIComponent(r)+"="+encodeURIComponent(a);return(e||"")+o}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 A(t){for(var e,r,s={},a=t.split("&");e=a.shift();)void 0!==s[r=(e=e.split("=")).shift()]?s[r]=[].concat(s[r],I(e.shift())):s[r]=I(e.shift());return s}const $="__root__";class F{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,s=this.options?.getParentRoute?.();r?this.path=$:n(s);let a=r?$:e.path;a&&"/"!==a&&(a=R(a));const o=e?.id||a;let i=r?$:L([s.id===$?"":s.id,o]);a===$&&(a="/"),i!==$&&(i=L(["/",i]));const c=i===$?"/":x(L([s.fullPath,a]));this.path=a,this.id=i,this.fullPath=c};addChildren=t=>(this.children=t,this);generate=t=>{n(!1)}}class T extends F{constructor(t){super(t)}static withRouterContext=()=>t=>new T(t)}const D=["component","errorComponent","pendingComponent"];class N{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 i({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.store.state,this.#e()||this.store.setState((t=>({...t,status:"success"})))}#e=()=>!(!this.route.options.onLoad&&!D.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:s}=this.#r({location:this.router.state.currentLocation});this.context=r,this.routeContext=s,this.store.setState((r=>({...r,routeSearch:v(r.routeSearch,t),search:v(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#s=t=>{const e=this.parentMatch?this.parentMatch.#s(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){console.error(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#r=t=>{const{search:e,routeSearch:r}=this.#s(t),s=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,...s},routeContext:s}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#r(t)}catch(t){return void this.store.setState((e=>({...e,status:"error",error:t})))}const{routeSearch:r,search:s,context:a,routeContext:o}=e;if(D.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#a=e;const n=()=>e!==this.#a?this.__loadPromise:void 0;let i;"idle"===this.state.status&&this.store.setState((t=>({...t,status:"pending"})));const c=(async()=>{await Promise.all(D.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:s,signal:this.abortController.signal,preload:!!t?.preload,routeContext:o,context:a})}));try{if(await c,await h,i=n())return await i;this.store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(t){this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#a=""}const B=U(JSON.parse),H=z(JSON.stringify);function U(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=A(e);for(let e in r){const s=r[e];if("string"==typeof s)try{r[e]=t(s)}catch(t){}}return r}}function z(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const s=e[r];if(void 0===s||void 0===s)delete e[r];else if(s&&"object"==typeof s&&null!==s)try{e[r]=t(s)}catch(t){}}));const r=j(e).toString();return r?`?${r}`:""}}const q=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),s=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(s.ok)return s.json();throw new Error("Failed to fetch match data")};class W{#o;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??H,parseSearch:t?.parseSearch??B,fetchServerDataFn:t?.fetchServerDataFn??q},this.store=new i(J(),{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,J())))};mount=()=>{if(!K){this.state.currentMatches.length||this.load();const t="visibilitychange",e="focus";return window.addEventListener&&(window.addEventListener(t,this.#n,!1),window.addEventListener(e,this.#n,!1)),()=>{window.removeEventListener&&(window.removeEventListener(t,this.#n),window.removeEventListener(e,this.#n))}}return()=>{}};update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#o&&this.#o(),this.history=this.options.history??(K?l():u());const t=this.#i();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#o=this.history.listen((()=>{this.load({next:this.#i(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${R(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#c(r)),this};buildNext=t=>{const e=this.#h(t),r=this.matchRoutes(e.pathname),s=r.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),a=r.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#h({...t,__preSearchFilters:s,__postSearchFilters:a})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};load=async t=>{let e=Date.now();const r=e;let s;this.startedLoadingAt=r,this.cancelMatches(),this.store.batch((()=>{t?.next&&this.store.setState((e=>({...e,latestLocation:t.next}))),s=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:s,pendingLocation:this.state.latestLocation})))}));try{await this.loadMatches(s,this.state.pendingLocation)}catch(t){console.warn(t),n(!1)}if(this.startedLoadingAt!==r)return this.navigationPromise;const a=this.state.currentMatches,o=[],i=[];a.forEach((t=>{s.find((e=>e.id===t.id))?i.push(t):o.push(t)}));const c=s.filter((t=>!a.find((e=>e.id===t.id))));e=Date.now(),o.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})))})),i.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),c.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})}));const h=this.state.currentLocation;this.store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:s,pendingLocation:void 0,pendingMatches:void 0}))),s.forEach((t=>{t.__commit()})),h.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 s=[...this.state.currentMatches,...this.state.pendingMatches??[]],a=async o=>{let n=f(r)?.params??{};const i=this.options.filterRoutes?.(o)??o;let c=[];const h=(r,s)=>(s.some((s=>{const a=s.children;if(!s.path&&a?.length)return h([...c,s],a);const o=!("/"===s.path&&!a?.length),i=k(this.basepath,t,{to:s.fullPath,fuzzy:o,caseSensitive:s.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=s.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,s]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=M(t.path,n),a=M(t.id,n,!0),o=s.find((t=>t.id===a))||new N(this,t,{id:a,params:n,pathname:L([this.basepath,e])});r.push(o)}));const u=f(c).children;u?.length&&a(u)};return a([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.onLoadError?.(e),e}})));const s=t.map((async(s,a)=>{const o=t[a-1];s.__load({preload:r?.preload,location:e,parentMatch:o}),await s.__loadPromise,o&&await o.__loadPromise}));await Promise.all(s)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>_(this.basepath,t,E(e));navigate=async({from:t,to:e="",search:r,hash:s,replace:a,params:o})=>{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.#u({from:c,to:i,search:r,hash:s,replace:a,params:o})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),s=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!s)return!1;const a=k(this.basepath,s.pathname,{...e,to:r.pathname});return!!a&&(e?.includeSearch??1?!!S(s.search,r.search)&&a:a)};buildLink=({from:t,to:e=".",search:r,params:s,hash:a,target:o,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:s,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)||S(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)}
/**

@@ -42,3 +42,3 @@ * react-store

* @license MIT
*/function V(t,e=(t=>t),s){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,s?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 s=0;s<r.length;s++)if(!Object.prototype.hasOwnProperty.call(e,r[s])||!Object.is(t[r[s]],e[r[s]]))return!1;return!0}function X(t){const e=et(),{type:r,children:s,target:o,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,preloadMaxAge:g,replace:v,style:w,className:b,onClick:S,onFocus:L,onMouseEnter:E,onMouseLeave:P,onTouchStart:x,onTouchEnd:R,...C}=t,_=e.buildLink(t);if("external"===_.type){const{href:t}=_;return{href:t}}const{handleClick:M,handleFocus:k,handleEnter:O,handleLeave:j,isActive:A,next:$}=_,F=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},T=A?y(n,{})??{}:{},D=A?{}:y(i,{})??{};return{...T,...D,...C,href:h?void 0:$.href,onClick:F([S,t=>{a.startTransition?a.startTransition((()=>{M(t)})):M(t)}]),onFocus:F([L,k]),onMouseEnter:F([E,O]),onMouseLeave:F([P,j]),target:o,style:{...w,...T.style,...D.style},className:[b,T.className,D.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":A?"active":void 0}}const Y=a.forwardRef(((t,e)=>{const r=X(t);return a.createElement("a",o({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))})),Z=a.createContext(null),tt=a.createContext(null);function et(){const t=a.useContext(tt);return m(!t,"useRouter must be used inside a <Router> component!"),V(t.router.store),t.router}function rt(){return a.useContext(Z)}function st(t){const e=et(),r=rt()[0],s=t?.from?e.state.currentMatches.find((e=>e.route.id===t?.from)):r;return n(s,t?.from&&t.from),(t?.strict??1)&&n(r.route.id==s?.route.id,(s?.route.id,r.route.id,s?.route.id,s?.route.id)),V(s.store,(e=>t?.track?.(s)??s),t?.shallow),s}function at(){const t=et();return e=>{const{pending:r,caseSensitive:s,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:s})}}function ot(){const t=rt().slice(1),e=t[0];return e?a.createElement(nt,{matches:t,match:e}):null}function nt({matches:t,match:e}){const r=et();V(e.store,(t=>[t.status,t.error]),!0);const s=a.useCallback((()=>null),[]),o=a.useCallback((t=>{if("error"===t.match.state.status)throw t.match.state.error;if("success"===t.match.state.status)return a.createElement(t.match.component??r.options.defaultComponent??ot);if("pending"===t.match.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??s,c=e.errorComponent??r.options.defaultErrorComponent;return a.createElement(Z.Provider,{value:t},e.route.options.wrapInSuspense??1?a.createElement(a.Suspense,{fallback:a.createElement(i,null)},a.createElement(it,{key:e.route.id,errorComponent:c,match:e},a.createElement(o,{match:e}))):a.createElement(it,{key:e.route.id,errorComponent:c,match:e},a.createElement(o,{match:e})))}class it extends a.Component{state={error:!1,info:void 0};componentDidCatch(t,e){console.error(`Error in route match: ${this.props.match.id}`),console.error(t),this.setState({error:t,info:e})}render(){return a.createElement(ct,o({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ct(t){const[e,r]=a.useState(t.errorState),s=et(),o=t.errorComponent??ht,n=a.useRef("");return a.useEffect((()=>{e&&s.state.currentLocation.key!==n.current&&r({}),n.current=s.state.currentLocation.key}),[e,s.state.currentLocation.key]),a.useEffect((()=>{t.errorState.error&&r(t.errorState)}),[t.errorState.error]),t.errorState.error&&e.error?a.createElement(o,e):t.children}function ht({error:t}){return a.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},a.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),a.createElement("div",{style:{height:".5rem"}}),a.createElement("div",null,a.createElement("pre",null,t.message?a.createElement("code",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red"}},t.message):null)))}t.DefaultErrorBoundary=ht,t.Link=Y,t.MatchRoute=function(t){const e=at()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Outlet=ot,t.ReactRouter=class extends W{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=D,t.Route=T,t.RouteMatch=N,t.Router=W,t.RouterProvider=function({router:t,...e}){t.update(e);const r=V(t.store,(t=>t.currentMatches));return a.useEffect(t.mount,[t]),a.createElement(a.Fragment,null,a.createElement(tt.Provider,{value:{router:t}},a.createElement(Z.Provider,{value:[void 0,...r]},a.createElement(ot,null))))},t.cleanPath=E,t.createBrowserHistory=u,t.createHashHistory=function(){return u({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=l,t.decode=$,t.defaultFetchServerDataFn=q,t.defaultParseSearch=B,t.defaultStringifySearch=H,t.encode=j,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=n,t.isPlainObject=w,t.joinPaths=L,t.last=f,t.lazy=function(t){const e=a.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=O,t.matchPathname=k,t.matchesContext=Z,t.parsePathname=_,t.parseSearchWith=U,t.partialDeepEqual=S,t.pick=g,t.replaceEqualDeep=v,t.resolvePath=C,t.rootRouteId=F,t.routerContext=tt,t.stringifySearchWith=z,t.trimPath=R,t.trimPathLeft=P,t.trimPathRight=x,t.useLinkProps=X,t.useMatch=st,t.useMatchRoute=at,t.useMatches=rt,t.useNavigate=function(t){const e=et();return r=>e.navigate({...t,...r})},t.useParams=function(t){const e=et();return V(e.store,(e=>{const r=f(e.currentMatches)?.params;return t?.track?.(r)??r}),!0),f(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 V(r.store,t,e),r},t.useRouterContext=et,t.useSearch=function(t){const e=st(t);return V(e.store,(e=>t?.track?.(e.search)??e.search),!0),e.state.search},t.useStore=V,t.warning=m,Object.defineProperty(t,"__esModule",{value:!0})}));
*/(t)||t.defaultPrevented||o&&"_self"!==o||0!==t.button||(t.preventDefault(),this.#u(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)},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 s=t.state.currentMatches[r];n(s&&s.id===e.id),e.store.setState((t=>({...t,...s.state})))})),{...e,...t.state,currentMatches:r}}))};#c=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 s=t.children;s?.length&&e(s)}))};return e([t]),t};#i=t=>{let{pathname:e,search:r,hash:s,state:a}=this.history.location;const o=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,o),hash:s.split("#").reverse()[0]??"",href:`${e}${r}${s}`,state:a,key:a?.key||"__init__"}};#n=()=>{this.load()};#h=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=_(this.basepath??"/",e,`${t.to??""}`);const s=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),a=this.matchRoutes(r),o={...f(s)?.params};let n=!0===(t.params??!0)?o:y(t.params,o);n&&a.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 d=!0===t.hash?this.state.latestLocation.hash:y(t.hash,this.state.latestLocation.hash);return d=d?`#${d}`:"",{pathname:r,search:u,searchStr:l,state:this.state.latestLocation.state,hash:d,href:`${r}${l}${d}`,key:t.key}};#u=t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let s="replace";t.replace||(s="push");this.state.latestLocation.href===e.href&&!e.key&&(s="replace");const a=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===s?"push":"replace"](a,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const K="undefined"==typeof window||!window.document.createElement;function J(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function G(t,e=(t=>t),s){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,s?V:void 0)}function V(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 s=0;s<r.length;s++)if(!Object.prototype.hasOwnProperty.call(e,r[s])||!Object.is(t[r[s]],e[r[s]]))return!1;return!0}function Q(t){const e=tt(),{type:r,children:s,target:o,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:g,style:v,className:w,onClick:b,onFocus:S,onMouseEnter:L,onMouseLeave:E,onTouchStart:P,onTouchEnd:x,...R}=t,_=e.buildLink(t);if("external"===_.type){const{href:t}=_;return{href:t}}const{handleClick:C,handleFocus:M,handleEnter:k,handleLeave:O,isActive:j,next:I}=_,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},$=j?y(n,{})??{}:{},F=j?{}:y(i,{})??{};return{...$,...F,...R,href:h?void 0:I.href,onClick:A([b,t=>{a.startTransition?a.startTransition((()=>{C(t)})):C(t)}]),onFocus:A([S,M]),onMouseEnter:A([L,k]),onMouseLeave:A([E,O]),target:o,style:{...v,...$.style,...F.style},className:[w,$.className,F.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}const X=a.forwardRef(((t,e)=>{const r=Q(t);return a.createElement("a",o({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))})),Y=a.createContext(null),Z=a.createContext(null);function tt(){const t=a.useContext(Z);return m(!t,"useRouter must be used inside a <Router> component!"),G(t.router.store),t.router}function et(){return a.useContext(Y)}function rt(t){const e=tt(),r=et()[0],s=t?.from?e.state.currentMatches.find((e=>e.route.id===t?.from)):r;return n(s,t?.from&&t.from),(t?.strict??1)&&n(r.route.id==s?.route.id,(s?.route.id,r.route.id,s?.route.id,s?.route.id)),G(s.store,(e=>t?.track?.(s)??s),t?.shallow),s}function st(){const t=tt();return e=>{const{pending:r,caseSensitive:s,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:s})}}function at(){const t=et().slice(1),e=t[0];return e?a.createElement(ot,{matches:t,match:e}):null}function ot({matches:t,match:e}){const r=tt();G(e.store,(t=>[t.status,t.error]),!0);const s=a.useCallback((()=>null),[]),o=a.useCallback((t=>{if("error"===t.match.state.status)throw t.match.state.error;if("success"===t.match.state.status)return a.createElement(t.match.component??r.options.defaultComponent??at);if("pending"===t.match.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??s,c=e.errorComponent??r.options.defaultErrorComponent;return a.createElement(Y.Provider,{value:t},e.route.options.wrapInSuspense??1?a.createElement(a.Suspense,{fallback:a.createElement(i,null)},a.createElement(nt,{key:e.route.id,errorComponent:c,match:e},a.createElement(o,{match:e}))):a.createElement(nt,{key:e.route.id,errorComponent:c,match:e},a.createElement(o,{match:e})))}class nt extends a.Component{state={error:!1,info:void 0};componentDidCatch(t,e){console.error(`Error in route match: ${this.props.match.id}`),console.error(t),this.setState({error:t,info:e})}render(){return a.createElement(it,o({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function it(t){const[e,r]=a.useState(t.errorState),s=tt(),o=t.errorComponent??ct,n=a.useRef("");return a.useEffect((()=>{e&&s.state.currentLocation.key!==n.current&&r({}),n.current=s.state.currentLocation.key}),[e,s.state.currentLocation.key]),a.useEffect((()=>{t.errorState.error&&r(t.errorState)}),[t.errorState.error]),t.errorState.error&&e.error?a.createElement(o,e):t.children}function ct({error:t}){return a.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},a.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),a.createElement("div",{style:{height:".5rem"}}),a.createElement("div",null,a.createElement("pre",null,t.message?a.createElement("code",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red"}},t.message):null)))}t.DefaultErrorBoundary=ct,t.Link=X,t.MatchRoute=function(t){const e=st()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Outlet=at,t.ReactRouter=class extends W{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=T,t.Route=F,t.RouteMatch=N,t.Router=W,t.RouterProvider=function({router:t,...e}){t.update(e);const r=G(t.store,(t=>t.currentMatches));return a.useEffect(t.mount,[t]),a.createElement(a.Fragment,null,a.createElement(Z.Provider,{value:{router:t}},a.createElement(Y.Provider,{value:[void 0,...r]},a.createElement(at,null))))},t.cleanPath=E,t.createBrowserHistory=u,t.createHashHistory=function(){return u({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=l,t.decode=A,t.defaultFetchServerDataFn=q,t.defaultParseSearch=B,t.defaultStringifySearch=H,t.encode=j,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=n,t.isPlainObject=w,t.joinPaths=L,t.last=f,t.lazy=function(t){const e=a.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=O,t.matchPathname=k,t.matchesContext=Y,t.parsePathname=C,t.parseSearchWith=U,t.partialDeepEqual=S,t.pick=g,t.replaceEqualDeep=v,t.resolvePath=_,t.rootRouteId=$,t.routerContext=Z,t.stringifySearchWith=z,t.trimPath=R,t.trimPathLeft=P,t.trimPathRight=x,t.useLinkProps=Q,t.useMatch=rt,t.useMatchRoute=st,t.useMatches=et,t.useNavigate=function(t){const e=tt();return r=>e.navigate({...t,...r})},t.useParams=function(t){const e=tt();return G(e.store,(e=>{const r=f(e.currentMatches)?.params;return t?.track?.(r)??r}),!0),f(e.state.currentMatches)?.params},t.useRoute=function(t){const e=tt().getRoute(t);return n(e),e},t.useRouter=function(t,e){const r=tt();return G(r.store,t,e),r},t.useRouterContext=tt,t.useSearch=function(t){const e=rt(t);return G(e.store,(e=>t?.track?.(e.search)??e.search),!0),e.state.search},t.useStore=G,t.warning=m,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/react-router",
"author": "Tanner Linsley",
"version": "0.0.1-beta.63",
"version": "0.0.1-beta.64",
"license": "MIT",

@@ -44,3 +44,3 @@ "repository": "tanstack/router",

"@babel/runtime": "^7.16.7",
"@tanstack/router": "0.0.1-beta.63",
"@tanstack/router": "0.0.1-beta.64",
"@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 not supported yet

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc