Socket
Socket
Sign inDemoInstall

@tanstack/router

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/router - npm Package Compare versions

Comparing version 0.0.1-beta.70 to 0.0.1-beta.71

6

build/cjs/path.js

@@ -82,3 +82,3 @@ /**

segments.push(...split.map(part => {
if (part === '$') {
if (part === '$' || part === '*') {
return {

@@ -112,3 +112,3 @@ type: 'wildcard',

return joinPaths(interpolatedPathSegments.map(segment => {
if (segment.value === '$' && !leaveWildcard) {
if (['$', '*'].includes(segment.value) && !leaveWildcard) {
return '';

@@ -152,3 +152,3 @@ }

if (baseSegment?.value) {
params['$'] = joinPaths(baseSegments.slice(i).map(d => d.value));
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
return true;

@@ -155,0 +155,0 @@ }

@@ -84,21 +84,2 @@ /**

}
const visibilityChangeEvent = 'visibilitychange';
const focusEvent = 'focus';
// addEventListener does not exist in React Native, but window does
// In the future, we might need to invert control here for more adapters
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window.addEventListener) {
// Listen to visibilitychange and focus
window.addEventListener(visibilityChangeEvent, this.#onFocus, false);
window.addEventListener(focusEvent, this.#onFocus, false);
}
return () => {
if (window.removeEventListener) {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener(visibilityChangeEvent, this.#onFocus);
window.removeEventListener(focusEvent, this.#onFocus);
}
};
}

@@ -596,3 +577,36 @@ return () => {};

const children = route.children;
if (children?.length) recurseRoutes(children);
if (children?.length) {
recurseRoutes(children);
route.children = children.map((d, i) => {
const parsed = path.parsePathname(path.trimPathLeft(path.cleanPath(d.path ?? '/')));
while (parsed.length > 1 && parsed[0]?.value === '/') {
parsed.shift();
}
let score = 0;
parsed.forEach((d, i) => {
let modifier = 1;
while (i--) {
modifier *= 0.001;
}
if (d.type === 'pathname' && d.value !== '/') {
score += 1 * modifier;
} else if (d.type === 'param') {
score += 2 * modifier;
} else if (d.type === 'wildcard') {
score += 3 * modifier;
}
});
return {
child: d,
parsed,
index: i,
score
};
}).sort((a, b) => {
if (a.score !== b.score) {
return a.score - b.score;
}
return a.index - b.index;
}).map(d => d.child);
}
});

@@ -621,5 +635,2 @@ };

};
#onFocus = () => {
this.safeLoad();
};
#buildLocation = (dest = {}) => {

@@ -626,0 +637,0 @@ dest.fromCurrent = dest.fromCurrent ?? dest.to === '';

@@ -314,3 +314,3 @@ /**

segments.push(...split.map(part => {
if (part === '$') {
if (part === '$' || part === '*') {
return {

@@ -344,3 +344,3 @@ type: 'wildcard',

return joinPaths(interpolatedPathSegments.map(segment => {
if (segment.value === '$' && !leaveWildcard) {
if (['$', '*'].includes(segment.value) && !leaveWildcard) {
return '';

@@ -384,3 +384,3 @@ }

if (baseSegment?.value) {
params['$'] = joinPaths(baseSegments.slice(i).map(d => d.value));
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
return true;

@@ -684,21 +684,2 @@ }

}
const visibilityChangeEvent = 'visibilitychange';
const focusEvent = 'focus';
// addEventListener does not exist in React Native, but window does
// In the future, we might need to invert control here for more adapters
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window.addEventListener) {
// Listen to visibilitychange and focus
window.addEventListener(visibilityChangeEvent, this.#onFocus, false);
window.addEventListener(focusEvent, this.#onFocus, false);
}
return () => {
if (window.removeEventListener) {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener(visibilityChangeEvent, this.#onFocus);
window.removeEventListener(focusEvent, this.#onFocus);
}
};
}

@@ -1196,3 +1177,36 @@ return () => {};

const children = route.children;
if (children?.length) recurseRoutes(children);
if (children?.length) {
recurseRoutes(children);
route.children = children.map((d, i) => {
const parsed = parsePathname(trimPathLeft(cleanPath(d.path ?? '/')));
while (parsed.length > 1 && parsed[0]?.value === '/') {
parsed.shift();
}
let score = 0;
parsed.forEach((d, i) => {
let modifier = 1;
while (i--) {
modifier *= 0.001;
}
if (d.type === 'pathname' && d.value !== '/') {
score += 1 * modifier;
} else if (d.type === 'param') {
score += 2 * modifier;
} else if (d.type === 'wildcard') {
score += 3 * modifier;
}
});
return {
child: d,
parsed,
index: i,
score
};
}).sort((a, b) => {
if (a.score !== b.score) {
return a.score - b.score;
}
return a.index - b.index;
}).map(d => d.child);
}
});

@@ -1221,5 +1235,2 @@ };

};
#onFocus = () => {
this.safeLoad();
};
#buildLocation = (dest = {}) => {

@@ -1226,0 +1237,0 @@ dest.fromCurrent = dest.fromCurrent ?? dest.to === '';

@@ -14,7 +14,7 @@ {

"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "d36d-32"
"uid": "48bd-32"
},
{
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"uid": "d36d-34"
"uid": "48bd-34"
}

@@ -30,35 +30,35 @@ ]

{
"uid": "d36d-36",
"uid": "48bd-36",
"name": "history.ts"
},
{
"uid": "d36d-38",
"uid": "48bd-38",
"name": "utils.ts"
},
{
"uid": "d36d-40",
"uid": "48bd-40",
"name": "path.ts"
},
{
"uid": "d36d-42",
"uid": "48bd-42",
"name": "qss.ts"
},
{
"uid": "d36d-44",
"uid": "48bd-44",
"name": "route.ts"
},
{
"uid": "d36d-48",
"uid": "48bd-48",
"name": "searchParams.ts"
},
{
"uid": "d36d-50",
"uid": "48bd-50",
"name": "router.ts"
},
{
"uid": "d36d-52",
"uid": "48bd-52",
"name": "routeMatch.ts"
},
{
"uid": "d36d-54",
"uid": "48bd-54",
"name": "index.ts"

@@ -70,3 +70,3 @@ }

"name": "store/build/esm/index.js",
"uid": "d36d-46"
"uid": "48bd-46"
}

@@ -81,80 +81,80 @@ ]

"nodeParts": {
"d36d-32": {
"48bd-32": {
"renderedLength": 199,
"gzipLength": 134,
"brotliLength": 0,
"mainUid": "d36d-31"
"mainUid": "48bd-31"
},
"d36d-34": {
"48bd-34": {
"renderedLength": 48,
"gzipLength": 65,
"brotliLength": 0,
"mainUid": "d36d-33"
"mainUid": "48bd-33"
},
"d36d-36": {
"48bd-36": {
"renderedLength": 4236,
"gzipLength": 1085,
"brotliLength": 0,
"mainUid": "d36d-35"
"mainUid": "48bd-35"
},
"d36d-38": {
"48bd-38": {
"renderedLength": 2821,
"gzipLength": 990,
"brotliLength": 0,
"mainUid": "d36d-37"
"mainUid": "48bd-37"
},
"d36d-40": {
"renderedLength": 5676,
"gzipLength": 1330,
"48bd-40": {
"renderedLength": 5705,
"gzipLength": 1352,
"brotliLength": 0,
"mainUid": "d36d-39"
"mainUid": "48bd-39"
},
"d36d-42": {
"48bd-42": {
"renderedLength": 1395,
"gzipLength": 558,
"brotliLength": 0,
"mainUid": "d36d-41"
"mainUid": "48bd-41"
},
"d36d-44": {
"48bd-44": {
"renderedLength": 2963,
"gzipLength": 847,
"brotliLength": 0,
"mainUid": "d36d-43"
"mainUid": "48bd-43"
},
"d36d-46": {
"48bd-46": {
"renderedLength": 1384,
"gzipLength": 502,
"brotliLength": 0,
"mainUid": "d36d-45"
"mainUid": "48bd-45"
},
"d36d-48": {
"48bd-48": {
"renderedLength": 1387,
"gzipLength": 483,
"brotliLength": 0,
"mainUid": "d36d-47"
"mainUid": "48bd-47"
},
"d36d-50": {
"renderedLength": 23459,
"gzipLength": 5443,
"48bd-50": {
"renderedLength": 23692,
"gzipLength": 5432,
"brotliLength": 0,
"mainUid": "d36d-49"
"mainUid": "48bd-49"
},
"d36d-52": {
"48bd-52": {
"renderedLength": 6868,
"gzipLength": 1717,
"brotliLength": 0,
"mainUid": "d36d-51"
"mainUid": "48bd-51"
},
"d36d-54": {
"48bd-54": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "d36d-53"
"mainUid": "48bd-53"
}
},
"nodeMetas": {
"d36d-31": {
"48bd-31": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "d36d-32"
"index.production.js": "48bd-32"
},

@@ -164,16 +164,16 @@ "imported": [],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-43"
"uid": "48bd-43"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
}
]
},
"d36d-33": {
"48bd-33": {
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"moduleParts": {
"index.production.js": "d36d-34"
"index.production.js": "48bd-34"
},

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

{
"uid": "d36d-53"
"uid": "48bd-53"
}
]
},
"d36d-35": {
"48bd-35": {
"id": "/packages/router/src/history.ts",
"moduleParts": {
"index.production.js": "d36d-36"
"index.production.js": "48bd-36"
},

@@ -196,13 +196,13 @@ "imported": [],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
}
]
},
"d36d-37": {
"48bd-37": {
"id": "/packages/router/src/utils.ts",
"moduleParts": {
"index.production.js": "d36d-38"
"index.production.js": "48bd-38"
},

@@ -212,23 +212,23 @@ "imported": [],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-39"
"uid": "48bd-39"
},
{
"uid": "d36d-51"
"uid": "48bd-51"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
}
]
},
"d36d-39": {
"48bd-39": {
"id": "/packages/router/src/path.ts",
"moduleParts": {
"index.production.js": "d36d-40"
"index.production.js": "48bd-40"
},
"imported": [
{
"uid": "d36d-37"
"uid": "48bd-37"
}

@@ -238,16 +238,16 @@ ],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-43"
"uid": "48bd-43"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
}
]
},
"d36d-41": {
"48bd-41": {
"id": "/packages/router/src/qss.ts",
"moduleParts": {
"index.production.js": "d36d-42"
"index.production.js": "48bd-42"
},

@@ -257,20 +257,20 @@ "imported": [],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-47"
"uid": "48bd-47"
}
]
},
"d36d-43": {
"48bd-43": {
"id": "/packages/router/src/route.ts",
"moduleParts": {
"index.production.js": "d36d-44"
"index.production.js": "48bd-44"
},
"imported": [
{
"uid": "d36d-31"
"uid": "48bd-31"
},
{
"uid": "d36d-39"
"uid": "48bd-39"
}

@@ -280,10 +280,10 @@ ],

{
"uid": "d36d-53"
"uid": "48bd-53"
}
]
},
"d36d-45": {
"48bd-45": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "d36d-46"
"index.production.js": "48bd-46"
},

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

{
"uid": "d36d-51"
"uid": "48bd-51"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
}
]
},
"d36d-47": {
"48bd-47": {
"id": "/packages/router/src/searchParams.ts",
"moduleParts": {
"index.production.js": "d36d-48"
"index.production.js": "48bd-48"
},
"imported": [
{
"uid": "d36d-41"
"uid": "48bd-41"
}

@@ -313,35 +313,35 @@ ],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
}
]
},
"d36d-49": {
"48bd-49": {
"id": "/packages/router/src/router.ts",
"moduleParts": {
"index.production.js": "d36d-50"
"index.production.js": "48bd-50"
},
"imported": [
{
"uid": "d36d-45"
"uid": "48bd-45"
},
{
"uid": "d36d-31"
"uid": "48bd-31"
},
{
"uid": "d36d-39"
"uid": "48bd-39"
},
{
"uid": "d36d-51"
"uid": "48bd-51"
},
{
"uid": "d36d-47"
"uid": "48bd-47"
},
{
"uid": "d36d-37"
"uid": "48bd-37"
},
{
"uid": "d36d-35"
"uid": "48bd-35"
}

@@ -351,23 +351,23 @@ ],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-51"
"uid": "48bd-51"
}
]
},
"d36d-51": {
"48bd-51": {
"id": "/packages/router/src/routeMatch.ts",
"moduleParts": {
"index.production.js": "d36d-52"
"index.production.js": "48bd-52"
},
"imported": [
{
"uid": "d36d-45"
"uid": "48bd-45"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
},
{
"uid": "d36d-37"
"uid": "48bd-37"
}

@@ -377,53 +377,53 @@ ],

{
"uid": "d36d-53"
"uid": "48bd-53"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
}
]
},
"d36d-53": {
"48bd-53": {
"id": "/packages/router/src/index.ts",
"moduleParts": {
"index.production.js": "d36d-54"
"index.production.js": "48bd-54"
},
"imported": [
{
"uid": "d36d-31"
"uid": "48bd-31"
},
{
"uid": "d36d-33"
"uid": "48bd-33"
},
{
"uid": "d36d-35"
"uid": "48bd-35"
},
{
"uid": "d36d-55"
"uid": "48bd-55"
},
{
"uid": "d36d-56"
"uid": "48bd-56"
},
{
"uid": "d36d-39"
"uid": "48bd-39"
},
{
"uid": "d36d-41"
"uid": "48bd-41"
},
{
"uid": "d36d-43"
"uid": "48bd-43"
},
{
"uid": "d36d-57"
"uid": "48bd-57"
},
{
"uid": "d36d-51"
"uid": "48bd-51"
},
{
"uid": "d36d-49"
"uid": "48bd-49"
},
{
"uid": "d36d-47"
"uid": "48bd-47"
},
{
"uid": "d36d-37"
"uid": "48bd-37"
}

@@ -434,3 +434,3 @@ ],

},
"d36d-55": {
"48bd-55": {
"id": "/packages/router/src/frameworks.ts",

@@ -441,7 +441,7 @@ "moduleParts": {},

{
"uid": "d36d-53"
"uid": "48bd-53"
}
]
},
"d36d-56": {
"48bd-56": {
"id": "/packages/router/src/link.ts",

@@ -452,7 +452,7 @@ "moduleParts": {},

{
"uid": "d36d-53"
"uid": "48bd-53"
}
]
},
"d36d-57": {
"48bd-57": {
"id": "/packages/router/src/routeInfo.ts",

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

{
"uid": "d36d-53"
"uid": "48bd-53"
}

@@ -466,0 +466,0 @@ ]

@@ -343,3 +343,3 @@ /**

segments.push(...split.map(part => {
if (part === '$') {
if (part === '$' || part === '*') {
return {

@@ -373,3 +373,3 @@ type: 'wildcard',

return joinPaths(interpolatedPathSegments.map(segment => {
if (segment.value === '$' && !leaveWildcard) {
if (['$', '*'].includes(segment.value) && !leaveWildcard) {
return '';

@@ -413,3 +413,3 @@ }

if (baseSegment?.value) {
params['$'] = joinPaths(baseSegments.slice(i).map(d => d.value));
params['*'] = joinPaths(baseSegments.slice(i).map(d => d.value));
return true;

@@ -762,21 +762,2 @@ }

}
const visibilityChangeEvent = 'visibilitychange';
const focusEvent = 'focus';
// addEventListener does not exist in React Native, but window does
// In the future, we might need to invert control here for more adapters
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window.addEventListener) {
// Listen to visibilitychange and focus
window.addEventListener(visibilityChangeEvent, this.#onFocus, false);
window.addEventListener(focusEvent, this.#onFocus, false);
}
return () => {
if (window.removeEventListener) {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener(visibilityChangeEvent, this.#onFocus);
window.removeEventListener(focusEvent, this.#onFocus);
}
};
}

@@ -1274,3 +1255,36 @@ return () => {};

const children = route.children;
if (children?.length) recurseRoutes(children);
if (children?.length) {
recurseRoutes(children);
route.children = children.map((d, i) => {
const parsed = parsePathname(trimPathLeft(cleanPath(d.path ?? '/')));
while (parsed.length > 1 && parsed[0]?.value === '/') {
parsed.shift();
}
let score = 0;
parsed.forEach((d, i) => {
let modifier = 1;
while (i--) {
modifier *= 0.001;
}
if (d.type === 'pathname' && d.value !== '/') {
score += 1 * modifier;
} else if (d.type === 'param') {
score += 2 * modifier;
} else if (d.type === 'wildcard') {
score += 3 * modifier;
}
});
return {
child: d,
parsed,
index: i,
score
};
}).sort((a, b) => {
if (a.score !== b.score) {
return a.score - b.score;
}
return a.index - b.index;
}).map(d => d.child);
}
});

@@ -1299,5 +1313,2 @@ };

};
#onFocus = () => {
this.safeLoad();
};
#buildLocation = (dest = {}) => {

@@ -1304,0 +1315,0 @@ dest.fromCurrent = dest.fromCurrent ?? dest.to === '';

@@ -11,3 +11,3 @@ /**

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={})}(this,(function(t){"use strict";function e(t,e){if(!t)throw new Error("Invariant failed")}const s="popstate";function a(t){let e=t.getLocation(),s=()=>{},a=new Set;const r=()=>{e=t.getLocation(),a.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===a.size&&(s=t.listener(r)),a.add(e),()=>{a.delete(e),0===a.size&&s()}),push:(e,s)=>{t.pushState(e,s),r()},replace:(e,s)=>{t.replaceState(e,s),r()},go:e=>{t.go(e),r()},back:()=>{t.back(),r()},forward:()=>{t.forward(),r()}}}function r(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return a({getLocation:()=>n(e(),history.state),listener:t=>(window.addEventListener(s,t),()=>{window.removeEventListener(s,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:i()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:i()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function o(t={initialEntries:["/"]}){const e=t.initialEntries;let s=t.initialIndex??e.length-1,r={};return a({getLocation:()=>n(e[s],r),listener:()=>()=>{},pushState:(t,a)=>{r={...a,key:i()},e.push(t),s++},replaceState:(t,a)=>{r={...a,key:i()},e[s]=t},back:()=>{s--},forward:()=>{s=Math.min(s+1,e.length-1)},go:t=>window.history.go(t)})}function n(t,e){let s=t.indexOf("#"),a=t.indexOf("?");return{href:t,pathname:t.substring(0,s>0?a>0?Math.min(s,a):s:a>0?a:t.length),hash:s>-1?t.substring(s,a):"",search:a>-1?t.substring(a):"",state:e}}function i(){return(Math.random()+1).toString(36).substring(7)}function h(t){return t[t.length-1]}function c(t,e){return"function"==typeof t?t(e):t}function u(t,e){return e.reduce(((e,s)=>(e[s]=t[s],e)),{})}function l(t,e){if(t===e)return t;const s=e,a=Array.isArray(t)&&Array.isArray(s);if(a||p(t)&&p(s)){const e=a?t.length:Object.keys(t).length,r=a?s:Object.keys(s),o=r.length,n=a?[]:{};let i=0;for(let e=0;e<o;e++){const o=a?e:r[e];n[o]=l(t[o],s[o]),n[o]===t[o]&&i++}return e===o&&i===e?t:n}return s}function p(t){if(!d(t))return!1;const e=t.constructor;if(void 0===e)return!0;const s=e.prototype;return!!d(s)&&!!s.hasOwnProperty("isPrototypeOf")}function d(t){return"[object Object]"===Object.prototype.toString.call(t)}function f(t,e){return t===e||typeof t==typeof e&&(p(t)&&p(e)?!Object.keys(e).some((s=>!f(t[s],e[s]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,s)=>f(t,e[s])))))}function m(t){return g(t.filter(Boolean).join("/"))}function g(t){return t.replace(/\/{2,}/g,"/")}function y(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function v(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function w(t){return v(y(t))}function S(t,e,s){e=e.replace(new RegExp(`^${t}`),"/"),s=s.replace(new RegExp(`^${t}`),"/");let a=L(e);const r=L(s);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&a.push(t):a=[t];else if(".."===t.value)a.length>1&&"/"===h(a)?.value&&a.pop(),a.pop();else{if("."===t.value)return;a.push(t)}}));return g(m([t,...a.map((t=>t.value))]))}function L(t){if(!t)return[];const e=[];if("/"===(t=g(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const s=t.split("/").filter(Boolean);return e.push(...s.map((t=>"$"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function b(t,e,s){return m(L(t).map((t=>"$"!==t.value||s?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function P(t,e,s){const a=_(t,e,s);if(!s.to||a)return a??{}}function _(t,e,s){if(!e.startsWith(t))return;const a=L(e="/"!=t?e.substring(t.length):e),r=L(`${s.to??"$"}`);"/"===h(a)?.value&&a.pop();const o={};return(()=>{for(let t=0;t<Math.max(a.length,r.length);t++){const e=a[t],n=r[t],i=t===r.length-1,h=t===a.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(o.$=m(a.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(s.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&&!h)return!!s.fuzzy}return!0})()?o:void 0}function x(t,e){var s,a,r,o="";for(s in t)if(void 0!==(r=t[s]))if(Array.isArray(r))for(a=0;a<r.length;a++)o&&(o+="&"),o+=encodeURIComponent(s)+"="+encodeURIComponent(r[a]);else o&&(o+="&"),o+=encodeURIComponent(s)+"="+encodeURIComponent(r);return(e||"")+o}function E(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function R(t){for(var e,s,a={},r=t.split("&");e=r.shift();)void 0!==a[s=(e=e.split("=")).shift()]?a[s]=[].concat(a[s],E(e.shift())):a[s]=E(e.shift());return a}const M="__root__";class C{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const s=this.options,a=!s?.path&&!s?.id,r=this.options?.getParentRoute?.();a?this.path=M:e(r);let o=a?M:s.path;o&&"/"!==o&&(o=w(o));const n=s?.id||o;let i=a?M:m([r.id===M?"":r.id,n]);o===M&&(o="/"),i!==M&&(i=m(["/",i]));const h=i===M?"/":v(m([r.fullPath,o]));this.path=o,this.id=i,this.fullPath=h};addChildren=t=>(this.children=t,this);generate=t=>{e(!1)}}class $ extends C{constructor(t){super(t)}static withRouterContext=()=>t=>new $(t)}
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={})}(this,(function(t){"use strict";function e(t,e){if(!t)throw new Error("Invariant failed")}const a="popstate";function s(t){let e=t.getLocation(),a=()=>{},s=new Set;const r=()=>{e=t.getLocation(),s.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===s.size&&(a=t.listener(r)),s.add(e),()=>{s.delete(e),0===s.size&&a()}),push:(e,a)=>{t.pushState(e,a),r()},replace:(e,a)=>{t.replaceState(e,a),r()},go:e=>{t.go(e),r()},back:()=>{t.back(),r()},forward:()=>{t.forward(),r()}}}function r(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return s({getLocation:()=>i(e(),history.state),listener:t=>(window.addEventListener(a,t),()=>{window.removeEventListener(a,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:n()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:n()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function o(t={initialEntries:["/"]}){const e=t.initialEntries;let a=t.initialIndex??e.length-1,r={};return s({getLocation:()=>i(e[a],r),listener:()=>()=>{},pushState:(t,s)=>{r={...s,key:n()},e.push(t),a++},replaceState:(t,s)=>{r={...s,key:n()},e[a]=t},back:()=>{a--},forward:()=>{a=Math.min(a+1,e.length-1)},go:t=>window.history.go(t)})}function i(t,e){let a=t.indexOf("#"),s=t.indexOf("?");return{href:t,pathname:t.substring(0,a>0?s>0?Math.min(a,s):a:s>0?s:t.length),hash:a>-1?t.substring(a,s):"",search:s>-1?t.substring(s):"",state:e}}function n(){return(Math.random()+1).toString(36).substring(7)}function h(t){return t[t.length-1]}function c(t,e){return"function"==typeof t?t(e):t}function u(t,e){return e.reduce(((e,a)=>(e[a]=t[a],e)),{})}function l(t,e){if(t===e)return t;const a=e,s=Array.isArray(t)&&Array.isArray(a);if(s||p(t)&&p(a)){const e=s?t.length:Object.keys(t).length,r=s?a:Object.keys(a),o=r.length,i=s?[]:{};let n=0;for(let e=0;e<o;e++){const o=s?e:r[e];i[o]=l(t[o],a[o]),i[o]===t[o]&&n++}return e===o&&n===e?t:i}return a}function p(t){if(!d(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!d(a)&&!!a.hasOwnProperty("isPrototypeOf")}function d(t){return"[object Object]"===Object.prototype.toString.call(t)}function f(t,e){return t===e||typeof t==typeof e&&(p(t)&&p(e)?!Object.keys(e).some((a=>!f(t[a],e[a]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,a)=>f(t,e[a])))))}function m(t){return g(t.filter(Boolean).join("/"))}function g(t){return t.replace(/\/{2,}/g,"/")}function y(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function v(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function w(t){return v(y(t))}function S(t,e,a){e=e.replace(new RegExp(`^${t}`),"/"),a=a.replace(new RegExp(`^${t}`),"/");let s=b(e);const r=b(a);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&s.push(t):s=[t];else if(".."===t.value)s.length>1&&"/"===h(s)?.value&&s.pop(),s.pop();else{if("."===t.value)return;s.push(t)}}));return g(m([t,...s.map((t=>t.value))]))}function b(t){if(!t)return[];const e=[];if("/"===(t=g(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const a=t.split("/").filter(Boolean);return e.push(...a.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function L(t,e,a){return m(b(t).map((t=>["$","*"].includes(t.value)&&!a?"":"param"===t.type?e[t.value.substring(1)]??"":t.value)))}function P(t,e,a){const s=_(t,e,a);if(!a.to||s)return s??{}}function _(t,e,a){if(!e.startsWith(t))return;const s=b(e="/"!=t?e.substring(t.length):e),r=b(`${a.to??"$"}`);"/"===h(s)?.value&&s.pop();const o={};return(()=>{for(let t=0;t<Math.max(s.length,r.length);t++){const e=s[t],i=r[t],n=t===r.length-1,h=t===s.length-1;if(i){if("wildcard"===i.type)return!!e?.value&&(o["*"]=m(s.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&!e?.value)return!0;if(e)if(a.caseSensitive){if(i.value!==e.value)return!1}else if(i.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===i.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(o[i.value.substring(1)]=e.value)}}if(n&&!h)return!!a.fuzzy}return!0})()?o:void 0}function x(t,e){var a,s,r,o="";for(a in t)if(void 0!==(r=t[a]))if(Array.isArray(r))for(s=0;s<r.length;s++)o&&(o+="&"),o+=encodeURIComponent(a)+"="+encodeURIComponent(r[s]);else o&&(o+="&"),o+=encodeURIComponent(a)+"="+encodeURIComponent(r);return(e||"")+o}function R(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function E(t){for(var e,a,s={},r=t.split("&");e=r.shift();)void 0!==s[a=(e=e.split("=")).shift()]?s[a]=[].concat(s[a],R(e.shift())):s[a]=R(e.shift());return s}const M="__root__";class C{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const a=this.options,s=!a?.path&&!a?.id,r=this.options?.getParentRoute?.();s?this.path=M:e(r);let o=s?M:a.path;o&&"/"!==o&&(o=w(o));const i=a?.id||o;let n=s?M:m([r.id===M?"":r.id,i]);o===M&&(o="/"),n!==M&&(n=m(["/",n]));const h=n===M?"/":v(m([r.fullPath,o]));this.path=o,this.id=n,this.fullPath=h};addChildren=t=>(this.children=t,this);generate=t=>{e(!1)}}class $ extends C{constructor(t){super(t)}static withRouterContext=()=>t=>new $(t)}
/**

@@ -22,3 +22,3 @@ * store

* @license MIT
*/class I{listeners=new Set;batching=!1;queue=[];constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=t=>{const e=this.state;this.state=this.options?.updateFn?this.options.updateFn(e)(t):t(e),this.state!==e&&(this.options?.onUpdate?.(this.state,e),this.queue.push((()=>{this.listeners.forEach((t=>t(this.state,e)))})),this.#t())};#t=()=>{this.batching||(this.queue.forEach((t=>t())),this.queue=[])};batch=t=>{this.batching=!0,t(),this.batching=!1,this.#t()}}const A=F(JSON.parse),k=T(JSON.stringify);function F(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let s=R(e);for(let e in s){const a=s[e];if("string"==typeof a)try{s[e]=t(a)}catch(t){}}return s}}function T(t){return e=>{(e={...e})&&Object.keys(e).forEach((s=>{const a=e[s];if(void 0===a||void 0===a)delete e[s];else if(a&&"object"==typeof a&&null!==a)try{e[s]=t(a)}catch(t){}}));const s=x(e).toString();return s?`?${s}`:""}}const j=async({router:t,routeMatch:e})=>{const s=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),a=await fetch(s.href,{method:"GET",signal:e.abortController.signal});if(a.ok)return a.json();throw new Error("Failed to fetch match data")};const D="undefined"==typeof window||!window.document.createElement;function O(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function H(t){return!!t?.isRedirect}const N=["component","errorComponent","pendingComponent"];class U{abortController=new AbortController;onLoaderDataListeners=new Set;constructor(t,e,s){Object.assign(this,{route:e,router:t,id:s.id,pathname:s.pathname,params:s.params,store:new I({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.store.state,N.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"idle"!==this.state.status||this.#e()||this.store.setState((t=>({...t,status:"success"})))}#e=()=>!(!this.route.options.onLoad&&!N.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:s,routeContext:a}=this.#s({location:this.router.state.currentLocation});this.context=s,this.routeContext=a,this.store.setState((s=>({...s,routeSearch:l(s.routeSearch,t),search:l(s.search,e)})))};cancel=()=>{this.abortController?.abort()};#a=t=>{const e=this.parentMatch?this.parentMatch.#a(t):{search:t.location.search,routeSearch:t.location.search};try{const t=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(e.search)??{};return{routeSearch:t,search:{...e.search,...t}}}catch(t){if(H(t))throw t;this.route.options.onValidateSearchError?.(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#s=t=>{const{search:e,routeSearch:s}=this.#a(t),a=this.route.options.getContext?.({parentContext:this.parentMatch?.routeContext??{},context:this.parentMatch?.context??this.router?.options.context??{},params:this.params,search:e})||{};return{routeSearch:s,search:e,context:{...this.parentMatch?.context??this.router?.options.context,...a},routeContext:a}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#s(t)}catch(t){return H(t)?void this.router.navigate(t):(this.route.options.onError?.(t),void this.store.setState((e=>({...e,status:"error",error:t}))))}const{routeSearch:s,search:a,context:r,routeContext:o}=e;if("pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#r=e;const n=()=>e!==this.#r?this.__loadPromise:void 0;let i;"idle"===this.state.status&&this.store.setState((t=>({...t,status:"pending"})));const h=(async()=>{await Promise.all(N.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),c=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,routeSearch:s,search:a,signal:this.abortController.signal,preload:!!t?.preload,routeContext:o,context:r})}));try{if(await Promise.all([h,c]),i=n())return await i;this.store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(t){if(H(t))return void this.router.navigate(t);this.route.options.onLoadError?.(t),this.route.options.onError?.(t),this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#r=""}t.RootRoute=$,t.Route=C,t.RouteMatch=U,t.Router=class{#o;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??k,parseSearch:t?.parseSearch??A,fetchServerDataFn:t?.fetchServerDataFn??j},this.store=new I(O(),{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,O())))};mount=()=>{if(!D){this.state.currentMatches.length||this.safeLoad();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??(D?o():r());const t=this.#i();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#o=this.history.listen((()=>{this.safeLoad({next:this.#i(this.state.latestLocation)})}))}const{basepath:e,routeTree:s}=this.options;return this.basepath=`/${w(e??"")??""}`,s&&(this.routesById={},this.routeTree=this.#h(s)),this};buildNext=t=>{const e=this.#c(t),s=this.matchRoutes(e.pathname),a=s.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),r=s.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#c({...t,__preSearchFilters:a,__postSearchFilters:r})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),e(!1)}))};load=async t=>{let e=Date.now();const s=e;let a;if(this.startedLoadingAt=s,this.cancelMatches(),this.store.batch((()=>{t?.next&&this.store.setState((e=>({...e,latestLocation:t.next}))),a=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:a,pendingLocation:this.state.latestLocation})))})),await this.loadMatches(a,this.state.pendingLocation),this.startedLoadingAt!==s)return this.navigationPromise;const r=this.state.currentMatches,o=[],n=[];r.forEach((t=>{a.find((e=>e.id===t.id))?n.push(t):o.push(t)}));const i=a.filter((t=>!r.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})))})),n.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),i.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})}));const h=this.state.currentLocation;this.store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:a,pendingLocation:void 0,pendingMatches:void 0}))),a.forEach((t=>{t.__commit()})),h.href!==this.state.currentLocation.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const s=this.routesById[t];return e(s),s};loadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),s=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(s,e),s};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),s=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(s,e,{preload:!0}),s};matchRoutes=(t,e)=>{const s=[];if(!this.routeTree)return s;const a=[...this.state.currentMatches,...this.state.pendingMatches??[]],r=async o=>{let n=h(s)?.params??{};const i=this.options.filterRoutes?.(o)??o;let c=[];const u=(s,a)=>(a.some((a=>{const r=a.children;if(!a.path&&r?.length)return u([...c,a],r);const o=!("/"===a.path&&!r?.length),i=P(this.basepath,t,{to:a.fullPath,fuzzy:o,caseSensitive:a.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=a.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...s,a]),!!c.length})),!!c.length);if(u([],i),!c.length)return;c.forEach((t=>{const e=b(t.path,n),r=b(t.id,n,!0),o=a.find((t=>t.id===r))||new U(this,t,{id:r,params:n,pathname:m([this.basepath,e])});s.push(o)}));const l=h(c).children;l?.length&&r(l)};return r([this.routeTree]),s};loadMatches=async(t,e,s)=>{await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(e){throw s?.preload||t.route.options.onBeforeLoadError?.(e),t.route.options.onError?.(e),e}})));const a=t.map((async(a,r)=>{const o=t[r-1];a.__load({preload:s?.preload,location:e,parentMatch:o}),await a.__loadPromise,o&&await o.__loadPromise}));await Promise.all(a)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>S(this.basepath,t,g(e));navigate=async({from:t,to:s="",search:a,hash:r,replace:o,params:n})=>{const i=String(s),h=void 0===t?t:String(t);let c;try{new URL(`${i}`),c=!0}catch(t){}return e(!c),this.#u({from:h,to:i,search:a,hash:r,replace:o,params:n})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const s=this.buildNext(t),a=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!a)return!1;const r=P(this.basepath,a.pathname,{...e,to:s.pathname});return!!r&&(e?.includeSearch??1?!!f(a.search,s.search)&&r:r)};buildLink=({from:t,to:e=".",search:s,params:a,hash:r,target:o,replace:n,activeOptions:i,preload:h,preloadDelay:c,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:s,params:a,hash:r,replace:n},p=this.buildNext(l);h=h??this.options.defaultPreload;const d=c??this.options.defaultPreloadDelay??0,m=this.state.currentLocation.pathname.split("/"),g=p.pathname.split("/").every(((t,e)=>t===m[e])),y=i?.exact?this.state.currentLocation.pathname===p.pathname:g,v=!i?.includeHash||this.state.currentLocation.hash===p.hash,w=!(i?.includeSearch??1)||f(this.state.currentLocation.search,p.search);return{type:"internal",next:p,handleFocus:t=>{h&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||o&&"_self"!==o||0!==t.button||(t.preventDefault(),this.#u(l))},handleEnter:t=>{const e=t.target||{};if(h){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),d)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&v&&w,disabled:u}};dehydrate=()=>({state:{...u(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((s=>{const a=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return a.forEach(((s,a)=>{const r=t.state.currentMatches[a];e(r&&r.id===s.id),s.store.setState((t=>({...t,...r.state})))})),{...s,...t.state,currentMatches:a}}))};#h=t=>{const e=t=>{t.forEach(((t,s)=>{t.init({originalIndex:s,router:this});if(this.routesById[t.id])throw new Error;this.routesById[t.id]=t;const a=t.children;a?.length&&e(a)}))};return e([t]),t};#i=t=>{let{pathname:e,search:s,hash:a,state:r}=this.history.location;const o=this.options.parseSearch(s);return{pathname:e,searchStr:s,search:l(t?.search,o),hash:a.split("#").reverse()[0]??"",href:`${e}${s}${a}`,state:r,key:r?.key||"__init__"}};#n=()=>{this.safeLoad()};#c=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let s=S(this.basepath??"/",e,`${t.to??""}`);const a=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),r=this.matchRoutes(s),o={...h(a)?.params};let n=!0===(t.params??!0)?o:c(t.params,o);n&&r.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},n,t(n))})),s=b(s,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,u=!0===t.search?i:t.search?c(t.search,i)??{}:t.__preSearchFilters?.length?i:{},p=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),u):u,d=l(this.state.latestLocation.search,p),f=this.options.stringifySearch(d);let m=!0===t.hash?this.state.latestLocation.hash:c(t.hash,this.state.latestLocation.hash);return m=m?`#${m}`:"",{pathname:s,search:d,searchStr:f,state:this.state.latestLocation.state,hash:m,href:`${s}${f}${m}`,key:t.key}};#u=async t=>{const e=this.buildNext(t),s=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let a="replace";t.replace||(a="push");this.state.latestLocation.href===e.href&&!e.key&&(a="replace");const r=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===a?"push":"replace"](r,{id:s,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}},t.cleanPath=g,t.createBrowserHistory=r,t.createHashHistory=function(){return r({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=o,t.decode=R,t.defaultFetchServerDataFn=j,t.defaultParseSearch=A,t.defaultStringifySearch=k,t.encode=x,t.functionalUpdate=c,t.interpolatePath=b,t.invariant=e,t.isPlainObject=p,t.isRedirect=H,t.joinPaths=m,t.last=h,t.matchByPath=_,t.matchPathname=P,t.parsePathname=L,t.parseSearchWith=F,t.partialDeepEqual=f,t.pick=u,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=l,t.resolvePath=S,t.rootRouteId=M,t.stringifySearchWith=T,t.trimPath=w,t.trimPathLeft=y,t.trimPathRight=v,t.warning=function(t,e){},Object.defineProperty(t,"__esModule",{value:!0})}));
*/class I{listeners=new Set;batching=!1;queue=[];constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=t=>{const e=this.state;this.state=this.options?.updateFn?this.options.updateFn(e)(t):t(e),this.state!==e&&(this.options?.onUpdate?.(this.state,e),this.queue.push((()=>{this.listeners.forEach((t=>t(this.state,e)))})),this.#t())};#t=()=>{this.batching||(this.queue.forEach((t=>t())),this.queue=[])};batch=t=>{this.batching=!0,t(),this.batching=!1,this.#t()}}const A=T(JSON.parse),k=j(JSON.stringify);function T(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=E(e);for(let e in a){const s=a[e];if("string"==typeof s)try{a[e]=t(s)}catch(t){}}return a}}function j(t){return e=>{(e={...e})&&Object.keys(e).forEach((a=>{const s=e[a];if(void 0===s||void 0===s)delete e[a];else if(s&&"object"==typeof s&&null!==s)try{e[a]=t(s)}catch(t){}}));const a=x(e).toString();return a?`?${a}`:""}}const D=async({router:t,routeMatch:e})=>{const a=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),s=await fetch(a.href,{method:"GET",signal:e.abortController.signal});if(s.ok)return s.json();throw new Error("Failed to fetch match data")};const O="undefined"==typeof window||!window.document.createElement;function F(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function H(t){return!!t?.isRedirect}const N=["component","errorComponent","pendingComponent"];class U{abortController=new AbortController;onLoaderDataListeners=new Set;constructor(t,e,a){Object.assign(this,{route:e,router:t,id:a.id,pathname:a.pathname,params:a.params,store:new I({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.store.state,N.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"idle"!==this.state.status||this.#e()||this.store.setState((t=>({...t,status:"success"})))}#e=()=>!(!this.route.options.onLoad&&!N.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:a,routeContext:s}=this.#a({location:this.router.state.currentLocation});this.context=a,this.routeContext=s,this.store.setState((a=>({...a,routeSearch:l(a.routeSearch,t),search:l(a.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){if(H(t))throw t;this.route.options.onValidateSearchError?.(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#a=t=>{const{search:e,routeSearch:a}=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:a,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.#a(t)}catch(t){return H(t)?void this.router.navigate(t):(this.route.options.onError?.(t),void this.store.setState((e=>({...e,status:"error",error:t}))))}const{routeSearch:a,search:s,context:r,routeContext:o}=e;if("pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#r=e;const i=()=>e!==this.#r?this.__loadPromise:void 0;let n;"idle"===this.state.status&&this.store.setState((t=>({...t,status:"pending"})));const h=(async()=>{await Promise.all(N.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),c=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,routeSearch:a,search:s,signal:this.abortController.signal,preload:!!t?.preload,routeContext:o,context:r})}));try{if(await Promise.all([h,c]),n=i())return await n;this.store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(t){if(H(t))return void this.router.navigate(t);this.route.options.onLoadError?.(t),this.route.options.onError?.(t),this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#r=""}t.RootRoute=$,t.Route=C,t.RouteMatch=U,t.Router=class{#o;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??k,parseSearch:t?.parseSearch??A,fetchServerDataFn:t?.fetchServerDataFn??D},this.store=new I(F(),{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,F())))};mount=()=>(O||this.state.currentMatches.length||this.safeLoad(),()=>{});update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#o&&this.#o(),this.history=this.options.history??(O?o():r());const t=this.#i();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#o=this.history.listen((()=>{this.safeLoad({next:this.#i(this.state.latestLocation)})}))}const{basepath:e,routeTree:a}=this.options;return this.basepath=`/${w(e??"")??""}`,a&&(this.routesById={},this.routeTree=this.#n(a)),this};buildNext=t=>{const e=this.#h(t),a=this.matchRoutes(e.pathname),s=a.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),r=a.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#h({...t,__preSearchFilters:s,__postSearchFilters:r})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),e(!1)}))};load=async t=>{let e=Date.now();const a=e;let s;if(this.startedLoadingAt=a,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})))})),await this.loadMatches(s,this.state.pendingLocation),this.startedLoadingAt!==a)return this.navigationPromise;const r=this.state.currentMatches,o=[],i=[];r.forEach((t=>{s.find((e=>e.id===t.id))?i.push(t):o.push(t)}));const n=s.filter((t=>!r.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})})),n.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 a=this.routesById[t];return e(a),a};loadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),a=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(a,e),a};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),a=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(a,e,{preload:!0}),a};matchRoutes=(t,e)=>{const a=[];if(!this.routeTree)return a;const s=[...this.state.currentMatches,...this.state.pendingMatches??[]],r=async o=>{let i=h(a)?.params??{};const n=this.options.filterRoutes?.(o)??o;let c=[];const u=(a,s)=>(s.some((s=>{const r=s.children;if(!s.path&&r?.length)return u([...c,s],r);const o=!("/"===s.path&&!r?.length),n=P(this.basepath,t,{to:s.fullPath,fuzzy:o,caseSensitive:s.options.caseSensitive??this.options.caseSensitive});if(n){let t;try{t=s.options.parseParams?.(n)??n}catch(t){if(e?.strictParseParams)throw t}i={...i,...t}}return n&&(c=[...a,s]),!!c.length})),!!c.length);if(u([],n),!c.length)return;c.forEach((t=>{const e=L(t.path,i),r=L(t.id,i,!0),o=s.find((t=>t.id===r))||new U(this,t,{id:r,params:i,pathname:m([this.basepath,e])});a.push(o)}));const l=h(c).children;l?.length&&r(l)};return r([this.routeTree]),a};loadMatches=async(t,e,a)=>{await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(e){throw a?.preload||t.route.options.onBeforeLoadError?.(e),t.route.options.onError?.(e),e}})));const s=t.map((async(s,r)=>{const o=t[r-1];s.__load({preload:a?.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)=>S(this.basepath,t,g(e));navigate=async({from:t,to:a="",search:s,hash:r,replace:o,params:i})=>{const n=String(a),h=void 0===t?t:String(t);let c;try{new URL(`${n}`),c=!0}catch(t){}return e(!c),this.#c({from:h,to:n,search:s,hash:r,replace:o,params:i})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const a=this.buildNext(t),s=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!s)return!1;const r=P(this.basepath,s.pathname,{...e,to:a.pathname});return!!r&&(e?.includeSearch??1?!!f(s.search,a.search)&&r:r)};buildLink=({from:t,to:e=".",search:a,params:s,hash:r,target:o,replace:i,activeOptions:n,preload:h,preloadDelay:c,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:a,params:s,hash:r,replace:i},p=this.buildNext(l);h=h??this.options.defaultPreload;const d=c??this.options.defaultPreloadDelay??0,m=this.state.currentLocation.pathname.split("/"),g=p.pathname.split("/").every(((t,e)=>t===m[e])),y=n?.exact?this.state.currentLocation.pathname===p.pathname:g,v=!n?.includeHash||this.state.currentLocation.hash===p.hash,w=!(n?.includeSearch??1)||f(this.state.currentLocation.search,p.search);return{type:"internal",next:p,handleFocus:t=>{h&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||o&&"_self"!==o||0!==t.button||(t.preventDefault(),this.#c(l))},handleEnter:t=>{const e=t.target||{};if(h){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),d)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&v&&w,disabled:u}};dehydrate=()=>({state:{...u(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((a=>{const s=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return s.forEach(((a,s)=>{const r=t.state.currentMatches[s];e(r&&r.id===a.id),a.store.setState((t=>({...t,...r.state})))})),{...a,...t.state,currentMatches:s}}))};#n=t=>{const e=t=>{t.forEach(((t,a)=>{t.init({originalIndex:a,router:this});if(this.routesById[t.id])throw new Error;this.routesById[t.id]=t;const s=t.children;s?.length&&(e(s),t.children=s.map(((t,e)=>{const a=b(y(g(t.path??"/")));for(;a.length>1&&"/"===a[0]?.value;)a.shift();let s=0;return a.forEach(((t,e)=>{let a=1;for(;e--;)a*=.001;"pathname"===t.type&&"/"!==t.value?s+=1*a:"param"===t.type?s+=2*a:"wildcard"===t.type&&(s+=3*a)})),{child:t,parsed:a,index:e,score:s}})).sort(((t,e)=>t.score!==e.score?t.score-e.score:t.index-e.index)).map((t=>t.child)))}))};return e([t]),t};#i=t=>{let{pathname:e,search:a,hash:s,state:r}=this.history.location;const o=this.options.parseSearch(a);return{pathname:e,searchStr:a,search:l(t?.search,o),hash:s.split("#").reverse()[0]??"",href:`${e}${a}${s}`,state:r,key:r?.key||"__init__"}};#h=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let a=S(this.basepath??"/",e,`${t.to??""}`);const s=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),r=this.matchRoutes(a),o={...h(s)?.params};let i=!0===(t.params??!0)?o:c(t.params,o);i&&r.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},i,t(i))})),a=L(a,i??{});const n=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,u=!0===t.search?n:t.search?c(t.search,n)??{}:t.__preSearchFilters?.length?n:{},p=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),u):u,d=l(this.state.latestLocation.search,p),f=this.options.stringifySearch(d);let m=!0===t.hash?this.state.latestLocation.hash:c(t.hash,this.state.latestLocation.hash);return m=m?`#${m}`:"",{pathname:a,search:d,searchStr:f,state:this.state.latestLocation.state,hash:m,href:`${a}${f}${m}`,key:t.key}};#c=async t=>{const e=this.buildNext(t),a=""+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 r=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===s?"push":"replace"](r,{id:a,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}},t.cleanPath=g,t.createBrowserHistory=r,t.createHashHistory=function(){return r({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=o,t.decode=E,t.defaultFetchServerDataFn=D,t.defaultParseSearch=A,t.defaultStringifySearch=k,t.encode=x,t.functionalUpdate=c,t.interpolatePath=L,t.invariant=e,t.isPlainObject=p,t.isRedirect=H,t.joinPaths=m,t.last=h,t.matchByPath=_,t.matchPathname=P,t.parsePathname=b,t.parseSearchWith=T,t.partialDeepEqual=f,t.pick=u,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=l,t.resolvePath=S,t.rootRouteId=M,t.stringifySearchWith=j,t.trimPath=w,t.trimPathLeft=y,t.trimPathRight=v,t.warning=function(t,e){},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/router",
"author": "Tanner Linsley",
"version": "0.0.1-beta.70",
"version": "0.0.1-beta.71",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "tanstack/router",

export { default as invariant } from 'tiny-invariant'
export { default as warning } from 'tiny-warning'
export * from './history'
export * from './frameworks'

@@ -15,1 +14,2 @@ export * from './link'

export * from './utils'
// export * from './routeError'

@@ -94,3 +94,3 @@ import invariant from 'tiny-invariant'

...split.map((part): Segment => {
if (part === '$') {
if (part === '$' || part === '*') {
return {

@@ -136,3 +136,3 @@ type: 'wildcard',

interpolatedPathSegments.map((segment) => {
if (segment.value === '$' && !leaveWildcard) {
if (['$', '*'].includes(segment.value) && !leaveWildcard) {
return ''

@@ -199,3 +199,3 @@ }

if (baseSegment?.value) {
params['$'] = joinPaths(baseSegments.slice(i).map((d) => d.value))
params['*'] = joinPaths(baseSegments.slice(i).map((d) => d.value))
return true

@@ -202,0 +202,0 @@ }

@@ -21,4 +21,6 @@ import { Store } from '@tanstack/store'

matchPathname,
parsePathname,
resolvePath,
trimPath,
trimPathLeft,
} from './path'

@@ -286,3 +288,3 @@ import {

startedLoadingAt = Date.now()
resolveNavigation = () => {}
resolveNavigation: () => void = () => {}

@@ -324,23 +326,2 @@ constructor(options?: RouterConstructorOptions<TRouteTree>) {

}
const visibilityChangeEvent = 'visibilitychange'
const focusEvent = 'focus'
// addEventListener does not exist in React Native, but window does
// In the future, we might need to invert control here for more adapters
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (window.addEventListener) {
// Listen to visibilitychange and focus
window.addEventListener(visibilityChangeEvent, this.#onFocus, false)
window.addEventListener(focusEvent, this.#onFocus, false)
}
return () => {
if (window.removeEventListener) {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener(visibilityChangeEvent, this.#onFocus)
window.removeEventListener(focusEvent, this.#onFocus)
}
}
}

@@ -1030,3 +1011,42 @@

if (children?.length) recurseRoutes(children)
if (children?.length) {
recurseRoutes(children)
route.children = children
.map((d, i) => {
const parsed = parsePathname(
trimPathLeft(cleanPath(d.path ?? '/')),
)
while (parsed.length > 1 && parsed[0]?.value === '/') {
parsed.shift()
}
let score = 0
parsed.forEach((d, i) => {
let modifier = 1
while (i--) {
modifier *= 0.001
}
if (d.type === 'pathname' && d.value !== '/') {
score += 1 * modifier
} else if (d.type === 'param') {
score += 2 * modifier
} else if (d.type === 'wildcard') {
score += 3 * modifier
}
})
return { child: d, parsed, index: i, score }
})
.sort((a, b) => {
if (a.score !== b.score) {
return a.score - b.score
}
return a.index - b.index
})
.map((d) => d.child)
}
})

@@ -1056,6 +1076,2 @@ }

#onFocus = () => {
this.safeLoad()
}
#buildLocation = (dest: BuildNextOptions = {}): ParsedLocation => {

@@ -1062,0 +1078,0 @@ dest.fromCurrent = dest.fromCurrent ?? dest.to === ''

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 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