Socket
Socket
Sign inDemoInstall

@tanstack/router

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/router - npm Package Compare versions

Comparing version 0.0.1-beta.67 to 0.0.1-beta.69

8

build/cjs/path.js

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

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

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

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

@@ -137,3 +137,3 @@ }

const baseSegments = parsePathname(from);
const to = `${matchLocation.to ?? '*'}`;
const to = `${matchLocation.to ?? '$'}`;
const routeSegments = parsePathname(to);

@@ -150,3 +150,3 @@ const params = {};

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

@@ -153,0 +153,0 @@ }

@@ -41,3 +41,9 @@ /**

this.state = this.store.state;
if (!this.#hasLoaders()) {
componentTypes.map(async type => {
const component = this.route.options[type];
if (typeof this[type] !== 'function') {
this[type] = component;
}
});
if (this.state.status === 'idle' && !this.#hasLoaders()) {
this.store.setState(s => ({

@@ -90,3 +96,3 @@ ...s,

} catch (err) {
console.error(err);
this.route.options.onValidateSearchError?.(err);
const error = new Error('Invalid search params found', {

@@ -127,2 +133,3 @@ cause: err

} catch (err) {
this.route.options.onError?.(err);
this.store.setState(s => ({

@@ -143,8 +150,2 @@ ...s,

} = info;
componentTypes.map(async type => {
const component = this.route.options[type];
if (typeof this[type] !== 'function') {
this[type] = component;
}
});

@@ -200,4 +201,3 @@ // If the match is invalid, errored or idle, trigger it to load

try {
await componentsPromise;
await dataPromise;
await Promise.all([componentsPromise, dataPromise]);
if (latestPromise = checkLatest()) return await latestPromise;

@@ -211,2 +211,4 @@ this.store.setState(s => ({

} catch (err) {
this.route.options.onLoadError?.(err);
this.route.options.onError?.(err);
this.store.setState(s => ({

@@ -213,0 +215,0 @@ ...s,

@@ -352,4 +352,5 @@ /**

if (!opts?.preload) {
match.route.options.onLoadError?.(err);
match.route.options.onBeforeLoadError?.(err);
}
match.route.options.onError?.(err);
throw err;

@@ -503,2 +504,8 @@ }

};
const handleTouchStart = e => {
this.preloadRoute(nextOpts).catch(err => {
console.warn(err);
console.warn('Error preloading route! ☝️');
});
};
const handleEnter = e => {

@@ -533,2 +540,3 @@ const target = e.target || {};

handleLeave,
handleTouchStart,
isActive,

@@ -659,3 +667,3 @@ disabled

};
#commitLocation = location => {
#commitLocation = async location => {
const next = this.buildNext(location);

@@ -662,0 +670,0 @@ const id = '' + Date.now() + Math.random();

@@ -322,3 +322,3 @@ /**

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

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

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

@@ -377,3 +377,3 @@ }

const baseSegments = parsePathname(from);
const to = `${matchLocation.to ?? '*'}`;
const to = `${matchLocation.to ?? '$'}`;
const routeSegments = parsePathname(to);

@@ -390,3 +390,3 @@ const params = {};

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

@@ -609,3 +609,9 @@ }

this.state = this.store.state;
if (!this.#hasLoaders()) {
componentTypes.map(async type => {
const component = this.route.options[type];
if (typeof this[type] !== 'function') {
this[type] = component;
}
});
if (this.state.status === 'idle' && !this.#hasLoaders()) {
this.store.setState(s => ({

@@ -658,3 +664,3 @@ ...s,

} catch (err) {
console.error(err);
this.route.options.onValidateSearchError?.(err);
const error = new Error('Invalid search params found', {

@@ -695,2 +701,3 @@ cause: err

} catch (err) {
this.route.options.onError?.(err);
this.store.setState(s => ({

@@ -711,8 +718,2 @@ ...s,

} = info;
componentTypes.map(async type => {
const component = this.route.options[type];
if (typeof this[type] !== 'function') {
this[type] = component;
}
});

@@ -768,4 +769,3 @@ // If the match is invalid, errored or idle, trigger it to load

try {
await componentsPromise;
await dataPromise;
await Promise.all([componentsPromise, dataPromise]);
if (latestPromise = checkLatest()) return await latestPromise;

@@ -779,2 +779,4 @@ this.store.setState(s => ({

} catch (err) {
this.route.options.onLoadError?.(err);
this.route.options.onError?.(err);
this.store.setState(s => ({

@@ -1167,4 +1169,5 @@ ...s,

if (!opts?.preload) {
match.route.options.onLoadError?.(err);
match.route.options.onBeforeLoadError?.(err);
}
match.route.options.onError?.(err);
throw err;

@@ -1318,2 +1321,8 @@ }

};
const handleTouchStart = e => {
this.preloadRoute(nextOpts).catch(err => {
console.warn(err);
console.warn('Error preloading route! ☝️');
});
};
const handleEnter = e => {

@@ -1348,2 +1357,3 @@ const target = e.target || {};

handleLeave,
handleTouchStart,
isActive,

@@ -1474,3 +1484,3 @@ disabled

};
#commitLocation = location => {
#commitLocation = async location => {
const next = this.buildNext(location);

@@ -1477,0 +1487,0 @@ const id = '' + Date.now() + Math.random();

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

"name": "node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "a145-30"
"uid": "61e0-30"
},

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

{
"uid": "a145-32",
"uid": "61e0-32",
"name": "history.ts"
},
{
"uid": "a145-34",
"uid": "61e0-34",
"name": "utils.ts"
},
{
"uid": "a145-36",
"uid": "61e0-36",
"name": "path.ts"
},
{
"uid": "a145-38",
"uid": "61e0-38",
"name": "qss.ts"
},
{
"uid": "a145-40",
"uid": "61e0-40",
"name": "route.ts"
},
{
"uid": "a145-44",
"uid": "61e0-44",
"name": "routeMatch.ts"
},
{
"uid": "a145-46",
"uid": "61e0-46",
"name": "searchParams.ts"
},
{
"uid": "a145-48",
"uid": "61e0-48",
"name": "router.ts"
},
{
"uid": "a145-50",
"uid": "61e0-50",
"name": "index.ts"

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

"name": "store/build/esm/index.js",
"uid": "a145-42"
"uid": "61e0-42"
}

@@ -72,74 +72,74 @@ ]

"nodeParts": {
"a145-30": {
"61e0-30": {
"renderedLength": 199,
"gzipLength": 134,
"brotliLength": 0,
"mainUid": "a145-29"
"mainUid": "61e0-29"
},
"a145-32": {
"61e0-32": {
"renderedLength": 4236,
"gzipLength": 1085,
"brotliLength": 0,
"mainUid": "a145-31"
"mainUid": "61e0-31"
},
"a145-34": {
"61e0-34": {
"renderedLength": 3046,
"gzipLength": 1062,
"brotliLength": 0,
"mainUid": "a145-33"
"mainUid": "61e0-33"
},
"a145-36": {
"renderedLength": 5601,
"gzipLength": 1328,
"61e0-36": {
"renderedLength": 5593,
"gzipLength": 1320,
"brotliLength": 0,
"mainUid": "a145-35"
"mainUid": "61e0-35"
},
"a145-38": {
"61e0-38": {
"renderedLength": 1395,
"gzipLength": 558,
"brotliLength": 0,
"mainUid": "a145-37"
"mainUid": "61e0-37"
},
"a145-40": {
"61e0-40": {
"renderedLength": 2963,
"gzipLength": 847,
"brotliLength": 0,
"mainUid": "a145-39"
"mainUid": "61e0-39"
},
"a145-42": {
"61e0-42": {
"renderedLength": 1384,
"gzipLength": 502,
"brotliLength": 0,
"mainUid": "a145-41"
"mainUid": "61e0-41"
},
"a145-44": {
"renderedLength": 6383,
"gzipLength": 1646,
"61e0-44": {
"renderedLength": 6584,
"gzipLength": 1666,
"brotliLength": 0,
"mainUid": "a145-43"
"mainUid": "61e0-43"
},
"a145-46": {
"61e0-46": {
"renderedLength": 1387,
"gzipLength": 483,
"brotliLength": 0,
"mainUid": "a145-45"
"mainUid": "61e0-45"
},
"a145-48": {
"renderedLength": 23024,
"gzipLength": 5366,
"61e0-48": {
"renderedLength": 23321,
"gzipLength": 5398,
"brotliLength": 0,
"mainUid": "a145-47"
"mainUid": "61e0-47"
},
"a145-50": {
"61e0-50": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "a145-49"
"mainUid": "61e0-49"
}
},
"nodeMetas": {
"a145-29": {
"61e0-29": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "a145-30"
"index.production.js": "61e0-30"
},

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

{
"uid": "a145-49"
"uid": "61e0-49"
},
{
"uid": "a145-39"
"uid": "61e0-39"
},
{
"uid": "a145-47"
"uid": "61e0-47"
}
]
},
"a145-31": {
"61e0-31": {
"id": "/packages/router/src/history.ts",
"moduleParts": {
"index.production.js": "a145-32"
"index.production.js": "61e0-32"
},

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

{
"uid": "a145-49"
"uid": "61e0-49"
},
{
"uid": "a145-47"
"uid": "61e0-47"
}
]
},
"a145-33": {
"61e0-33": {
"id": "/packages/router/src/utils.ts",
"moduleParts": {
"index.production.js": "a145-34"
"index.production.js": "61e0-34"
},

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

{
"uid": "a145-49"
"uid": "61e0-49"
},
{
"uid": "a145-35"
"uid": "61e0-35"
},
{
"uid": "a145-43"
"uid": "61e0-43"
},
{
"uid": "a145-47"
"uid": "61e0-47"
}
]
},
"a145-35": {
"61e0-35": {
"id": "/packages/router/src/path.ts",
"moduleParts": {
"index.production.js": "a145-36"
"index.production.js": "61e0-36"
},
"imported": [
{
"uid": "a145-33"
"uid": "61e0-33"
}

@@ -210,16 +210,16 @@ ],

{
"uid": "a145-49"
"uid": "61e0-49"
},
{
"uid": "a145-39"
"uid": "61e0-39"
},
{
"uid": "a145-47"
"uid": "61e0-47"
}
]
},
"a145-37": {
"61e0-37": {
"id": "/packages/router/src/qss.ts",
"moduleParts": {
"index.production.js": "a145-38"
"index.production.js": "61e0-38"
},

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

{
"uid": "a145-49"
"uid": "61e0-49"
},
{
"uid": "a145-45"
"uid": "61e0-45"
}
]
},
"a145-39": {
"61e0-39": {
"id": "/packages/router/src/route.ts",
"moduleParts": {
"index.production.js": "a145-40"
"index.production.js": "61e0-40"
},
"imported": [
{
"uid": "a145-29"
"uid": "61e0-29"
},
{
"uid": "a145-35"
"uid": "61e0-35"
}

@@ -252,10 +252,10 @@ ],

{
"uid": "a145-49"
"uid": "61e0-49"
}
]
},
"a145-41": {
"61e0-41": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "a145-42"
"index.production.js": "61e0-42"
},

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

{
"uid": "a145-43"
"uid": "61e0-43"
},
{
"uid": "a145-47"
"uid": "61e0-47"
}
]
},
"a145-43": {
"61e0-43": {
"id": "/packages/router/src/routeMatch.ts",
"moduleParts": {
"index.production.js": "a145-44"
"index.production.js": "61e0-44"
},
"imported": [
{
"uid": "a145-41"
"uid": "61e0-41"
},
{
"uid": "a145-33"
"uid": "61e0-33"
}

@@ -288,17 +288,17 @@ ],

{
"uid": "a145-49"
"uid": "61e0-49"
},
{
"uid": "a145-47"
"uid": "61e0-47"
}
]
},
"a145-45": {
"61e0-45": {
"id": "/packages/router/src/searchParams.ts",
"moduleParts": {
"index.production.js": "a145-46"
"index.production.js": "61e0-46"
},
"imported": [
{
"uid": "a145-37"
"uid": "61e0-37"
}

@@ -308,35 +308,35 @@ ],

{
"uid": "a145-49"
"uid": "61e0-49"
},
{
"uid": "a145-47"
"uid": "61e0-47"
}
]
},
"a145-47": {
"61e0-47": {
"id": "/packages/router/src/router.ts",
"moduleParts": {
"index.production.js": "a145-48"
"index.production.js": "61e0-48"
},
"imported": [
{
"uid": "a145-41"
"uid": "61e0-41"
},
{
"uid": "a145-29"
"uid": "61e0-29"
},
{
"uid": "a145-35"
"uid": "61e0-35"
},
{
"uid": "a145-43"
"uid": "61e0-43"
},
{
"uid": "a145-45"
"uid": "61e0-45"
},
{
"uid": "a145-33"
"uid": "61e0-33"
},
{
"uid": "a145-31"
"uid": "61e0-31"
}

@@ -346,47 +346,47 @@ ],

{
"uid": "a145-49"
"uid": "61e0-49"
}
]
},
"a145-49": {
"61e0-49": {
"id": "/packages/router/src/index.ts",
"moduleParts": {
"index.production.js": "a145-50"
"index.production.js": "61e0-50"
},
"imported": [
{
"uid": "a145-29"
"uid": "61e0-29"
},
{
"uid": "a145-31"
"uid": "61e0-31"
},
{
"uid": "a145-51"
"uid": "61e0-51"
},
{
"uid": "a145-52"
"uid": "61e0-52"
},
{
"uid": "a145-35"
"uid": "61e0-35"
},
{
"uid": "a145-37"
"uid": "61e0-37"
},
{
"uid": "a145-39"
"uid": "61e0-39"
},
{
"uid": "a145-53"
"uid": "61e0-53"
},
{
"uid": "a145-43"
"uid": "61e0-43"
},
{
"uid": "a145-47"
"uid": "61e0-47"
},
{
"uid": "a145-45"
"uid": "61e0-45"
},
{
"uid": "a145-33"
"uid": "61e0-33"
}

@@ -397,3 +397,3 @@ ],

},
"a145-51": {
"61e0-51": {
"id": "/packages/router/src/frameworks.ts",

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

{
"uid": "a145-49"
"uid": "61e0-49"
}
]
},
"a145-52": {
"61e0-52": {
"id": "/packages/router/src/link.ts",

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

{
"uid": "a145-49"
"uid": "61e0-49"
}
]
},
"a145-53": {
"61e0-53": {
"id": "/packages/router/src/routeInfo.ts",

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

{
"uid": "a145-49"
"uid": "61e0-49"
}

@@ -429,0 +429,0 @@ ]

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

declare const defaultFetchServerDataFn: FetchServerDataFn;
type RouterConstructorOptions<TRouteTree extends AnyRoute> = Omit<RouterOptions<TRouteTree>, 'context'> & RouterContextOptions<TRouteTree>;
declare class Router<TRouteTree extends AnyRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteTree>> {

@@ -218,3 +219,3 @@ #private;

};
options: PickAsRequired<Omit<RouterOptions<TRouteTree>, 'context'>, 'stringifySearch' | 'parseSearch'> & RouterContextOptions<TRouteTree>;
options: PickAsRequired<RouterOptions<TRouteTree>, 'stringifySearch' | 'parseSearch' | 'context'>;
history: RouterHistory;

@@ -231,3 +232,3 @@ basepath: string;

resolveNavigation: () => void;
constructor(options?: RouterOptions<TRouteTree>);
constructor(options?: RouterConstructorOptions<TRouteTree>);
reset: () => void;

@@ -252,5 +253,5 @@ mount: () => () => void;

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

@@ -327,6 +328,10 @@ hydrate: (dehydratedRouter: DehydratedRouter) => void;

}
type MetaOptions = keyof PickRequired<RouteMeta> extends never ? {
meta?: RouteMeta;
} : {
meta: RouteMeta;
};
type RouteOptions<TParentRoute extends AnyRoute = AnyRoute, TCustomId extends string = string, TPath extends string = string, TParentSearchSchema extends {} = {}, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = TSearchSchema, TParentParams extends AnyPathParams = {}, TParams extends Record<ParsePathParams<TPath>, any> = Record<ParsePathParams<TPath>, string>, TAllParams = TParams, TParentContext extends AnyContext = AnyContext, TAllParentContext extends AnyContext = AnyContext, TRouteContext extends AnyContext = AnyContext, TContext extends AnyContext = TRouteContext> = RouteOptionsBase<TCustomId, TPath> & FrameworkRouteOptions & {
getParentRoute: () => TParentRoute;
caseSensitive?: boolean;
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
preSearchFilters?: SearchFilter<TFullSearchSchema>[];

@@ -341,4 +346,8 @@ postSearchFilters?: SearchFilter<TFullSearchSchema>[];

}) => Promise<void> | void;
onBeforeLoadError?: (err: any) => void;
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>;
onValidateSearchError?: (err: any) => void;
onLoad?: OnLoadFn<TSearchSchema, TFullSearchSchema, TAllParams, TRouteContext, TContext>;
onLoadError?: (err: any) => void;
onError?: (err: any) => void;
onLoaded?: (matchContext: {

@@ -365,3 +374,3 @@ params: TAllParams;

})) => TRouteContext;
} & ({
} & MetaOptions & ({
parseParams?: (rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>) => TParams extends Record<string, any> ? TParams : 'parseParams must return a Record<string, any>';

@@ -545,2 +554,3 @@ stringifyParams?: (params: NoInfer<TParams>) => Record<ParsePathParams<TPath>, string>;

handleLeave: (e: any) => void;
handleTouchStart: (e: any) => void;
isActive: boolean;

@@ -566,6 +576,6 @@ disabled?: boolean;

} ? never : './' : never) | (TFrom extends `/` ? never : '../') | AllPaths;
type NavigateOptions<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '.'> = ToOptions<TRoutesInfo, TFrom, TTo> & {
type NavigateOptions<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<TRoutesInfo, TFrom, TTo> & {
replace?: boolean;
};
type ToOptions<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '.', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
type ToOptions<TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TFrom extends TRoutesInfo['routePaths'] = '/', TTo extends string = '', TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
to?: ToPathOption<TRoutesInfo, TFrom, TTo>;

@@ -590,4 +600,4 @@ hash?: Updater<string>;

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

@@ -598,3 +608,3 @@ exact?: boolean;

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

@@ -646,2 +656,2 @@ activeOptions?: ActiveOptions;

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

@@ -334,3 +334,3 @@ /**

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

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

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

@@ -389,3 +389,3 @@ }

const baseSegments = parsePathname(from);
const to = `${matchLocation.to ?? '*'}`;
const to = `${matchLocation.to ?? '$'}`;
const routeSegments = parsePathname(to);

@@ -402,3 +402,3 @@ const params = {};

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

@@ -670,3 +670,9 @@ }

this.state = this.store.state;
if (!this.#hasLoaders()) {
componentTypes.map(async type => {
const component = this.route.options[type];
if (typeof this[type] !== 'function') {
this[type] = component;
}
});
if (this.state.status === 'idle' && !this.#hasLoaders()) {
this.store.setState(s => ({

@@ -719,3 +725,3 @@ ...s,

} catch (err) {
console.error(err);
this.route.options.onValidateSearchError?.(err);
const error = new Error('Invalid search params found', {

@@ -756,2 +762,3 @@ cause: err

} catch (err) {
this.route.options.onError?.(err);
this.store.setState(s => ({

@@ -772,8 +779,2 @@ ...s,

} = info;
componentTypes.map(async type => {
const component = this.route.options[type];
if (typeof this[type] !== 'function') {
this[type] = component;
}
});

@@ -829,4 +830,3 @@ // If the match is invalid, errored or idle, trigger it to load

try {
await componentsPromise;
await dataPromise;
await Promise.all([componentsPromise, dataPromise]);
if (latestPromise = checkLatest()) return await latestPromise;

@@ -840,2 +840,4 @@ this.store.setState(s => ({

} catch (err) {
this.route.options.onLoadError?.(err);
this.route.options.onError?.(err);
this.store.setState(s => ({

@@ -1228,4 +1230,5 @@ ...s,

if (!opts?.preload) {
match.route.options.onLoadError?.(err);
match.route.options.onBeforeLoadError?.(err);
}
match.route.options.onError?.(err);
throw err;

@@ -1379,2 +1382,8 @@ }

};
const handleTouchStart = e => {
this.preloadRoute(nextOpts).catch(err => {
console.warn(err);
console.warn('Error preloading route! ☝️');
});
};
const handleEnter = e => {

@@ -1409,2 +1418,3 @@ const target = e.target || {};

handleLeave,
handleTouchStart,
isActive,

@@ -1535,3 +1545,3 @@ disabled

};
#commitLocation = location => {
#commitLocation = async location => {
const next = this.buildNext(location);

@@ -1538,0 +1548,0 @@ const id = '' + Date.now() + Math.random();

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

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

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

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

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

@@ -23,2 +23,3 @@ import { AnyRoutesInfo, DefaultRoutesInfo, RouteByPath } from './routeInfo'

handleLeave: (e: any) => void
handleTouchStart: (e: any) => void
isActive: boolean

@@ -121,5 +122,5 @@ disabled?: boolean

TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
TTo extends string = '',
> = ToOptions<TRoutesInfo, TFrom, TTo> & {
// Whether to replace the current history stack instead of pushing a new one
// `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
replace?: boolean

@@ -131,3 +132,3 @@ }

TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
TTo extends string = '',
TResolvedTo = ResolveRelativePath<TFrom, NoInfer<TTo>>,

@@ -220,3 +221,3 @@ > = {

TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
TTo extends string = '',
> =

@@ -233,3 +234,3 @@ | TTo

TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
TTo extends string = '',
> =

@@ -252,3 +253,3 @@ | TTo

TFrom extends TRoutesInfo['routePaths'] = '/',
TTo extends string = '.',
TTo extends string = '',
> = NavigateOptions<TRoutesInfo, TFrom, TTo> & {

@@ -255,0 +256,0 @@ // The standard anchor tag target attribute

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

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

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

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

@@ -175,3 +175,3 @@ }

const baseSegments = parsePathname(from)
const to = `${matchLocation.to ?? '*'}`
const to = `${matchLocation.to ?? '$'}`
const routeSegments = parsePathname(to)

@@ -196,3 +196,3 @@

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

@@ -199,0 +199,0 @@ }

import { GetFrameworkGeneric } from './frameworks'
import { ParsePathParams } from './link'
import { RouteMatch } from './routeMatch'
import { AnyRouter, RegisteredRouter, Router } from './router'
import { AnyRouter, Router } from './router'
import {

@@ -9,2 +9,3 @@ Expand,

NoInfer,
PickRequired,
PickUnsafe,

@@ -15,3 +16,3 @@ UnionToIntersection,

import { joinPaths, trimPath, trimPathRight } from './path'
import { AnyRoutesInfo, DefaultRoutesInfo } from './routeInfo'
import { DefaultRoutesInfo } from './routeInfo'

@@ -40,2 +41,10 @@ export const rootRouteId = '__root__' as const

export type MetaOptions = keyof PickRequired<RouteMeta> extends never
? {
meta?: RouteMeta
}
: {
meta: RouteMeta
}
export type RouteOptions<

@@ -63,3 +72,2 @@ TParentRoute extends AnyRoute = AnyRoute,

caseSensitive?: boolean
validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>
// Filter functions that can manipulate search params *before* they are passed to links and navigate

@@ -85,3 +93,10 @@ // calls that match this route.

}) => 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**.
// If you want to redirect due to an error, call `router.navigate()` from within this function.
// If you want to display the errorComponent, rethrow the error
onValidateSearchError?: (err: any) => void
// An asynchronous function responsible for preparing or fetching data for the route before it is rendered

@@ -95,6 +110,4 @@ onLoad?: OnLoadFn<

>
// This function will be called if the route's loader throws an error **during an attempted navigation**.
// If you want to redirect due to an error, call `router.navigate()` from within this function.
onLoadError?: (err: any) => void
onError?: (err: any) => void
// This function is called

@@ -115,3 +128,3 @@ // when moving from an inactive state to an active one. Likewise, when moving from

}) => void
// An object of whatever you want! This object is accessible anywhere matches are.
// An object of whatever you want! This object is accessible anywhere the route is
getContext?: (

@@ -131,3 +144,4 @@ opts: {

) => TRouteContext
} & (
} & MetaOptions &
(
| {

@@ -134,0 +148,0 @@ // Parse params optionally receives path params as strings and returns them in a parsed format (like a number or boolean)

@@ -97,3 +97,11 @@ import { Store } from '@tanstack/store'

if (!this.#hasLoaders()) {
componentTypes.map(async (type) => {
const component = this.route.options[type]
if (typeof this[type] !== 'function') {
this[type] = component
}
})
if (this.state.status === 'idle' && !this.#hasLoaders()) {
this.store.setState((s) => ({

@@ -156,3 +164,3 @@ ...s,

} catch (err: any) {
console.error(err)
this.route.options.onValidateSearchError?.(err)
const error = new (Error as any)('Invalid search params found', {

@@ -204,2 +212,4 @@ cause: err,

} catch (err) {
this.route.options.onError?.(err)
this.store.setState((s) => ({

@@ -217,10 +227,2 @@ ...s,

componentTypes.map(async (type) => {
const component = this.route.options[type]
if (typeof this[type] !== 'function') {
this[type] = component
}
})
// If the match is invalid, errored or idle, trigger it to load

@@ -283,4 +285,3 @@ if (this.state.status === 'pending') {

try {
await componentsPromise
await dataPromise
await Promise.all([componentsPromise, dataPromise])
if ((latestPromise = checkLatest())) return await latestPromise

@@ -294,2 +295,4 @@ this.store.setState((s) => ({

} catch (err) {
this.route.options.onLoadError?.(err)
this.route.options.onError?.(err)
this.store.setState((s) => ({

@@ -296,0 +299,0 @@ ...s,

@@ -247,2 +247,8 @@ import { Store } from '@tanstack/store'

export type RouterConstructorOptions<TRouteTree extends AnyRoute> = Omit<
RouterOptions<TRouteTree>,
'context'
> &
RouterContextOptions<TRouteTree>
export class Router<

@@ -259,6 +265,5 @@ TRouteTree extends AnyRoute = RootRoute,

options: PickAsRequired<
Omit<RouterOptions<TRouteTree>, 'context'>,
'stringifySearch' | 'parseSearch'
> &
RouterContextOptions<TRouteTree>
RouterOptions<TRouteTree>,
'stringifySearch' | 'parseSearch' | 'context'
>
history!: RouterHistory

@@ -279,3 +284,3 @@ #unsubHistory?: () => void

constructor(options?: RouterOptions<TRouteTree>) {
constructor(options?: RouterConstructorOptions<TRouteTree>) {
this.options = {

@@ -697,5 +702,7 @@ defaultPreloadDelay: 50,

if (!opts?.preload) {
match.route.options.onLoadError?.(err)
match.route.options.onBeforeLoadError?.(err)
}
match.route.options.onError?.(err)
throw err

@@ -735,3 +742,3 @@ }

TFrom extends ValidFromPath<TRoutesInfo> = '/',
TTo extends string = '.',
TTo extends string = '',
>({

@@ -776,3 +783,3 @@ from,

TFrom extends ValidFromPath<TRoutesInfo> = '/',
TTo extends string = '.',
TTo extends string = '',
TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,

@@ -817,3 +824,3 @@ >(

TFrom extends ValidFromPath<TRoutesInfo> = '/',
TTo extends string = '.',
TTo extends string = '',
>({

@@ -908,2 +915,9 @@ from,

const handleTouchStart = (e: TouchEvent) => {
this.preloadRoute(nextOpts).catch((err) => {
console.warn(err)
console.warn('Error preloading route! ☝️')
})
}
const handleEnter = (e: MouseEvent) => {

@@ -943,2 +957,3 @@ const target = (e.target || {}) as LinkCurrentTargetElement

handleLeave,
handleTouchStart,
isActive,

@@ -1132,3 +1147,5 @@ disabled,

#commitLocation = (location: BuildNextOptions & { replace?: boolean }) => {
#commitLocation = async (
location: BuildNextOptions & { replace?: boolean },
) => {
const next = this.buildNext(location)

@@ -1135,0 +1152,0 @@ const id = '' + Date.now() + Math.random()

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc