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.60 to 0.0.1-beta.61

96

build/stats-react.json

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

{
"uid": "5334-99",
"uid": "eda2-99",
"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": "5334-101"
"uid": "eda2-101"
},

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

"name": "store/build/esm/index.js",
"uid": "5334-103"
"uid": "eda2-103"
},
{
"name": "router/build/esm/index.js",
"uid": "5334-105"
"uid": "eda2-105"
},
{
"name": "react-store/build/esm/index.js",
"uid": "5334-107"
"uid": "eda2-107"
},
{
"name": "react-router/src/index.tsx",
"uid": "5334-109"
"uid": "eda2-109"
}

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

"nodeParts": {
"5334-99": {
"eda2-99": {
"renderedLength": 429,
"gzipLength": 238,
"brotliLength": 0,
"mainUid": "5334-98"
"mainUid": "eda2-98"
},
"5334-101": {
"eda2-101": {
"renderedLength": 181,
"gzipLength": 129,
"brotliLength": 0,
"mainUid": "5334-100"
"mainUid": "eda2-100"
},
"5334-103": {
"eda2-103": {
"renderedLength": 1290,
"gzipLength": 496,
"brotliLength": 0,
"mainUid": "5334-102"
"mainUid": "eda2-102"
},
"5334-105": {
"renderedLength": 44621,
"gzipLength": 10817,
"eda2-105": {
"renderedLength": 44177,
"gzipLength": 10709,
"brotliLength": 0,
"mainUid": "5334-104"
"mainUid": "eda2-104"
},
"5334-107": {
"eda2-107": {
"renderedLength": 1571,
"gzipLength": 594,
"brotliLength": 0,
"mainUid": "5334-106"
"mainUid": "eda2-106"
},
"5334-109": {
"eda2-109": {
"renderedLength": 11729,
"gzipLength": 3116,
"brotliLength": 0,
"mainUid": "5334-108"
"mainUid": "eda2-108"
}
},
"nodeMetas": {
"5334-98": {
"eda2-98": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "5334-99"
"index.production.js": "eda2-99"
},

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

{
"uid": "5334-108"
"uid": "eda2-108"
}
]
},
"5334-100": {
"eda2-100": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "5334-101"
"index.production.js": "eda2-101"
},

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

{
"uid": "5334-104"
"uid": "eda2-104"
}
]
},
"5334-102": {
"eda2-102": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "5334-103"
"index.production.js": "eda2-103"
},

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

{
"uid": "5334-104"
"uid": "eda2-104"
}
]
},
"5334-104": {
"eda2-104": {
"id": "/packages/router/build/esm/index.js",
"moduleParts": {
"index.production.js": "5334-105"
"index.production.js": "eda2-105"
},
"imported": [
{
"uid": "5334-100"
"uid": "eda2-100"
},
{
"uid": "5334-102"
"uid": "eda2-102"
}

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

{
"uid": "5334-108"
"uid": "eda2-108"
}
]
},
"5334-106": {
"eda2-106": {
"id": "/packages/react-store/build/esm/index.js",
"moduleParts": {
"index.production.js": "5334-107"
"index.production.js": "eda2-107"
},
"imported": [
{
"uid": "5334-111"
"uid": "eda2-111"
}

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

{
"uid": "5334-108"
"uid": "eda2-108"
}
]
},
"5334-108": {
"eda2-108": {
"id": "/packages/react-router/src/index.tsx",
"moduleParts": {
"index.production.js": "5334-109"
"index.production.js": "eda2-109"
},
"imported": [
{
"uid": "5334-98"
"uid": "eda2-98"
},
{
"uid": "5334-110"
"uid": "eda2-110"
},
{
"uid": "5334-104"
"uid": "eda2-104"
},
{
"uid": "5334-106"
"uid": "eda2-106"
}

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

},
"5334-110": {
"eda2-110": {
"id": "react",

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

{
"uid": "5334-108"
"uid": "eda2-108"
}

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

},
"5334-111": {
"eda2-111": {
"id": "use-sync-external-store/shim/with-selector",

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

{
"uid": "5334-106"
"uid": "eda2-106"
}

@@ -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){return L(t.filter(Boolean).join("/"))}function L(t){return t.replace(/\/{2,}/g,"/")}function E(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function P(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function _(t){return P(E(t))}function R(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let s=M(e);const a=M(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 L(S([t,...s.map((t=>t.value))]))}function M(t){if(!t)return[];const e=[];if("/"===(t=L(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 x(t,e,r){return S(M(t).map((t=>"*"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function C(t,e,r){const s=k(t,e,r);if(!r.to||s)return s??{}}function k(t,e,r){if(!e.startsWith(t))return;const s=M(e="/"!=t?e.substring(t.length):e),a=M(`${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["*"]=S(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 O(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 j(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],j(e.shift())):s[r]=j(e.shift());return s}const A="__root__";class F{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=()=>{const t=this.options,e=!t?.path&&!t?.id,r=this.options?.getParentRoute?.();e?this.path=A:n(r);let s=e?A:t.path;s&&"/"!==s&&(s=_(s));const a=t?.id||s;let o=e?A:S([r.id===A?"":r.id,a]);s===A&&(s="/"),o!==A&&(o=S(["/",o]));const i=o===A?"/":P(S([r.fullPath,s]));this.id=o,this.fullPath=i};addChildren=t=>(this.children=t,this)}const T=["component","errorComponent","pendingComponent"];class D{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"})}),this.#e()||this.store.setState((t=>({...t,status:"success"})))}cancel=()=>{this.abortController?.abort()};load=async t=>{"pending"!==this.store.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.store.state.status&&this.store.setState((t=>({...t,status:"pending"})))}));const a=(async()=>{await Promise.all(T.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.store.state.search,signal:this.abortController.signal,preload:!!t?.preload})}));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);#e=()=>!(!this.route.options.onLoad&&!T.some((t=>this.route.options[t]?.preload)));__setParentMatch=t=>{!this.parentMatch&&t&&(this.parentMatch=t)};__validate=()=>{const t=this.parentMatch?.store.state.search??this.router.store.state.latestLocation.search;try{let e=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(t)??{};this.store.setState((r=>({...r,routeSearch:e,search:{...t,...e}}))),T.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)}))}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})))}}}const I=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 s=r[e];if("string"==typeof s)try{r[e]=t(s)}catch(t){}}return r}}function H(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=O(e).toString();return r?`?${r}`:""}}const z=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 U{#s;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??N,parseSearch:t?.parseSearch??I,fetchServerDataFn:t?.fetchServerDataFn??z},this.store=new i(W()),this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,W())))};mount=()=>{if(!q){this.store.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??(q?l():u());const t=this.#o();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#s=this.history.listen((()=>{this.load(this.#o(this.store.state.latestLocation))}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${_(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.store.state.currentMatches,...this.store.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&&this.store.setState((e=>({...e,latestLocation:t}))),s=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:s,pendingLocation:this.store.state.latestLocation})))}));try{await this.loadMatches(s)}catch(t){console.warn(t),n(!1)}if(this.startedLoadingAt!==r)return this.navigationPromise;const a=this.store.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.store.state.routeSearch}),"error"===t.store.state.status&&this.store.setState((t=>({...t,status:"idle",error:void 0})))})),i.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.store.state.routeSearch})})),c.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.store.state.search})})),this.store.setState((t=>({...t,status:"idle",currentLocation:this.store.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.store.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r),r};preloadRoute=async(t=this.store.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.store.state.currentMatches,...this.store.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=C(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=x(t.path,n),a=x(t.id,n,!0),o=s.find((t=>t.id===a))||new D(this,t,{id:a,params:n,pathname:S([this.basepath,e])});r.push(o)}));const u=f(c).children;u?.length&&a(u)};return a([this.routeTree]),function(t){t.forEach(((e,r)=>{const s=t[r-1];s&&e.__setParentMatch(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){return L(t.filter(Boolean).join("/"))}function L(t){return t.replace(/\/{2,}/g,"/")}function E(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function P(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function _(t){return P(E(t))}function R(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let s=M(e);const a=M(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 L(S([t,...s.map((t=>t.value))]))}function M(t){if(!t)return[];const e=[];if("/"===(t=L(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 x(t,e,r){return S(M(t).map((t=>"*"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function C(t,e,r){const s=k(t,e,r);if(!r.to||s)return s??{}}function k(t,e,r){if(!e.startsWith(t))return;const s=M(e="/"!=t?e.substring(t.length):e),a=M(`${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["*"]=S(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 O(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 j(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],j(e.shift())):s[r]=j(e.shift());return s}const A="__root__";class F{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=()=>{const t=this.options,e=!t?.path&&!t?.id,r=this.options?.getParentRoute?.();e?this.path=A:n(r);let s=e?A:t.path;s&&"/"!==s&&(s=_(s));const a=t?.id||s;let o=e?A:S([r.id===A?"":r.id,a]);s===A&&(s="/"),o!==A&&(o=S(["/",o]));const i=o===A?"/":P(S([r.fullPath,s]));this.path=s,this.id=o,this.fullPath=i};addChildren=t=>(this.children=t,this)}const T=["component","errorComponent","pendingComponent"];class D{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"})}),this.#e()||this.store.setState((t=>({...t,status:"success"})))}cancel=()=>{this.abortController?.abort()};load=async t=>{"pending"!==this.store.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.store.state.status&&this.store.setState((t=>({...t,status:"pending"})))}));const a=(async()=>{await Promise.all(T.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.store.state.search,signal:this.abortController.signal,preload:!!t?.preload})}));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);#e=()=>!(!this.route.options.onLoad&&!T.some((t=>this.route.options[t]?.preload)));__setParentMatch=t=>{!this.parentMatch&&t&&(this.parentMatch=t)};__validate=()=>{const t=this.parentMatch?.store.state.search??this.router.store.state.latestLocation.search;try{let e=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(t)??{};this.store.setState((r=>({...r,routeSearch:e,search:{...t,...e}}))),T.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)}))}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})))}}}const I=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 s=r[e];if("string"==typeof s)try{r[e]=t(s)}catch(t){}}return r}}function H(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=O(e).toString();return r?`?${r}`:""}}const z=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 U{#s;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??N,parseSearch:t?.parseSearch??I,fetchServerDataFn:t?.fetchServerDataFn??z},this.store=new i(W()),this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,W())))};mount=()=>{if(!q){this.store.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??(q?l():u());const t=this.#o();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#s=this.history.listen((()=>{this.load(this.#o(this.store.state.latestLocation))}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${_(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.store.state.currentMatches,...this.store.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&&this.store.setState((e=>({...e,latestLocation:t}))),s=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:s,pendingLocation:this.store.state.latestLocation})))}));try{await this.loadMatches(s)}catch(t){console.warn(t),n(!1)}if(this.startedLoadingAt!==r)return this.navigationPromise;const a=this.store.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.store.state.routeSearch}),"error"===t.store.state.status&&this.store.setState((t=>({...t,status:"idle",error:void 0})))})),i.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.store.state.routeSearch})})),c.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.store.state.search})})),this.store.setState((t=>({...t,status:"idle",currentLocation:this.store.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.store.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r),r};preloadRoute=async(t=this.store.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.store.state.currentMatches,...this.store.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=C(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=x(t.path,n),a=x(t.id,n,!0),o=s.find((t=>t.id===a))||new D(this,t,{id:a,params:n,pathname:S([this.basepath,e])});r.push(o)}));const u=f(c).children;u?.length&&a(u)};return a([this.routeTree]),r};loadMatches=async(t,e)=>{var r;
/**

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

* @license MIT
*/(r),r};loadMatches=async(t,e)=>{t.forEach((async t=>{t.__validate()})),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],o=r.store.state.search;o.__data?.matchId&&o.__data.matchId!==r.id||(r.load({preload:e?.preload}),"success"!==r.store.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)=>R(this.basepath,t,L(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);return e?.pending?!!this.store.state.pendingLocation&&C(this.basepath,this.store.state.pendingLocation.pathname,{...e,to:r.pathname}):C(this.basepath,this.store.state.currentLocation.pathname,{...e,to:r.pathname})};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.store.state.currentLocation.pathname===f.pathname,g=this.store.state.currentLocation.pathname.split("/"),v=f.pathname.split("/").every(((t,e)=>t===g[e])),w=this.store.state.currentLocation.hash===f.hash;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:(i?.exact?y:v)&&(!i?.includeHash||w),disabled:d}};dehydrate=()=>({state:{...g(this.store.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.store.state.currentMatches.map((t=>({id:t.id,state:{...g(t.store.state,["status"])}})))},context:this.options.context});hydrate=t=>{this.store.setState((e=>{this.options.context=t.context;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})))})),r.forEach((t=>t.__validate())),{...e,...t.state,currentMatches:r}}))};#n=t=>{const e=t=>{t.forEach(((t,r)=>{t.init(),t.originalIndex=r,t.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={})=>{const e=t.fromCurrent?this.store.state.latestLocation.pathname:t.from??this.store.state.latestLocation.pathname;let r=R(this.basepath??"/",e,`${t.to??"."}`);const s=this.matchRoutes(this.store.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=x(r,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.store.state.latestLocation.search):this.store.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.store.state.latestLocation.search,h),l=this.options.stringifySearch(u);let d=!0===t.hash?this.store.state.latestLocation.hash:y(t.hash,this.store.state.latestLocation.hash);return d=d?`#${d}`:"",{pathname:r,search:u,searchStr:l,state:this.store.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.store.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 q="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function K(t,e=(t=>t),s){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,s?G:void 0)}function G(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 J(t){const e=Y(),{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:_,onTouchEnd:R,...M}=t,x=e.buildLink(t);if("external"===x.type){const{href:t}=x;return{href:t}}const{handleClick:C,handleFocus:k,handleEnter:O,handleLeave:j,isActive:$,next:A}=x,F=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},T=$?y(n,{})??{}:{},D=$?{}:y(i,{})??{};return{...T,...D,...M,href:h?void 0:A.href,onClick:F([S,t=>{a.startTransition?a.startTransition((()=>{C(t)})):C(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":$?"active":void 0}}const V=a.forwardRef(((t,e)=>{const r=J(t);return a.createElement("a",o({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))})),Q=a.createContext(null),X=a.createContext(null);function Y(){const t=a.useContext(X);return m(!t,"useRouter must be used inside a <Router> component!"),t.router}function Z(){return a.useContext(Q)}function tt(t){const e=Y(),r=Z()[0],s=t?.from?e.store.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)),K(s.store,(e=>t?.track?.(s)??s),t?.shallow),s}function et(){const t=Y();return e=>{const{pending:r,caseSensitive:s,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:s})}}function rt(){const t=Z().slice(1),e=t[0];return e?a.createElement(st,{matches:t,match:e}):null}function st({matches:t,match:e}){const r=Y();K(e.store);const s=a.useCallback((()=>null),[]),o=a.useCallback((t=>{if("error"===t.match.store.state.status)throw t.match.store.state.error;if("success"===t.match.store.state.status)return a.createElement(t.match.component??r.options.defaultComponent??rt);if("pending"===t.match.store.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??s,c=e.errorComponent??r.options.defaultErrorComponent;return a.createElement(Q.Provider,{value:t},a.createElement(a.Suspense,{fallback:a.createElement(i,null)},a.createElement(at,{key:e.route.id,errorComponent:c,match:e},a.createElement(o,{match:e}))))}class at 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(ot,o({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ot(t){const[e,r]=a.useState(t.errorState),s=Y(),o=t.errorComponent??nt,n=a.useRef("");return a.useEffect((()=>{e&&s.store.state.currentLocation.key!==n.current&&r({}),n.current=s.store.state.currentLocation.key}),[e,s.store.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 nt({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=nt,t.Link=V,t.MatchRoute=function(t){const e=et()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Outlet=rt,t.ReactRouter=class extends U{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=class extends F{constructor(t){super(t)}},t.Route=F,t.RouteMatch=D,t.Router=U,t.RouterProvider=function({router:t,...e}){t.update(e);const r=K(t.store,(t=>t.currentMatches),void 0);return a.useEffect(t.mount,[t]),a.createElement(a.Fragment,null,a.createElement(X.Provider,{value:{router:t}},a.createElement(Q.Provider,{value:[void 0,...r]},a.createElement(rt,null))))},t.cleanPath=L,t.createBrowserHistory=u,t.createHashHistory=function(){return u({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=l,t.decode=$,t.defaultFetchServerDataFn=z,t.defaultParseSearch=I,t.defaultStringifySearch=N,t.encode=O,t.functionalUpdate=y,t.interpolatePath=x,t.invariant=n,t.isPlainObject=w,t.joinPaths=S,t.last=f,t.lazy=function(t){const e=a.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=k,t.matchPathname=C,t.matchesContext=Q,t.parsePathname=M,t.parseSearchWith=B,t.pick=g,t.replaceEqualDeep=v,t.resolvePath=R,t.rootRouteId=A,t.routerContext=X,t.stringifySearchWith=H,t.trimPath=_,t.trimPathLeft=E,t.trimPathRight=P,t.useLinkProps=J,t.useMatch=tt,t.useMatchRoute=et,t.useMatches=Z,t.useNavigate=function(t){const e=Y();return r=>e.navigate({...t,...r})},t.useParams=function(t){const e=Y();return K(e.store,(e=>{const r=f(e.currentMatches)?.params;return t?.track?.(r)??r})),f(e.store.state.currentMatches)?.params},t.useRoute=function(t){const e=Y().getRoute(t);return n(e),e},t.useRouter=Y,t.useRouterStore=function(t,e){return K(Y().store,t,e)},t.useSearch=function(t){const e=tt(t);return K(e.store,(e=>t?.track?.(e.search)??e.search)),e.store.state.search},t.useStore=K,t.warning=m,Object.defineProperty(t,"__esModule",{value:!0})}));
*/(r=t).forEach(((t,e)=>{const s=r[e-1];s&&t.__setParentMatch(s)})),t.forEach((async t=>{t.__validate()})),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 s=t.map((async(r,s)=>{const a=t[1],o=r.store.state.search;o.__data?.matchId&&o.__data.matchId!==r.id||(r.load({preload:e?.preload}),"success"!==r.store.state.status&&r.__loadPromise&&await r.__loadPromise,a&&await a.__loadPromise)}));await Promise.all(s)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>R(this.basepath,t,L(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);return e?.pending?!!this.store.state.pendingLocation&&C(this.basepath,this.store.state.pendingLocation.pathname,{...e,to:r.pathname}):C(this.basepath,this.store.state.currentLocation.pathname,{...e,to:r.pathname})};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.store.state.currentLocation.pathname===f.pathname,g=this.store.state.currentLocation.pathname.split("/"),v=f.pathname.split("/").every(((t,e)=>t===g[e])),w=this.store.state.currentLocation.hash===f.hash;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:(i?.exact?y:v)&&(!i?.includeHash||w),disabled:d}};dehydrate=()=>({state:{...g(this.store.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.store.state.currentMatches.map((t=>({id:t.id,state:{...g(t.store.state,["status"])}})))},context:this.options.context});hydrate=t=>{this.store.setState((e=>{this.options.context=t.context;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})))})),r.forEach((t=>t.__validate())),{...e,...t.state,currentMatches:r}}))};#n=t=>{const e=t=>{t.forEach(((t,r)=>{t.init(),t.originalIndex=r,t.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={})=>{const e=t.fromCurrent?this.store.state.latestLocation.pathname:t.from??this.store.state.latestLocation.pathname;let r=R(this.basepath??"/",e,`${t.to??"."}`);const s=this.matchRoutes(this.store.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=x(r,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.store.state.latestLocation.search):this.store.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.store.state.latestLocation.search,h),l=this.options.stringifySearch(u);let d=!0===t.hash?this.store.state.latestLocation.hash:y(t.hash,this.store.state.latestLocation.hash);return d=d?`#${d}`:"",{pathname:r,search:u,searchStr:l,state:this.store.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.store.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 q="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function K(t,e=(t=>t),s){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,s?G:void 0)}function G(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 J(t){const e=Y(),{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:_,onTouchEnd:R,...M}=t,x=e.buildLink(t);if("external"===x.type){const{href:t}=x;return{href:t}}const{handleClick:C,handleFocus:k,handleEnter:O,handleLeave:j,isActive:$,next:A}=x,F=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},T=$?y(n,{})??{}:{},D=$?{}:y(i,{})??{};return{...T,...D,...M,href:h?void 0:A.href,onClick:F([S,t=>{a.startTransition?a.startTransition((()=>{C(t)})):C(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":$?"active":void 0}}const V=a.forwardRef(((t,e)=>{const r=J(t);return a.createElement("a",o({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))})),Q=a.createContext(null),X=a.createContext(null);function Y(){const t=a.useContext(X);return m(!t,"useRouter must be used inside a <Router> component!"),t.router}function Z(){return a.useContext(Q)}function tt(t){const e=Y(),r=Z()[0],s=t?.from?e.store.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)),K(s.store,(e=>t?.track?.(s)??s),t?.shallow),s}function et(){const t=Y();return e=>{const{pending:r,caseSensitive:s,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:s})}}function rt(){const t=Z().slice(1),e=t[0];return e?a.createElement(st,{matches:t,match:e}):null}function st({matches:t,match:e}){const r=Y();K(e.store);const s=a.useCallback((()=>null),[]),o=a.useCallback((t=>{if("error"===t.match.store.state.status)throw t.match.store.state.error;if("success"===t.match.store.state.status)return a.createElement(t.match.component??r.options.defaultComponent??rt);if("pending"===t.match.store.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??s,c=e.errorComponent??r.options.defaultErrorComponent;return a.createElement(Q.Provider,{value:t},a.createElement(a.Suspense,{fallback:a.createElement(i,null)},a.createElement(at,{key:e.route.id,errorComponent:c,match:e},a.createElement(o,{match:e}))))}class at 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(ot,o({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ot(t){const[e,r]=a.useState(t.errorState),s=Y(),o=t.errorComponent??nt,n=a.useRef("");return a.useEffect((()=>{e&&s.store.state.currentLocation.key!==n.current&&r({}),n.current=s.store.state.currentLocation.key}),[e,s.store.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 nt({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=nt,t.Link=V,t.MatchRoute=function(t){const e=et()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Outlet=rt,t.ReactRouter=class extends U{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=class extends F{constructor(t){super(t)}},t.Route=F,t.RouteMatch=D,t.Router=U,t.RouterProvider=function({router:t,...e}){t.update(e);const r=K(t.store,(t=>t.currentMatches),void 0);return a.useEffect(t.mount,[t]),a.createElement(a.Fragment,null,a.createElement(X.Provider,{value:{router:t}},a.createElement(Q.Provider,{value:[void 0,...r]},a.createElement(rt,null))))},t.cleanPath=L,t.createBrowserHistory=u,t.createHashHistory=function(){return u({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=l,t.decode=$,t.defaultFetchServerDataFn=z,t.defaultParseSearch=I,t.defaultStringifySearch=N,t.encode=O,t.functionalUpdate=y,t.interpolatePath=x,t.invariant=n,t.isPlainObject=w,t.joinPaths=S,t.last=f,t.lazy=function(t){const e=a.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=k,t.matchPathname=C,t.matchesContext=Q,t.parsePathname=M,t.parseSearchWith=B,t.pick=g,t.replaceEqualDeep=v,t.resolvePath=R,t.rootRouteId=A,t.routerContext=X,t.stringifySearchWith=H,t.trimPath=_,t.trimPathLeft=E,t.trimPathRight=P,t.useLinkProps=J,t.useMatch=tt,t.useMatchRoute=et,t.useMatches=Z,t.useNavigate=function(t){const e=Y();return r=>e.navigate({...t,...r})},t.useParams=function(t){const e=Y();return K(e.store,(e=>{const r=f(e.currentMatches)?.params;return t?.track?.(r)??r})),f(e.store.state.currentMatches)?.params},t.useRoute=function(t){const e=Y().getRoute(t);return n(e),e},t.useRouter=Y,t.useRouterStore=function(t,e){return K(Y().store,t,e)},t.useSearch=function(t){const e=tt(t);return K(e.store,(e=>t?.track?.(e.search)??e.search)),e.store.state.search},t.useStore=K,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.60",
"version": "0.0.1-beta.61",
"license": "MIT",

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

"@babel/runtime": "^7.16.7",
"@tanstack/router": "0.0.1-beta.60",
"@tanstack/react-store": "0.0.1-beta.57"
"@tanstack/router": "0.0.1-beta.61",
"@tanstack/react-store": "0.0.1-beta.61"
},

@@ -48,0 +48,0 @@ "devDependencies": {

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

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