Socket
Socket
Sign inDemoInstall

@tanstack/router

Package Overview
Dependencies
Maintainers
2
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.134 to 0.0.1-beta.135

3

build/cjs/index.js

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

exports.isRedirect = router.isRedirect;
exports.lazyFn = router.lazyFn;
exports.redirect = router.redirect;

@@ -85,3 +86,3 @@ exports.defaultParseSearch = searchParams.defaultParseSearch;

exports.RouterProvider = react.RouterProvider;
exports.lazy = react.lazy;
exports.lazyRouteComponent = react.lazyRouteComponent;
exports.matchIdsContext = react.matchIdsContext;

@@ -88,0 +89,0 @@ exports.routerContext = react.routerContext;

@@ -48,17 +48,19 @@ /**

function lazy(importer, exportName = 'default') {
function lazyRouteComponent(importer, exportName) {
let loadPromise;
const load = () => {
if (!loadPromise) {
loadPromise = importer();
}
return loadPromise;
};
const lazyComp = /*#__PURE__*/React__namespace.lazy(async () => {
const moduleExports = await importer();
const component = moduleExports[exportName];
const moduleExports = await load();
const comp = moduleExports[exportName ?? 'default'];
return {
default: component
default: comp
};
});
const finalComp = lazyComp;
finalComp.preload = async () => {
{
await importer();
}
};
return finalComp;
lazyComp.preload = load;
return lazyComp;
}

@@ -188,7 +190,15 @@ //

router.update(rest);
React__namespace.useEffect(router.mount, [router]);
React__namespace.useEffect(() => {
let unsub;
React__namespace.startTransition(() => {
unsub = router.mount();
});
return unsub;
}, [router]);
const Wrap = router.options.Wrap || React__namespace.Fragment;
return /*#__PURE__*/React__namespace.createElement(Wrap, null, /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
return /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
fallback: null
}, /*#__PURE__*/React__namespace.createElement(Wrap, null, /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
value: router
}, /*#__PURE__*/React__namespace.createElement(Matches, null)));
}, /*#__PURE__*/React__namespace.createElement(Matches, null))));
}

@@ -512,3 +522,3 @@ function Matches() {

exports.RouterProvider = RouterProvider;
exports.lazy = lazy;
exports.lazyRouteComponent = lazyRouteComponent;
exports.matchIdsContext = matchIdsContext;

@@ -515,0 +525,0 @@ exports.routerContext = routerContext;

@@ -38,4 +38,4 @@ /**

this.router = opts.router;
const allOptions = this.options;
const isRoot = !allOptions?.path && !allOptions?.id;
const options = this.options;
const isRoot = !options?.path && !options?.id;
this.parentRoute = this.options?.getParentRoute?.();

@@ -47,3 +47,3 @@ if (isRoot) {

}
let path$1 = isRoot ? rootRouteId : allOptions.path;
let path$1 = isRoot ? rootRouteId : options.path;

@@ -54,3 +54,3 @@ // If the path is anything other than an index path, trim it up

}
const customId = allOptions?.id || path$1;
const customId = options?.id || path$1;

@@ -76,2 +76,6 @@ // Strip the parentId prefix from the first level of children

};
update = options => {
Object.assign(this.options, options);
return this;
};
useMatch = opts => {

@@ -78,0 +82,0 @@ return react.useMatch({

@@ -149,3 +149,3 @@ /**

pendingMatches = this.matchRoutes(this.state.location.pathname, this.state.location.search, {
// throwOnError: true,
throwOnError: true
});

@@ -391,4 +391,4 @@ this.__store.setState(s => ({

await route.options.beforeLoad?.({
router: this,
match
...match,
preload: !!opts?.preload
});

@@ -400,11 +400,7 @@ } catch (err) {

} catch (err) {
if (isRedirect(err)) {
if (!opts?.preload) {
this.navigate(err);
}
return;
if (!opts?.preload) {
this.navigate(err);
}
throw err; // we should never end up here
throw err;
}
const validResolvedMatches = resolvedMatches.slice(0, firstBadMatchIndex);

@@ -423,13 +419,8 @@ const matchPromises = [];

let latestPromise;
const componentsPromise = (async () => {
// then run all component and data loaders in parallel
// For each component type, potentially load it asynchronously
await Promise.all(componentTypes.map(async type => {
const component = route.options[type];
if (component?.preload) {
await component.preload();
}
}));
})();
const componentsPromise = Promise.all(componentTypes.map(async type => {
const component = route.options[type];
if (component?.preload) {
await component.preload();
}
}));
const loaderPromise = Promise.resolve().then(() => {

@@ -1003,2 +994,12 @@ if (route.options.loader) {

// A function that takes an import() argument which is a function and returns a new function that will
// proxy arguments from the caller to the imported function, retaining all type
// information along the way
function lazyFn(fn, key) {
return async (...args) => {
const imported = await fn();
return imported[key || 'default'](...args);
};
}
exports.PathParamError = PathParamError;

@@ -1009,3 +1010,4 @@ exports.Router = Router;

exports.isRedirect = isRedirect;
exports.lazyFn = lazyFn;
exports.redirect = redirect;
//# sourceMappingURL=router.js.map

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

"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "2231-47"
"uid": "8c88-47"
},
{
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"uid": "2231-49"
"uid": "8c88-49"
}

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

{
"uid": "2231-51",
"uid": "8c88-51",
"name": "history.ts"
},
{
"uid": "2231-53",
"uid": "8c88-53",
"name": "utils.ts"
},
{
"uid": "2231-55",
"uid": "8c88-55",
"name": "path.ts"
},
{
"uid": "2231-57",
"uid": "8c88-57",
"name": "qss.ts"
},
{
"uid": "2231-65",
"uid": "8c88-65",
"name": "react.tsx"
},
{
"uid": "2231-67",
"uid": "8c88-67",
"name": "route.ts"
},
{
"uid": "2231-69",
"uid": "8c88-69",
"name": "searchParams.ts"
},
{
"uid": "2231-71",
"uid": "8c88-71",
"name": "router.ts"
},
{
"uid": "2231-73",
"uid": "8c88-73",
"name": "index.ts"

@@ -70,7 +70,7 @@ }

"name": "store/build/esm/index.js",
"uid": "2231-61"
"uid": "8c88-61"
},
{
"name": "react-store/build/esm/index.js",
"uid": "2231-63"
"uid": "8c88-63"
}

@@ -80,3 +80,3 @@ ]

{
"uid": "2231-59",
"uid": "8c88-59",
"name": "\u0000rollupPluginBabelHelpers.js"

@@ -90,92 +90,92 @@ }

"nodeParts": {
"2231-47": {
"8c88-47": {
"renderedLength": 199,
"gzipLength": 134,
"brotliLength": 0,
"mainUid": "2231-46"
"mainUid": "8c88-46"
},
"2231-49": {
"8c88-49": {
"renderedLength": 48,
"gzipLength": 65,
"brotliLength": 0,
"mainUid": "2231-48"
"mainUid": "8c88-48"
},
"2231-51": {
"8c88-51": {
"renderedLength": 5643,
"gzipLength": 1404,
"brotliLength": 0,
"mainUid": "2231-50"
"mainUid": "8c88-50"
},
"2231-53": {
"8c88-53": {
"renderedLength": 2821,
"gzipLength": 990,
"brotliLength": 0,
"mainUid": "2231-52"
"mainUid": "8c88-52"
},
"2231-55": {
"8c88-55": {
"renderedLength": 6028,
"gzipLength": 1423,
"brotliLength": 0,
"mainUid": "2231-54"
"mainUid": "8c88-54"
},
"2231-57": {
"8c88-57": {
"renderedLength": 1395,
"gzipLength": 558,
"brotliLength": 0,
"mainUid": "2231-56"
"mainUid": "8c88-56"
},
"2231-59": {
"8c88-59": {
"renderedLength": 457,
"gzipLength": 241,
"brotliLength": 0,
"mainUid": "2231-58"
"mainUid": "8c88-58"
},
"2231-61": {
"8c88-61": {
"renderedLength": 1969,
"gzipLength": 653,
"brotliLength": 0,
"mainUid": "2231-60"
"mainUid": "8c88-60"
},
"2231-63": {
"8c88-63": {
"renderedLength": 1070,
"gzipLength": 485,
"brotliLength": 0,
"mainUid": "2231-62"
"mainUid": "8c88-62"
},
"2231-65": {
"renderedLength": 14740,
"gzipLength": 3365,
"8c88-65": {
"renderedLength": 15046,
"gzipLength": 3421,
"brotliLength": 0,
"mainUid": "2231-64"
"mainUid": "8c88-64"
},
"2231-67": {
"renderedLength": 4479,
"gzipLength": 1105,
"8c88-67": {
"renderedLength": 4568,
"gzipLength": 1127,
"brotliLength": 0,
"mainUid": "2231-66"
"mainUid": "8c88-66"
},
"2231-69": {
"8c88-69": {
"renderedLength": 1387,
"gzipLength": 483,
"brotliLength": 0,
"mainUid": "2231-68"
"mainUid": "8c88-68"
},
"2231-71": {
"renderedLength": 34072,
"gzipLength": 7720,
"8c88-71": {
"renderedLength": 34156,
"gzipLength": 7760,
"brotliLength": 0,
"mainUid": "2231-70"
"mainUid": "8c88-70"
},
"2231-73": {
"8c88-73": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "2231-72"
"mainUid": "8c88-72"
}
},
"nodeMetas": {
"2231-46": {
"8c88-46": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "2231-47"
"index.production.js": "8c88-47"
},

@@ -185,19 +185,19 @@ "imported": [],

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-66"
"uid": "8c88-66"
},
{
"uid": "2231-70"
"uid": "8c88-70"
},
{
"uid": "2231-64"
"uid": "8c88-64"
}
]
},
"2231-48": {
"8c88-48": {
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"moduleParts": {
"index.production.js": "2231-49"
"index.production.js": "8c88-49"
},

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

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-64"
"uid": "8c88-64"
}
]
},
"2231-50": {
"8c88-50": {
"id": "/packages/router/src/history.ts",
"moduleParts": {
"index.production.js": "2231-51"
"index.production.js": "8c88-51"
},

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

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-70"
"uid": "8c88-70"
}
]
},
"2231-52": {
"8c88-52": {
"id": "/packages/router/src/utils.ts",
"moduleParts": {
"index.production.js": "2231-53"
"index.production.js": "8c88-53"
},

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

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-54"
"uid": "8c88-54"
},
{
"uid": "2231-70"
"uid": "8c88-70"
},
{
"uid": "2231-64"
"uid": "8c88-64"
}
]
},
"2231-54": {
"8c88-54": {
"id": "/packages/router/src/path.ts",
"moduleParts": {
"index.production.js": "2231-55"
"index.production.js": "8c88-55"
},
"imported": [
{
"uid": "2231-52"
"uid": "8c88-52"
}

@@ -265,16 +265,16 @@ ],

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-66"
"uid": "8c88-66"
},
{
"uid": "2231-70"
"uid": "8c88-70"
}
]
},
"2231-56": {
"8c88-56": {
"id": "/packages/router/src/qss.ts",
"moduleParts": {
"index.production.js": "2231-57"
"index.production.js": "8c88-57"
},

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

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-68"
"uid": "8c88-68"
}
]
},
"2231-58": {
"8c88-58": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "2231-59"
"index.production.js": "8c88-59"
},

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

{
"uid": "2231-64"
"uid": "8c88-64"
}
]
},
"2231-60": {
"8c88-60": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "2231-61"
"index.production.js": "8c88-61"
},

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

{
"uid": "2231-62"
"uid": "8c88-62"
}
]
},
"2231-62": {
"8c88-62": {
"id": "/packages/react-store/build/esm/index.js",
"moduleParts": {
"index.production.js": "2231-63"
"index.production.js": "8c88-63"
},
"imported": [
{
"uid": "2231-77"
"uid": "8c88-77"
},
{
"uid": "2231-60"
"uid": "8c88-60"
}

@@ -333,32 +333,32 @@ ],

{
"uid": "2231-70"
"uid": "8c88-70"
},
{
"uid": "2231-64"
"uid": "8c88-64"
}
]
},
"2231-64": {
"8c88-64": {
"id": "/packages/router/src/react.tsx",
"moduleParts": {
"index.production.js": "2231-65"
"index.production.js": "8c88-65"
},
"imported": [
{
"uid": "2231-58"
"uid": "8c88-58"
},
{
"uid": "2231-76"
"uid": "8c88-76"
},
{
"uid": "2231-62"
"uid": "8c88-62"
},
{
"uid": "2231-46"
"uid": "8c88-46"
},
{
"uid": "2231-48"
"uid": "8c88-48"
},
{
"uid": "2231-52"
"uid": "8c88-52"
}

@@ -368,23 +368,23 @@ ],

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-66"
"uid": "8c88-66"
}
]
},
"2231-66": {
"8c88-66": {
"id": "/packages/router/src/route.ts",
"moduleParts": {
"index.production.js": "2231-67"
"index.production.js": "8c88-67"
},
"imported": [
{
"uid": "2231-46"
"uid": "8c88-46"
},
{
"uid": "2231-54"
"uid": "8c88-54"
},
{
"uid": "2231-64"
"uid": "8c88-64"
}

@@ -394,14 +394,14 @@ ],

{
"uid": "2231-72"
"uid": "8c88-72"
}
]
},
"2231-68": {
"8c88-68": {
"id": "/packages/router/src/searchParams.ts",
"moduleParts": {
"index.production.js": "2231-69"
"index.production.js": "8c88-69"
},
"imported": [
{
"uid": "2231-56"
"uid": "8c88-56"
}

@@ -411,32 +411,32 @@ ],

{
"uid": "2231-72"
"uid": "8c88-72"
},
{
"uid": "2231-70"
"uid": "8c88-70"
}
]
},
"2231-70": {
"8c88-70": {
"id": "/packages/router/src/router.ts",
"moduleParts": {
"index.production.js": "2231-71"
"index.production.js": "8c88-71"
},
"imported": [
{
"uid": "2231-62"
"uid": "8c88-62"
},
{
"uid": "2231-46"
"uid": "8c88-46"
},
{
"uid": "2231-54"
"uid": "8c88-54"
},
{
"uid": "2231-68"
"uid": "8c88-68"
},
{
"uid": "2231-52"
"uid": "8c88-52"
},
{
"uid": "2231-50"
"uid": "8c88-50"
}

@@ -446,47 +446,47 @@ ],

{
"uid": "2231-72"
"uid": "8c88-72"
}
]
},
"2231-72": {
"8c88-72": {
"id": "/packages/router/src/index.ts",
"moduleParts": {
"index.production.js": "2231-73"
"index.production.js": "8c88-73"
},
"imported": [
{
"uid": "2231-46"
"uid": "8c88-46"
},
{
"uid": "2231-48"
"uid": "8c88-48"
},
{
"uid": "2231-50"
"uid": "8c88-50"
},
{
"uid": "2231-74"
"uid": "8c88-74"
},
{
"uid": "2231-54"
"uid": "8c88-54"
},
{
"uid": "2231-56"
"uid": "8c88-56"
},
{
"uid": "2231-66"
"uid": "8c88-66"
},
{
"uid": "2231-75"
"uid": "8c88-75"
},
{
"uid": "2231-70"
"uid": "8c88-70"
},
{
"uid": "2231-68"
"uid": "8c88-68"
},
{
"uid": "2231-52"
"uid": "8c88-52"
},
{
"uid": "2231-64"
"uid": "8c88-64"
}

@@ -497,3 +497,3 @@ ],

},
"2231-74": {
"8c88-74": {
"id": "/packages/router/src/link.ts",

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

{
"uid": "2231-72"
"uid": "8c88-72"
}
]
},
"2231-75": {
"8c88-75": {
"id": "/packages/router/src/routeInfo.ts",

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

{
"uid": "2231-72"
"uid": "8c88-72"
}
]
},
"2231-76": {
"8c88-76": {
"id": "react",

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

{
"uid": "2231-64"
"uid": "8c88-64"
}

@@ -532,3 +532,3 @@ ],

},
"2231-77": {
"8c88-77": {
"id": "use-sync-external-store/shim/with-selector",

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

{
"uid": "2231-62"
"uid": "8c88-62"
}

@@ -542,0 +542,0 @@ ],

import * as React from 'react';
import { NoInfer, useStore } from '@tanstack/react-store';
import { LinkOptions, ToOptions, ResolveRelativePath, NavigateOptions } from './link';
import { AnyRoute } from './route';
import { AnyRoute, AnyRouteProps } from './route';
import { RouteByPath, AnyRoutesInfo, DefaultRoutesInfo } from './routeInfo';

@@ -9,7 +9,16 @@ import { RegisteredRoutesInfo, MatchRouteOptions, RegisteredRouter, RouterOptions, Router, RouteMatch } from './router';

type ReactNode = any;
export type SyncRouteComponent<TProps = {}> = (props: TProps) => ReactNode;
export type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {
export type SyncRouteComponent<TProps> = ((props: TProps) => ReactNode) | React.LazyExoticComponent<(props: TProps) => ReactNode>;
export type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
preload?: () => Promise<void>;
};
export declare function lazy<T extends Record<string, SyncRouteComponent>>(importer: () => Promise<T>, exportName?: keyof T): RouteComponent;
export type RouteErrorComponent = AsyncRouteComponent<RouteErrorComponentProps>;
export type RouteErrorComponentProps = {
error: Error;
info: {
componentStack: string;
};
};
export type AnyRouteComponent = RouteComponent<AnyRouteProps>;
export type RouteComponent<TProps> = AsyncRouteComponent<TProps>;
export declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
export type LinkPropsOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkOptions<RegisteredRoutesInfo, TFrom, TTo> & {

@@ -16,0 +25,0 @@ activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);

import { ParsePathParams } from './link';
import { AnyRouter, Router, AnyRouteMatch, RouteMatch } from './router';
import { AnyRouter, Router, RouteMatch } from './router';
import { IsAny, NoInfer, PickRequired, PickUnsafe, UnionToIntersection } from './utils';
import { AnyRoutesInfo, DefaultRoutesInfo } from './routeInfo';
import { RouteComponent } from './react';
import { RouteComponent, RouteErrorComponent } from './react';
export declare const rootRouteId: "__root__";

@@ -15,3 +15,3 @@ export type RootRouteId = typeof rootRouteId;

}
export type RouteOptionsBase<TCustomId, TPath> = {
export type RoutePathOptions<TCustomId, TPath> = {
path: TPath;

@@ -21,3 +21,3 @@ } | {

};
export type RouteOptionsBaseIntersection<TCustomId, TPath> = UnionToIntersection<RouteOptionsBase<TCustomId, TPath>>;
export type RoutePathOptionsIntersection<TCustomId, TPath> = UnionToIntersection<RoutePathOptions<TCustomId, TPath>>;
export type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {

@@ -28,19 +28,8 @@ meta?: RouteMeta;

};
type GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext> = (opts: {
params: TAllParams;
search: TFullSearchSchema;
} & (TParentRoute extends undefined ? {
context?: TAllParentContext;
parentContext?: TParentContext;
} : {
context: TAllParentContext;
parentContext: TParentContext;
})) => TRouteContext;
export type ContextOptions<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext> = keyof PickRequired<RouteContext> extends never ? {
getContext?: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
} : {
getContext: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
};
export type RouteProps<TParentRoute extends AnyRoute, TPath extends string, TFullPath extends ResolveFullPath<TParentRoute, TPath, RoutePrefix<TParentRoute['fullPath'], TPath>>, TCustomId extends string, TId extends ResolveId<TParentRoute, TCustomId, TPath>, TLoader, TSearchSchema extends AnySearchSchema, TFullSearchSchema extends AnySearchSchema, TAllParams, TParentContext, TAllParentContext extends IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext>, TRouteContext, TContext, TRouterContext extends AnyContext> = {
useMatch: () => RouteMatch<AnyRoutesInfo, Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, any, any>>;
export type AnyRouteProps = RouteProps<any, any, any, any>;
export type ComponentPropsFromRoute<TRoute> = TRoute extends Route<infer TParentRoute, infer TPath, infer TFullPath, infer TCustomId, infer TId, infer TLoader, infer TSearchSchema, infer TFullSearchSchema, infer TParams, infer TAllParams, infer TParentContext, infer TAllParentContext, infer TRouteContext, infer TContext, infer TRouterContext, infer TChildren, infer TRoutesInfo> ? RouteProps<TLoader, TFullSearchSchema, TAllParams, TContext> : never;
export type ComponentFromRoute<TRoute> = RouteComponent<ComponentPropsFromRoute<TRoute>>;
export type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<TRoute['__types']['loader'], TRoute['__types']['searchSchema'], TRoute['__types']['fullSearchSchema'], TRoute['__types']['allParams'], TRoute['__types']['routeContext'], TRoute['__types']['context']>;
export type RouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams = AnyPathParams, TContext = AnyContext> = {
useMatch: () => RouteMatch<AnyRoutesInfo, AnyRoute>;
useLoader: () => UseLoaderResult<TLoader>;

@@ -58,26 +47,41 @@ useSearch: <TStrict extends boolean = true, TSearch = TFullSearchSchema, TSelected = TSearch>(opts?: {

};
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams = Record<ParsePathParams<TPath>, string>, TAllParams = TParams, TParentContext extends AnyContext = AnyContext, TAllParentContext extends IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext> = IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext>, TRouteContext extends RouteContext = RouteContext, TContext extends MergeFromParent<TAllParentContext, TRouteContext> = MergeFromParent<TAllParentContext, TRouteContext>> = RouteOptionsBase<TCustomId, TPath> & {
export type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = AnyPathParams, TParams extends AnyPathParams = Record<ParsePathParams<TPath>, string>, TAllParams extends AnyPathParams = TParams, TParentContext extends AnyContext = AnyContext, TAllParentContext extends IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext> = IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext>, TRouteContext extends RouteContext = RouteContext, TContext extends MergeFromParent<TAllParentContext, TRouteContext> = MergeFromParent<TAllParentContext, TRouteContext>> = BaseRouteOptions<TParentRoute, TCustomId, TPath, TLoader, TParentSearchSchema, TSearchSchema, TFullSearchSchema, TParentParams, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>;
export type BaseRouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TLoader = unknown, TParentSearchSchema extends AnySearchSchema = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = AnyPathParams, TParams = Record<ParsePathParams<TPath>, string>, TAllParams = TParams, TParentContext extends AnyContext = AnyContext, TAllParentContext extends IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext> = IsAny<TParentRoute['__types']['allParams'], TParentContext, TParentRoute['__types']['allParams'] & TParentContext>, TRouteContext extends RouteContext = RouteContext, TContext extends MergeFromParent<TAllParentContext, TRouteContext> = MergeFromParent<TAllParentContext, TRouteContext>> = RoutePathOptions<TCustomId, TPath> & {
getParentRoute: () => TParentRoute;
getKey?: OnLoadFnKey<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>;
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
loader?: LoaderFn<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>;
} & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {} : 'Cannot redefined path params in child routes!') & ({
parseParams?: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : 'parseParams must return an object';
stringifyParams?: (params: NoInfer<TParams>) => Record<ParsePathParams<TPath>, string>;
} | {
stringifyParams?: never;
parseParams?: never;
}) & (keyof PickRequired<RouteContext> extends never ? {
getContext?: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
} : {
getContext: GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext>;
});
type GetContextFn<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext> = (opts: {
params: TAllParams;
search: TFullSearchSchema;
} & (TParentRoute extends undefined ? {
context?: TAllParentContext;
parentContext?: TParentContext;
} : {
context: TAllParentContext;
parentContext: TParentContext;
})) => TRouteContext;
export type UpdatableRouteOptions<TLoader, TSearchSchema extends AnySearchSchema, TFullSearchSchema extends AnySearchSchema, TAllParams extends AnyPathParams, TRouteContext extends AnyContext, TContext extends AnyContext> = MetaOptions & {
getKey?: GetKeyFn<TFullSearchSchema, TAllParams>;
caseSensitive?: boolean;
wrapInSuspense?: boolean;
component?: RouteComponent<RouteProps<TLoader, TFullSearchSchema, TAllParams, TContext>>;
errorComponent?: RouteErrorComponent;
pendingComponent?: RouteComponent<RouteProps<TLoader, TFullSearchSchema, TAllParams, TContext>>;
preSearchFilters?: SearchFilter<TFullSearchSchema>[];
postSearchFilters?: SearchFilter<TFullSearchSchema>[];
component?: RouteComponent<RouteProps<TParentRoute, TPath, ResolveFullPath<TParentRoute, TPath>, TCustomId, ResolveId<TParentRoute, TCustomId, TPath>, TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, NoInfer<TRouteContext>>>;
errorComponent?: RouteComponent<{
error: Error;
info: {
componentStack: string;
};
}>;
pendingComponent?: RouteComponent<RouteProps<TParentRoute, TPath, ResolveFullPath<TParentRoute, TPath>, TCustomId, ResolveId<TParentRoute, TCustomId, TPath>, TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, NoInfer<TRouteContext>>>;
wrapInSuspense?: boolean;
beforeLoad?: (opts: {
router: AnyRouter;
match: AnyRouteMatch;
}) => Promise<void> | void;
beforeLoad?: (opts: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>) => Promise<void> | void;
onBeforeLoadError?: (err: any) => void;
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
onValidateSearchError?: (err: any) => void;
onParseParamsError?: (err: any) => void;
loader?: OnLoadFn<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, NoInfer<TRouteContext>, TContext>;
onLoadError?: (err: any) => void;

@@ -96,11 +100,3 @@ onError?: (err: any) => void;

}) => void;
} & MetaOptions & ContextOptions<TParentRoute, TAllParams, TFullSearchSchema, TParentContext, TAllParentContext, TRouteContext> & ({
parseParams?: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams extends Record<ParsePathParams<TPath>, any> ? TParams : 'parseParams must return an object';
stringifyParams?: (params: NoInfer<TParams>) => Record<ParsePathParams<TPath>, string>;
} | {
stringifyParams?: never;
parseParams?: never;
}) & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never ? {
test?: PickUnsafe<TParentParams, ParsePathParams<TPath>>;
} : 'Cannot redefined path params in child routes!');
};
export type SearchSchemaValidator<TReturn, TParentSchema> = SearchSchemaValidatorObj<TReturn, TParentSchema> | SearchSchemaValidatorFn<TReturn, TParentSchema>;

@@ -118,6 +114,6 @@ export type SearchSchemaValidatorObj<TReturn, TParentSchema> = {

};
export type OnLoadFn<TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}, TContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = (match: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, TContext, TAllContext> & {
export type LoaderFn<TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}, TContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = (match: LoaderContext<TSearchSchema, TFullSearchSchema, TAllParams, TContext, TAllContext> & {
parentMatchPromise?: Promise<void>;
}) => Promise<TLoader> | TLoader;
export type OnLoadFnKey<TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}, TContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = (loaderContext: {
export type GetKeyFn<TFullSearchSchema extends AnySearchSchema = {}, TAllParams = {}> = (loaderContext: {
params: TAllParams;

@@ -187,3 +183,3 @@ search: TFullSearchSchema;

isRoot: TParentRoute extends Route<any> ? true : false;
options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, InferFullSearchSchema<TParentRoute> & TSearchSchema, TParentRoute['__types']['allParams'], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>;
options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute['__types']['allParams'], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>;
parentRoute: TParentRoute;

@@ -198,3 +194,3 @@ id: TId;

rank: number;
constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute['__types']['allParams'], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext>);
constructor(options: RouteOptions<TParentRoute, TCustomId, TPath, TLoader, InferFullSearchSchema<TParentRoute>, TSearchSchema, TFullSearchSchema, TParentRoute['__types']['allParams'], TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext> & UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>);
init: (opts: {

@@ -205,2 +201,3 @@ originalIndex: number;

addChildren: <TNewChildren extends AnyRoute[]>(children: TNewChildren) => Route<TParentRoute, TPath, TFullPath, TCustomId, TId, TLoader, TSearchSchema, TFullSearchSchema, TParams, TAllParams, TParentContext, TAllParentContext, TRouteContext, TContext, TRouterContext, TNewChildren, TRoutesInfo>;
update: (options: UpdatableRouteOptions<TLoader, TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>) => this;
useMatch: <TStrict extends boolean = true, TSelected = TContext>(opts?: {

@@ -230,6 +227,6 @@ strict?: TStrict | undefined;

constructor();
createRootRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", TLoader, {}, TSearchSchema, NoInfer<TSearchSchema>, {}, TRouterContext, TRouterContext, TContext, NoInfer<TContext>, RouteContext, IsAny<NoInfer<TContext>, RouteContext, NoInfer<TContext> & RouteContext>>, "caseSensitive" | "id" | "path" | "getParentRoute" | "parseParams" | "stringifyParams"> | undefined) => RootRoute<TLoader, TSearchSchema, TContext, TRouterContext>;
createRootRoute: <TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext>(options?: Omit<RouteOptions<AnyRoute, "__root__", "", {}, TSearchSchema, {}, {}, AnyPathParams, Record<never, string>, Record<never, string>, AnyContext, AnyContext, RouteContext, RouteContext>, "caseSensitive" | "id" | "path" | "getParentRoute" | "stringifyParams" | "parseParams"> | undefined) => RootRoute<TLoader, TSearchSchema, TContext, TRouterContext>;
}
export declare class RootRoute<TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TContext extends RouteContext = RouteContext, TRouterContext extends {} = {}> extends Route<any, '/', '/', string, RootRouteId, TLoader, TSearchSchema, TSearchSchema, {}, {}, TRouterContext, TRouterContext, MergeFromParent<TRouterContext, TContext>, MergeFromParent<TRouterContext, TContext>, TRouterContext, any, any> {
constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', TLoader, {}, TSearchSchema, NoInfer<TSearchSchema>, {}, TRouterContext, TRouterContext, TContext, NoInfer<TContext>>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
constructor(options?: Omit<RouteOptions<AnyRoute, RootRouteId, '', {}, TSearchSchema, {}, {}>, 'path' | 'id' | 'getParentRoute' | 'caseSensitive' | 'parseParams' | 'stringifyParams'>);
}

@@ -236,0 +233,0 @@ type ResolveFullPath<TParentRoute extends AnyRoute, TPath extends string, TPrefixed extends RoutePrefix<TParentRoute['fullPath'], TPath> = RoutePrefix<TParentRoute['fullPath'], TPath>> = TPrefixed extends RootRouteId ? '/' : TPrefixed;

/// <reference types="react" />
import { Store } from '@tanstack/react-store';
import { LinkInfo, LinkOptions, NavigateOptions, ToOptions, ResolveRelativePath } from './link';
import { Route, AnySearchSchema, AnyRoute, RootRoute, AnyContext } from './route';
import { Route, AnySearchSchema, AnyRoute, RootRoute, AnyContext, AnyPathParams, RouteProps } from './route';
import { RoutesInfo, AnyRoutesInfo, RoutesById, RoutesByPath, DefaultRoutesInfo } from './routeInfo';
import { NoInfer, PickAsRequired, Timeout, Updater } from './utils';
import { RouterHistory } from './history';
import { RouteComponent } from './react';
import { RouteComponent, RouteErrorComponent } from './react';
declare global {

@@ -85,10 +85,5 @@ interface Window {

defaultPreloadDelay?: number;
defaultComponent?: RouteComponent;
defaultErrorComponent?: RouteComponent<{
error: Error;
info: {
componentStack: string;
};
}>;
defaultPendingComponent?: RouteComponent;
defaultComponent?: RouteComponent<RouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext>>;
defaultErrorComponent?: RouteErrorComponent;
defaultPendingComponent?: RouteComponent<RouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext>>;
defaultLoaderMaxAge?: number;

@@ -219,1 +214,2 @@ defaultLoaderGcMaxAge?: number;

}
export declare function lazyFn<T extends Record<string, (...args: any[]) => any>, TKey extends keyof T = 'default'>(fn: () => Promise<T>, key?: TKey): (...args: Parameters<T[TKey]>) => Promise<ReturnType<T[TKey]>>;

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

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var n=o(e);function s(t,e){if(!t)throw new Error("Invariant failed")}const a="popstate",i="beforeunload",c=t=>(t.preventDefault(),t.returnValue=""),h=()=>{removeEventListener(i,c,{capture:!0})};function u(t){let e=t.getLocation(),r=()=>{},o=new Set,n=[],s=[];const a=()=>{if(n.length)n[0]?.(a,(()=>{n=[],h()}));else{for(;s.length;)s.shift()?.();l()}},u=t=>{s.push(t),a()},l=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(l)),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{u((()=>{t.pushState(e,r)}))},replace:(e,r)=>{u((()=>{t.replaceState(e,r)}))},go:e=>{u((()=>{t.go(e)}))},back:()=>{u((()=>{t.back()}))},forward:()=>{u((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(n.push(t),1===n.length&&addEventListener(i,c,{capture:!0}),()=>{n=n.filter((e=>e!==t)),n.length||h()})}}function l(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return u({getLocation:()=>p(e(),history.state),listener:t=>(window.addEventListener(a,t),()=>{window.removeEventListener(a,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:f()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:f()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function d(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return u({getLocation:()=>p(e[r],o),listener:()=>()=>{},pushState:(t,n)=>{o={...n,key:f()},e.push(t),r++},replaceState:(t,n)=>{o={...n,key:f()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function p(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r):"",search:o>-1?t.slice(o,-1===r?void 0:r):"",state:e}}function f(){return(Math.random()+1).toString(36).substring(7)}function m(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function g(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function v(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||w(t)&&w(r)){const e=o?t.length:Object.keys(t).length,n=o?r:Object.keys(r),s=n.length,a=o?[]:{};let i=0;for(let e=0;e<s;e++){const s=o?e:n[e];a[s]=v(t[s],r[s]),a[s]===t[s]&&i++}return e===s&&i===e?t:a}return r}function w(t){if(!b(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!b(r)&&!!r.hasOwnProperty("isPrototypeOf")}function b(t){return"[object Object]"===Object.prototype.toString.call(t)}function S(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!S(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>S(t,e[r])))))}function R(t){return E(t.filter(Boolean).join("/"))}function E(t){return t.replace(/\/{2,}/g,"/")}function _(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function P(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function x(t){return P(_(t))}function M(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=C(e);const n=C(r);n.forEach(((t,e)=>{if("/"===t.value)e?e===n.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===m(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return E(R([t,...o.map((t=>t.value))]))}function C(t){if(!t)return[];const e=[];if("/"===(t=E(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function L(t,e,r=!1){return R(C(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return r?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function O(t,e,r){const o=j(t,e,r);if(!r.to||o)return o??{}}function j(t,e,r){e="/"!=t?e.substring(t.length):e;const o=`${r.to??"$"}`,n=C(e),s=C(o);e.startsWith("/")||n.unshift({type:"pathname",value:"/"}),o.startsWith("/")||s.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(n.length,s.length);t++){const e=n[t],o=s[t],i=t>=n.length-1,c=t>=s.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(a["*"]=R(n.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(o.value!==e.value)return!1}else if(o.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===o.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[o.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?a:void 0}function k(t,e){var r,o,n,s="";for(r in t)if(void 0!==(n=t[r]))if(Array.isArray(n))for(o=0;o<n.length;o++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(n[o]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(n);return(e||"")+s}function I(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function D(t){for(var e,r,o={},n=t.split("&");e=n.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],I(e.shift())):o[r]=I(e.shift());return o}function $(){return $=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},$.apply(this,arguments)}
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var n=o(e);function s(t,e){if(!t)throw new Error("Invariant failed")}const a="popstate",i="beforeunload",c=t=>(t.preventDefault(),t.returnValue=""),h=()=>{removeEventListener(i,c,{capture:!0})};function l(t){let e=t.getLocation(),r=()=>{},o=new Set,n=[],s=[];const a=()=>{if(n.length)n[0]?.(a,(()=>{n=[],h()}));else{for(;s.length;)s.shift()?.();u()}},l=t=>{s.push(t),a()},u=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(u)),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{l((()=>{t.pushState(e,r)}))},replace:(e,r)=>{l((()=>{t.replaceState(e,r)}))},go:e=>{l((()=>{t.go(e)}))},back:()=>{l((()=>{t.back()}))},forward:()=>{l((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(n.push(t),1===n.length&&addEventListener(i,c,{capture:!0}),()=>{n=n.filter((e=>e!==t)),n.length||h()})}}function u(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return l({getLocation:()=>p(e(),history.state),listener:t=>(window.addEventListener(a,t),()=>{window.removeEventListener(a,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:f()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:f()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function d(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return l({getLocation:()=>p(e[r],o),listener:()=>()=>{},pushState:(t,n)=>{o={...n,key:f()},e.push(t),r++},replaceState:(t,n)=>{o={...n,key:f()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function p(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r):"",search:o>-1?t.slice(o,-1===r?void 0:r):"",state:e}}function f(){return(Math.random()+1).toString(36).substring(7)}function m(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function g(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function v(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||w(t)&&w(r)){const e=o?t.length:Object.keys(t).length,n=o?r:Object.keys(r),s=n.length,a=o?[]:{};let i=0;for(let e=0;e<s;e++){const s=o?e:n[e];a[s]=v(t[s],r[s]),a[s]===t[s]&&i++}return e===s&&i===e?t:a}return r}function w(t){if(!b(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!b(r)&&!!r.hasOwnProperty("isPrototypeOf")}function b(t){return"[object Object]"===Object.prototype.toString.call(t)}function S(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!S(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>S(t,e[r])))))}function E(t){return R(t.filter(Boolean).join("/"))}function R(t){return t.replace(/\/{2,}/g,"/")}function _(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function P(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function x(t){return P(_(t))}function M(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=C(e);const n=C(r);n.forEach(((t,e)=>{if("/"===t.value)e?e===n.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===m(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return R(E([t,...o.map((t=>t.value))]))}function C(t){if(!t)return[];const e=[];if("/"===(t=R(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function L(t,e,r=!1){return E(C(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return r?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function O(t,e,r){const o=j(t,e,r);if(!r.to||o)return o??{}}function j(t,e,r){e="/"!=t?e.substring(t.length):e;const o=`${r.to??"$"}`,n=C(e),s=C(o);e.startsWith("/")||n.unshift({type:"pathname",value:"/"}),o.startsWith("/")||s.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(n.length,s.length);t++){const e=n[t],o=s[t],i=t>=n.length-1,c=t>=s.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(a["*"]=E(n.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(o.value!==e.value)return!1}else if(o.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===o.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[o.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?a:void 0}function k(t,e){var r,o,n,s="";for(r in t)if(void 0!==(n=t[r]))if(Array.isArray(n))for(o=0;o<n.length;o++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(n[o]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(n);return(e||"")+s}function I(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function D(t){for(var e,r,o={},n=t.split("&");e=n.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],I(e.shift())):o[r]=I(e.shift());return o}function $(){return $=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},$.apply(this,arguments)}
/**

@@ -32,3 +32,3 @@ * @tanstack/store/src/index.ts

* @license MIT
*/function A(t,e=(t=>t)){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,H)}function H(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0}function N(t){const e=J(),{type:r,children:o,target:s,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:g,style:v,className:w,onClick:b,onFocus:S,onMouseEnter:R,onMouseLeave:E,onTouchStart:_,...P}=t,x=e.buildLink(t);if("external"===x.type){const{href:t}=x;return{href:t}}const{handleClick:M,handleFocus:C,handleEnter:L,handleLeave:O,handleTouchStart:j,isActive:k,next:I}=x,D=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},$=k?y(a,{})??{}:{},T=k?{}:y(i,{})??{};return{...$,...T,...P,href:h?void 0:I.href,onClick:D([b,e=>{(t.startTransition??1)&&(n.startTransition||(t=>t))((()=>{M(e)}))}]),onFocus:D([S,C]),onMouseEnter:D([R,L]),onMouseLeave:D([E,O]),onTouchStart:D([_,j]),target:s,style:{...v,...$.style,...T.style},className:[w,$.className,T.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":k?"active":void 0}}const B=n.forwardRef(((t,e)=>{const r=N(t);return n.createElement("a",$({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const U=n.createContext(null),F=n.createContext(null);function z(t){return A(J().__store,t?.select)}function W(){const t=z({select:t=>t.matches.map((t=>t.id))});return n.createElement(U.Provider,{value:[void 0,...t]},n.createElement(rt,{errorComponent:nt,onCatch:()=>{}},n.createElement(Q,null)))}function J(){return n.useContext(F)}function K(t){const e=J(),r=n.useContext(U)[0],o=e.getRouteMatch(r)?.routeId,a=z({select:e=>{const o=e.matches;return(t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r))).routeId}});(t?.strict??1)&&s(o==a);return z({select:e=>{const o=e.matches,n=t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r));return s(n,t?.from&&t.from),t?.select?.(n)??n}})}function q(t){return K({...t,select:e=>t?.select?.(e.loader)??e.loader})}function Y(t){return K({...t,select:e=>t?.select?.(e.search)??e.search})}function V(t){return z({select:e=>{const r=m(e.matches)?.params;return t?.select?.(r)??r}})}function G(){const t=J();return n.useCallback((e=>{const{pending:r,caseSensitive:o,...n}=e;return t.matchRoute(n,{pending:r,caseSensitive:o})}),[])}function Q(){const t=n.useContext(U).slice(1);return t[0]?n.createElement(Z,{matchIds:t}):null}const X=()=>null;function Z({matchIds:t}){const e=J(),r=t[0],o=e.getRouteMatch(r).routeId,s=e.getRoute(o),a=s.options.pendingComponent??e.options.defaultPendingComponent??X,i=s.options.errorComponent??e.options.defaultErrorComponent,c=s.options.wrapInSuspense??!s.isRoot?n.Suspense:et,h=i?rt:et;return n.createElement(U.Provider,{value:t},n.createElement(c,{fallback:n.createElement(a,null)},n.createElement(h,{key:s.id,errorComponent:i,onCatch:()=>{}},n.createElement(tt,{matchId:r}))))}function tt({matchId:t}){const e=J(),r=z({select:e=>g(e.matches.find((e=>e.id===t)),["status","loadPromise","routeId","error"])}),o=e.getRoute(r.routeId);if("error"===r.status)throw r.error;if("pending"===r.status&&s(!1),"success"===r.status){let t=o.options.component??e.options.defaultComponent;return t?n.createElement(t,{useLoader:o.useLoader,useMatch:o.useMatch,useContext:o.useContext,useSearch:o.useSearch,useParams:o.useParams}):n.createElement(Q,null)}s(!1)}function et(t){return n.createElement(n.Fragment,null,t.children)}class rt extends n.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),this.setState({error:t,info:e})}render(){return n.createElement(ot,$({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ot(t){const e=z({select:t=>t.resolvedLocation.key}),[r,o]=n.useState(t.errorState),s=t.errorComponent??nt,a=n.useRef("");return n.useEffect((()=>{r&&e!==a.current&&o({}),a.current=e}),[r,e]),n.useEffect((()=>{t.errorState.error&&o(t.errorState)}),[t.errorState.error]),t.errorState.error&&r.error?n.createElement(s,r):t.children}function nt({error:t}){return n.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},n.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),n.createElement("div",{style:{height:".5rem"}}),n.createElement("div",null,n.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red",overflow:"auto"}},t.message?n.createElement("code",null,t.message):null)))}function st(t,e=!0){const r=J();n.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)&&(o(),e())}));return o}))}const at="__root__";class it{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=at:s(this.parentRoute);let o=r?at:e.path;o&&"/"!==o&&(o=x(o));const n=e?.id||o;let a=r?at:R([this.parentRoute.id===at?"":this.parentRoute.id,n]);o===at&&(o="/"),a!==at&&(a=R(["/",a]));const i=a===at?"/":R([this.parentRoute.fullPath,o]);this.path=o,this.id=a,this.fullPath=i,this.to=i};addChildren=t=>(this.children=t,this);useMatch=t=>K({...t,from:this.id});useLoader=t=>q({...t,from:this.id});useContext=t=>K({...t,from:this.id,select:e=>t?.select?.(e.context)??e.context});useSearch=t=>Y({...t,from:this.id});useParams=t=>V({...t,from:this.id})}class ct extends it{constructor(t){super(t)}}const ht=lt(JSON.parse),ut=dt(JSON.stringify);function lt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=D(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function dt(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=k(e).toString();return r?`?${r}`:""}}const pt=["component","errorComponent","pendingComponent"];const ft="undefined"==typeof window||!window.document.createElement;function mt(){return{status:"idle",resolvedLocation:null,location:null,matches:[],pendingMatches:[],preloadMatches:{},lastUpdated:Date.now()}}function yt(t){return!!t?.isRedirect}class gt extends Error{}class vt extends Error{}t.Block=function({message:t,condition:e,children:r}){return st(t,e),r??null},t.ErrorComponent=nt,t.Link=B,t.MatchRoute=function(t){const e=G()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Navigate=function(t){const e=J();return n.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=Q,t.PathParamError=vt,t.RootRoute=ct,t.Route=it,t.Router=class{#t;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??ut,parseSearch:t?.parseSearch??ht},this.__store=new T(mt(),{onUpdate:()=>{this.state=this.__store.state},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,mt())))};mount=()=>{this.state.matches.length||this.safeLoad()};update=t=>{if(this.options={...this.options,...t,context:{...this.options.context,...t?.context}},!this.history||this.options.history&&this.options.history!==this.history){this.#t&&this.#t(),this.history=this.options.history??(ft?d():l());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.listen((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${x(e??"")??""}`,r&&r!==this.routeTree&&this.#o(r),this};buildNext=t=>{const e=this.#n(t),r=this.matchRoutes(e.pathname,e.search);return this.#n({...t,__matches:r})};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=t=>{this.load(t).catch((t=>{}))};load=async t=>{this.#s();const e=Date.now();let r;if(this.startedLoadingAt=e,this.cancelMatches(),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),r=this.matchRoutes(this.state.location.pathname,this.state.location.search,{}),this.__store.setState((t=>({...t,status:"pending",pendingMatches:r})))})),await this.loadMatches(r),this.startedLoadingAt!==e)return this.navigationPromise;const o=this.state.resolvedLocation;this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matches:t.pendingMatches,pendingMatches:[]}))),o.href!==this.state.location.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return s(e),e};preloadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{throwOnError:!0}),o={};return r.forEach((t=>{this.state.matches.find((e=>e.id===t.id))||(o[t.id]=t)})),this.__store.setState((t=>({...t,preloadMatches:{...t.preloadMatches,...o}}))),await this.loadMatches(r,{preload:!0}),r};matchRoutes=(t,e,r)=>{let o={},n=this.flatRoutes.find((e=>{const r=O(this.basepath,t,{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!r&&(o=r,!0)}))||this.routesById.__root__,s=[n];for(;n?.parentRoute;)n=n.parentRoute,n&&s.unshift(n);let a={};const i=s.map((t=>{let n,s;try{n=t.options.parseParams?.(o)??o}catch(t){if(s=new vt(t.message,{cause:t}),r?.throwOnError)throw s}Object.assign(a,n);const i=L(t.path,a),c=L(t.id,a,!0)+(t.options.getKey?.({params:a,search:e})??""),h=this.getRouteMatch(c);if(h)return{...h};const u=!(!t.options.loader&&!pt.some((e=>t.options[e]?.preload)));return{id:c,routeId:t.id,params:a,pathname:R([this.basepath,i]),updatedAt:0,routeSearch:{},search:{},status:u?"pending":"success",error:void 0,paramsError:s,searchError:void 0,loader:void 0,loadPromise:Promise.resolve(),routeContext:void 0,context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const n=i[o-1],s=this.getRoute(t.routeId),a=(()=>{const o={search:n?.search??e,routeSearch:n?.routeSearch??e};try{const e=("object"==typeof s.options.validateSearch?s.options.validateSearch.parse:s.options.validateSearch)?.(o.search)??{},r={...o.search,...e};return{routeSearch:v(t.routeSearch,e),search:v(t.search,r)}}catch(e){if(t.searchError=new gt(e.message,{cause:e}),r?.throwOnError)throw t.searchError;return o}})(),c=(()=>{try{const e=s.options.getContext?.({parentContext:n?.routeContext??{},context:n?.context??this?.options.context??{},params:t.params,search:t.search})||{};return{context:{...n?.context??this?.options.context,...e},routeContext:e}}catch(t){throw s.options.onError?.(t),t}})();Object.assign(t,{...a,...c})})),i};loadMatches=async(t,e)=>{let r;try{await Promise.all(t.map((async(t,e)=>{const o=this.getRoute(t.routeId),n=(n,s)=>{if(r=r??e,s=s||o.options.onError,yt(n))throw n;try{s?.(n)}catch(t){if(n=t,yt(t))throw t}this.setRouteMatch(t.id,(t=>({...t,error:n,status:"error",updatedAt:Date.now()})))};t.paramsError&&n(t.paramsError,o.options.onParseParamsError),t.searchError&&n(t.searchError,o.options.onValidateSearchError);try{await(o.options.beforeLoad?.({router:this,match:t}))}catch(t){n(t,o.options.onBeforeLoadError)}})))}catch(t){if(yt(t))return void(e?.preload||this.navigate(t));throw t}const o=t.slice(0,r),n=[];o.forEach(((t,r)=>{n.push(Promise.resolve().then((async()=>{const o=n[r-1],s=this.getRoute(t.routeId),a=Date.now(),i=Promise.resolve().then((async()=>{const r=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==a?e.loadPromise:void 0};let n;const i=(async()=>{await Promise.all(pt.map((async t=>{const e=s.options[t];e?.preload&&await e.preload()})))})(),c=Promise.resolve().then((()=>{if(s.options.loader)return s.options.loader({...t,preload:!!e?.preload,parentMatchPromise:o})}));try{const[o,s]=await Promise.all([i,c]);if(n=r())return await n;e?.preload&&this.state.matches.find((e=>e.id===t.id))||this.setRouteMatch(t.id,(t=>({...t,error:void 0,status:"success",updatedAt:Date.now(),loader:s})))}catch(o){if(n=r())return await n;if(yt(o))return void(e?.preload||this.navigate(o));const a=s.options.onLoadError??s.options.onError;let i=o;try{a?.(o)}catch(t){if(i=t,yt(t))return void(e?.preload||this.navigate(t))}this.setRouteMatch(t.id,(t=>({...t,error:i,status:"error",updatedAt:Date.now()})))}finally{if(n=r())return await n;e?.preload&&this.__store.setState((e=>{const r={...e.preloadMatches};return delete r[t.id],{...e,preloadMatches:r}}))}}));this.setRouteMatch(t.id,(t=>({...t,loadPromise:i,fetchedAt:a}))),await i})))})),await Promise.all(n)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>M(this.basepath,t,E(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:n,params:a})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return s(!h),this.#e({from:c,to:i,search:r,hash:o,replace:n,params:a})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t);if(e?.pending&&"pending"!==this.state.status)return!1;const o=e?.pending?this.state.location:this.state.resolvedLocation;if(!o)return!1;const n=O(this.basepath,o.pathname,{...e,to:r.pathname});return!!n&&(e?.includeSearch??1?!!S(o.search,r.search)&&n:n)};buildLink=({from:t,to:e=".",search:r,params:o,hash:n,target:s,replace:a,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:n,replace:a},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.location.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.location.pathname===d.pathname:m,g=!i?.includeHash||this.state.location.hash===d.hash,v=!(i?.includeSearch??1)||S(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),this.#e(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:g(this.state,["location","status","lastUpdated"])});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),s(e);const r=e;this.dehydratedData=r.payload,this.options.hydrate?.(r.payload),this.__store.setState((t=>({...t,...r.router.state,matches:t.matches,resolvedLocation:r.router.state.location}))),await this.load()};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const r="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${r}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${n=r,n.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(o)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`;var n})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#o=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(s(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=P(t.fullPath);this.routesByPath[e]&&!t.fullPath.endsWith("/")||(this.routesByPath[e]=t)}const o=t.children;o?.length&&e(o)}))};e([t]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const r=x(t.fullPath),o=C(r);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const n=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:r,parsed:o,index:e,score:n}})).sort(((t,e)=>{let r="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==r)return r;const o=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let r=0;r<o;r++)if(t.score[r]!==e.score[r])return e.score[r]-t.score[r];for(let r=0;r<o;r++)if(t.parsed[r].value!==e.parsed[r].value)return t.parsed[r].value>e.parsed[r].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};#r=t=>{let{pathname:e,search:r,hash:o,state:n}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:n,key:n?.key||"__init__"}};#n=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.location.pathname:t.from??this.state.location.pathname;let r=M(this.basepath??"/",e,`${t.to??""}`);const o={...m(this.matchRoutes(this.state.location.pathname,this.state.location.search))?.params};let n=!0===(t.params??!0)?o:y(t.params,o);n&&t.__matches?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{n={...n,...t(n)}})),r=L(r,n??{});const s=t.__matches?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],a=t.__matches?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],i=s?.length?s?.reduce(((t,e)=>e(t)),this.state.location.search):this.state.location.search,c=!0===t.search?i:t.search?y(t.search,i)??{}:s?.length?i:{},h=a?.length?a.reduce(((t,e)=>e(t)),c):c,u=v(this.state.location.search,h),l=this.options.stringifySearch(u),d=!0===t.hash?this.state.location.hash:y(t.hash,this.state.location.hash),p=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.location.state:y(t.state,this.state.location.state),hash:d,href:this.history.createHref(`${r}${l}${p}`),key:t.key}};#e=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.location.href===e.href&&!e.key&&(o="replace");const n=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](n,{id:r,...e.state}),this.#s()};#s=()=>{const t=this.resolveNavigation;return this.navigationPromise=new Promise((e=>{this.resolveNavigation=()=>{e(),t()}})),this.navigationPromise};getRouteMatch=t=>this.state.matches.find((e=>e.id===t))||this.state.preloadMatches[t];#a=(t,e)=>{this.__store.setState((r=>({...r,matches:r.matches.map((r=>r.id===t?e(r):r))})))};#i=(t,e)=>{this.__store.setState((r=>({...r,pendingMatches:r.pendingMatches.map((r=>r.id===t?e(r):r))})))};#c=(t,e)=>{s(this.state.preloadMatches[t]),this.__store.setState((r=>({...r,preloadMatches:{...r.preloadMatches,[t]:e(r.preloadMatches[t])}})))};setRouteMatch=(t,e)=>this.state.matches.find((e=>e.id===t))?this.#a(t,e):this.state.pendingMatches.find((e=>e.id===t))?this.#i(t,e):this.state.preloadMatches[t]?this.#c(t,e):void 0},t.RouterContext=class{constructor(){}createRootRoute=t=>new ct(t)},t.RouterProvider=function({router:t,...e}){t.update(e),n.useEffect(t.mount,[t]);const r=t.options.Wrap||n.Fragment;return n.createElement(r,null,n.createElement(F.Provider,{value:t},n.createElement(W,null)))},t.SearchParamError=gt,t.cleanPath=E,t.componentTypes=pt,t.createBrowserHistory=l,t.createHashHistory=function(){return l({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=d,t.decode=D,t.defaultParseSearch=ht,t.defaultStringifySearch=ut,t.encode=k,t.functionalUpdate=y,t.interpolatePath=L,t.invariant=s,t.isPlainObject=w,t.isRedirect=yt,t.joinPaths=R,t.last=m,t.lazy=function(t,e="default"){const r=n.lazy((async()=>({default:(await t())[e]})));return r.preload=async()=>{await t()},r},t.matchByPath=j,t.matchIdsContext=U,t.matchPathname=O,t.parsePathname=C,t.parseSearchWith=lt,t.partialDeepEqual=S,t.pick=g,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=v,t.resolvePath=M,t.rootRouteId=at,t.routerContext=F,t.shallow=function(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0},t.stringifySearchWith=dt,t.trimPath=x,t.trimPathLeft=_,t.trimPathRight=P,t.useBlocker=st,t.useDehydrate=function(){const t=J();return n.useCallback((function(e,r){return t.dehydrateData(e,r)}),[])},t.useHydrate=function(){const t=J();return function(e){return t.hydrateData(e)}},t.useInjectHtml=function(){const t=J();return n.useCallback((e=>{t.injectHtml(e)}),[])},t.useLinkProps=N,t.useLoader=q,t.useMatch=K,t.useMatchRoute=G,t.useMatches=function(t){const e=n.useContext(U);return z({select:r=>{const o=r.matches.slice(r.matches.findIndex((t=>t.id===e[0])));return t?.select?.(o)??o}})},t.useNavigate=function(t){const e=J();return n.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=V,t.useRouter=J,t.useRouterState=z,t.useSearch=Y,t.useStore=A,t.warning=function(t,e){},Object.defineProperty(t,"__esModule",{value:!0})}));
*/function A(t,e=(t=>t)){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,H)}function H(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0}function N(t){const e=J(),{type:r,children:o,target:s,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:l,search:u,params:d,to:p=".",preload:f,preloadDelay:m,replace:g,style:v,className:w,onClick:b,onFocus:S,onMouseEnter:E,onMouseLeave:R,onTouchStart:_,...P}=t,x=e.buildLink(t);if("external"===x.type){const{href:t}=x;return{href:t}}const{handleClick:M,handleFocus:C,handleEnter:L,handleLeave:O,handleTouchStart:j,isActive:k,next:I}=x,D=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},$=k?y(a,{})??{}:{},T=k?{}:y(i,{})??{};return{...$,...T,...P,href:h?void 0:I.href,onClick:D([b,e=>{(t.startTransition??1)&&(n.startTransition||(t=>t))((()=>{M(e)}))}]),onFocus:D([S,C]),onMouseEnter:D([E,L]),onMouseLeave:D([R,O]),onTouchStart:D([_,j]),target:s,style:{...v,...$.style,...T.style},className:[w,$.className,T.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":k?"active":void 0}}const B=n.forwardRef(((t,e)=>{const r=N(t);return n.createElement("a",$({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const U=n.createContext(null),F=n.createContext(null);function z(t){return A(J().__store,t?.select)}function W(){const t=z({select:t=>t.matches.map((t=>t.id))});return n.createElement(U.Provider,{value:[void 0,...t]},n.createElement(rt,{errorComponent:nt,onCatch:()=>{}},n.createElement(Q,null)))}function J(){return n.useContext(F)}function K(t){const e=J(),r=n.useContext(U)[0],o=e.getRouteMatch(r)?.routeId,a=z({select:e=>{const o=e.matches;return(t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r))).routeId}});(t?.strict??1)&&s(o==a);return z({select:e=>{const o=e.matches,n=t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r));return s(n,t?.from&&t.from),t?.select?.(n)??n}})}function q(t){return K({...t,select:e=>t?.select?.(e.loader)??e.loader})}function Y(t){return K({...t,select:e=>t?.select?.(e.search)??e.search})}function V(t){return z({select:e=>{const r=m(e.matches)?.params;return t?.select?.(r)??r}})}function G(){const t=J();return n.useCallback((e=>{const{pending:r,caseSensitive:o,...n}=e;return t.matchRoute(n,{pending:r,caseSensitive:o})}),[])}function Q(){const t=n.useContext(U).slice(1);return t[0]?n.createElement(Z,{matchIds:t}):null}const X=()=>null;function Z({matchIds:t}){const e=J(),r=t[0],o=e.getRouteMatch(r).routeId,s=e.getRoute(o),a=s.options.pendingComponent??e.options.defaultPendingComponent??X,i=s.options.errorComponent??e.options.defaultErrorComponent,c=s.options.wrapInSuspense??!s.isRoot?n.Suspense:et,h=i?rt:et;return n.createElement(U.Provider,{value:t},n.createElement(c,{fallback:n.createElement(a,null)},n.createElement(h,{key:s.id,errorComponent:i,onCatch:()=>{}},n.createElement(tt,{matchId:r}))))}function tt({matchId:t}){const e=J(),r=z({select:e=>g(e.matches.find((e=>e.id===t)),["status","loadPromise","routeId","error"])}),o=e.getRoute(r.routeId);if("error"===r.status)throw r.error;if("pending"===r.status&&s(!1),"success"===r.status){let t=o.options.component??e.options.defaultComponent;return t?n.createElement(t,{useLoader:o.useLoader,useMatch:o.useMatch,useContext:o.useContext,useSearch:o.useSearch,useParams:o.useParams}):n.createElement(Q,null)}s(!1)}function et(t){return n.createElement(n.Fragment,null,t.children)}class rt extends n.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),this.setState({error:t,info:e})}render(){return n.createElement(ot,$({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ot(t){const e=z({select:t=>t.resolvedLocation.key}),[r,o]=n.useState(t.errorState),s=t.errorComponent??nt,a=n.useRef("");return n.useEffect((()=>{r&&e!==a.current&&o({}),a.current=e}),[r,e]),n.useEffect((()=>{t.errorState.error&&o(t.errorState)}),[t.errorState.error]),t.errorState.error&&r.error?n.createElement(s,r):t.children}function nt({error:t}){return n.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},n.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),n.createElement("div",{style:{height:".5rem"}}),n.createElement("div",null,n.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red",overflow:"auto"}},t.message?n.createElement("code",null,t.message):null)))}function st(t,e=!0){const r=J();n.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)&&(o(),e())}));return o}))}const at="__root__";class it{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=at:s(this.parentRoute);let o=r?at:e.path;o&&"/"!==o&&(o=x(o));const n=e?.id||o;let a=r?at:E([this.parentRoute.id===at?"":this.parentRoute.id,n]);o===at&&(o="/"),a!==at&&(a=E(["/",a]));const i=a===at?"/":E([this.parentRoute.fullPath,o]);this.path=o,this.id=a,this.fullPath=i,this.to=i};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);useMatch=t=>K({...t,from:this.id});useLoader=t=>q({...t,from:this.id});useContext=t=>K({...t,from:this.id,select:e=>t?.select?.(e.context)??e.context});useSearch=t=>Y({...t,from:this.id});useParams=t=>V({...t,from:this.id})}class ct extends it{constructor(t){super(t)}}const ht=ut(JSON.parse),lt=dt(JSON.stringify);function ut(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=D(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function dt(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=k(e).toString();return r?`?${r}`:""}}const pt=["component","errorComponent","pendingComponent"];const ft="undefined"==typeof window||!window.document.createElement;function mt(){return{status:"idle",resolvedLocation:null,location:null,matches:[],pendingMatches:[],preloadMatches:{},lastUpdated:Date.now()}}function yt(t){return!!t?.isRedirect}class gt extends Error{}class vt extends Error{}t.Block=function({message:t,condition:e,children:r}){return st(t,e),r??null},t.ErrorComponent=nt,t.Link=B,t.MatchRoute=function(t){const e=G()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Navigate=function(t){const e=J();return n.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=Q,t.PathParamError=vt,t.RootRoute=ct,t.Route=it,t.Router=class{#t;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??lt,parseSearch:t?.parseSearch??ht},this.__store=new T(mt(),{onUpdate:()=>{this.state=this.__store.state},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,mt())))};mount=()=>{this.state.matches.length||this.safeLoad()};update=t=>{if(this.options={...this.options,...t,context:{...this.options.context,...t?.context}},!this.history||this.options.history&&this.options.history!==this.history){this.#t&&this.#t(),this.history=this.options.history??(ft?d():u());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.listen((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${x(e??"")??""}`,r&&r!==this.routeTree&&this.#o(r),this};buildNext=t=>{const e=this.#n(t),r=this.matchRoutes(e.pathname,e.search);return this.#n({...t,__matches:r})};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=t=>{this.load(t).catch((t=>{}))};load=async t=>{this.#s();const e=Date.now();let r;if(this.startedLoadingAt=e,this.cancelMatches(),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),r=this.matchRoutes(this.state.location.pathname,this.state.location.search,{throwOnError:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatches:r})))})),await this.loadMatches(r),this.startedLoadingAt!==e)return this.navigationPromise;const o=this.state.resolvedLocation;this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matches:t.pendingMatches,pendingMatches:[]}))),o.href!==this.state.location.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return s(e),e};preloadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{throwOnError:!0}),o={};return r.forEach((t=>{this.state.matches.find((e=>e.id===t.id))||(o[t.id]=t)})),this.__store.setState((t=>({...t,preloadMatches:{...t.preloadMatches,...o}}))),await this.loadMatches(r,{preload:!0}),r};matchRoutes=(t,e,r)=>{let o={},n=this.flatRoutes.find((e=>{const r=O(this.basepath,t,{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!r&&(o=r,!0)}))||this.routesById.__root__,s=[n];for(;n?.parentRoute;)n=n.parentRoute,n&&s.unshift(n);let a={};const i=s.map((t=>{let n,s;try{n=t.options.parseParams?.(o)??o}catch(t){if(s=new vt(t.message,{cause:t}),r?.throwOnError)throw s}Object.assign(a,n);const i=L(t.path,a),c=L(t.id,a,!0)+(t.options.getKey?.({params:a,search:e})??""),h=this.getRouteMatch(c);if(h)return{...h};const l=!(!t.options.loader&&!pt.some((e=>t.options[e]?.preload)));return{id:c,routeId:t.id,params:a,pathname:E([this.basepath,i]),updatedAt:0,routeSearch:{},search:{},status:l?"pending":"success",error:void 0,paramsError:s,searchError:void 0,loader:void 0,loadPromise:Promise.resolve(),routeContext:void 0,context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const n=i[o-1],s=this.getRoute(t.routeId),a=(()=>{const o={search:n?.search??e,routeSearch:n?.routeSearch??e};try{const e=("object"==typeof s.options.validateSearch?s.options.validateSearch.parse:s.options.validateSearch)?.(o.search)??{},r={...o.search,...e};return{routeSearch:v(t.routeSearch,e),search:v(t.search,r)}}catch(e){if(t.searchError=new gt(e.message,{cause:e}),r?.throwOnError)throw t.searchError;return o}})(),c=(()=>{try{const e=s.options.getContext?.({parentContext:n?.routeContext??{},context:n?.context??this?.options.context??{},params:t.params,search:t.search})||{};return{context:{...n?.context??this?.options.context,...e},routeContext:e}}catch(t){throw s.options.onError?.(t),t}})();Object.assign(t,{...a,...c})})),i};loadMatches=async(t,e)=>{let r;try{await Promise.all(t.map((async(t,o)=>{const n=this.getRoute(t.routeId),s=(e,s)=>{if(r=r??o,s=s||n.options.onError,yt(e))throw e;try{s?.(e)}catch(t){if(e=t,yt(t))throw t}this.setRouteMatch(t.id,(t=>({...t,error:e,status:"error",updatedAt:Date.now()})))};t.paramsError&&s(t.paramsError,n.options.onParseParamsError),t.searchError&&s(t.searchError,n.options.onValidateSearchError);try{await(n.options.beforeLoad?.({...t,preload:!!e?.preload}))}catch(t){s(t,n.options.onBeforeLoadError)}})))}catch(t){throw e?.preload||this.navigate(t),t}const o=t.slice(0,r),n=[];o.forEach(((t,r)=>{n.push(Promise.resolve().then((async()=>{const o=n[r-1],s=this.getRoute(t.routeId),a=Date.now(),i=Promise.resolve().then((async()=>{const r=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==a?e.loadPromise:void 0};let n;const i=Promise.all(pt.map((async t=>{const e=s.options[t];e?.preload&&await e.preload()}))),c=Promise.resolve().then((()=>{if(s.options.loader)return s.options.loader({...t,preload:!!e?.preload,parentMatchPromise:o})}));try{const[o,s]=await Promise.all([i,c]);if(n=r())return await n;e?.preload&&this.state.matches.find((e=>e.id===t.id))||this.setRouteMatch(t.id,(t=>({...t,error:void 0,status:"success",updatedAt:Date.now(),loader:s})))}catch(o){if(n=r())return await n;if(yt(o))return void(e?.preload||this.navigate(o));const a=s.options.onLoadError??s.options.onError;let i=o;try{a?.(o)}catch(t){if(i=t,yt(t))return void(e?.preload||this.navigate(t))}this.setRouteMatch(t.id,(t=>({...t,error:i,status:"error",updatedAt:Date.now()})))}finally{if(n=r())return await n;e?.preload&&this.__store.setState((e=>{const r={...e.preloadMatches};return delete r[t.id],{...e,preloadMatches:r}}))}}));this.setRouteMatch(t.id,(t=>({...t,loadPromise:i,fetchedAt:a}))),await i})))})),await Promise.all(n)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>M(this.basepath,t,R(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:n,params:a})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return s(!h),this.#e({from:c,to:i,search:r,hash:o,replace:n,params:a})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t);if(e?.pending&&"pending"!==this.state.status)return!1;const o=e?.pending?this.state.location:this.state.resolvedLocation;if(!o)return!1;const n=O(this.basepath,o.pathname,{...e,to:r.pathname});return!!n&&(e?.includeSearch??1?!!S(o.search,r.search)&&n:n)};buildLink=({from:t,to:e=".",search:r,params:o,hash:n,target:s,replace:a,activeOptions:i,preload:c,preloadDelay:h,disabled:l})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const u={from:t,to:e,search:r,params:o,hash:n,replace:a},d=this.buildNext(u);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.location.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.location.pathname===d.pathname:m,g=!i?.includeHash||this.state.location.hash===d.hash,v=!(i?.includeSearch??1)||S(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(u).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{l||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),this.#e(u))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(u).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(u).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:l}};dehydrate=()=>({state:g(this.state,["location","status","lastUpdated"])});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),s(e);const r=e;this.dehydratedData=r.payload,this.options.hydrate?.(r.payload),this.__store.setState((t=>({...t,...r.router.state,matches:t.matches,resolvedLocation:r.router.state.location}))),await this.load()};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const r="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${r}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${n=r,n.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(o)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`;var n})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#o=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(s(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=P(t.fullPath);this.routesByPath[e]&&!t.fullPath.endsWith("/")||(this.routesByPath[e]=t)}const o=t.children;o?.length&&e(o)}))};e([t]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const r=x(t.fullPath),o=C(r);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const n=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:r,parsed:o,index:e,score:n}})).sort(((t,e)=>{let r="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==r)return r;const o=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let r=0;r<o;r++)if(t.score[r]!==e.score[r])return e.score[r]-t.score[r];for(let r=0;r<o;r++)if(t.parsed[r].value!==e.parsed[r].value)return t.parsed[r].value>e.parsed[r].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};#r=t=>{let{pathname:e,search:r,hash:o,state:n}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:n,key:n?.key||"__init__"}};#n=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.location.pathname:t.from??this.state.location.pathname;let r=M(this.basepath??"/",e,`${t.to??""}`);const o={...m(this.matchRoutes(this.state.location.pathname,this.state.location.search))?.params};let n=!0===(t.params??!0)?o:y(t.params,o);n&&t.__matches?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{n={...n,...t(n)}})),r=L(r,n??{});const s=t.__matches?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],a=t.__matches?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],i=s?.length?s?.reduce(((t,e)=>e(t)),this.state.location.search):this.state.location.search,c=!0===t.search?i:t.search?y(t.search,i)??{}:s?.length?i:{},h=a?.length?a.reduce(((t,e)=>e(t)),c):c,l=v(this.state.location.search,h),u=this.options.stringifySearch(l),d=!0===t.hash?this.state.location.hash:y(t.hash,this.state.location.hash),p=d?`#${d}`:"";return{pathname:r,search:l,searchStr:u,state:!0===t.state?this.state.location.state:y(t.state,this.state.location.state),hash:d,href:this.history.createHref(`${r}${u}${p}`),key:t.key}};#e=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.location.href===e.href&&!e.key&&(o="replace");const n=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](n,{id:r,...e.state}),this.#s()};#s=()=>{const t=this.resolveNavigation;return this.navigationPromise=new Promise((e=>{this.resolveNavigation=()=>{e(),t()}})),this.navigationPromise};getRouteMatch=t=>this.state.matches.find((e=>e.id===t))||this.state.preloadMatches[t];#a=(t,e)=>{this.__store.setState((r=>({...r,matches:r.matches.map((r=>r.id===t?e(r):r))})))};#i=(t,e)=>{this.__store.setState((r=>({...r,pendingMatches:r.pendingMatches.map((r=>r.id===t?e(r):r))})))};#c=(t,e)=>{s(this.state.preloadMatches[t]),this.__store.setState((r=>({...r,preloadMatches:{...r.preloadMatches,[t]:e(r.preloadMatches[t])}})))};setRouteMatch=(t,e)=>this.state.matches.find((e=>e.id===t))?this.#a(t,e):this.state.pendingMatches.find((e=>e.id===t))?this.#i(t,e):this.state.preloadMatches[t]?this.#c(t,e):void 0},t.RouterContext=class{constructor(){}createRootRoute=t=>new ct(t)},t.RouterProvider=function({router:t,...e}){t.update(e),n.useEffect((()=>{let e;return n.startTransition((()=>{e=t.mount()})),e}),[t]);const r=t.options.Wrap||n.Fragment;return n.createElement(n.Suspense,{fallback:null},n.createElement(r,null,n.createElement(F.Provider,{value:t},n.createElement(W,null))))},t.SearchParamError=gt,t.cleanPath=R,t.componentTypes=pt,t.createBrowserHistory=u,t.createHashHistory=function(){return u({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=d,t.decode=D,t.defaultParseSearch=ht,t.defaultStringifySearch=lt,t.encode=k,t.functionalUpdate=y,t.interpolatePath=L,t.invariant=s,t.isPlainObject=w,t.isRedirect=yt,t.joinPaths=E,t.last=m,t.lazyFn=function(t,e){return async(...r)=>(await t())[e||"default"](...r)},t.lazyRouteComponent=function(t,e){let r;const o=()=>(r||(r=t()),r),s=n.lazy((async()=>({default:(await o())[e??"default"]})));return s.preload=o,s},t.matchByPath=j,t.matchIdsContext=U,t.matchPathname=O,t.parsePathname=C,t.parseSearchWith=ut,t.partialDeepEqual=S,t.pick=g,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=v,t.resolvePath=M,t.rootRouteId=at,t.routerContext=F,t.shallow=function(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0},t.stringifySearchWith=dt,t.trimPath=x,t.trimPathLeft=_,t.trimPathRight=P,t.useBlocker=st,t.useDehydrate=function(){const t=J();return n.useCallback((function(e,r){return t.dehydrateData(e,r)}),[])},t.useHydrate=function(){const t=J();return function(e){return t.hydrateData(e)}},t.useInjectHtml=function(){const t=J();return n.useCallback((e=>{t.injectHtml(e)}),[])},t.useLinkProps=N,t.useLoader=q,t.useMatch=K,t.useMatchRoute=G,t.useMatches=function(t){const e=n.useContext(U);return z({select:r=>{const o=r.matches.slice(r.matches.findIndex((t=>t.id===e[0])));return t?.select?.(o)??o}})},t.useNavigate=function(t){const e=J();return n.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=V,t.useRouter=J,t.useRouterState=z,t.useSearch=Y,t.useStore=A,t.warning=function(t,e){},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/router",
"author": "Tanner Linsley",
"version": "0.0.1-beta.134",
"version": "0.0.1-beta.135",
"license": "MIT",

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

import { ParsePathParams } from './link'
import { AnyRouter, Router, RouteMatch } from './router'
import {
AnyRouter,
Router,
AnyRouteMatch,
RouteMatch,
RouterConstructorOptions,
} from './router'
import {
IsAny,

@@ -18,5 +12,6 @@ NoInfer,

import { joinPaths, trimPath } from './path'
import { AnyRoutesInfo, DefaultRoutesInfo, RoutesInfo } from './routeInfo'
import { AnyRoutesInfo, DefaultRoutesInfo } from './routeInfo'
import {
RouteComponent,
RouteErrorComponent,
useLoader,

@@ -36,3 +31,3 @@ useMatch,

export type RouteOptionsBase<TCustomId, TPath> =
export type RoutePathOptions<TCustomId, TPath> =
| {

@@ -45,4 +40,4 @@ path: TPath

export type RouteOptionsBaseIntersection<TCustomId, TPath> =
UnionToIntersection<RouteOptionsBase<TCustomId, TPath>>
export type RoutePathOptionsIntersection<TCustomId, TPath> =
UnionToIntersection<RoutePathOptions<TCustomId, TPath>>

@@ -57,97 +52,45 @@ export type MetaOptions = keyof PickRequired<RouteMeta> extends never

type GetContextFn<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext,
> = (
opts: {
params: TAllParams
search: TFullSearchSchema
} & (TParentRoute extends undefined
? {
context?: TAllParentContext
parentContext?: TParentContext
}
: {
context: TAllParentContext
parentContext: TParentContext
}),
) => TRouteContext
export type AnyRouteProps = RouteProps<any, any, any, any>
export type ComponentPropsFromRoute<TRoute> = TRoute extends Route<
infer TParentRoute,
infer TPath,
infer TFullPath,
infer TCustomId,
infer TId,
infer TLoader,
infer TSearchSchema,
infer TFullSearchSchema,
infer TParams,
infer TAllParams,
infer TParentContext,
infer TAllParentContext,
infer TRouteContext,
infer TContext,
infer TRouterContext,
infer TChildren,
infer TRoutesInfo
>
? RouteProps<TLoader, TFullSearchSchema, TAllParams, TContext>
: never
export type ContextOptions<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext,
> = keyof PickRequired<RouteContext> extends never
? {
getContext?: GetContextFn<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext
>
}
: {
getContext: GetContextFn<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext
>
}
export type ComponentFromRoute<TRoute> = RouteComponent<
ComponentPropsFromRoute<TRoute>
>
export type RouteLoaderFromRoute<TRoute extends AnyRoute> = LoaderFn<
TRoute['__types']['loader'],
TRoute['__types']['searchSchema'],
TRoute['__types']['fullSearchSchema'],
TRoute['__types']['allParams'],
TRoute['__types']['routeContext'],
TRoute['__types']['context']
>
export type RouteProps<
TParentRoute extends AnyRoute,
TPath extends string,
TFullPath extends ResolveFullPath<
TParentRoute,
TPath,
RoutePrefix<TParentRoute['fullPath'], TPath>
>,
TCustomId extends string,
TId extends ResolveId<TParentRoute, TCustomId, TPath>,
TLoader,
TSearchSchema extends AnySearchSchema,
TFullSearchSchema extends AnySearchSchema,
TAllParams,
TParentContext,
TAllParentContext extends IsAny<
TParentRoute['__types']['allParams'],
TParentContext,
TParentRoute['__types']['allParams'] & TParentContext
>,
TRouteContext,
TContext,
TRouterContext extends AnyContext,
TLoader = unknown,
TFullSearchSchema extends AnySearchSchema = AnySearchSchema,
TAllParams = AnyPathParams,
TContext = AnyContext,
> = {
useMatch: () => RouteMatch<
AnyRoutesInfo,
Route<
TParentRoute,
TPath,
TFullPath,
TCustomId,
TId,
TLoader,
TSearchSchema,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext,
TContext,
TRouterContext,
any,
any
>
>
useMatch: () => RouteMatch<AnyRoutesInfo, AnyRoute>
useLoader: () => UseLoaderResult<TLoader>

@@ -181,6 +124,57 @@ useSearch: <

TLoader = unknown,
TParentSearchSchema extends {} = {},
TParentSearchSchema extends AnySearchSchema = {},
TSearchSchema extends AnySearchSchema = {},
TFullSearchSchema extends AnySearchSchema = TSearchSchema,
TParentParams extends AnyPathParams = {},
TParentParams extends AnyPathParams = AnyPathParams,
TParams extends AnyPathParams = Record<ParsePathParams<TPath>, string>,
TAllParams extends AnyPathParams = TParams,
TParentContext extends AnyContext = AnyContext,
TAllParentContext extends IsAny<
TParentRoute['__types']['allParams'],
TParentContext,
TParentRoute['__types']['allParams'] & TParentContext
> = IsAny<
TParentRoute['__types']['allParams'],
TParentContext,
TParentRoute['__types']['allParams'] & TParentContext
>,
TRouteContext extends RouteContext = RouteContext,
TContext extends MergeFromParent<
TAllParentContext,
TRouteContext
> = MergeFromParent<TAllParentContext, TRouteContext>,
> = BaseRouteOptions<
TParentRoute,
TCustomId,
TPath,
TLoader,
TParentSearchSchema,
TSearchSchema,
TFullSearchSchema,
TParentParams,
TParams,
TAllParams,
TParentContext,
TAllParentContext,
TRouteContext,
TContext
> &
UpdatableRouteOptions<
TLoader,
TSearchSchema,
TFullSearchSchema,
TAllParams,
TRouteContext,
TContext
>
export type BaseRouteOptions<
TParentRoute extends AnyRoute = AnyRoute,
TCustomId extends string = string,
TPath extends string = string,
TLoader = unknown,
TParentSearchSchema extends AnySearchSchema = {},
TSearchSchema extends AnySearchSchema = {},
TFullSearchSchema extends AnySearchSchema = TSearchSchema,
TParentParams extends AnyPathParams = AnyPathParams,
TParams = Record<ParsePathParams<TPath>, string>,

@@ -203,8 +197,7 @@ TAllParams = TParams,

> = MergeFromParent<TAllParentContext, TRouteContext>,
> = RouteOptionsBase<TCustomId, TPath> & {
> = RoutePathOptions<TCustomId, TPath> & {
getParentRoute: () => TParentRoute
// Optionally call this function to get a unique key for this route.
// This is useful for routes that need to be uniquely identified
// by more than their by search params
getKey?: OnLoadFnKey<
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>
loader?: LoaderFn<
TLoader,
TSearchSchema,

@@ -216,4 +209,90 @@ TFullSearchSchema,

>
} & (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never
? // Detect if an existing path param is being redefined
{}
: 'Cannot redefined path params in child routes!') &
(
| {
// Both or none
parseParams?: (
rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,
) => TParams extends Record<ParsePathParams<TPath>, any>
? TParams
: 'parseParams must return an object'
stringifyParams?: (
params: NoInfer<TParams>,
) => Record<ParsePathParams<TPath>, string>
}
| {
stringifyParams?: never
parseParams?: never
}
) &
(keyof PickRequired<RouteContext> extends never
? {
getContext?: GetContextFn<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext
>
}
: {
getContext: GetContextFn<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext
>
})
type GetContextFn<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext,
> = (
opts: {
params: TAllParams
search: TFullSearchSchema
} & (TParentRoute extends undefined
? {
context?: TAllParentContext
parentContext?: TParentContext
}
: {
context: TAllParentContext
parentContext: TParentContext
}),
) => TRouteContext
export type UpdatableRouteOptions<
TLoader,
TSearchSchema extends AnySearchSchema,
TFullSearchSchema extends AnySearchSchema,
TAllParams extends AnyPathParams,
TRouteContext extends AnyContext,
TContext extends AnyContext,
> = MetaOptions & {
getKey?: GetKeyFn<TFullSearchSchema, TAllParams>
// If true, this route will be matched as case-sensitive
caseSensitive?: boolean
// If true, this route will be forcefully wrapped in a suspense boundary
wrapInSuspense?: boolean
// The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`
component?: RouteComponent<
RouteProps<TLoader, TFullSearchSchema, TAllParams, TContext>
>
// The content to be rendered when the route encounters an error
errorComponent?: RouteErrorComponent //
// If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
pendingComponent?: RouteComponent<
RouteProps<TLoader, TFullSearchSchema, TAllParams, TContext>
>
// Filter functions that can manipulate search params *before* they are passed to links and navigate

@@ -225,47 +304,2 @@ // 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?: RouteComponent<
RouteProps<
TParentRoute,
TPath,
ResolveFullPath<TParentRoute, TPath>,
TCustomId,
ResolveId<TParentRoute, TCustomId, TPath>,
TLoader,
TSearchSchema,
TFullSearchSchema,
TAllParams,
TParentContext,
TAllParentContext,
TRouteContext,
TContext,
NoInfer<TRouteContext>
>
> //
// The content to be rendered when the route encounters an error
errorComponent?: RouteComponent<{
error: Error
info: { componentStack: string }
}> //
// If supported by your framework, the content to be rendered as the fallback content until the route is ready to render
pendingComponent?: RouteComponent<
RouteProps<
TParentRoute,
TPath,
ResolveFullPath<TParentRoute, TPath>,
TCustomId,
ResolveId<TParentRoute, TCustomId, TPath>,
TLoader,
TSearchSchema,
TFullSearchSchema,
TAllParams,
TParentContext,
TAllParentContext,
TRouteContext,
TContext,
NoInfer<TRouteContext>
>
> //
wrapInSuspense?: boolean
// This async function is called before a route is loaded.

@@ -275,10 +309,14 @@ // If an error is thrown here, the route's loader will not be called.

// If thrown during a preload event, the error will be logged to the console.
beforeLoad?: (opts: {
router: AnyRouter
match: AnyRouteMatch
}) => Promise<void> | void
beforeLoad?: (
opts: LoaderContext<
TSearchSchema,
TFullSearchSchema,
TAllParams,
NoInfer<TRouteContext>,
TContext
>,
) => Promise<void> | void
// 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.
onBeforeLoadError?: (err: any) => void
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>
// This function will be called if the route's validateSearch option throws an error **during an attempted validation**.

@@ -289,11 +327,2 @@ // If you want to redirect due to an error, call `router.navigate()` from within this function.

onParseParamsError?: (err: any) => void
// An asynchronous function responsible for preparing or fetching data for the route before it is rendered
loader?: OnLoadFn<
TLoader,
TSearchSchema,
TFullSearchSchema,
TAllParams,
NoInfer<TRouteContext>,
TContext
>
onLoadError?: (err: any) => void

@@ -316,31 +345,3 @@ onError?: (err: any) => void

}) => void
} & MetaOptions &
ContextOptions<
TParentRoute,
TAllParams,
TFullSearchSchema,
TParentContext,
TAllParentContext,
TRouteContext
> &
(
| {
// 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 extends Record<ParsePathParams<TPath>, any>
? TParams
: 'parseParams must return an object'
stringifyParams?: (
params: NoInfer<TParams>,
) => Record<ParsePathParams<TPath>, string>
}
| {
stringifyParams?: never
parseParams?: never
}
) &
(PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never // Detect if an existing path param is being redefined
? { test?: PickUnsafe<TParentParams, ParsePathParams<TPath>> }
: 'Cannot redefined path params in child routes!')
}

@@ -376,3 +377,3 @@ // The parse type here allows a zod schema to be passed directly to the validator

export type OnLoadFn<
export type LoaderFn<
TLoader = unknown,

@@ -396,21 +397,6 @@ TSearchSchema extends AnySearchSchema = {},

export type OnLoadFnKey<
TSearchSchema extends AnySearchSchema = {},
export type GetKeyFn<
TFullSearchSchema extends AnySearchSchema = {},
TAllParams = {},
TContext extends AnyContext = AnyContext,
TAllContext extends AnyContext = AnyContext,
> = (
loaderContext: {
params: TAllParams
search: TFullSearchSchema
},
// loaderContext: LoaderContext<
// TSearchSchema,
// TFullSearchSchema,
// TAllParams,
// TContext,
// TAllContext
// >,
) => any
> = (loaderContext: { params: TAllParams; search: TFullSearchSchema }) => any

@@ -431,10 +417,2 @@ export interface LoaderContext<

context: TAllContext
// serverOnly: <
// TServer extends object | (() => object),
// TClient extends object | (() => object),
// >(
// server: TServer,
// client: TClient,
// ) => (TServer extends () => infer TReturn ? TReturn : TServer) &
// (TClient extends () => infer TReturn ? TReturn : TClient)
}

@@ -601,3 +579,3 @@

TSearchSchema,
InferFullSearchSchema<TParentRoute> & TSearchSchema,
TFullSearchSchema,
TParentRoute['__types']['allParams'],

@@ -610,3 +588,11 @@ TParams,

TContext
>
> &
UpdatableRouteOptions<
TLoader,
TSearchSchema,
TFullSearchSchema,
TAllParams,
TRouteContext,
TContext
>

@@ -643,3 +629,11 @@ // Set up in this.init()

TContext
>,
> &
UpdatableRouteOptions<
TLoader,
TSearchSchema,
TFullSearchSchema,
TAllParams,
TRouteContext,
TContext
>,
) {

@@ -654,21 +648,14 @@ this.options = (options as any) || {}

const allOptions = this.options as RouteOptions<
const options = this.options as RouteOptions<
TParentRoute,
TCustomId,
TPath,
TLoader,
InferFullSearchSchema<TParentRoute>,
TSearchSchema,
TFullSearchSchema,
TParentRoute['__types']['allParams'],
TParams,
TAllParams,
TParentContext,
TAllParentContext,
TRouteContext,
TContext
TParams
> &
RouteOptionsBaseIntersection<TCustomId, TPath>
RoutePathOptionsIntersection<TCustomId, TPath>
const isRoot = !allOptions?.path && !allOptions?.id
const isRoot = !options?.path && !options?.id

@@ -686,3 +673,3 @@ this.parentRoute = this.options?.getParentRoute?.()

let path: undefined | string = isRoot ? rootRouteId : allOptions.path
let path: undefined | string = isRoot ? rootRouteId : options.path

@@ -694,3 +681,3 @@ // If the path is anything other than an index path, trim it up

const customId = allOptions?.id || path
const customId = options?.id || path

@@ -750,2 +737,16 @@ // Strip the parentId prefix from the first level of children

update = (
options: UpdatableRouteOptions<
TLoader,
TSearchSchema,
TFullSearchSchema,
TAllParams,
TRouteContext,
TContext
>,
) => {
Object.assign(this.options, options)
return this
}
useMatch = <TStrict extends boolean = true, TSelected = TContext>(opts?: {

@@ -807,16 +808,3 @@ strict?: TStrict

options?: Omit<
RouteOptions<
AnyRoute,
RootRouteId,
'',
TLoader,
{},
TSearchSchema,
NoInfer<TSearchSchema>,
{},
TRouterContext,
TRouterContext,
TContext,
NoInfer<TContext>
>,
RouteOptions<AnyRoute, RootRouteId, '', {}, TSearchSchema, {}, {}>,
| 'path'

@@ -890,16 +878,3 @@ | 'id'

options?: Omit<
RouteOptions<
AnyRoute,
RootRouteId,
'',
TLoader,
{},
TSearchSchema,
NoInfer<TSearchSchema>,
{},
TRouterContext,
TRouterContext,
TContext,
NoInfer<TContext>
>,
RouteOptions<AnyRoute, RootRouteId, '', {}, TSearchSchema, {}, {}>,
| 'path'

@@ -906,0 +881,0 @@ | 'id'

@@ -30,2 +30,3 @@ import { Store } from '@tanstack/react-store'

AnyPathParams,
RouteProps,
} from './route'

@@ -56,3 +57,3 @@ import {

} from './history'
import { RouteComponent } from './react'
import { RouteComponent, RouteErrorComponent } from './react'

@@ -165,8 +166,9 @@ //

defaultPreloadDelay?: number
defaultComponent?: RouteComponent
defaultErrorComponent?: RouteComponent<{
error: Error
info: { componentStack: string }
}>
defaultPendingComponent?: RouteComponent
defaultComponent?: RouteComponent<
RouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext>
>
defaultErrorComponent?: RouteErrorComponent
defaultPendingComponent?: RouteComponent<
RouteProps<unknown, AnySearchSchema, AnyPathParams, AnyContext>
>
defaultLoaderMaxAge?: number

@@ -179,3 +181,2 @@ defaultLoaderGcMaxAge?: number

onRouteChange?: () => void
// fetchServerDataFn?: FetchServerDataFn
context?: TRouteTree['__types']['routerContext']

@@ -437,3 +438,3 @@ Wrap?: React.ComponentType<{

{
// throwOnError: true,
throwOnError: true,
},

@@ -753,4 +754,4 @@ )

await route.options.beforeLoad?.({
router: this as any,
match,
...match,
preload: !!opts?.preload,
})

@@ -763,10 +764,7 @@ } catch (err) {

} catch (err) {
if (isRedirect(err)) {
if (!opts?.preload) {
this.navigate(err as any)
}
return
if (!opts?.preload) {
this.navigate(err as any)
}
throw err // we should never end up here
throw err
}

@@ -793,17 +791,12 @@

const componentsPromise = (async () => {
// then run all component and data loaders in parallel
// For each component type, potentially load it asynchronously
const componentsPromise = Promise.all(
componentTypes.map(async (type) => {
const component = route.options[type]
await Promise.all(
componentTypes.map(async (type) => {
const component = route.options[type]
if (component?.preload) {
await component.preload()
}
}),
)
if (component?.preload) {
await component.preload()
}
}),
)
})()
const loaderPromise = Promise.resolve().then(() => {

@@ -1612,1 +1605,14 @@ if (route.options.loader) {

}
// A function that takes an import() argument which is a function and returns a new function that will
// proxy arguments from the caller to the imported function, retaining all type
// information along the way
export function lazyFn<
T extends Record<string, (...args: any[]) => any>,
TKey extends keyof T = 'default',
>(fn: () => Promise<T>, key?: TKey) {
return async (...args: Parameters<T[TKey]>): Promise<ReturnType<T[TKey]>> => {
const imported = await fn()
return imported[key || 'default'](...args)
}
}

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc