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.57 to 0.0.1-beta.58

5

build/cjs/index.js

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

var route = require('./route.js');
var routeConfig = require('./routeConfig.js');
var routeMatch = require('./routeMatch.js');

@@ -52,5 +51,5 @@ var router = require('./router.js');

exports.encode = qss.encode;
exports.RootRoute = route.RootRoute;
exports.Route = route.Route;
exports.createRouteConfig = routeConfig.createRouteConfig;
exports.rootRouteId = routeConfig.rootRouteId;
exports.rootRouteId = route.rootRouteId;
exports.RouteMatch = routeMatch.RouteMatch;

@@ -57,0 +56,0 @@ exports.Router = router.Router;

123

build/cjs/route.js

@@ -15,20 +15,117 @@ /**

var invariant = require('tiny-invariant');
var path = require('./path.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
const rootRouteId = '__root__';
class Route {
constructor(routeConfig, options, originalIndex, parent, router) {
Object.assign(this, {
...routeConfig,
originalIndex,
options,
getRouter: () => router,
childRoutes: undefined,
getParentRoute: () => parent
});
router.options.createRoute?.({
router,
route: this
});
// Set up in this.init()
// customId!: TCustomId
// Optional
constructor(options) {
this.options = options || {};
this.isRoot = !options?.getParentRoute;
}
init = () => {
const allOptions = this.options;
const isRoot = !allOptions?.path && !allOptions?.id;
const parent = this.options?.getParentRoute?.();
if (isRoot) {
this.path = rootRouteId;
} else {
invariant__default["default"](parent, `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
}
let path$1 = isRoot ? rootRouteId : allOptions.path;
// If the path is anything other than an index path, trim it up
if (path$1 && path$1 !== '/') {
path$1 = path.trimPath(path$1);
}
const customId = allOptions?.id || path$1;
// Strip the parentId prefix from the first level of children
let id = isRoot ? rootRouteId : path.joinPaths([parent.id === rootRouteId ? '' : parent.id, customId]);
if (path$1 === rootRouteId) {
path$1 = '/';
}
if (id !== rootRouteId) {
id = path.joinPaths(['/', id]);
}
const fullPath = id === rootRouteId ? '/' : path.trimPathRight(path.joinPaths([parent.fullPath, path$1]));
this.id = id;
// this.customId = customId as TCustomId
this.fullPath = fullPath;
};
addChildren = children => {
this.children = children;
return this;
};
// generate: () => {
// invariant(
// false,
// `routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `,
// )
// },
}
class RootRoute extends Route {
constructor(options) {
super(options);
}
}
// const rootRoute = new RootRoute({
// validateSearch: () => null as unknown as { root?: boolean },
// })
// const aRoute = new Route({
// getParentRoute: () => rootRoute,
// path: 'a',
// validateSearch: () => null as unknown as { a?: string },
// })
// const bRoute = new Route({
// getParentRoute: () => aRoute,
// path: 'b',
// })
// const rootIsRoot = rootRoute.isRoot
// // ^?
// const aIsRoot = aRoute.isRoot
// // ^?
// const rId = rootRoute.id
// // ^?
// const aId = aRoute.id
// // ^?
// const bId = bRoute.id
// // ^?
// const rPath = rootRoute.fullPath
// // ^?
// const aPath = aRoute.fullPath
// // ^?
// const bPath = bRoute.fullPath
// // ^?
// const rSearch = rootRoute.__types.fullSearchSchema
// // ^?
// const aSearch = aRoute.__types.fullSearchSchema
// // ^?
// const bSearch = bRoute.__types.fullSearchSchema
// // ^?
// const config = rootRoute.addChildren([aRoute.addChildren([bRoute])])
// // ^?
exports.RootRoute = RootRoute;
exports.Route = Route;
exports.rootRouteId = rootRouteId;
//# sourceMappingURL=route.js.map

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

var path = require('./path.js');
var route = require('./route.js');
var routeMatch = require('./routeMatch.js');

@@ -122,8 +121,8 @@ var searchParams = require('./searchParams.js');

basepath,
routeConfig
routeTree
} = this.options;
this.basepath = `/${path.trimPath(basepath ?? '') ?? ''}`;
if (routeConfig) {
if (routeTree) {
this.routesById = {};
this.routeTree = this.#buildRouteTree(routeConfig);
this.routeTree = this.#buildRouteTree(routeTree);
}

@@ -271,13 +270,14 @@ return this;

const existingMatches = [...this.store.state.currentMatches, ...(this.store.state.pendingMatches ?? [])];
const recurse = async routes => {
const findInRouteTree = async routes => {
const parentMatch = utils.last(matches);
let params = parentMatch?.params ?? {};
const filteredRoutes = this.options.filterRoutes?.(routes) ?? routes;
let foundRoutes = [];
let matchingRoutes = [];
const findMatchInRoutes = (parentRoutes, routes) => {
routes.some(route => {
if (!route.path && route.childRoutes?.length) {
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
const children = route.children;
if (!route.path && children?.length) {
return findMatchInRoutes([...matchingRoutes, route], children);
}
const fuzzy = !!(route.path !== '/' || route.childRoutes?.length);
const fuzzy = route.path === '/' ? false : !!children?.length;
const matchParams = path.matchPathname(this.basepath, pathname, {

@@ -303,13 +303,13 @@ to: route.fullPath,

if (!!matchParams) {
foundRoutes = [...parentRoutes, route];
matchingRoutes = [...parentRoutes, route];
}
return !!foundRoutes.length;
return !!matchingRoutes.length;
});
return !!foundRoutes.length;
return !!matchingRoutes.length;
};
findMatchInRoutes([], filteredRoutes);
if (!foundRoutes.length) {
if (!matchingRoutes.length) {
return;
}
foundRoutes.forEach(foundRoute => {
matchingRoutes.forEach(foundRoute => {
const interpolatedPath = path.interpolatePath(foundRoute.path, params);

@@ -326,8 +326,9 @@ const matchId = path.interpolatePath(foundRoute.id, params, true);

});
const foundRoute = utils.last(foundRoutes);
if (foundRoute.childRoutes?.length) {
recurse(foundRoute.childRoutes);
const foundRoute = utils.last(matchingRoutes);
const foundChildren = foundRoute.children;
if (foundChildren?.length) {
findInRouteTree(foundChildren);
}
};
recurse([this.routeTree]);
findInRouteTree([this.routeTree]);
linkMatches(matches);

@@ -579,22 +580,22 @@ return matches;

};
#buildRouteTree = rootRouteConfig => {
const recurseRoutes = (routeConfigs, parent) => {
return routeConfigs.map((routeConfig, i) => {
const routeOptions = routeConfig.options;
const route$1 = new route.Route(routeConfig, routeOptions, i, parent, this);
const existingRoute = this.routesById[route$1.id];
#buildRouteTree = routeTree => {
const recurseRoutes = routes => {
routes.forEach((route, i) => {
route.init();
route.originalIndex = i;
route.router = this;
const existingRoute = this.routesById[route.id];
if (existingRoute) {
if (process.env.NODE_ENV !== 'production') {
console.warn(`Duplicate routes found with id: ${String(route$1.id)}`, this.routesById, route$1);
console.warn(`Duplicate routes found with id: ${String(route.id)}`, this.routesById, route);
}
throw new Error();
}
this.routesById[route$1.id] = route$1;
const children = routeConfig.children;
route$1.childRoutes = children.length ? recurseRoutes(children, route$1) : undefined;
return route$1;
this.routesById[route.id] = route;
const children = route.children;
if (children?.length) recurseRoutes(children);
});
};
const routes = recurseRoutes([rootRouteConfig]);
return routes[0];
recurseRoutes([routeTree]);
return routeTree;
};

@@ -601,0 +602,0 @@ #parseLocation = previousLocation => {

@@ -461,59 +461,107 @@ /**

const rootRouteId = '__root__';
class Route {
constructor(routeConfig, options, originalIndex, parent, router) {
Object.assign(this, {
...routeConfig,
originalIndex,
options,
getRouter: () => router,
childRoutes: undefined,
getParentRoute: () => parent
});
router.options.createRoute?.({
router,
route: this
});
}
}
// Set up in this.init()
const rootRouteId = '__root__';
const createRouteConfig = (options = {}, children = [], isRoot = true, parentId, parentPath) => {
if (isRoot) {
options.path = rootRouteId;
}
// customId!: TCustomId
// Strip the root from parentIds
if (parentId === rootRouteId) {
parentId = '';
}
let path = isRoot ? rootRouteId : options.path;
// Optional
// If the path is anything other than an index path, trim it up
if (path && path !== '/') {
path = trimPath(path);
constructor(options) {
this.options = options || {};
this.isRoot = !options?.getParentRoute;
}
const routeId = path || options.id;
let id = joinPaths([parentId, routeId]);
if (path === rootRouteId) {
path = '/';
}
if (id !== rootRouteId) {
id = joinPaths(['/', id]);
}
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]));
return {
id: id,
routeId: routeId,
path: path,
fullPath: fullPath,
options: options,
children,
addChildren: children => createRouteConfig(options, children, false, parentId, parentPath),
createRoute: childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath),
generate: () => {
invariant(false, `routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `);
init = () => {
const allOptions = this.options;
const isRoot = !allOptions?.path && !allOptions?.id;
const parent = this.options?.getParentRoute?.();
if (isRoot) {
this.path = rootRouteId;
} else {
invariant(parent, `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
}
let path = isRoot ? rootRouteId : allOptions.path;
// If the path is anything other than an index path, trim it up
if (path && path !== '/') {
path = trimPath(path);
}
const customId = allOptions?.id || path;
// Strip the parentId prefix from the first level of children
let id = isRoot ? rootRouteId : joinPaths([parent.id === rootRouteId ? '' : parent.id, customId]);
if (path === rootRouteId) {
path = '/';
}
if (id !== rootRouteId) {
id = joinPaths(['/', id]);
}
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parent.fullPath, path]));
this.id = id;
// this.customId = customId as TCustomId
this.fullPath = fullPath;
};
};
addChildren = children => {
this.children = children;
return this;
};
// generate: () => {
// invariant(
// false,
// `routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `,
// )
// },
}
class RootRoute extends Route {
constructor(options) {
super(options);
}
}
// const rootRoute = new RootRoute({
// validateSearch: () => null as unknown as { root?: boolean },
// })
// const aRoute = new Route({
// getParentRoute: () => rootRoute,
// path: 'a',
// validateSearch: () => null as unknown as { a?: string },
// })
// const bRoute = new Route({
// getParentRoute: () => aRoute,
// path: 'b',
// })
// const rootIsRoot = rootRoute.isRoot
// // ^?
// const aIsRoot = aRoute.isRoot
// // ^?
// const rId = rootRoute.id
// // ^?
// const aId = aRoute.id
// // ^?
// const bId = bRoute.id
// // ^?
// const rPath = rootRoute.fullPath
// // ^?
// const aPath = aRoute.fullPath
// // ^?
// const bPath = bRoute.fullPath
// // ^?
// const rSearch = rootRoute.__types.fullSearchSchema
// // ^?
// const aSearch = aRoute.__types.fullSearchSchema
// // ^?
// const bSearch = bRoute.__types.fullSearchSchema
// // ^?
// const config = rootRoute.addChildren([aRoute.addChildren([bRoute])])
// // ^?
//

@@ -806,8 +854,8 @@

basepath,
routeConfig
routeTree
} = this.options;
this.basepath = `/${trimPath(basepath ?? '') ?? ''}`;
if (routeConfig) {
if (routeTree) {
this.routesById = {};
this.routeTree = this.#buildRouteTree(routeConfig);
this.routeTree = this.#buildRouteTree(routeTree);
}

@@ -955,13 +1003,14 @@ return this;

const existingMatches = [...this.store.state.currentMatches, ...(this.store.state.pendingMatches ?? [])];
const recurse = async routes => {
const findInRouteTree = async routes => {
const parentMatch = last(matches);
let params = parentMatch?.params ?? {};
const filteredRoutes = this.options.filterRoutes?.(routes) ?? routes;
let foundRoutes = [];
let matchingRoutes = [];
const findMatchInRoutes = (parentRoutes, routes) => {
routes.some(route => {
if (!route.path && route.childRoutes?.length) {
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
const children = route.children;
if (!route.path && children?.length) {
return findMatchInRoutes([...matchingRoutes, route], children);
}
const fuzzy = !!(route.path !== '/' || route.childRoutes?.length);
const fuzzy = route.path === '/' ? false : !!children?.length;
const matchParams = matchPathname(this.basepath, pathname, {

@@ -987,13 +1036,13 @@ to: route.fullPath,

if (!!matchParams) {
foundRoutes = [...parentRoutes, route];
matchingRoutes = [...parentRoutes, route];
}
return !!foundRoutes.length;
return !!matchingRoutes.length;
});
return !!foundRoutes.length;
return !!matchingRoutes.length;
};
findMatchInRoutes([], filteredRoutes);
if (!foundRoutes.length) {
if (!matchingRoutes.length) {
return;
}
foundRoutes.forEach(foundRoute => {
matchingRoutes.forEach(foundRoute => {
const interpolatedPath = interpolatePath(foundRoute.path, params);

@@ -1010,8 +1059,9 @@ const matchId = interpolatePath(foundRoute.id, params, true);

});
const foundRoute = last(foundRoutes);
if (foundRoute.childRoutes?.length) {
recurse(foundRoute.childRoutes);
const foundRoute = last(matchingRoutes);
const foundChildren = foundRoute.children;
if (foundChildren?.length) {
findInRouteTree(foundChildren);
}
};
recurse([this.routeTree]);
findInRouteTree([this.routeTree]);
linkMatches(matches);

@@ -1263,7 +1313,8 @@ return matches;

};
#buildRouteTree = rootRouteConfig => {
const recurseRoutes = (routeConfigs, parent) => {
return routeConfigs.map((routeConfig, i) => {
const routeOptions = routeConfig.options;
const route = new Route(routeConfig, routeOptions, i, parent, this);
#buildRouteTree = routeTree => {
const recurseRoutes = routes => {
routes.forEach((route, i) => {
route.init();
route.originalIndex = i;
route.router = this;
const existingRoute = this.routesById[route.id];

@@ -1277,9 +1328,8 @@ if (existingRoute) {

this.routesById[route.id] = route;
const children = routeConfig.children;
route.childRoutes = children.length ? recurseRoutes(children, route) : undefined;
return route;
const children = route.children;
if (children?.length) recurseRoutes(children);
});
};
const routes = recurseRoutes([rootRouteConfig]);
return routes[0];
recurseRoutes([routeTree]);
return routeTree;
};

@@ -1418,3 +1468,3 @@ #parseLocation = previousLocation => {

export { Route, RouteMatch, Router, cleanPath, createBrowserHistory, createHashHistory, createMemoryHistory, createRouteConfig, decode, defaultFetchServerDataFn, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
export { RootRoute, Route, RouteMatch, Router, cleanPath, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultFetchServerDataFn, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
//# sourceMappingURL=index.js.map

@@ -11,3 +11,3 @@ {

"name": "node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "740d-32"
"uid": "c2ff-30"
},

@@ -21,39 +21,35 @@ {

{
"uid": "740d-34",
"uid": "c2ff-32",
"name": "history.ts"
},
{
"uid": "740d-36",
"uid": "c2ff-34",
"name": "utils.ts"
},
{
"uid": "740d-38",
"uid": "c2ff-36",
"name": "path.ts"
},
{
"uid": "740d-40",
"uid": "c2ff-38",
"name": "qss.ts"
},
{
"uid": "740d-42",
"uid": "c2ff-40",
"name": "route.ts"
},
{
"uid": "740d-44",
"name": "routeConfig.ts"
},
{
"uid": "740d-48",
"uid": "c2ff-44",
"name": "routeMatch.ts"
},
{
"uid": "740d-50",
"uid": "c2ff-46",
"name": "searchParams.ts"
},
{
"uid": "740d-52",
"uid": "c2ff-48",
"name": "router.ts"
},
{
"uid": "740d-54",
"uid": "c2ff-50",
"name": "index.ts"

@@ -65,3 +61,3 @@ }

"name": "store/build/esm/index.js",
"uid": "740d-46"
"uid": "c2ff-42"
}

@@ -76,80 +72,74 @@ ]

"nodeParts": {
"740d-32": {
"c2ff-30": {
"renderedLength": 199,
"gzipLength": 134,
"brotliLength": 0,
"mainUid": "740d-31"
"mainUid": "c2ff-29"
},
"740d-34": {
"c2ff-32": {
"renderedLength": 4236,
"gzipLength": 1085,
"brotliLength": 0,
"mainUid": "740d-33"
"mainUid": "c2ff-31"
},
"740d-36": {
"c2ff-34": {
"renderedLength": 2572,
"gzipLength": 950,
"brotliLength": 0,
"mainUid": "740d-35"
"mainUid": "c2ff-33"
},
"740d-38": {
"c2ff-36": {
"renderedLength": 5601,
"gzipLength": 1328,
"brotliLength": 0,
"mainUid": "740d-37"
"mainUid": "c2ff-35"
},
"740d-40": {
"c2ff-38": {
"renderedLength": 1395,
"gzipLength": 558,
"brotliLength": 0,
"mainUid": "740d-39"
"mainUid": "c2ff-37"
},
"740d-42": {
"renderedLength": 415,
"gzipLength": 208,
"c2ff-40": {
"renderedLength": 2936,
"gzipLength": 885,
"brotliLength": 0,
"mainUid": "740d-41"
"mainUid": "c2ff-39"
},
"740d-44": {
"renderedLength": 1261,
"gzipLength": 478,
"brotliLength": 0,
"mainUid": "740d-43"
},
"740d-46": {
"c2ff-42": {
"renderedLength": 1386,
"gzipLength": 501,
"brotliLength": 0,
"mainUid": "740d-45"
"mainUid": "c2ff-41"
},
"740d-48": {
"c2ff-44": {
"renderedLength": 4873,
"gzipLength": 1357,
"brotliLength": 0,
"mainUid": "740d-47"
"mainUid": "c2ff-43"
},
"740d-50": {
"c2ff-46": {
"renderedLength": 1387,
"gzipLength": 483,
"brotliLength": 0,
"mainUid": "740d-49"
"mainUid": "c2ff-45"
},
"740d-52": {
"renderedLength": 24208,
"gzipLength": 5647,
"c2ff-48": {
"renderedLength": 24146,
"gzipLength": 5621,
"brotliLength": 0,
"mainUid": "740d-51"
"mainUid": "c2ff-47"
},
"740d-54": {
"c2ff-50": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "740d-53"
"mainUid": "c2ff-49"
}
},
"nodeMetas": {
"740d-31": {
"c2ff-29": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "740d-32"
"index.production.js": "c2ff-30"
},

@@ -159,16 +149,16 @@ "imported": [],

{
"uid": "740d-53"
"uid": "c2ff-49"
},
{
"uid": "740d-43"
"uid": "c2ff-39"
},
{
"uid": "740d-51"
"uid": "c2ff-47"
}
]
},
"740d-33": {
"c2ff-31": {
"id": "/packages/router/src/history.ts",
"moduleParts": {
"index.production.js": "740d-34"
"index.production.js": "c2ff-32"
},

@@ -178,13 +168,13 @@ "imported": [],

{
"uid": "740d-53"
"uid": "c2ff-49"
},
{
"uid": "740d-51"
"uid": "c2ff-47"
}
]
},
"740d-35": {
"c2ff-33": {
"id": "/packages/router/src/utils.ts",
"moduleParts": {
"index.production.js": "740d-36"
"index.production.js": "c2ff-34"
},

@@ -194,20 +184,20 @@ "imported": [],

{
"uid": "740d-53"
"uid": "c2ff-49"
},
{
"uid": "740d-37"
"uid": "c2ff-35"
},
{
"uid": "740d-51"
"uid": "c2ff-47"
}
]
},
"740d-37": {
"c2ff-35": {
"id": "/packages/router/src/path.ts",
"moduleParts": {
"index.production.js": "740d-38"
"index.production.js": "c2ff-36"
},
"imported": [
{
"uid": "740d-35"
"uid": "c2ff-33"
}

@@ -217,16 +207,16 @@ ],

{
"uid": "740d-53"
"uid": "c2ff-49"
},
{
"uid": "740d-43"
"uid": "c2ff-39"
},
{
"uid": "740d-51"
"uid": "c2ff-47"
}
]
},
"740d-39": {
"c2ff-37": {
"id": "/packages/router/src/qss.ts",
"moduleParts": {
"index.production.js": "740d-40"
"index.production.js": "c2ff-38"
},

@@ -236,35 +226,20 @@ "imported": [],

{
"uid": "740d-53"
"uid": "c2ff-49"
},
{
"uid": "740d-49"
"uid": "c2ff-45"
}
]
},
"740d-41": {
"c2ff-39": {
"id": "/packages/router/src/route.ts",
"moduleParts": {
"index.production.js": "740d-42"
"index.production.js": "c2ff-40"
},
"imported": [],
"importedBy": [
{
"uid": "740d-53"
},
{
"uid": "740d-51"
}
]
},
"740d-43": {
"id": "/packages/router/src/routeConfig.ts",
"moduleParts": {
"index.production.js": "740d-44"
},
"imported": [
{
"uid": "740d-31"
"uid": "c2ff-29"
},
{
"uid": "740d-37"
"uid": "c2ff-35"
}

@@ -274,10 +249,10 @@ ],

{
"uid": "740d-53"
"uid": "c2ff-49"
}
]
},
"740d-45": {
"c2ff-41": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "740d-46"
"index.production.js": "c2ff-42"
},

@@ -287,17 +262,17 @@ "imported": [],

{
"uid": "740d-47"
"uid": "c2ff-43"
},
{
"uid": "740d-51"
"uid": "c2ff-47"
}
]
},
"740d-47": {
"c2ff-43": {
"id": "/packages/router/src/routeMatch.ts",
"moduleParts": {
"index.production.js": "740d-48"
"index.production.js": "c2ff-44"
},
"imported": [
{
"uid": "740d-45"
"uid": "c2ff-41"
}

@@ -307,17 +282,17 @@ ],

{
"uid": "740d-53"
"uid": "c2ff-49"
},
{
"uid": "740d-51"
"uid": "c2ff-47"
}
]
},
"740d-49": {
"c2ff-45": {
"id": "/packages/router/src/searchParams.ts",
"moduleParts": {
"index.production.js": "740d-50"
"index.production.js": "c2ff-46"
},
"imported": [
{
"uid": "740d-39"
"uid": "c2ff-37"
}

@@ -327,38 +302,35 @@ ],

{
"uid": "740d-53"
"uid": "c2ff-49"
},
{
"uid": "740d-51"
"uid": "c2ff-47"
}
]
},
"740d-51": {
"c2ff-47": {
"id": "/packages/router/src/router.ts",
"moduleParts": {
"index.production.js": "740d-52"
"index.production.js": "c2ff-48"
},
"imported": [
{
"uid": "740d-45"
"uid": "c2ff-41"
},
{
"uid": "740d-31"
"uid": "c2ff-29"
},
{
"uid": "740d-37"
"uid": "c2ff-35"
},
{
"uid": "740d-41"
"uid": "c2ff-43"
},
{
"uid": "740d-47"
"uid": "c2ff-45"
},
{
"uid": "740d-49"
"uid": "c2ff-33"
},
{
"uid": "740d-35"
},
{
"uid": "740d-33"
"uid": "c2ff-31"
}

@@ -368,50 +340,47 @@ ],

{
"uid": "740d-53"
"uid": "c2ff-49"
}
]
},
"740d-53": {
"c2ff-49": {
"id": "/packages/router/src/index.ts",
"moduleParts": {
"index.production.js": "740d-54"
"index.production.js": "c2ff-50"
},
"imported": [
{
"uid": "740d-31"
"uid": "c2ff-29"
},
{
"uid": "740d-33"
"uid": "c2ff-31"
},
{
"uid": "740d-55"
"uid": "c2ff-51"
},
{
"uid": "740d-56"
"uid": "c2ff-52"
},
{
"uid": "740d-37"
"uid": "c2ff-35"
},
{
"uid": "740d-39"
"uid": "c2ff-37"
},
{
"uid": "740d-41"
"uid": "c2ff-39"
},
{
"uid": "740d-43"
"uid": "c2ff-53"
},
{
"uid": "740d-57"
"uid": "c2ff-43"
},
{
"uid": "740d-47"
"uid": "c2ff-47"
},
{
"uid": "740d-51"
"uid": "c2ff-45"
},
{
"uid": "740d-49"
},
{
"uid": "740d-35"
"uid": "c2ff-33"
}

@@ -422,3 +391,3 @@ ],

},
"740d-55": {
"c2ff-51": {
"id": "/packages/router/src/frameworks.ts",

@@ -429,7 +398,7 @@ "moduleParts": {},

{
"uid": "740d-53"
"uid": "c2ff-49"
}
]
},
"740d-56": {
"c2ff-52": {
"id": "/packages/router/src/link.ts",

@@ -440,7 +409,7 @@ "moduleParts": {},

{
"uid": "740d-53"
"uid": "c2ff-49"
}
]
},
"740d-57": {
"c2ff-53": {
"id": "/packages/router/src/routeInfo.ts",

@@ -451,3 +420,3 @@ "moduleParts": {},

{
"uid": "740d-53"
"uid": "c2ff-49"
}

@@ -454,0 +423,0 @@ ]

@@ -94,7 +94,7 @@ /**

type RegisteredRouter = RegisterRouter extends {
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
} ? Router<TRouteConfig, TAllRouteInfo, TRouterContext> : Router;
type RegisteredAllRouteInfo = RegisterRouter extends {
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>;
} ? TAllRouteInfo : AnyAllRouteInfo;
router: Router<infer TRoute, infer TRoutesInfo, infer TRouterContext>;
} ? Router<TRoute, TRoutesInfo, TRouterContext> : Router;
type RegisteredRoutesInfo = RegisterRouter extends {
router: Router<infer TRoute, infer TRoutesInfo, infer TRouterContext>;
} ? TRoutesInfo : AnyRoutesInfo;
interface LocationState {

@@ -119,4 +119,4 @@ }

type SearchParser = (searchStr: string) => Record<string, any>;
type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(routeConfigs: TRoute[]) => TRoute[];
interface RouterOptions<TRouteConfig extends AnyRouteConfig, TRouterContext> {
type FilterRoutesFn = <TRoute extends AnyRoute>(routes: TRoute[]) => TRoute[];
interface RouterOptions<TRouteTree extends AnyRoute, TRouterContext> {
history?: RouterHistory;

@@ -134,3 +134,3 @@ stringifySearch?: SearchSerializer;

caseSensitive?: boolean;
routeConfig?: TRouteConfig;
routeTree?: TRouteTree;
basepath?: string;

@@ -208,32 +208,32 @@ Router?: (router: AnyRouter) => void;

declare const defaultFetchServerDataFn: FetchServerDataFn;
declare class Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>, TRouterContext = unknown> {
declare class Router<TRouteTree extends AnyRoute = Route, TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteTree>, TRouterContext = unknown> {
#private;
types: {
RouteConfig: TRouteConfig;
AllRouteInfo: TAllRouteInfo;
RootRoute: TRouteTree;
RoutesInfo: TRoutesInfo;
};
options: PickAsRequired<RouterOptions<TRouteConfig, TRouterContext>, 'stringifySearch' | 'parseSearch' | 'context'>;
options: PickAsRequired<RouterOptions<TRouteTree, TRouterContext>, 'stringifySearch' | 'parseSearch' | 'context'>;
history: RouterHistory;
basepath: string;
routeTree: Route<TAllRouteInfo, RouteInfo>;
routesById: RoutesById<TAllRouteInfo>;
routeTree: Route;
routesById: RoutesById<TRoutesInfo>;
navigateTimeout: undefined | Timeout;
nextAction: undefined | 'push' | 'replace';
navigationPromise: undefined | Promise<void>;
store: Store<RouterStore<TAllRouteInfo['fullSearchSchema']>>;
store: Store<RouterStore<TRoutesInfo['fullSearchSchema']>>;
startedLoadingAt: number;
resolveNavigation: () => void;
constructor(options?: RouterOptions<TRouteConfig, TRouterContext>);
constructor(options?: RouterOptions<TRouteTree, TRouterContext>);
reset: () => void;
mount: () => () => void;
update: <TRouteConfig_1 extends RouteConfig<string, string, string, string, {}, {}, {}, {}, {}, {}, unknown> = RouteConfig<string, string, string, string, {}, {}, {}, {}, {}, {}, unknown>, TAllRouteInfo_1 extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig_1>, TRouterContext_1 = unknown>(opts?: RouterOptions<TRouteConfig_1, TRouterContext_1> | undefined) => Router<TRouteConfig_1, TAllRouteInfo_1, TRouterContext_1>;
update: <TRoute extends Route<AnyRoute, string, "/", string, "__root__", {}, any, Record<never, string>, any, unknown, DefaultRoutesInfo> = Route<AnyRoute, string, "/", string, "__root__", {}, any, Record<never, string>, any, unknown, DefaultRoutesInfo>, TRoutesInfo_1 extends AnyRoutesInfo = RoutesInfo<TRoute>, TRouterContext_1 = unknown>(opts?: RouterOptions<TRoute, TRouterContext_1> | undefined) => this;
buildNext: (opts: BuildNextOptions) => ParsedLocation<{}, LocationState>;
cancelMatches: () => void;
load: (next?: ParsedLocation) => Promise<void>;
getRoute: <TId extends keyof TAllRouteInfo["routeInfoById"]>(id: TId) => Route<TAllRouteInfo, TAllRouteInfo["routeInfoById"][TId], unknown>;
getRoute: <TId extends keyof TRoutesInfo["routesById"]>(id: TId) => TRoutesInfo["routesById"][TId];
loadRoute: (navigateOpts?: BuildNextOptions) => Promise<RouteMatch[]>;
preloadRoute: (navigateOpts?: BuildNextOptions) => Promise<RouteMatch<DefaultAllRouteInfo, RouteInfo<string, string, string, "/", {}, {}, {}, {}, {}, {}>>[]>;
preloadRoute: (navigateOpts?: BuildNextOptions) => Promise<RouteMatch<DefaultRoutesInfo, AnyRoute>[]>;
matchRoutes: (pathname: string, opts?: {
strictParseParams?: boolean;
}) => RouteMatch<DefaultAllRouteInfo, RouteInfo<string, string, string, "/", {}, {}, {}, {}, {}, {}>>[];
}) => RouteMatch<DefaultRoutesInfo, AnyRoute>[];
loadMatches: (resolvedMatches: RouteMatch[], loaderOpts?: {

@@ -244,5 +244,5 @@ preload?: boolean;

resolvePath: (from: string, path: string) => string;
navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = "/", TTo extends string = ".">({ from, to, search, hash, replace, params, }: NavigateOptions<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = "/", TTo extends string = ".">(location: ToOptions<TAllRouteInfo, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | TAllRouteInfo["routeInfoById"][ResolveRelativePath<TFrom, NoInfer<TTo>>]["allParams"];
buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = "/", TTo extends string = ".">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadMaxAge: userPreloadMaxAge, preloadGcMaxAge: userPreloadGcMaxAge, preloadDelay: userPreloadDelay, disabled, }: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
navigate: <TFrom extends ValidFromPath<TRoutesInfo> = "/", TTo extends string = ".">({ from, to, search, hash, replace, params, }: NavigateOptions<TRoutesInfo, TFrom, TTo>) => Promise<void>;
matchRoute: <TFrom extends ValidFromPath<TRoutesInfo> = "/", TTo extends string = ".", TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>>(location: ToOptions<TRoutesInfo, TFrom, TTo, ResolveRelativePath<TFrom, NoInfer<TTo>>>, opts?: MatchRouteOptions) => false | TRoutesInfo["routesById"][TResolved]["__types"]["allParams"];
buildLink: <TFrom extends ValidFromPath<TRoutesInfo> = "/", TTo extends string = ".">({ from, to, search, params, hash, target, replace, activeOptions, preload, preloadMaxAge: userPreloadMaxAge, preloadGcMaxAge: userPreloadGcMaxAge, preloadDelay: userPreloadDelay, disabled, }: LinkOptions<TRoutesInfo, TFrom, TTo>) => LinkInfo;
dehydrate: () => DehydratedRouter<TRouterContext>;

@@ -252,5 +252,5 @@ hydrate: (dehydratedRouter: DehydratedRouter<TRouterContext>) => void;

interface RouteMatchStore<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
routeSearch: TRouteInfo['searchSchema'];
search: Expand<TAllRouteInfo['fullSearchSchema'] & TRouteInfo['fullSearchSchema']>;
interface RouteMatchStore<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TRoute extends AnyRoute = Route> {
routeSearch: TRoute['__types']['searchSchema'];
search: Expand<TRoutesInfo['fullSearchSchema'] & TRoute['__types']['fullSearchSchema']>;
status: 'idle' | 'pending' | 'success' | 'error';

@@ -260,10 +260,10 @@ error?: unknown;

}
declare class RouteMatch<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo> {
declare class RouteMatch<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TRoute extends AnyRoute = AnyRoute> {
#private;
route: Route<TAllRouteInfo, TRouteInfo>;
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>;
store: Store<RouteMatchStore<TAllRouteInfo, TRouteInfo>>;
route: TRoute;
router: Router<TRoutesInfo['routeTree'], TRoutesInfo>;
store: Store<RouteMatchStore<TRoutesInfo, TRoute>>;
id: string;
pathname: string;
params: TRouteInfo['allParams'];
params: TRoute['__types']['allParams'];
component: GetFrameworkGeneric<'Component'>;

@@ -277,8 +277,8 @@ errorComponent: GetFrameworkGeneric<'ErrorComponent'>;

__onExit?: void | ((matchContext: {
params: TRouteInfo['allParams'];
search: TRouteInfo['fullSearchSchema'];
params: TRoute['__types']['allParams'];
search: TRoute['__types']['fullSearchSchema'];
}) => void);
constructor(router: AnyRouter, route: Route<TAllRouteInfo, TRouteInfo>, opts: {
constructor(router: AnyRouter, route: TRoute, opts: {
id: string;
params: TRouteInfo['allParams'];
params: TRoute['__types']['allParams'];
pathname: string;

@@ -304,27 +304,10 @@ });

}
type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>;
};
type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
error: 'Top level search params cannot be redefined by child routes!';
keys: keyof TReturn & keyof TParentSchema;
} : TReturn;
type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
[Key in keyof TParentParams]?: DefinedPathParamWarning;
};
type OnLoadFn<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TFullSearchSchema, TAllParams>) => Promise<any> | void;
interface LoaderContext<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
params: TAllParams;
search: TFullSearchSchema;
signal?: AbortSignal;
preload: boolean;
}
type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, RouteInfo<string, TPath>>) => void;
type RouteOptions<TRouteId extends string = string, TPath extends string = string, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> = ({
type RouteOptionsBase<TCustomId, TPath> = {
path: TPath;
} | {
id: TRouteId;
}) & {
id: TCustomId;
};
type RouteOptionsBaseIntersection<TCustomId, TPath> = UnionToIntersection<RouteOptionsBase<TCustomId, TPath>>;
type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = {}> = RouteOptionsBase<TCustomId, TPath> & {
getParentRoute: () => TParentRoute;
caseSensitive?: boolean;

@@ -362,53 +345,79 @@ validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;

}) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!');
type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;
type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>;
};
type SearchSchemaValidatorFn<TReturn, TParentSchema> = (searchObj: Record<string, unknown>) => {} extends TParentSchema ? TReturn : keyof TReturn extends keyof TParentSchema ? {
error: 'Top level search params cannot be redefined by child routes!';
keys: keyof TReturn & keyof TParentSchema;
} : TReturn;
type DefinedPathParamWarning = 'Path params cannot be redefined by child routes!';
type ParentParams<TParentParams> = AnyPathParams extends TParentParams ? {} : {
[Key in keyof TParentParams]?: DefinedPathParamWarning;
};
type OnLoadFn<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> = (loaderContext: LoaderContext<TFullSearchSchema, TAllParams>) => Promise<any> | void;
interface LoaderContext<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
params: TAllParams;
search: TFullSearchSchema;
signal?: AbortSignal;
preload: boolean;
}
type UnloaderFn<TPath extends string> = (routeMatch: RouteMatch<any, Route>) => void;
type SearchFilter<T, U = T> = (prev: T) => U;
interface RouteConfig<TId extends string = string, TRouteId extends string = string, TPath extends string = string, TFullPath extends string = string, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}, TKnownChildren = unknown> {
type ResolveId<TParentRoute, TCustomId extends string, TPath extends string> = TParentRoute extends Route<any> ? RootRouteId : TParentRoute extends {
id: infer TParentId extends string;
} ? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId> : never;
type InferFullSearchSchema<TRoute> = TRoute extends {
isRoot: true;
__types: {
searchSchema: infer TSearchSchema;
};
} ? TSearchSchema : TRoute extends {
__types: {
fullSearchSchema: infer TFullSearchSchema;
};
} ? TFullSearchSchema : {};
type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<InferFullSearchSchema<TParentRoute> & TSearchSchema>;
interface AnyRoute extends Route<any, any, any, any, any, any, any, any, any, any, any> {
}
type RouteWithRoutesInfo<TRoute> = TRoute extends Route<infer TParentRoute, infer TPath, infer TFullPath, infer TCustomId, infer TId, infer TSearchSchema, infer TFullSearchSchema, infer TParams, infer TAllParams, infer TChildren> ? Route<any, any, any, any, any, any, any, any, any, TChildren, any> : never;
declare class Route<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = string, TFullPath extends ResolveFullPath<TParentRoute, TPath> = ResolveFullPath<TParentRoute, TPath>, TCustomId extends string = string, TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<TParentRoute, TCustomId, TPath>, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends Expand<TParentRoute['__types']['allParams'] & TParams> = Expand<TParentRoute['__types']['allParams'] & TParams>, TChildren extends unknown = unknown, TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo> {
__types: {
parentRoute: TParentRoute;
path: TPath;
fullPath: TFullPath;
id: TId;
searchSchema: TSearchSchema;
fullSearchSchema: TFullSearchSchema;
params: TParams;
allParams: TAllParams;
children: TChildren;
routesInfo: TRoutesInfo;
};
isRoot: TParentRoute extends Route<any> ? true : false;
options: RouteOptions<TParentRoute, TCustomId, TPath, InferFullSearchSchema<TParentRoute>, TSearchSchema, Expand<InferFullSearchSchema<TParentRoute> & TSearchSchema>, TParentRoute['__types']['allParams'], TParams, TAllParams>;
parentRoute: TParentRoute;
id: TId;
routeId: TRouteId;
path: NoInfer<TPath>;
path: TPath;
fullPath: TFullPath;
options: RouteOptions<TRouteId, TPath, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
children?: TKnownChildren;
addChildren: IsAny<TId, any, <TNewChildren extends any>(children: TNewChildren extends AnyRouteConfig[] ? TNewChildren : {
error: 'Invalid route detected';
route: TNewChildren;
}) => RouteConfig<TId, TRouteId, TPath, TFullPath, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TNewChildren>>;
createRoute: CreateRouteConfigFn<false, TId, TFullPath, TFullSearchSchema, TAllParams>;
generate: GenerateFn<TRouteId, TPath, TParentSearchSchema, TParentParams>;
children?: TChildren;
originalIndex?: number;
router?: Router<TRoutesInfo['routeTree'], TRoutesInfo, unknown>;
constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute['__types']['allParams'], TParams, TAllParams>);
init: () => void;
addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TNewChildren, DefaultRoutesInfo>;
}
type GenerateFn<TRouteId extends string = string, TPath extends string = string, TParentSearchSchema extends {} = {}, TParentParams extends AnyPathParams = {}> = <TSearchSchema extends AnySearchSchema = {}, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>>(options: Omit<RouteOptions<TRouteId, TPath, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'>) => void;
type CreateRouteConfigFn<TIsRoot extends boolean = false, TParentId extends string = string, TParentPath extends string = string, TParentRouteLoaderData extends AnyLoaderData = {}, TParentAllLoaderData extends AnyLoaderData = {}, TParentSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}> = <TRouteId extends string, TPath extends string, TLoaderData extends AnyLoaderData, TSearchSchema extends AnySearchSchema = AnySearchSchema, TParams extends Record<ParsePathParams<TPath>, unknown> = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams> = AnyPathParams extends TParams ? Record<ParsePathParams<TPath>, string> : NoInfer<TParams>, TKnownChildren extends RouteConfig[] = RouteConfig[], TResolvedId extends string = string extends TRouteId ? string extends TPath ? string : TPath : TRouteId>(options?: TIsRoot extends true ? Omit<RouteOptions<TRouteId, TPath, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, 'path'> & {
path?: never;
} : RouteOptions<TRouteId, TPath, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>>, children?: TKnownChildren, isRoot?: boolean, parentId?: string, parentPath?: string) => RouteConfig<RoutePrefix<TParentId, TResolvedId>, TResolvedId, TPath, string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>, TParentSearchSchema, TSearchSchema, Expand<TParentSearchSchema & TSearchSchema>, TParentParams, TParams, Expand<TParentParams & TAllParams>, TKnownChildren>;
type RoutePath<T extends string> = T extends RootRouteId ? '/' : TrimPathRight<`${T}`>;
type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
interface AnyRouteConfig extends RouteConfig<any, any, any, any, any, any, any, any, any, any, any> {
declare class RootRoute<TSearchSchema extends AnySearchSchema = {}> extends Route<any, '/', '/', string, RootRouteId, TSearchSchema, TSearchSchema, {}, {}> {
constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', {}, TSearchSchema, NoInfer<TSearchSchema>, {}, {}, {}>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive'>);
}
interface AnyRouteConfigWithChildren<TChildren> extends RouteConfig<any, any, any, any, any, any, any, any, any, any, TChildren> {
}
type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed extends RoutePrefix<TParentRoute['fullPath'], TPath> = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TrimPathRight<`${TPrefixed}`>;
type RoutePrefix<TPrefix extends string, TId extends string> = string extends TId ? RootRouteId : TId extends string ? TPrefix extends RootRouteId ? TId extends '/' ? '/' : `/${TrimPath<TId>}` : `${TPrefix}/${TId}` extends '/' ? '/' : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}` : never;
type TrimPath<T extends string> = '' extends T ? '' : TrimPathRight<TrimPathLeft<T>>;
type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}` ? TrimPathLeft<U> : T extends `/${infer U}` ? TrimPathLeft<U> : T;
type TrimPathRight<T extends string> = T extends '/' ? '/' : T extends `${infer U}/` ? TrimPathRight<U> : T;
declare const createRouteConfig: CreateRouteConfigFn<true>;
interface AnyRoute extends Route<any, any, any> {
}
declare class Route<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TRouteInfo extends AnyRouteInfo = RouteInfo, TRouterContext = unknown> {
routeInfo: TRouteInfo;
id: TRouteInfo['id'];
customId: TRouteInfo['customId'];
path: TRouteInfo['path'];
fullPath: TRouteInfo['fullPath'];
getParentRoute: () => undefined | AnyRoute;
childRoutes?: AnyRoute[];
options: RouteOptions;
originalIndex: number;
getRouter: () => Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>;
constructor(routeConfig: RouteConfig, options: TRouteInfo['options'], originalIndex: number, parent: undefined | Route<TAllRouteInfo, any>, router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>);
}
interface AnyAllRouteInfo {
routeConfig: AnyRouteConfig;
routeInfo: AnyRouteInfo;
routeInfoById: Record<string, AnyRouteInfo>;
routeInfoByFullPath: Record<string, AnyRouteInfo>;
interface AnyRoutesInfo {
routeTree: AnyRoute;
routesById: Record<string, AnyRoute>;
routesByFullPath: Record<string, AnyRoute>;
routeIds: any;

@@ -419,7 +428,6 @@ routePaths: any;

}
interface DefaultAllRouteInfo {
routeConfig: RouteConfig;
routeInfo: RouteInfo;
routeInfoById: Record<string, RouteInfo>;
routeInfoByFullPath: Record<string, RouteInfo>;
interface DefaultRoutesInfo {
routeTree: Route;
routesById: Record<string, Route>;
routesByFullPath: Record<string, Route>;
routeIds: string;

@@ -430,49 +438,32 @@ routePaths: string;

}
interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig> extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {
interface RoutesInfo<TRouteTree extends AnyRoute = Route> extends RoutesInfoInner<TRouteTree, ParseRoute<TRouteTree>> {
}
type ParseRouteConfig<TRouteConfig = AnyRouteConfig> = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig> : never;
type ParseRouteChildren<TRouteConfig> = TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren> ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{
[TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
}> : never : never;
type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
id: TId;
} extends AnyRouteConfig ? ParseRouteConfig<TRouteConfig> : never;
type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<infer TId, infer TCustomId, infer TPath, infer TFullPath, infer TParentSearchSchema, infer TSearchSchema, infer TFullSearchSchema, infer TParentParams, infer TParams, infer TAllParams, any> ? string extends TCustomId ? never : RouteInfo<TId, TCustomId, TPath, TFullPath, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams> : never;
interface RoutesInfoInner<TRouteConfig extends AnyRouteConfig, TRouteInfo extends RouteInfo<string, string, any, any, any, any, any, any, any, any> = RouteInfo, TRouteInfoById = {
'/': TRouteInfo;
interface RoutesInfoInner<TRouteTree extends AnyRoute, TRoutes extends AnyRoute = Route, TRoutesById = {
'/': TRoutes;
} & {
[TInfo in TRouteInfo as TInfo['id']]: TInfo;
}, TRouteInfoByFullPath = {
'/': TRouteInfo;
[TRoute in TRoutes as TRoute['id']]: TRoute;
}, TRoutesByFullPath = {
'/': TRoutes;
} & {
[TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo;
[TRoute in TRoutes as TRoute['fullPath'] extends RootRouteId ? never : string extends TRoute['fullPath'] ? never : TRoute['fullPath']]: TRoute;
}> {
routeConfig: TRouteConfig;
routeInfo: TRouteInfo;
routeInfoById: TRouteInfoById;
routeInfoByFullPath: TRouteInfoByFullPath;
routeIds: keyof TRouteInfoById;
routePaths: keyof TRouteInfoByFullPath;
fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>;
allParams: Partial<UnionToIntersection<TRouteInfo['allParams']>>;
routeTree: TRouteTree;
routes: TRoutes;
routesById: TRoutesById;
routesByFullPath: TRoutesByFullPath;
routeIds: keyof TRoutesById;
routePaths: keyof TRoutesByFullPath;
fullSearchSchema: Partial<UnionToIntersection<TRoutes['__types']['fullSearchSchema']>>;
allParams: Partial<UnionToIntersection<TRoutes['__types']['allParams']>>;
}
interface AnyRouteInfo extends RouteInfo<any, any, any, any, any, any, any, any, any, any> {
}
interface RouteInfo<TId extends string = string, TCustomId extends string = string, TPath extends string = string, TFullPath extends string = '/', TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TParentParams extends AnyPathParams = {}, TParams extends AnyPathParams = {}, TAllParams extends AnyPathParams = {}> {
id: TId;
customId: TCustomId;
path: TPath;
fullPath: TFullPath;
searchSchema: TSearchSchema;
fullSearchSchema: TFullSearchSchema;
parentParams: TParentParams;
params: TParams;
allParams: TAllParams;
options: RouteOptions<TCustomId, TPath, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams>;
}
type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
[K in keyof TAllRouteInfo['routeInfoById']]: Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][K]>;
type ParseRoute<TRouteTree> = TRouteTree extends AnyRoute ? TRouteTree | ParseRouteChildren<TRouteTree> : never;
type ParseRouteChildren<TRouteTree> = TRouteTree extends Route<any, any, any, any, any, any, any, any, any, infer TChildren, any> ? unknown extends TChildren ? never : TChildren extends AnyRoute[] ? Values<{
[TId in TChildren[number]['id']]: ParseRouteChild<TChildren[number], TId>;
}> : never : never;
type ParseRouteChild<TRoute, TId> = TRoute extends AnyRoute ? ParseRoute<TRoute> : never;
type RoutesById<TRoutesInfo extends AnyRoutesInfo> = {
[K in keyof TRoutesInfo['routesById']]: TRoutesInfo['routesById'][K];
};
type RouteInfoById<TAllRouteInfo extends AnyAllRouteInfo, TId> = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny<TAllRouteInfo['routeInfoById'][TId]['id'], RouteInfo, TAllRouteInfo['routeInfoById'][TId]> : never;
type RouteInfoByPath<TAllRouteInfo extends AnyAllRouteInfo, TPath> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny<TAllRouteInfo['routeInfoByFullPath'][TPath]['id'], RouteInfo, TAllRouteInfo['routeInfoByFullPath'][TPath]> : never;
type RouteById<TRoutesInfo extends AnyRoutesInfo, TId> = TId extends keyof TRoutesInfo['routesById'] ? IsAny<TRoutesInfo['routesById'][TId]['id'], Route, TRoutesInfo['routesById'][TId]> : never;
type RouteByPath<TRoutesInfo extends AnyRoutesInfo, TPath> = TPath extends keyof TRoutesInfo['routesByFullPath'] ? IsAny<TRoutesInfo['routesByFullPath'][TPath]['id'], Route, TRoutesInfo['routesByFullPath'][TPath]> : never;

@@ -509,12 +500,12 @@ type LinkInfo = {

} ? never : './' : never) | (TFrom extends `/` ? never : '../') | AllPaths;
type NavigateOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends TAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
type NavigateOptions<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '.'> = ToOptions<TRoutesInfo, TFrom, TTo> & {
replace?: boolean;
};
type ToOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends TAllRouteInfo['routePaths'] = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
to?: ToPathOption<TAllRouteInfo, TFrom, TTo>;
type ToOptions<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
to?: ToPathOption<TRoutesInfo, TFrom, TTo>;
hash?: Updater<string>;
state?: LocationState;
from?: TFrom;
} & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> & PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>;
type SearchParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & RouteInfoByPath<TAllRouteInfo, TFrom> extends never ? {} : RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']>>, TToSchema = Partial<RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']> & Omit<RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema'], keyof PickRequired<RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']>>, TFromFullSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TFromSchema>>, TToFullSchema = Expand<UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
} & CheckPath<TRoutesInfo, NoInfer<TResolvedTo>, {}> & SearchParamOptions<TRoutesInfo, TFrom, TResolvedTo> & PathParamOptions<TRoutesInfo, TFrom, TResolvedTo>;
type SearchParamOptions<TRoutesInfo extends AnyRoutesInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<TRoutesInfo['fullSearchSchema'] & RouteByPath<TRoutesInfo, TFrom> extends never ? {} : RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']>>, TToSchema = Partial<RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']> & Omit<RouteByPath<TRoutesInfo, TTo>['__types']['fullSearchSchema'], keyof PickRequired<RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']>>, TFromFullSchema = Expand<UnionToIntersection<TRoutesInfo['fullSearchSchema'] & TFromSchema>>, TToFullSchema = Expand<UnionToIntersection<TRoutesInfo['fullSearchSchema'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
search?: true | SearchReducer<TFromFullSchema, TToFullSchema>;

@@ -527,3 +518,3 @@ } : {

} | ((current: TFrom) => TTo);
type PathParamOptions<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<RouteInfoByPath<TAllRouteInfo, TFrom> extends never ? {} : RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']>>, TToSchema = Partial<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']> & Omit<RouteInfoByPath<TAllRouteInfo, TTo>['allParams'], keyof PickRequired<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']>>, TFromFullParams = Expand<UnionToIntersection<TAllRouteInfo['allParams'] & TFromSchema>>, TToFullParams = Expand<UnionToIntersection<TAllRouteInfo['allParams'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
type PathParamOptions<TRoutesInfo extends AnyRoutesInfo, TFrom, TTo, TFromSchema = Expand<UnionToIntersection<RouteByPath<TRoutesInfo, TFrom> extends never ? {} : RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']>>, TToSchema = Partial<RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']> & Omit<RouteByPath<TRoutesInfo, TTo>['__types']['allParams'], keyof PickRequired<RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']>>, TFromFullParams = Expand<UnionToIntersection<TRoutesInfo['allParams'] & TFromSchema>>, TToFullParams = Expand<UnionToIntersection<TRoutesInfo['allParams'] & TToSchema>>> = keyof PickRequired<TToSchema> extends never ? {
params?: ParamsReducer<TFromFullParams, TToFullParams>;

@@ -534,4 +525,4 @@ } : {

type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
type ToPathOption<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends TAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TAllRouteInfo['routePaths'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
type ToIdOption<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends TAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TAllRouteInfo['routeIds'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
type ToPathOption<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TRoutesInfo['routePaths'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
type ToIdOption<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '.'> = TTo | RelativeToPathAutoComplete<TRoutesInfo['routeIds'], NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
interface ActiveOptions {

@@ -541,3 +532,3 @@ exact?: boolean;

}
type LinkOptions<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo, TFrom extends TAllRouteInfo['routePaths'] = '/', TTo extends string = '.'> = NavigateOptions<TAllRouteInfo, TFrom, TTo> & {
type LinkOptions<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '.'> = NavigateOptions<TRoutesInfo, TFrom, TTo> & {
target?: HTMLAnchorElement['target'];

@@ -551,18 +542,18 @@ activeOptions?: ActiveOptions;

};
type CheckRelativePath<TAllRouteInfo extends AnyAllRouteInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths'] ? {} : {
type CheckRelativePath<TRoutesInfo extends AnyRoutesInfo, TFrom, TTo> = TTo extends string ? TFrom extends string ? ResolveRelativePath<TFrom, TTo> extends TRoutesInfo['routePaths'] ? {} : {
Error: `${TFrom} + ${TTo} resolves to ${ResolveRelativePath<TFrom, TTo>}, which is not a valid route path.`;
'Valid Route Paths': TAllRouteInfo['routePaths'];
'Valid Route Paths': TRoutesInfo['routePaths'];
} : {} : {};
type CheckPath<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routePaths']> extends never ? TPass : CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>;
type CheckPathError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
type CheckPath<TRoutesInfo extends AnyRoutesInfo, TPath, TPass> = Exclude<TPath, TRoutesInfo['routePaths']> extends never ? TPass : CheckPathError<TRoutesInfo, Exclude<TPath, TRoutesInfo['routePaths']>>;
type CheckPathError<TRoutesInfo extends AnyRoutesInfo, TInvalids> = Expand<{
Error: `${TInvalids extends string ? TInvalids : never} is not a valid route path.`;
'Valid Route Paths': TAllRouteInfo['routePaths'];
'Valid Route Paths': TRoutesInfo['routePaths'];
}>;
type CheckId<TAllRouteInfo extends AnyAllRouteInfo, TPath, TPass> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never ? TPass : CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>;
type CheckIdError<TAllRouteInfo extends AnyAllRouteInfo, TInvalids> = Expand<{
type CheckId<TRoutesInfo extends AnyRoutesInfo, TPath, TPass> = Exclude<TPath, TRoutesInfo['routeIds']> extends never ? TPass : CheckIdError<TRoutesInfo, Exclude<TPath, TRoutesInfo['routeIds']>>;
type CheckIdError<TRoutesInfo extends AnyRoutesInfo, TInvalids> = Expand<{
Error: `${TInvalids extends string ? TInvalids : never} is not a valid route ID.`;
'Valid Route IDs': TAllRouteInfo['routeIds'];
'Valid Route IDs': TRoutesInfo['routeIds'];
}>;
type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string ? TTo extends string ? TTo extends '.' ? TFrom : TTo extends `./` ? Join<[TFrom, '/']> : TTo extends `./${infer TRest}` ? ResolveRelativePath<TFrom, TRest> : TTo extends `/${infer TRest}` ? TTo : Split<TTo> extends ['..', ...infer ToRest] ? Split<TFrom> extends [...infer FromRest, infer FromTail] ? ToRest extends ['/'] ? Join<[...FromRest, '/']> : ResolveRelativePath<Join<FromRest>, Join<ToRest>> : never : Split<TTo> extends ['.', ...infer ToRest] ? ToRest extends ['/'] ? Join<[TFrom, '/']> : ResolveRelativePath<TFrom, Join<ToRest>> : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>> : never : never;
type ValidFromPath<TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo> = undefined | (string extends TAllRouteInfo['routePaths'] ? string : TAllRouteInfo['routePaths']);
type ValidFromPath<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo> = undefined | (string extends TRoutesInfo['routePaths'] ? string : TRoutesInfo['routePaths']);

@@ -592,2 +583,2 @@ interface Segment {

export { ActiveOptions, AllRouteInfo, AnyAllRouteInfo, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouteConfig, AnyRouteConfigWithChildren, AnyRouteInfo, AnyRouter, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultAllRouteInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FilterRoutesFn, FrameworkGenerics, FromLocation, GetFrameworkGeneric, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderState, LocationState, MatchCache, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptions, NoInfer, OnLoadFn, ParentParams, ParsePathParams, ParseRouteConfig, ParsedLocation, ParsedPath, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RegisterRouter, RegisteredAllRouteInfo, RegisteredRouter, RelativeToPathAutoComplete, ResolveRelativePath, RootRouteId, Route, RouteConfig, RouteConfigRoute, RouteInfo, RouteInfoById, RouteInfoByPath, RouteMatch, RouteMatchStore, RouteMeta, RouteOptions, Router, RouterContext, RouterHistory, RouterLocation, RouterOptions, RouterStore, RoutesById, RoutesInfoInner, SearchFilter, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnionToIntersection, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values, cleanPath, createBrowserHistory, createHashHistory, createMemoryHistory, createRouteConfig, decode, defaultFetchServerDataFn, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };
export { ActiveOptions, AnyLoaderData, AnyPathParams, AnyRoute, AnyRouter, AnyRoutesInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, DeepAwaited, DefaultRoutesInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FilterRoutesFn, FrameworkGenerics, FromLocation, GetFrameworkGeneric, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LoaderState, LocationState, MatchCache, MatchCacheEntry, MatchLocation, MatchRouteOptions, NavigateOptions, NoInfer, OnLoadFn, ParentParams, ParsePathParams, ParseRoute, ParseRouteChild, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamMask, PathParamOptions, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, RegisterRouter, RegisteredRouter, RegisteredRoutesInfo, RelativeToPathAutoComplete, ResolveFullSearchSchema, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteMatch, RouteMatchStore, RouteMeta, RouteOptions, RouteOptionsBase, RouteOptionsBaseIntersection, RouteWithRoutesInfo, Router, RouterContext, RouterHistory, RouterLocation, RouterOptions, RouterStore, RoutesById, RoutesInfo, RoutesInfoInner, SearchFilter, SearchParamOptions, SearchParser, SearchSchemaValidator, SearchSchemaValidatorFn, SearchSchemaValidatorObj, SearchSerializer, Segment, Split, Timeout, ToIdOption, ToOptions, ToPathOption, UnionToIntersection, UnloaderFn, Updater, ValidFromPath, ValueKeys, Values, cleanPath, createBrowserHistory, createHashHistory, createMemoryHistory, decode, defaultFetchServerDataFn, defaultParseSearch, defaultStringifySearch, encode, functionalUpdate, interpolatePath, isPlainObject, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, pick, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight, warning };

@@ -473,59 +473,107 @@ /**

const rootRouteId = '__root__';
class Route {
constructor(routeConfig, options, originalIndex, parent, router) {
Object.assign(this, {
...routeConfig,
originalIndex,
options,
getRouter: () => router,
childRoutes: undefined,
getParentRoute: () => parent
});
router.options.createRoute?.({
router,
route: this
});
}
}
// Set up in this.init()
const rootRouteId = '__root__';
const createRouteConfig = (options = {}, children = [], isRoot = true, parentId, parentPath) => {
if (isRoot) {
options.path = rootRouteId;
}
// customId!: TCustomId
// Strip the root from parentIds
if (parentId === rootRouteId) {
parentId = '';
}
let path = isRoot ? rootRouteId : options.path;
// Optional
// If the path is anything other than an index path, trim it up
if (path && path !== '/') {
path = trimPath(path);
constructor(options) {
this.options = options || {};
this.isRoot = !options?.getParentRoute;
}
const routeId = path || options.id;
let id = joinPaths([parentId, routeId]);
if (path === rootRouteId) {
path = '/';
}
if (id !== rootRouteId) {
id = joinPaths(['/', id]);
}
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]));
return {
id: id,
routeId: routeId,
path: path,
fullPath: fullPath,
options: options,
children,
addChildren: children => createRouteConfig(options, children, false, parentId, parentPath),
createRoute: childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath),
generate: () => {
invariant(false, `routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `);
init = () => {
const allOptions = this.options;
const isRoot = !allOptions?.path && !allOptions?.id;
const parent = this.options?.getParentRoute?.();
if (isRoot) {
this.path = rootRouteId;
} else {
invariant(parent, `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`);
}
let path = isRoot ? rootRouteId : allOptions.path;
// If the path is anything other than an index path, trim it up
if (path && path !== '/') {
path = trimPath(path);
}
const customId = allOptions?.id || path;
// Strip the parentId prefix from the first level of children
let id = isRoot ? rootRouteId : joinPaths([parent.id === rootRouteId ? '' : parent.id, customId]);
if (path === rootRouteId) {
path = '/';
}
if (id !== rootRouteId) {
id = joinPaths(['/', id]);
}
const fullPath = id === rootRouteId ? '/' : trimPathRight(joinPaths([parent.fullPath, path]));
this.id = id;
// this.customId = customId as TCustomId
this.fullPath = fullPath;
};
};
addChildren = children => {
this.children = children;
return this;
};
// generate: () => {
// invariant(
// false,
// `routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `,
// )
// },
}
class RootRoute extends Route {
constructor(options) {
super(options);
}
}
// const rootRoute = new RootRoute({
// validateSearch: () => null as unknown as { root?: boolean },
// })
// const aRoute = new Route({
// getParentRoute: () => rootRoute,
// path: 'a',
// validateSearch: () => null as unknown as { a?: string },
// })
// const bRoute = new Route({
// getParentRoute: () => aRoute,
// path: 'b',
// })
// const rootIsRoot = rootRoute.isRoot
// // ^?
// const aIsRoot = aRoute.isRoot
// // ^?
// const rId = rootRoute.id
// // ^?
// const aId = aRoute.id
// // ^?
// const bId = bRoute.id
// // ^?
// const rPath = rootRoute.fullPath
// // ^?
// const aPath = aRoute.fullPath
// // ^?
// const bPath = bRoute.fullPath
// // ^?
// const rSearch = rootRoute.__types.fullSearchSchema
// // ^?
// const aSearch = aRoute.__types.fullSearchSchema
// // ^?
// const bSearch = bRoute.__types.fullSearchSchema
// // ^?
// const config = rootRoute.addChildren([aRoute.addChildren([bRoute])])
// // ^?
/**

@@ -867,8 +915,8 @@ * store

basepath,
routeConfig
routeTree
} = this.options;
this.basepath = `/${trimPath(basepath ?? '') ?? ''}`;
if (routeConfig) {
if (routeTree) {
this.routesById = {};
this.routeTree = this.#buildRouteTree(routeConfig);
this.routeTree = this.#buildRouteTree(routeTree);
}

@@ -1016,13 +1064,14 @@ return this;

const existingMatches = [...this.store.state.currentMatches, ...(this.store.state.pendingMatches ?? [])];
const recurse = async routes => {
const findInRouteTree = async routes => {
const parentMatch = last(matches);
let params = parentMatch?.params ?? {};
const filteredRoutes = this.options.filterRoutes?.(routes) ?? routes;
let foundRoutes = [];
let matchingRoutes = [];
const findMatchInRoutes = (parentRoutes, routes) => {
routes.some(route => {
if (!route.path && route.childRoutes?.length) {
return findMatchInRoutes([...foundRoutes, route], route.childRoutes);
const children = route.children;
if (!route.path && children?.length) {
return findMatchInRoutes([...matchingRoutes, route], children);
}
const fuzzy = !!(route.path !== '/' || route.childRoutes?.length);
const fuzzy = route.path === '/' ? false : !!children?.length;
const matchParams = matchPathname(this.basepath, pathname, {

@@ -1048,13 +1097,13 @@ to: route.fullPath,

if (!!matchParams) {
foundRoutes = [...parentRoutes, route];
matchingRoutes = [...parentRoutes, route];
}
return !!foundRoutes.length;
return !!matchingRoutes.length;
});
return !!foundRoutes.length;
return !!matchingRoutes.length;
};
findMatchInRoutes([], filteredRoutes);
if (!foundRoutes.length) {
if (!matchingRoutes.length) {
return;
}
foundRoutes.forEach(foundRoute => {
matchingRoutes.forEach(foundRoute => {
const interpolatedPath = interpolatePath(foundRoute.path, params);

@@ -1071,8 +1120,9 @@ const matchId = interpolatePath(foundRoute.id, params, true);

});
const foundRoute = last(foundRoutes);
if (foundRoute.childRoutes?.length) {
recurse(foundRoute.childRoutes);
const foundRoute = last(matchingRoutes);
const foundChildren = foundRoute.children;
if (foundChildren?.length) {
findInRouteTree(foundChildren);
}
};
recurse([this.routeTree]);
findInRouteTree([this.routeTree]);
linkMatches(matches);

@@ -1324,7 +1374,8 @@ return matches;

};
#buildRouteTree = rootRouteConfig => {
const recurseRoutes = (routeConfigs, parent) => {
return routeConfigs.map((routeConfig, i) => {
const routeOptions = routeConfig.options;
const route = new Route(routeConfig, routeOptions, i, parent, this);
#buildRouteTree = routeTree => {
const recurseRoutes = routes => {
routes.forEach((route, i) => {
route.init();
route.originalIndex = i;
route.router = this;
const existingRoute = this.routesById[route.id];

@@ -1338,9 +1389,8 @@ if (existingRoute) {

this.routesById[route.id] = route;
const children = routeConfig.children;
route.childRoutes = children.length ? recurseRoutes(children, route) : undefined;
return route;
const children = route.children;
if (children?.length) recurseRoutes(children);
});
};
const routes = recurseRoutes([rootRouteConfig]);
return routes[0];
recurseRoutes([routeTree]);
return routeTree;
};

@@ -1479,2 +1529,3 @@ #parseLocation = previousLocation => {

exports.RootRoute = RootRoute;
exports.Route = Route;

@@ -1487,3 +1538,2 @@ exports.RouteMatch = RouteMatch;

exports.createMemoryHistory = createMemoryHistory;
exports.createRouteConfig = createRouteConfig;
exports.decode = decode;

@@ -1490,0 +1540,0 @@ exports.defaultFetchServerDataFn = defaultFetchServerDataFn;

@@ -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 o=()=>{e=t.getLocation(),a.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===a.size&&(s=t.listener(o)),a.add(e),()=>{a.delete(e),0===a.size&&s()}),push:(e,s)=>{t.pushState(e,s),o()},replace:(e,s)=>{t.replaceState(e,s),o()},go:e=>{t.go(e),o()},back:()=>{t.back(),o()},forward:()=>{t.forward(),o()}}}function o(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),o=t?.createHref??(t=>t);return a({getLocation:()=>i(e(),history.state),listener:t=>(window.addEventListener(s,t),()=>{window.removeEventListener(s,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:n()},"",o(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:n()},"",o(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function r(t={initialEntries:["/"]}){const e=t.initialEntries;let s=t.initialIndex??e.length-1,o={};return a({getLocation:()=>i(e[s],o),listener:()=>()=>{},pushState:(t,a)=>{o={...a,key:n()},e.push(t),s++},replaceState:(t,a)=>{o={...a,key:n()},e[s]=t},back:()=>{s--},forward:()=>{s=Math.min(s+1,e.length-1)},go:t=>window.history.go(t)})}function i(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 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,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,o=a?s:Object.keys(s),r=o.length,i=a?[]:{};let n=0;for(let e=0;e<r;e++){const r=a?e:o[e];i[r]=l(t[r],s[r]),i[r]===t[r]&&n++}return e===r&&n===e?t:i}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){return m(t.filter(Boolean).join("/"))}function m(t){return t.replace(/\/{2,}/g,"/")}function g(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function y(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function w(t){return y(g(t))}function v(t,e,s){e=e.replace(new RegExp(`^${t}`),"/"),s=s.replace(new RegExp(`^${t}`),"/");let a=b(e);const o=b(s);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.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 m(f([t,...a.map((t=>t.value))]))}function b(t){if(!t)return[];const e=[];if("/"===(t=m(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.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 L(t,e,s){return f(b(t).map((t=>"*"!==t.value||s?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function S(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=b(e="/"!=t?e.substring(t.length):e),o=b(`${s.to??"*"}`),r={};return(()=>{for(let t=0;t<Math.max(a.length,o.length);t++){const e=a[t],i=o[t],n=t===o.length-1,h=t===a.length-1;if(i){if("wildcard"===i.type)return!!e?.value&&(r["*"]=f(a.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&!e?.value)return!0;if(e)if(s.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)&&(r[i.value.substring(1)]=e.value)}}if(n&&!h)return!!s.fuzzy}return!0})()?r:void 0}function P(t,e){var s,a,o,r="";for(s in t)if(void 0!==(o=t[s]))if(Array.isArray(o))for(a=0;a<o.length;a++)r&&(r+="&"),r+=encodeURIComponent(s)+"="+encodeURIComponent(o[a]);else r&&(r+="&"),r+=encodeURIComponent(s)+"="+encodeURIComponent(o);return(e||"")+r}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,s,a={},o=t.split("&");e=o.shift();)void 0!==a[s=(e=e.split("=")).shift()]?a[s]=[].concat(a[s],R(e.shift())):a[s]=R(e.shift());return a}class M{constructor(t,e,s,a,o){Object.assign(this,{...t,originalIndex:s,options:e,getRouter:()=>o,childRoutes:void 0,getParentRoute:()=>a}),o.options.createRoute?.({router:o,route:this})}}const x="__root__",$=(t={},s=[],a=!0,o,r)=>{a&&(t.path=x),o===x&&(o="");let i=a?x:t.path;i&&"/"!==i&&(i=w(i));const n=i||t.id;let h=f([o,n]);i===x&&(i="/"),h!==x&&(h=f(["/",h]));const c=h===x?"/":y(f([r,i]));return{id:h,routeId:n,path:i,fullPath:c,options:t,children:s,addChildren:e=>$(t,e,!1,o,r),createRoute:t=>$(t,void 0,!1,h,c),generate:()=>{e(!1)}}};
!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 o=()=>{e=t.getLocation(),a.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===a.size&&(s=t.listener(o)),a.add(e),()=>{a.delete(e),0===a.size&&s()}),push:(e,s)=>{t.pushState(e,s),o()},replace:(e,s)=>{t.replaceState(e,s),o()},go:e=>{t.go(e),o()},back:()=>{t.back(),o()},forward:()=>{t.forward(),o()}}}function o(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),o=t?.createHref??(t=>t);return a({getLocation:()=>i(e(),history.state),listener:t=>(window.addEventListener(s,t),()=>{window.removeEventListener(s,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:n()},"",o(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:n()},"",o(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function r(t={initialEntries:["/"]}){const e=t.initialEntries;let s=t.initialIndex??e.length-1,o={};return a({getLocation:()=>i(e[s],o),listener:()=>()=>{},pushState:(t,a)=>{o={...a,key:n()},e.push(t),s++},replaceState:(t,a)=>{o={...a,key:n()},e[s]=t},back:()=>{s--},forward:()=>{s=Math.min(s+1,e.length-1)},go:t=>window.history.go(t)})}function i(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 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,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,o=a?s:Object.keys(s),r=o.length,i=a?[]:{};let n=0;for(let e=0;e<r;e++){const r=a?e:o[e];i[r]=l(t[r],s[r]),i[r]===t[r]&&n++}return e===r&&n===e?t:i}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){return m(t.filter(Boolean).join("/"))}function m(t){return t.replace(/\/{2,}/g,"/")}function g(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function y(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function w(t){return y(g(t))}function v(t,e,s){e=e.replace(new RegExp(`^${t}`),"/"),s=s.replace(new RegExp(`^${t}`),"/");let a=b(e);const o=b(s);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.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 m(f([t,...a.map((t=>t.value))]))}function b(t){if(!t)return[];const e=[];if("/"===(t=m(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.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 L(t,e,s){return f(b(t).map((t=>"*"!==t.value||s?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function S(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=b(e="/"!=t?e.substring(t.length):e),o=b(`${s.to??"*"}`),r={};return(()=>{for(let t=0;t<Math.max(a.length,o.length);t++){const e=a[t],i=o[t],n=t===o.length-1,h=t===a.length-1;if(i){if("wildcard"===i.type)return!!e?.value&&(r["*"]=f(a.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&!e?.value)return!0;if(e)if(s.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)&&(r[i.value.substring(1)]=e.value)}}if(n&&!h)return!!s.fuzzy}return!0})()?r:void 0}function P(t,e){var s,a,o,r="";for(s in t)if(void 0!==(o=t[s]))if(Array.isArray(o))for(a=0;a<o.length;a++)r&&(r+="&"),r+=encodeURIComponent(s)+"="+encodeURIComponent(o[a]);else r&&(r+="&"),r+=encodeURIComponent(s)+"="+encodeURIComponent(o);return(e||"")+r}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={},o=t.split("&");e=o.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 x{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=()=>{const t=this.options,s=!t?.path&&!t?.id,a=this.options?.getParentRoute?.();s?this.path=M:e(a);let o=s?M:t.path;o&&"/"!==o&&(o=w(o));const r=t?.id||o;let i=s?M:f([a.id===M?"":a.id,r]);o===M&&(o="/"),i!==M&&(i=f(["/",i]));const n=i===M?"/":y(f([a.fullPath,o]));this.id=i,this.fullPath=n};addChildren=t=>(this.children=t,this)}
/**

@@ -23,3 +23,3 @@ * store

*/
class C{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.queue.push((()=>{this.listeners.forEach((t=>t(this.state,e))),this.options?.onUpdate?.(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=["component","errorComponent","pendingComponent"];class I{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 C({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)};#s="";fetch=async t=>(this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#s=e;const s=()=>e!==this.#s?this.__loadPromise:void 0;let a;this.store.batch((()=>{"idle"===this.store.state.status&&this.store.setState((t=>({...t,status:"pending"})))}));const o=(async()=>{await Promise.all(A.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),r=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 o,await r,a=s())return await a;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&&!A.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((s=>({...s,routeSearch:e,search:{...t,...e}}))),A.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 F=T(JSON.parse),k=j(JSON.stringify);function T(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let s=E(e);for(let e in s){const a=s[e];if("string"==typeof a)try{s[e]=t(a)}catch(t){}}return s}}function j(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=P(e).toString();return s?`?${s}`:""}}const O=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 H(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}t.Route=M,t.RouteMatch=I,t.Router=class{#a;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??k,parseSearch:t?.parseSearch??F,fetchServerDataFn:t?.fetchServerDataFn??O},this.store=new C(H()),this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,H())))};mount=()=>{if(!D){this.store.state.currentMatches.length||this.load();const t="visibilitychange",e="focus";return window.addEventListener&&(window.addEventListener(t,this.#o,!1),window.addEventListener(e,this.#o,!1)),()=>{window.removeEventListener&&(window.removeEventListener(t,this.#o),window.removeEventListener(e,this.#o))}}return()=>{}};update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#a&&this.#a(),this.history=this.options.history??(D?r():o());const t=this.#r();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#a=this.history.listen((()=>{this.load(this.#r(this.store.state.latestLocation))}))}const{basepath:e,routeConfig:s}=this.options;return this.basepath=`/${w(e??"")??""}`,s&&(this.routesById={},this.routeTree=this.#i(s)),this};buildNext=t=>{const e=this.#n(t),s=this.matchRoutes(e.pathname),a=s.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),o=s.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#n({...t,__preSearchFilters:a,__postSearchFilters:o})};cancelMatches=()=>{[...this.store.state.currentMatches,...this.store.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};load=async t=>{let s=Date.now();const a=s;let o;this.startedLoadingAt=a,this.cancelMatches(),this.store.batch((()=>{t&&this.store.setState((e=>({...e,latestLocation:t}))),o=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:o,pendingLocation:this.store.state.latestLocation})))}));try{await this.loadMatches(o)}catch(t){console.warn(t),e(!1)}if(this.startedLoadingAt!==a)return this.navigationPromise;const r=this.store.state.currentMatches,i=[],n=[];r.forEach((t=>{o.find((e=>e.id===t.id))?n.push(t):i.push(t)}));const h=o.filter((t=>!r.find((e=>e.id===t.id))));s=Date.now(),i.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})))})),n.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.store.state.routeSearch})})),h.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:o,pendingLocation:void 0,pendingMatches:void 0}))),this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const s=this.routesById[t];return e(s),s};loadRoute=async(t=this.store.state.latestLocation)=>{const e=this.buildNext(t),s=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(s),s};preloadRoute=async(t=this.store.state.latestLocation)=>{const e=this.buildNext(t),s=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(s,{preload:!0}),s};matchRoutes=(t,e)=>{const s=[];if(!this.routeTree)return s;const a=[...this.store.state.currentMatches,...this.store.state.pendingMatches??[]],o=async r=>{let i=h(s)?.params??{};const n=this.options.filterRoutes?.(r)??r;let c=[];const u=(s,a)=>(a.some((a=>{if(!a.path&&a.childRoutes?.length)return u([...c,a],a.childRoutes);const o=!("/"===a.path&&!a.childRoutes?.length),r=S(this.basepath,t,{to:a.fullPath,fuzzy:o,caseSensitive:a.options.caseSensitive??this.options.caseSensitive});if(r){let t;try{t=a.options.parseParams?.(r)??r}catch(t){if(e?.strictParseParams)throw t}i={...i,...t}}return r&&(c=[...s,a]),!!c.length})),!!c.length);if(u([],n),!c.length)return;c.forEach((t=>{const e=L(t.path,i),o=L(t.id,i,!0),r=a.find((t=>t.id===o))||new I(this,t,{id:o,params:i,pathname:f([this.basepath,e])});s.push(r)}));const l=h(c);l.childRoutes?.length&&o(l.childRoutes)};return o([this.routeTree]),function(t){t.forEach(((e,s)=>{const a=t[s-1];a&&e.__setParentMatch(a)}))}(s),s};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(s){throw e?.preload||t.route.options.onLoadError?.(s),s}})));const s=t.map((async(s,a)=>{const o=t[1],r=s.store.state.search;r.__data?.matchId&&r.__data.matchId!==s.id||(s.load({preload:e?.preload}),"success"!==s.store.state.status&&s.__loadPromise&&await s.__loadPromise,o&&await o.__loadPromise)}));await Promise.all(s)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>v(this.basepath,t,m(e));navigate=async({from:t,to:s=".",search:a,hash:o,replace:r,params:i})=>{const n=String(s),h=void 0===t?t:String(t);let c;try{new URL(`${n}`),c=!0}catch(t){}return e(!c),this.#h({from:h,to:n,search:a,hash:o,replace:r,params:i})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const s=this.buildNext(t);return e?.pending?!!this.store.state.pendingLocation&&S(this.basepath,this.store.state.pendingLocation.pathname,{...e,to:s.pathname}):S(this.basepath,this.store.state.currentLocation.pathname,{...e,to:s.pathname})};buildLink=({from:t,to:e=".",search:s,params:a,hash:o,target:r,replace:i,activeOptions:n,preload:h,preloadMaxAge:c,preloadGcMaxAge:u,preloadDelay:l,disabled:p})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const d={from:t,to:e,search:s,params:a,hash:o,replace:i},f=this.buildNext(d);h=h??this.options.defaultPreload;const m=l??this.options.defaultPreloadDelay??0,g=this.store.state.currentLocation.pathname===f.pathname,y=this.store.state.currentLocation.pathname.split("/"),w=f.pathname.split("/").every(((t,e)=>t===y[e])),v=this.store.state.currentLocation.hash===f.hash;return{type:"internal",next:f,handleFocus:t=>{h&&this.preloadRoute(d).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{p||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||r&&"_self"!==r||0!==t.button||(t.preventDefault(),this.#h(d))},handleEnter:t=>{const e=t.target||{};if(h){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(d).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:(n?.exact?g:w)&&(!n?.includeHash||v),disabled:p}};dehydrate=()=>({state:{...u(this.store.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.store.state.currentMatches.map((t=>({id:t.id,state:{...u(t.store.state,["status"])}})))},context:this.options.context});hydrate=t=>{this.store.setState((s=>{this.options.context=t.context;const a=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return a.forEach(((s,a)=>{const o=t.state.currentMatches[a];e(o&&o.id===s.id),s.store.setState((t=>({...t,...o.state})))})),a.forEach((t=>t.__validate())),{...s,...t.state,currentMatches:a}}))};#i=t=>{const e=(t,s)=>t.map(((t,a)=>{const o=t.options,r=new M(t,o,a,s,this);if(this.routesById[r.id])throw new Error;this.routesById[r.id]=r;const i=t.children;return r.childRoutes=i.length?e(i,r):void 0,r}));return e([t])[0]};#r=t=>{let{pathname:e,search:s,hash:a,state:o}=this.history.location;const r=this.options.parseSearch(s);return{pathname:e,searchStr:s,search:l(t?.search,r),hash:a.split("#").reverse()[0]??"",href:`${e}${s}${a}`,state:o,key:o?.key||"__init__"}};#o=()=>{this.load()};#n=(t={})=>{const e=t.fromCurrent?this.store.state.latestLocation.pathname:t.from??this.store.state.latestLocation.pathname;let s=v(this.basepath??"/",e,`${t.to??"."}`);const a=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),o=this.matchRoutes(s),r={...h(a)?.params};let i=!0===(t.params??!0)?r:c(t.params,r);i&&o.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},i,t(i))})),s=L(s,i??{});const n=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.store.state.latestLocation.search):this.store.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.store.state.latestLocation.search,p),f=this.options.stringifySearch(d);let m=!0===t.hash?this.store.state.latestLocation.hash:c(t.hash,this.store.state.latestLocation.hash);return m=m?`#${m}`:"",{pathname:s,search:d,searchStr:f,state:this.store.state.latestLocation.state,hash:m,href:`${s}${f}${m}`,key:t.key}};#h=t=>{const e=this.buildNext(t),s=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let a="replace";t.replace||(a="push");this.store.state.latestLocation.href===e.href&&!e.key&&(a="replace");const o=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===a?"push":"replace"](o,{id:s,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}},t.cleanPath=m,t.createBrowserHistory=o,t.createHashHistory=function(){return o({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=r,t.createRouteConfig=$,t.decode=E,t.defaultFetchServerDataFn=O,t.defaultParseSearch=F,t.defaultStringifySearch=k,t.encode=P,t.functionalUpdate=c,t.interpolatePath=L,t.invariant=e,t.isPlainObject=p,t.joinPaths=f,t.last=h,t.matchByPath=_,t.matchPathname=S,t.parsePathname=b,t.parseSearchWith=T,t.pick=u,t.replaceEqualDeep=l,t.resolvePath=v,t.rootRouteId=x,t.stringifySearchWith=j,t.trimPath=w,t.trimPathLeft=g,t.trimPathRight=y,t.warning=function(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
class ${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.queue.push((()=>{this.listeners.forEach((t=>t(this.state,e))),this.options?.onUpdate?.(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=["component","errorComponent","pendingComponent"];class C{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 $({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)};#s="";fetch=async t=>(this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#s=e;const s=()=>e!==this.#s?this.__loadPromise:void 0;let a;this.store.batch((()=>{"idle"===this.store.state.status&&this.store.setState((t=>({...t,status:"pending"})))}));const o=(async()=>{await Promise.all(A.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),r=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 o,await r,a=s())return await a;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&&!A.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((s=>({...s,routeSearch:e,search:{...t,...e}}))),A.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 F=k(JSON.parse),I=T(JSON.stringify);function k(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=P(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()}}t.RootRoute=class extends x{constructor(t){super(t)}},t.Route=x,t.RouteMatch=C,t.Router=class{#a;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??I,parseSearch:t?.parseSearch??F,fetchServerDataFn:t?.fetchServerDataFn??j},this.store=new $(O()),this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,O())))};mount=()=>{if(!D){this.store.state.currentMatches.length||this.load();const t="visibilitychange",e="focus";return window.addEventListener&&(window.addEventListener(t,this.#o,!1),window.addEventListener(e,this.#o,!1)),()=>{window.removeEventListener&&(window.removeEventListener(t,this.#o),window.removeEventListener(e,this.#o))}}return()=>{}};update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#a&&this.#a(),this.history=this.options.history??(D?r():o());const t=this.#r();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#a=this.history.listen((()=>{this.load(this.#r(this.store.state.latestLocation))}))}const{basepath:e,routeTree:s}=this.options;return this.basepath=`/${w(e??"")??""}`,s&&(this.routesById={},this.routeTree=this.#i(s)),this};buildNext=t=>{const e=this.#n(t),s=this.matchRoutes(e.pathname),a=s.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),o=s.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#n({...t,__preSearchFilters:a,__postSearchFilters:o})};cancelMatches=()=>{[...this.store.state.currentMatches,...this.store.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};load=async t=>{let s=Date.now();const a=s;let o;this.startedLoadingAt=a,this.cancelMatches(),this.store.batch((()=>{t&&this.store.setState((e=>({...e,latestLocation:t}))),o=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:o,pendingLocation:this.store.state.latestLocation})))}));try{await this.loadMatches(o)}catch(t){console.warn(t),e(!1)}if(this.startedLoadingAt!==a)return this.navigationPromise;const r=this.store.state.currentMatches,i=[],n=[];r.forEach((t=>{o.find((e=>e.id===t.id))?n.push(t):i.push(t)}));const h=o.filter((t=>!r.find((e=>e.id===t.id))));s=Date.now(),i.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})))})),n.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.store.state.routeSearch})})),h.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:o,pendingLocation:void 0,pendingMatches:void 0}))),this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const s=this.routesById[t];return e(s),s};loadRoute=async(t=this.store.state.latestLocation)=>{const e=this.buildNext(t),s=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(s),s};preloadRoute=async(t=this.store.state.latestLocation)=>{const e=this.buildNext(t),s=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(s,{preload:!0}),s};matchRoutes=(t,e)=>{const s=[];if(!this.routeTree)return s;const a=[...this.store.state.currentMatches,...this.store.state.pendingMatches??[]],o=async r=>{let i=h(s)?.params??{};const n=this.options.filterRoutes?.(r)??r;let c=[];const u=(s,a)=>(a.some((a=>{const o=a.children;if(!a.path&&o?.length)return u([...c,a],o);const r="/"!==a.path&&!!o?.length,n=S(this.basepath,t,{to:a.fullPath,fuzzy:r,caseSensitive:a.options.caseSensitive??this.options.caseSensitive});if(n){let t;try{t=a.options.parseParams?.(n)??n}catch(t){if(e?.strictParseParams)throw t}i={...i,...t}}return n&&(c=[...s,a]),!!c.length})),!!c.length);if(u([],n),!c.length)return;c.forEach((t=>{const e=L(t.path,i),o=L(t.id,i,!0),r=a.find((t=>t.id===o))||new C(this,t,{id:o,params:i,pathname:f([this.basepath,e])});s.push(r)}));const l=h(c).children;l?.length&&o(l)};return o([this.routeTree]),function(t){t.forEach(((e,s)=>{const a=t[s-1];a&&e.__setParentMatch(a)}))}(s),s};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(s){throw e?.preload||t.route.options.onLoadError?.(s),s}})));const s=t.map((async(s,a)=>{const o=t[1],r=s.store.state.search;r.__data?.matchId&&r.__data.matchId!==s.id||(s.load({preload:e?.preload}),"success"!==s.store.state.status&&s.__loadPromise&&await s.__loadPromise,o&&await o.__loadPromise)}));await Promise.all(s)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>v(this.basepath,t,m(e));navigate=async({from:t,to:s=".",search:a,hash:o,replace:r,params:i})=>{const n=String(s),h=void 0===t?t:String(t);let c;try{new URL(`${n}`),c=!0}catch(t){}return e(!c),this.#h({from:h,to:n,search:a,hash:o,replace:r,params:i})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const s=this.buildNext(t);return e?.pending?!!this.store.state.pendingLocation&&S(this.basepath,this.store.state.pendingLocation.pathname,{...e,to:s.pathname}):S(this.basepath,this.store.state.currentLocation.pathname,{...e,to:s.pathname})};buildLink=({from:t,to:e=".",search:s,params:a,hash:o,target:r,replace:i,activeOptions:n,preload:h,preloadMaxAge:c,preloadGcMaxAge:u,preloadDelay:l,disabled:p})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const d={from:t,to:e,search:s,params:a,hash:o,replace:i},f=this.buildNext(d);h=h??this.options.defaultPreload;const m=l??this.options.defaultPreloadDelay??0,g=this.store.state.currentLocation.pathname===f.pathname,y=this.store.state.currentLocation.pathname.split("/"),w=f.pathname.split("/").every(((t,e)=>t===y[e])),v=this.store.state.currentLocation.hash===f.hash;return{type:"internal",next:f,handleFocus:t=>{h&&this.preloadRoute(d).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{p||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||r&&"_self"!==r||0!==t.button||(t.preventDefault(),this.#h(d))},handleEnter:t=>{const e=t.target||{};if(h){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(d).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:(n?.exact?g:w)&&(!n?.includeHash||v),disabled:p}};dehydrate=()=>({state:{...u(this.store.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.store.state.currentMatches.map((t=>({id:t.id,state:{...u(t.store.state,["status"])}})))},context:this.options.context});hydrate=t=>{this.store.setState((s=>{this.options.context=t.context;const a=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return a.forEach(((s,a)=>{const o=t.state.currentMatches[a];e(o&&o.id===s.id),s.store.setState((t=>({...t,...o.state})))})),a.forEach((t=>t.__validate())),{...s,...t.state,currentMatches:a}}))};#i=t=>{const e=t=>{t.forEach(((t,s)=>{t.init(),t.originalIndex=s,t.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};#r=t=>{let{pathname:e,search:s,hash:a,state:o}=this.history.location;const r=this.options.parseSearch(s);return{pathname:e,searchStr:s,search:l(t?.search,r),hash:a.split("#").reverse()[0]??"",href:`${e}${s}${a}`,state:o,key:o?.key||"__init__"}};#o=()=>{this.load()};#n=(t={})=>{const e=t.fromCurrent?this.store.state.latestLocation.pathname:t.from??this.store.state.latestLocation.pathname;let s=v(this.basepath??"/",e,`${t.to??"."}`);const a=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),o=this.matchRoutes(s),r={...h(a)?.params};let i=!0===(t.params??!0)?r:c(t.params,r);i&&o.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},i,t(i))})),s=L(s,i??{});const n=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.store.state.latestLocation.search):this.store.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.store.state.latestLocation.search,p),f=this.options.stringifySearch(d);let m=!0===t.hash?this.store.state.latestLocation.hash:c(t.hash,this.store.state.latestLocation.hash);return m=m?`#${m}`:"",{pathname:s,search:d,searchStr:f,state:this.store.state.latestLocation.state,hash:m,href:`${s}${f}${m}`,key:t.key}};#h=t=>{const e=this.buildNext(t),s=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let a="replace";t.replace||(a="push");this.store.state.latestLocation.href===e.href&&!e.key&&(a="replace");const o=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===a?"push":"replace"](o,{id:s,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}},t.cleanPath=m,t.createBrowserHistory=o,t.createHashHistory=function(){return o({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=r,t.decode=R,t.defaultFetchServerDataFn=j,t.defaultParseSearch=F,t.defaultStringifySearch=I,t.encode=P,t.functionalUpdate=c,t.interpolatePath=L,t.invariant=e,t.isPlainObject=p,t.joinPaths=f,t.last=h,t.matchByPath=_,t.matchPathname=S,t.parsePathname=b,t.parseSearchWith=k,t.pick=u,t.replaceEqualDeep=l,t.resolvePath=v,t.rootRouteId=M,t.stringifySearchWith=T,t.trimPath=w,t.trimPathLeft=g,t.trimPathRight=y,t.warning=function(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/router",
"author": "Tanner Linsley",
"version": "0.0.1-beta.57",
"version": "0.0.1-beta.58",
"license": "MIT",

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

@@ -9,3 +9,2 @@ export { default as invariant } from 'tiny-invariant'

export * from './route'
export * from './routeConfig'
export * from './routeInfo'

@@ -12,0 +11,0 @@ export * from './routeMatch'

@@ -1,6 +0,2 @@

import {
AnyAllRouteInfo,
DefaultAllRouteInfo,
RouteInfoByPath,
} from './routeInfo'
import { AnyRoutesInfo, DefaultRoutesInfo, RouteByPath } from './routeInfo'
import { ParsedLocation, LocationState } from './router'

@@ -122,6 +118,6 @@ import {

export type NavigateOptions<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TFrom extends TAllRouteInfo['routePaths'] = '/',
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
> = ToOptions<TAllRouteInfo, TFrom, TTo> & {
> = ToOptions<TRoutesInfo, TFrom, TTo> & {
// Whether to replace the current history stack instead of pushing a new one

@@ -132,8 +128,8 @@ replace?: boolean

export type ToOptions<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TFrom extends TAllRouteInfo['routePaths'] = '/',
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>,
> = {
to?: ToPathOption<TAllRouteInfo, TFrom, TTo>
to?: ToPathOption<TRoutesInfo, TFrom, TTo>
// The new has string or a function to update it

@@ -147,8 +143,8 @@ hash?: Updater<string>

// fromCurrent?: boolean
} & CheckPath<TAllRouteInfo, NoInfer<TResolvedTo>, {}> &
SearchParamOptions<TAllRouteInfo, TFrom, TResolvedTo> &
PathParamOptions<TAllRouteInfo, TFrom, TResolvedTo>
} & CheckPath<TRoutesInfo, NoInfer<TResolvedTo>, {}> &
SearchParamOptions<TRoutesInfo, TFrom, TResolvedTo> &
PathParamOptions<TRoutesInfo, TFrom, TResolvedTo>
export type SearchParamOptions<
TAllRouteInfo extends AnyAllRouteInfo,
TRoutesInfo extends AnyRoutesInfo,
TFrom,

@@ -158,6 +154,6 @@ TTo,

UnionToIntersection<
TAllRouteInfo['fullSearchSchema'] &
RouteInfoByPath<TAllRouteInfo, TFrom> extends never
TRoutesInfo['fullSearchSchema'] &
RouteByPath<TRoutesInfo, TFrom> extends never
? {}
: RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']
: RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']
>

@@ -168,15 +164,15 @@ >,

TToSchema = Partial<
RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']
RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']
> &
Omit<
RouteInfoByPath<TAllRouteInfo, TTo>['fullSearchSchema'],
RouteByPath<TRoutesInfo, TTo>['__types']['fullSearchSchema'],
keyof PickRequired<
RouteInfoByPath<TAllRouteInfo, TFrom>['fullSearchSchema']
RouteByPath<TRoutesInfo, TFrom>['__types']['fullSearchSchema']
>
>,
TFromFullSchema = Expand<
UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TFromSchema>
UnionToIntersection<TRoutesInfo['fullSearchSchema'] & TFromSchema>
>,
TToFullSchema = Expand<
UnionToIntersection<TAllRouteInfo['fullSearchSchema'] & TToSchema>
UnionToIntersection<TRoutesInfo['fullSearchSchema'] & TToSchema>
>,

@@ -196,3 +192,3 @@ > = keyof PickRequired<TToSchema> extends never

export type PathParamOptions<
TAllRouteInfo extends AnyAllRouteInfo,
TRoutesInfo extends AnyRoutesInfo,
TFrom,

@@ -202,5 +198,5 @@ TTo,

UnionToIntersection<
RouteInfoByPath<TAllRouteInfo, TFrom> extends never
RouteByPath<TRoutesInfo, TFrom> extends never
? {}
: RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']
: RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']
>

@@ -210,12 +206,14 @@ >,

// that are already defined in the current schema
TToSchema = Partial<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']> &
TToSchema = Partial<RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']> &
Omit<
RouteInfoByPath<TAllRouteInfo, TTo>['allParams'],
keyof PickRequired<RouteInfoByPath<TAllRouteInfo, TFrom>['allParams']>
RouteByPath<TRoutesInfo, TTo>['__types']['allParams'],
keyof PickRequired<
RouteByPath<TRoutesInfo, TFrom>['__types']['allParams']
>
>,
TFromFullParams = Expand<
UnionToIntersection<TAllRouteInfo['allParams'] & TFromSchema>
UnionToIntersection<TRoutesInfo['allParams'] & TFromSchema>
>,
TToFullParams = Expand<
UnionToIntersection<TAllRouteInfo['allParams'] & TToSchema>
UnionToIntersection<TRoutesInfo['allParams'] & TToSchema>
>,

@@ -233,4 +231,4 @@ > = keyof PickRequired<TToSchema> extends never

export type ToPathOption<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TFrom extends TAllRouteInfo['routePaths'] = '/',
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',

@@ -240,3 +238,3 @@ > =

| RelativeToPathAutoComplete<
TAllRouteInfo['routePaths'],
TRoutesInfo['routePaths'],
NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',

@@ -247,4 +245,4 @@ NoInfer<TTo> & string

export type ToIdOption<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TFrom extends TAllRouteInfo['routePaths'] = '/',
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',

@@ -254,3 +252,3 @@ > =

| RelativeToPathAutoComplete<
TAllRouteInfo['routeIds'],
TRoutesInfo['routeIds'],
NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',

@@ -266,6 +264,6 @@ NoInfer<TTo> & string

export type LinkOptions<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TFrom extends TAllRouteInfo['routePaths'] = '/',
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
> = NavigateOptions<TAllRouteInfo, TFrom, TTo> & {
> = NavigateOptions<TRoutesInfo, TFrom, TTo> & {
// The standard anchor tag target attribute

@@ -288,3 +286,3 @@ target?: HTMLAnchorElement['target']

export type CheckRelativePath<
TAllRouteInfo extends AnyAllRouteInfo,
TRoutesInfo extends AnyRoutesInfo,
TFrom,

@@ -294,3 +292,3 @@ TTo,

? TFrom extends string
? ResolveRelativePath<TFrom, TTo> extends TAllRouteInfo['routePaths']
? ResolveRelativePath<TFrom, TTo> extends TRoutesInfo['routePaths']
? {}

@@ -302,3 +300,3 @@ : {

>}, which is not a valid route path.`
'Valid Route Paths': TAllRouteInfo['routePaths']
'Valid Route Paths': TRoutesInfo['routePaths']
}

@@ -309,11 +307,11 @@ : {}

export type CheckPath<
TAllRouteInfo extends AnyAllRouteInfo,
TRoutesInfo extends AnyRoutesInfo,
TPath,
TPass,
> = Exclude<TPath, TAllRouteInfo['routePaths']> extends never
> = Exclude<TPath, TRoutesInfo['routePaths']> extends never
? TPass
: CheckPathError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routePaths']>>
: CheckPathError<TRoutesInfo, Exclude<TPath, TRoutesInfo['routePaths']>>
export type CheckPathError<
TAllRouteInfo extends AnyAllRouteInfo,
TRoutesInfo extends AnyRoutesInfo,
TInvalids,

@@ -324,15 +322,14 @@ > = Expand<{

: never} is not a valid route path.`
'Valid Route Paths': TAllRouteInfo['routePaths']
'Valid Route Paths': TRoutesInfo['routePaths']
}>
export type CheckId<
TAllRouteInfo extends AnyAllRouteInfo,
export type CheckId<TRoutesInfo extends AnyRoutesInfo, TPath, TPass> = Exclude<
TPath,
TPass,
> = Exclude<TPath, TAllRouteInfo['routeIds']> extends never
TRoutesInfo['routeIds']
> extends never
? TPass
: CheckIdError<TAllRouteInfo, Exclude<TPath, TAllRouteInfo['routeIds']>>
: CheckIdError<TRoutesInfo, Exclude<TPath, TRoutesInfo['routeIds']>>
export type CheckIdError<
TAllRouteInfo extends AnyAllRouteInfo,
TRoutesInfo extends AnyRoutesInfo,
TInvalids,

@@ -343,3 +340,3 @@ > = Expand<{

: never} is not a valid route ID.`
'Valid Route IDs': TAllRouteInfo['routeIds']
'Valid Route IDs': TRoutesInfo['routeIds']
}>

@@ -372,7 +369,7 @@

export type ValidFromPath<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
> =
| undefined
| (string extends TAllRouteInfo['routePaths']
| (string extends TRoutesInfo['routePaths']
? string
: TAllRouteInfo['routePaths'])
: TRoutesInfo['routePaths'])
import invariant from 'tiny-invariant'
import { AnyPathParams } from './routeConfig'
import { AnyPathParams } from './route'
import { MatchLocation } from './router'

@@ -4,0 +4,0 @@ import { last } from './utils'

@@ -1,49 +0,500 @@

import { RouteConfig, RouteOptions } from './routeConfig'
import { GetFrameworkGeneric } from './frameworks'
import { ParsePathParams } from './link'
import { RouteMatch } from './routeMatch'
import { AnyRouter, Router } from './router'
import {
AnyAllRouteInfo,
AnyRouteInfo,
DefaultAllRouteInfo,
RouteInfo,
} from './routeInfo'
import { Router } from './router'
Expand,
IsAny,
NoInfer,
PickUnsafe,
UnionToIntersection,
} from './utils'
import invariant from 'tiny-invariant'
import { joinPaths, trimPath, trimPathRight } from './path'
import { AnyRoutesInfo, DefaultRoutesInfo } from './routeInfo'
export interface AnyRoute extends Route<any, any, any> {}
export const rootRouteId = '__root__' as const
export type RootRouteId = typeof rootRouteId
export type AnyLoaderData = {}
export type AnyPathParams = {}
export type AnySearchSchema = {}
export interface RouteMeta {}
export type RouteOptionsBase<TCustomId, TPath> =
| {
path: TPath
}
| {
id: TCustomId
}
export type RouteOptionsBaseIntersection<TCustomId, TPath> =
UnionToIntersection<RouteOptionsBase<TCustomId, TPath>>
export type RouteOptions<
TParentRoute extends AnyRoute = AnyRoute,
TCustomId extends string = string,
TPath extends string = string,
TParentSearchSchema extends {} = {},
TSearchSchema extends AnySearchSchema = {},
TFullSearchSchema extends AnySearchSchema = TSearchSchema,
TParentParams extends AnyPathParams = {},
TParams extends Record<ParsePathParams<TPath>, unknown> = Record<
ParsePathParams<TPath>,
string
>,
TAllParams extends AnyPathParams = {},
> = RouteOptionsBase<TCustomId, TPath> & {
getParentRoute: () => TParentRoute
// If true, this route will be matched as case-sensitive
caseSensitive?: boolean
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>
// Filter functions that can manipulate search params *before* they are passed to links and navigate
// calls that match this route.
preSearchFilters?: SearchFilter<TFullSearchSchema>[]
// Filter functions that can manipulate search params *after* they are passed to links and navigate
// calls that match this route.
postSearchFilters?: SearchFilter<TFullSearchSchema>[]
// The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
component?: GetFrameworkGeneric<'Component'> // , NoInfer<TParentAllLoaderData>>
// The content to be rendered when the route encounters an error
errorComponent?: GetFrameworkGeneric<'ErrorComponent'> // , NoInfer<TParentAllLoaderData>>
// If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
pendingComponent?: GetFrameworkGeneric<'Component'> //, NoInfer<TParentAllLoaderData>>
// This async function is called before a route is loaded.
// If an error is thrown here, the route's loader will not be called.
// If thrown during a navigation, the navigation will be cancelled and the error will be passed to the `onLoadError` function.
// If thrown during a preload event, the error will be logged to the console.
beforeLoad?: (opts: {
router: AnyRouter
match: RouteMatch
}) => Promise<void> | void
// An asynchronous function responsible for preparing or fetching data for the route before it is rendered
onLoad?: OnLoadFn<TFullSearchSchema, TAllParams>
// This function will be called if the route's loader throws an error **during an attempted navigation**.
// If you want to redirect due to an error, call `router.navigate()` from within this function.
onLoadError?: (err: any) => void
// This function is called
// when moving from an inactive state to an active one. Likewise, when moving from
// an active to an inactive state, the return function (if provided) is called.
onLoaded?: (matchContext: {
params: TAllParams
search: TFullSearchSchema
}) =>
| void
| undefined
| ((match: { params: TAllParams; search: TFullSearchSchema }) => void)
// This function is called when the route remains active from one transition to the next.
onTransition?: (match: {
params: TAllParams
search: TFullSearchSchema
}) => void
// An object of whatever you want! This object is accessible anywhere matches are.
meta?: RouteMeta // TODO: Make this nested and mergeable
} & (
| {
parseParams?: never
stringifyParams?: never
}
| {
// Parse params optionally receives path params as strings and returns them in a parsed format (like a number or boolean)
parseParams: (
rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,
) => TParams
stringifyParams: (
params: TParams,
) => Record<ParsePathParams<TPath>, string>
}
) &
(PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never // Detect if an existing path param is being redefined
? {}
: 'Cannot redefined path params in child routes!')
// The parse type here allows a zod schema to be passed directly to the validator
export type SearchSchemaValidator<TReturn, TParentSchema> =
| SearchSchemaValidatorObj<TReturn, TParentSchema>
| SearchSchemaValidatorFn<TReturn, TParentSchema>
export type SearchSchemaValidatorObj<TReturn, TParentSchema> = {
parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>
}
export type SearchSchemaValidatorFn<TReturn, TParentSchema> = (
searchObj: Record<string, unknown>,
) => {} extends TParentSchema
? TReturn
: keyof TReturn extends keyof TParentSchema
? {
error: 'Top level search params cannot be redefined by child routes!'
keys: keyof TReturn & keyof TParentSchema
}
: TReturn
export type DefinedPathParamWarning =
'Path params cannot be redefined by child routes!'
export type ParentParams<TParentParams> = AnyPathParams extends TParentParams
? {}
: {
[Key in keyof TParentParams]?: DefinedPathParamWarning
}
export type OnLoadFn<
TFullSearchSchema extends AnySearchSchema = {},
TAllParams extends AnyPathParams = {},
> = (
loaderContext: LoaderContext<TFullSearchSchema, TAllParams>,
) => Promise<any> | void
export interface LoaderContext<
TFullSearchSchema extends AnySearchSchema = {},
TAllParams extends AnyPathParams = {},
> {
params: TAllParams
search: TFullSearchSchema
signal?: AbortSignal
preload: boolean
// parentLoaderPromise?: Promise<TParentRouteLoaderData>
}
export type UnloaderFn<TPath extends string> = (
routeMatch: RouteMatch<any, Route>,
) => void
export type SearchFilter<T, U = T> = (prev: T) => U
type ResolveId<
TParentRoute,
TCustomId extends string,
TPath extends string,
> = TParentRoute extends Route<any>
? RootRouteId
: TParentRoute extends { id: infer TParentId extends string }
? RoutePrefix<TParentId, string extends TCustomId ? TPath : TCustomId>
: never
export type InferFullSearchSchema<TRoute> = TRoute extends {
isRoot: true
__types: {
searchSchema: infer TSearchSchema
}
}
? TSearchSchema
: TRoute extends {
__types: {
fullSearchSchema: infer TFullSearchSchema
}
}
? TFullSearchSchema
: {}
export type ResolveFullSearchSchema<TParentRoute, TSearchSchema> = Expand<
InferFullSearchSchema<TParentRoute> & TSearchSchema
>
export interface AnyRoute
extends Route<any, any, any, any, any, any, any, any, any, any, any> {}
export type RouteWithRoutesInfo<TRoute> = TRoute extends Route<
infer TParentRoute,
infer TPath,
infer TFullPath,
infer TCustomId,
infer TId,
infer TSearchSchema,
infer TFullSearchSchema,
infer TParams,
infer TAllParams,
infer TChildren
>
? Route<any, any, any, any, any, any, any, any, any, TChildren, any>
: never
export class Route<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TRouteInfo extends AnyRouteInfo = RouteInfo,
TRouterContext = unknown,
TParentRoute extends AnyRoute = AnyRoute,
TPath extends string = string,
TFullPath extends ResolveFullPath<TParentRoute, TPath> = ResolveFullPath<
TParentRoute,
TPath
>,
TCustomId extends string = string,
TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<
TParentRoute,
TCustomId,
TPath
>,
TSearchSchema extends AnySearchSchema = {},
TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<
TParentRoute,
TSearchSchema
>,
TParams extends Record<ParsePathParams<TPath>, unknown> = Record<
ParsePathParams<TPath>,
string
>,
TAllParams extends Expand<
TParentRoute['__types']['allParams'] & TParams
> = Expand<TParentRoute['__types']['allParams'] & TParams>,
TChildren extends unknown = unknown,
TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo,
> {
routeInfo!: TRouteInfo
id!: TRouteInfo['id']
customId!: TRouteInfo['customId']
path!: TRouteInfo['path']
fullPath!: TRouteInfo['fullPath']
getParentRoute!: () => undefined | AnyRoute
childRoutes?: AnyRoute[]
options!: RouteOptions
originalIndex!: number
getRouter!: () => Router<
TAllRouteInfo['routeConfig'],
TAllRouteInfo,
TRouterContext
__types!: {
parentRoute: TParentRoute
path: TPath
fullPath: TFullPath
// customId: TCustomId
id: TId
searchSchema: TSearchSchema
fullSearchSchema: TFullSearchSchema
params: TParams
allParams: TAllParams
children: TChildren
routesInfo: TRoutesInfo
}
isRoot: TParentRoute extends Route<any> ? true : false
options: RouteOptions<
TParentRoute,
TCustomId,
TPath,
InferFullSearchSchema<TParentRoute>,
TSearchSchema,
Expand<InferFullSearchSchema<TParentRoute> & TSearchSchema>,
TParentRoute['__types']['allParams'],
TParams,
TAllParams
>
// Set up in this.init()
parentRoute!: TParentRoute
id!: TId
// customId!: TCustomId
path!: TPath
fullPath!: TFullPath
// Optional
children?: TChildren
originalIndex?: number
router?: Router<TRoutesInfo['routeTree'], TRoutesInfo, unknown>
constructor(
routeConfig: RouteConfig,
options: TRouteInfo['options'],
originalIndex: number,
parent: undefined | Route<TAllRouteInfo, any>,
router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo, TRouterContext>,
options: RouteOptions<
TParentRoute,
TCustomId,
TPath,
InferFullSearchSchema<TParentRoute>,
TSearchSchema,
TFullSearchSchema,
TParentRoute['__types']['allParams'],
TParams,
TAllParams
>,
) {
Object.assign(this, {
...routeConfig,
originalIndex,
options,
getRouter: () => router,
childRoutes: undefined!,
getParentRoute: () => parent,
})
this.options = (options as any) || {}
this.isRoot = !options?.getParentRoute as any
}
router.options.createRoute?.({ router, route: this })
init = () => {
const allOptions = this.options as RouteOptions<
TParentRoute,
TCustomId,
TPath,
InferFullSearchSchema<TParentRoute>,
TSearchSchema,
TFullSearchSchema,
TParentRoute['__types']['allParams'],
TParams,
TAllParams
> &
RouteOptionsBaseIntersection<TCustomId, TPath>
const isRoot = !allOptions?.path && !allOptions?.id
const parent = this.options?.getParentRoute?.()
if (isRoot) {
this.path = rootRouteId as TPath
} else {
invariant(
parent,
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`,
)
}
let path: undefined | string = isRoot ? rootRouteId : allOptions.path
// If the path is anything other than an index path, trim it up
if (path && path !== '/') {
path = trimPath(path)
}
const customId = allOptions?.id || path
// Strip the parentId prefix from the first level of children
let id = isRoot
? rootRouteId
: joinPaths([
(parent.id as any) === rootRouteId ? '' : parent.id,
customId,
])
if (path === rootRouteId) {
path = '/'
}
if (id !== rootRouteId) {
id = joinPaths(['/', id])
}
const fullPath =
id === rootRouteId
? '/'
: trimPathRight(joinPaths([parent.fullPath, path]))
this.id = id as TId
// this.customId = customId as TCustomId
this.fullPath = fullPath as TFullPath
}
addChildren = <TNewChildren extends AnyRoute[]>(children: TNewChildren) => {
this.children = children as any
return this as unknown as Route<
TParentRoute,
TPath,
TFullPath,
TCustomId,
TId,
TSearchSchema,
TFullSearchSchema,
TParams,
TAllParams,
TNewChildren
>
}
// generate: () => {
// invariant(
// false,
// `routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. `,
// )
// },
}
export class RootRoute<
TSearchSchema extends AnySearchSchema = {},
> extends Route<
any,
'/',
'/',
string,
RootRouteId,
TSearchSchema,
TSearchSchema,
{},
{}
> {
constructor(
options?: Omit<
RouteOptions<
AnyRoute,
RootRouteId,
'',
{},
TSearchSchema,
NoInfer<TSearchSchema>,
{},
{},
{}
>,
'path' | 'id' | 'getParentRoute' | 'caseSensitive'
>,
) {
super(options as any)
}
}
type ResolveFullPath<
TParentRoute extends AnyRoute,
TPath extends string,
TPrefixed extends RoutePrefix<TParentRoute['fullPath'], TPath> = RoutePrefix<
TParentRoute['fullPath'],
TPath
>,
> = TPrefixed extends RootRouteId ? '/' : TrimPathRight<`${TPrefixed}`>
type RoutePrefix<
TPrefix extends string,
TId extends string,
> = string extends TId
? RootRouteId
: TId extends string
? TPrefix extends RootRouteId
? TId extends '/'
? '/'
: `/${TrimPath<TId>}`
: `${TPrefix}/${TId}` extends '/'
? '/'
: `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}`
: never
type TrimPath<T extends string> = '' extends T
? ''
: TrimPathRight<TrimPathLeft<T>>
type TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}`
? TrimPathLeft<U>
: T extends `/${infer U}`
? TrimPathLeft<U>
: T
type TrimPathRight<T extends string> = T extends '/'
? '/'
: T extends `${infer U}/`
? TrimPathRight<U>
: T
// const rootRoute = new RootRoute({
// validateSearch: () => null as unknown as { root?: boolean },
// })
// const aRoute = new Route({
// getParentRoute: () => rootRoute,
// path: 'a',
// validateSearch: () => null as unknown as { a?: string },
// })
// const bRoute = new Route({
// getParentRoute: () => aRoute,
// path: 'b',
// })
// const rootIsRoot = rootRoute.isRoot
// // ^?
// const aIsRoot = aRoute.isRoot
// // ^?
// const rId = rootRoute.id
// // ^?
// const aId = aRoute.id
// // ^?
// const bId = bRoute.id
// // ^?
// const rPath = rootRoute.fullPath
// // ^?
// const aPath = aRoute.fullPath
// // ^?
// const bPath = bRoute.fullPath
// // ^?
// const rSearch = rootRoute.__types.fullSearchSchema
// // ^?
// const aSearch = aRoute.__types.fullSearchSchema
// // ^?
// const bSearch = bRoute.__types.fullSearchSchema
// // ^?
// const config = rootRoute.addChildren([aRoute.addChildren([bRoute])])
// // ^?

@@ -1,19 +0,9 @@

import { Route } from './route'
import {
AnyLoaderData,
AnyPathParams,
AnyRouteConfig,
AnyRouteConfigWithChildren,
AnySearchSchema,
RootRouteId,
RouteConfig,
RouteOptions,
} from './routeConfig'
import { AnyRoute, Route } from './route'
import { AnyPathParams, AnySearchSchema, RootRouteId } from './route'
import { IsAny, UnionToIntersection, Values } from './utils'
export interface AnyAllRouteInfo {
routeConfig: AnyRouteConfig
routeInfo: AnyRouteInfo
routeInfoById: Record<string, AnyRouteInfo>
routeInfoByFullPath: Record<string, AnyRouteInfo>
export interface AnyRoutesInfo {
routeTree: AnyRoute
routesById: Record<string, AnyRoute>
routesByFullPath: Record<string, AnyRoute>
routeIds: any

@@ -25,7 +15,6 @@ routePaths: any

export interface DefaultAllRouteInfo {
routeConfig: RouteConfig
routeInfo: RouteInfo
routeInfoById: Record<string, RouteInfo>
routeInfoByFullPath: Record<string, RouteInfo>
export interface DefaultRoutesInfo {
routeTree: Route
routesById: Record<string, Route>
routesByFullPath: Record<string, Route>
routeIds: string

@@ -37,158 +26,88 @@ routePaths: string

export interface AllRouteInfo<TRouteConfig extends AnyRouteConfig = RouteConfig>
extends RoutesInfoInner<TRouteConfig, ParseRouteConfig<TRouteConfig>> {}
export interface RoutesInfo<TRouteTree extends AnyRoute = Route>
extends RoutesInfoInner<TRouteTree, ParseRoute<TRouteTree>> {}
export type ParseRouteConfig<TRouteConfig = AnyRouteConfig> =
TRouteConfig extends AnyRouteConfig
? RouteConfigRoute<TRouteConfig> | ParseRouteChildren<TRouteConfig>
: never
type ParseRouteChildren<TRouteConfig> =
TRouteConfig extends AnyRouteConfigWithChildren<infer TChildren>
? unknown extends TChildren
export interface RoutesInfoInner<
TRouteTree extends AnyRoute,
TRoutes extends AnyRoute = Route,
TRoutesById = { '/': TRoutes } & {
[TRoute in TRoutes as TRoute['id']]: TRoute
},
TRoutesByFullPath = { '/': TRoutes } & {
[TRoute in TRoutes as TRoute['fullPath'] extends RootRouteId
? never
: TChildren extends AnyRouteConfig[]
? Values<{
[TId in TChildren[number]['id']]: ParseRouteChild<
TChildren[number],
TId
>
}>
: never // Children are not routes
: never // No children
: string extends TRoute['fullPath']
? never
: TRoute['fullPath']]: TRoute
},
> {
routeTree: TRouteTree
routes: TRoutes
routesById: TRoutesById
routesByFullPath: TRoutesByFullPath
routeIds: keyof TRoutesById
routePaths: keyof TRoutesByFullPath
fullSearchSchema: Partial<
UnionToIntersection<TRoutes['__types']['fullSearchSchema']>
>
allParams: Partial<UnionToIntersection<TRoutes['__types']['allParams']>>
}
type ParseRouteChild<TRouteConfig, TId> = TRouteConfig & {
id: TId
} extends AnyRouteConfig
? ParseRouteConfig<TRouteConfig>
export type ParseRoute<TRouteTree> = TRouteTree extends AnyRoute
? TRouteTree | ParseRouteChildren<TRouteTree>
: never
// Generics!
export type RouteConfigRoute<TRouteConfig> = TRouteConfig extends RouteConfig<
infer TId,
infer TCustomId,
infer TPath,
infer TFullPath,
infer TParentSearchSchema,
infer TSearchSchema,
infer TFullSearchSchema,
infer TParentParams,
infer TParams,
infer TAllParams,
export type ParseRouteChildren<TRouteTree> = TRouteTree extends Route<
any,
any,
any,
any,
any,
any,
any,
any,
any,
infer TChildren,
any
>
? string extends TCustomId
? unknown extends TChildren
? never
: RouteInfo<
TId,
TCustomId,
TPath,
TFullPath,
TParentSearchSchema,
TSearchSchema,
TFullSearchSchema,
TParentParams,
TParams,
TAllParams
>
: TChildren extends AnyRoute[]
? Values<{
[TId in TChildren[number]['id']]: ParseRouteChild<
TChildren[number],
TId
>
}>
: never
: never
export interface RoutesInfoInner<
TRouteConfig extends AnyRouteConfig,
TRouteInfo extends RouteInfo<
string,
string,
any,
any,
any,
any,
any,
any,
any,
any
> = RouteInfo,
TRouteInfoById = { '/': TRouteInfo } & {
[TInfo in TRouteInfo as TInfo['id']]: TInfo
},
TRouteInfoByFullPath = { '/': TRouteInfo } & {
[TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId
? never
: string extends TInfo['fullPath']
? never
: TInfo['fullPath']]: TInfo
},
> {
routeConfig: TRouteConfig
routeInfo: TRouteInfo
routeInfoById: TRouteInfoById
routeInfoByFullPath: TRouteInfoByFullPath
routeIds: keyof TRouteInfoById
routePaths: keyof TRouteInfoByFullPath
fullSearchSchema: Partial<UnionToIntersection<TRouteInfo['fullSearchSchema']>>
allParams: Partial<UnionToIntersection<TRouteInfo['allParams']>>
}
export type ParseRouteChild<TRoute, TId> = TRoute extends AnyRoute
? ParseRoute<TRoute>
: never
export interface AnyRouteInfo
extends RouteInfo<any, any, any, any, any, any, any, any, any, any> {}
export interface RouteInfo<
TId extends string = string,
TCustomId extends string = string,
TPath extends string = string,
TFullPath extends string = '/',
TParentSearchSchema extends {} = {},
TSearchSchema extends AnySearchSchema = {},
TFullSearchSchema extends AnySearchSchema = {},
TParentParams extends AnyPathParams = {},
TParams extends AnyPathParams = {},
TAllParams extends AnyPathParams = {},
> {
id: TId
customId: TCustomId
path: TPath
fullPath: TFullPath
searchSchema: TSearchSchema
fullSearchSchema: TFullSearchSchema
parentParams: TParentParams
params: TParams
allParams: TAllParams
options: RouteOptions<
TCustomId,
TPath,
TParentSearchSchema,
TSearchSchema,
TFullSearchSchema,
TParentParams,
TParams,
TAllParams
>
export type RoutesById<TRoutesInfo extends AnyRoutesInfo> = {
[K in keyof TRoutesInfo['routesById']]: TRoutesInfo['routesById'][K]
}
export type RoutesById<TAllRouteInfo extends AnyAllRouteInfo> = {
[K in keyof TAllRouteInfo['routeInfoById']]: Route<
TAllRouteInfo,
TAllRouteInfo['routeInfoById'][K]
>
}
export type RouteInfoById<
TAllRouteInfo extends AnyAllRouteInfo,
export type RouteById<
TRoutesInfo extends AnyRoutesInfo,
TId,
> = TId extends keyof TAllRouteInfo['routeInfoById']
> = TId extends keyof TRoutesInfo['routesById']
? IsAny<
TAllRouteInfo['routeInfoById'][TId]['id'],
RouteInfo,
TAllRouteInfo['routeInfoById'][TId]
TRoutesInfo['routesById'][TId]['id'],
Route,
TRoutesInfo['routesById'][TId]
>
: never
export type RouteInfoByPath<
TAllRouteInfo extends AnyAllRouteInfo,
export type RouteByPath<
TRoutesInfo extends AnyRoutesInfo,
TPath,
> = TPath extends keyof TAllRouteInfo['routeInfoByFullPath']
> = TPath extends keyof TRoutesInfo['routesByFullPath']
? IsAny<
TAllRouteInfo['routeInfoByFullPath'][TPath]['id'],
RouteInfo,
TAllRouteInfo['routeInfoByFullPath'][TPath]
TRoutesInfo['routesByFullPath'][TPath]['id'],
Route,
TRoutesInfo['routesByFullPath'][TPath]
>
: never
import { Store } from '@tanstack/store'
//
import { GetFrameworkGeneric } from './frameworks'
import { Route } from './route'
import {
AnyAllRouteInfo,
AnyRouteInfo,
DefaultAllRouteInfo,
RouteInfo,
} from './routeInfo'
import { AnyRoute, Route } from './route'
import { AnyRoutesInfo, DefaultRoutesInfo } from './routeInfo'
import { AnyRouter, Router } from './router'

@@ -15,8 +10,8 @@ import { Expand } from './utils'

export interface RouteMatchStore<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TRouteInfo extends AnyRouteInfo = RouteInfo,
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
TRoute extends AnyRoute = Route,
> {
routeSearch: TRouteInfo['searchSchema']
routeSearch: TRoute['__types']['searchSchema']
search: Expand<
TAllRouteInfo['fullSearchSchema'] & TRouteInfo['fullSearchSchema']
TRoutesInfo['fullSearchSchema'] & TRoute['__types']['fullSearchSchema']
>

@@ -35,11 +30,11 @@ status: 'idle' | 'pending' | 'success' | 'error'

export class RouteMatch<
TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,
TRouteInfo extends AnyRouteInfo = RouteInfo,
TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,
TRoute extends AnyRoute = AnyRoute,
> {
route!: Route<TAllRouteInfo, TRouteInfo>
router!: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>
store!: Store<RouteMatchStore<TAllRouteInfo, TRouteInfo>>
route!: TRoute
router!: Router<TRoutesInfo['routeTree'], TRoutesInfo>
store!: Store<RouteMatchStore<TRoutesInfo, TRoute>>
id!: string
pathname!: string
params!: TRouteInfo['allParams']
params!: TRoute['__types']['allParams']

@@ -57,4 +52,4 @@ component: GetFrameworkGeneric<'Component'>

| ((matchContext: {
params: TRouteInfo['allParams']
search: TRouteInfo['fullSearchSchema']
params: TRoute['__types']['allParams']
search: TRoute['__types']['fullSearchSchema']
}) => void)

@@ -64,6 +59,6 @@

router: AnyRouter,
route: Route<TAllRouteInfo, TRouteInfo>,
route: TRoute,
opts: {
id: string
params: TRouteInfo['allParams']
params: TRoute['__types']['allParams']
pathname: string

@@ -78,3 +73,3 @@ },

params: opts.params,
store: new Store<RouteMatchStore<TAllRouteInfo, TRouteInfo>>({
store: new Store<RouteMatchStore<TRoutesInfo, TRoute>>({
updatedAt: 0,

@@ -81,0 +76,0 @@ routeSearch: {},

@@ -24,17 +24,11 @@ import { Store } from '@tanstack/store'

} from './path'
import { AnyRoute, Route } from './route'
import {
Route,
AnyPathParams,
AnyRouteConfig,
AnyRoute,
AnySearchSchema,
LoaderContext,
RouteConfig,
SearchFilter,
} from './routeConfig'
import {
AllRouteInfo,
AnyAllRouteInfo,
RouteInfo,
RoutesById,
} from './routeInfo'
} from './route'
import { RoutesInfo, AnyRoutesInfo, RoutesById } from './routeInfo'
import { RouteMatch, RouteMatchStore } from './routeMatch'

@@ -66,12 +60,12 @@ import { defaultParseSearch, defaultStringifySearch } from './searchParams'

export type RegisteredRouter = RegisterRouter extends {
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>
router: Router<infer TRoute, infer TRoutesInfo, infer TRouterContext>
}
? Router<TRouteConfig, TAllRouteInfo, TRouterContext>
? Router<TRoute, TRoutesInfo, TRouterContext>
: Router
export type RegisteredAllRouteInfo = RegisterRouter extends {
router: Router<infer TRouteConfig, infer TAllRouteInfo, infer TRouterContext>
export type RegisteredRoutesInfo = RegisterRouter extends {
router: Router<infer TRoute, infer TRoutesInfo, infer TRouterContext>
}
? TAllRouteInfo
: AnyAllRouteInfo
? TRoutesInfo
: AnyRoutesInfo

@@ -102,10 +96,7 @@ export interface LocationState {}

export type SearchParser = (searchStr: string) => Record<string, any>
export type FilterRoutesFn = <TRoute extends Route<any, RouteInfo>>(
routeConfigs: TRoute[],
export type FilterRoutesFn = <TRoute extends AnyRoute>(
routes: TRoute[],
) => TRoute[]
export interface RouterOptions<
TRouteConfig extends AnyRouteConfig,
TRouterContext,
> {
export interface RouterOptions<TRouteTree extends AnyRoute, TRouterContext> {
history?: RouterHistory

@@ -123,3 +114,3 @@ stringifySearch?: SearchSerializer

caseSensitive?: boolean
routeConfig?: TRouteConfig
routeTree?: TRouteTree
basepath?: string

@@ -250,4 +241,4 @@ Router?: (router: AnyRouter) => void

export class Router<
TRouteConfig extends AnyRouteConfig = RouteConfig,
TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>,
TRouteTree extends AnyRoute = Route,
TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteTree>,
TRouterContext = unknown,

@@ -257,8 +248,8 @@ > {

// Super secret internal stuff
RouteConfig: TRouteConfig
AllRouteInfo: TAllRouteInfo
RootRoute: TRouteTree
RoutesInfo: TRoutesInfo
}
options: PickAsRequired<
RouterOptions<TRouteConfig, TRouterContext>,
RouterOptions<TRouteTree, TRouterContext>,
'stringifySearch' | 'parseSearch' | 'context'

@@ -269,5 +260,5 @@ >

basepath: string
// __location: Location<TAllRouteInfo['fullSearchSchema']>
routeTree!: Route<TAllRouteInfo, RouteInfo>
routesById!: RoutesById<TAllRouteInfo>
// __location: Location<TRoutesInfo['fullSearchSchema']>
routeTree!: Route
routesById!: RoutesById<TRoutesInfo>
navigateTimeout: undefined | Timeout

@@ -277,7 +268,7 @@ nextAction: undefined | 'push' | 'replace'

store: Store<RouterStore<TAllRouteInfo['fullSearchSchema']>>
store: Store<RouterStore<TRoutesInfo['fullSearchSchema']>>
startedLoadingAt = Date.now()
resolveNavigation = () => {}
constructor(options?: RouterOptions<TRouteConfig, TRouterContext>) {
constructor(options?: RouterOptions<TRouteTree, TRouterContext>) {
this.options = {

@@ -339,8 +330,8 @@ defaultPreloadDelay: 50,

update = <
TRouteConfig extends RouteConfig = RouteConfig,
TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>,
TRoute extends Route = Route,
TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRoute>,
TRouterContext = unknown,
>(
opts?: RouterOptions<TRouteConfig, TRouterContext>,
): Router<TRouteConfig, TAllRouteInfo, TRouterContext> => {
opts?: RouterOptions<TRoute, TRouterContext>,
): this => {
Object.assign(this.options, opts)

@@ -373,9 +364,9 @@

const { basepath, routeConfig } = this.options
const { basepath, routeTree } = this.options
this.basepath = `/${trimPath(basepath ?? '') ?? ''}`
if (routeConfig) {
if (routeTree) {
this.routesById = {} as any
this.routeTree = this.#buildRouteTree(routeConfig)
this.routeTree = this.#buildRouteTree(routeTree)
}

@@ -529,5 +520,5 @@

getRoute = <TId extends keyof TAllRouteInfo['routeInfoById']>(
getRoute = <TId extends keyof TRoutesInfo['routesById']>(
id: TId,
): Route<TAllRouteInfo, TAllRouteInfo['routeInfoById'][TId]> => {
): TRoutesInfo['routesById'][TId] => {
const route = this.routesById[id]

@@ -577,3 +568,5 @@

const recurse = async (routes: Route<any, any>[]): Promise<void> => {
const findInRouteTree = async (
routes: Route<any, any>[],
): Promise<void> => {
const parentMatch = last(matches)

@@ -584,11 +577,15 @@ let params = parentMatch?.params ?? {}

let foundRoutes: Route[] = []
let matchingRoutes: Route[] = []
const findMatchInRoutes = (parentRoutes: Route[], routes: Route[]) => {
routes.some((route) => {
if (!route.path && route.childRoutes?.length) {
return findMatchInRoutes([...foundRoutes, route], route.childRoutes)
const children = route.children as undefined | Route[]
if (!route.path && children?.length) {
return findMatchInRoutes(
[...matchingRoutes, route],
children as any,
)
}
const fuzzy = !!(route.path !== '/' || route.childRoutes?.length)
const fuzzy = route.path === '/' ? false : !!children?.length

@@ -621,9 +618,9 @@ const matchParams = matchPathname(this.basepath, pathname, {

if (!!matchParams) {
foundRoutes = [...parentRoutes, route]
matchingRoutes = [...parentRoutes, route]
}
return !!foundRoutes.length
return !!matchingRoutes.length
})
return !!foundRoutes.length
return !!matchingRoutes.length
}

@@ -633,7 +630,7 @@

if (!foundRoutes.length) {
if (!matchingRoutes.length) {
return
}
foundRoutes.forEach((foundRoute) => {
matchingRoutes.forEach((foundRoute) => {
const interpolatedPath = interpolatePath(foundRoute.path, params)

@@ -654,10 +651,12 @@ const matchId = interpolatePath(foundRoute.id, params, true)

const foundRoute = last(foundRoutes)!
const foundRoute = last(matchingRoutes)!
if (foundRoute.childRoutes?.length) {
recurse(foundRoute.childRoutes)
const foundChildren = foundRoute.children as any
if (foundChildren?.length) {
findInRouteTree(foundChildren)
}
}
recurse([this.routeTree])
findInRouteTree([this.routeTree])

@@ -733,3 +732,3 @@ linkMatches(matches)

navigate = async <
TFrom extends ValidFromPath<TAllRouteInfo> = '/',
TFrom extends ValidFromPath<TRoutesInfo> = '/',
TTo extends string = '.',

@@ -743,3 +742,3 @@ >({

params,
}: NavigateOptions<TAllRouteInfo, TFrom, TTo>) => {
}: NavigateOptions<TRoutesInfo, TFrom, TTo>) => {
// If this link simply reloads the current route,

@@ -775,13 +774,9 @@ // make sure it has a new key so it will trigger a data refresh

matchRoute = <
TFrom extends ValidFromPath<TAllRouteInfo> = '/',
TFrom extends ValidFromPath<TRoutesInfo> = '/',
TTo extends string = '.',
TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,
>(
location: ToOptions<TAllRouteInfo, TFrom, TTo>,
location: ToOptions<TRoutesInfo, TFrom, TTo>,
opts?: MatchRouteOptions,
):
| false
| TAllRouteInfo['routeInfoById'][ResolveRelativePath<
TFrom,
NoInfer<TTo>
>]['allParams'] => {
): false | TRoutesInfo['routesById'][TResolved]['__types']['allParams'] => {
location = {

@@ -792,3 +787,3 @@ ...location,

: undefined,
}
} as any

@@ -823,3 +818,3 @@ const next = this.buildNext(location)

buildLink = <
TFrom extends ValidFromPath<TAllRouteInfo> = '/',
TFrom extends ValidFromPath<TRoutesInfo> = '/',
TTo extends string = '.',

@@ -840,3 +835,3 @@ >({

disabled,
}: LinkOptions<TAllRouteInfo, TFrom, TTo>): LinkInfo => {
}: LinkOptions<TRoutesInfo, TFrom, TTo>): LinkInfo => {
// If this link simply reloads the current route,

@@ -1007,10 +1002,10 @@ // make sure it has a new key so it will trigger a data refresh

#buildRouteTree = (rootRouteConfig: RouteConfig) => {
const recurseRoutes = (
routeConfigs: RouteConfig[],
parent?: Route<TAllRouteInfo, any, any>,
): Route<TAllRouteInfo, any, any>[] => {
return routeConfigs.map((routeConfig, i) => {
const routeOptions = routeConfig.options
const route = new Route(routeConfig, routeOptions, i, parent, this)
#buildRouteTree = (routeTree: Route) => {
const recurseRoutes = (routes: Route[]) => {
routes.forEach((route, i) => {
route.init()
route.originalIndex = i
route.router = this as any
const existingRoute = (this.routesById as any)[route.id]

@@ -1031,15 +1026,11 @@

const children = routeConfig.children as RouteConfig[]
const children = route.children as Route[]
route.childRoutes = children.length
? recurseRoutes(children, route)
: undefined
return route
if (children?.length) recurseRoutes(children)
})
}
const routes = recurseRoutes([rootRouteConfig])
recurseRoutes([routeTree])
return routes[0]!
return routeTree
}

@@ -1046,0 +1037,0 @@

import { decode, encode } from './qss'
import { AnySearchSchema } from './routeConfig'
import { AnySearchSchema } from './route'

@@ -4,0 +4,0 @@ export const defaultParseSearch = parseSearchWith(JSON.parse)

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

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