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.79 to 0.0.1-beta.81

69

build/cjs/routeMatch.js

@@ -98,3 +98,4 @@ /**

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

@@ -112,18 +113,23 @@ cause: err

} = this.#resolveSearchInfo(opts);
const routeContext = this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context: this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search
}) || {};
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext
};
return {
routeSearch,
search,
context,
routeContext
};
try {
const routeContext = this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context: this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search
}) || {};
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext
};
return {
routeSearch,
search,
context,
routeContext
};
} catch (err) {
this.route.options.onError?.(err);
throw err;
}
};

@@ -137,6 +143,7 @@ __load = async opts => {

if (router.isRedirect(err)) {
this.router.navigate(err);
if (!opts?.preload) {
this.router.navigate(err);
}
return;
}
this.route.options.onError?.(err);
this.__store.setState(s => ({

@@ -217,7 +224,25 @@ ...s,

if (router.isRedirect(err)) {
this.router.navigate(err);
if (!opts?.preload) {
this.router.navigate(err);
}
return;
}
this.route.options.onLoadError?.(err);
this.route.options.onError?.(err);
const errorHandler = this.route.options.onLoadError ?? this.route.options.onError;
try {
errorHandler?.(err);
} catch (errorHandlerErr) {
if (router.isRedirect(errorHandlerErr)) {
if (!opts?.preload) {
this.router.navigate(errorHandlerErr);
}
return;
}
this.__store.setState(s => ({
...s,
error: errorHandlerErr,
status: 'error',
updatedAt: Date.now()
}));
return;
}
this.__store.setState(s => ({

@@ -224,0 +249,0 @@ ...s,

@@ -336,16 +336,27 @@ /**

// Check each match middleware to see if the route can be accessed
await Promise.all(resolvedMatches.map(async match => {
try {
await match.route.options.beforeLoad?.({
router: this,
match
});
} catch (err) {
try {
await Promise.all(resolvedMatches.map(async match => {
try {
await match.route.options.beforeLoad?.({
router: this,
match
});
} catch (err) {
if (isRedirect(err)) {
throw err;
}
const errorHandler = match.route.options.onBeforeLoadError ?? match.route.options.onError;
errorHandler?.(err);
throw err;
}
}));
} catch (err) {
if (isRedirect(err)) {
if (!opts?.preload) {
match.route.options.onBeforeLoadError?.(err);
this.navigate(err);
}
match.route.options.onError?.(err);
throw err;
return;
}
}));
throw err;
}
const matchPromises = resolvedMatches.map(async (match, index) => {

@@ -352,0 +363,0 @@ const parentMatch = resolvedMatches[index - 1];

@@ -1009,16 +1009,27 @@ /**

// Check each match middleware to see if the route can be accessed
await Promise.all(resolvedMatches.map(async match => {
try {
await match.route.options.beforeLoad?.({
router: this,
match
});
} catch (err) {
try {
await Promise.all(resolvedMatches.map(async match => {
try {
await match.route.options.beforeLoad?.({
router: this,
match
});
} catch (err) {
if (isRedirect(err)) {
throw err;
}
const errorHandler = match.route.options.onBeforeLoadError ?? match.route.options.onError;
errorHandler?.(err);
throw err;
}
}));
} catch (err) {
if (isRedirect(err)) {
if (!opts?.preload) {
match.route.options.onBeforeLoadError?.(err);
this.navigate(err);
}
match.route.options.onError?.(err);
throw err;
return;
}
}));
throw err;
}
const matchPromises = resolvedMatches.map(async (match, index) => {

@@ -1501,3 +1512,4 @@ const parentMatch = resolvedMatches[index - 1];

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

@@ -1515,18 +1527,23 @@ cause: err

} = this.#resolveSearchInfo(opts);
const routeContext = this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context: this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search
}) || {};
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext
};
return {
routeSearch,
search,
context,
routeContext
};
try {
const routeContext = this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context: this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search
}) || {};
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext
};
return {
routeSearch,
search,
context,
routeContext
};
} catch (err) {
this.route.options.onError?.(err);
throw err;
}
};

@@ -1540,6 +1557,7 @@ __load = async opts => {

if (isRedirect(err)) {
this.router.navigate(err);
if (!opts?.preload) {
this.router.navigate(err);
}
return;
}
this.route.options.onError?.(err);
this.__store.setState(s => ({

@@ -1620,7 +1638,25 @@ ...s,

if (isRedirect(err)) {
this.router.navigate(err);
if (!opts?.preload) {
this.router.navigate(err);
}
return;
}
this.route.options.onLoadError?.(err);
this.route.options.onError?.(err);
const errorHandler = this.route.options.onLoadError ?? this.route.options.onError;
try {
errorHandler?.(err);
} catch (errorHandlerErr) {
if (isRedirect(errorHandlerErr)) {
if (!opts?.preload) {
this.router.navigate(errorHandlerErr);
}
return;
}
this.__store.setState(s => ({
...s,
error: errorHandlerErr,
status: 'error',
updatedAt: Date.now()
}));
return;
}
this.__store.setState(s => ({

@@ -1627,0 +1663,0 @@ ...s,

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

"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "9710-32"
"uid": "298b-32"
},
{
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"uid": "9710-34"
"uid": "298b-34"
}

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

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

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

"name": "store/build/esm/index.js",
"uid": "9710-46"
"uid": "298b-46"
}

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

"nodeParts": {
"9710-32": {
"298b-32": {
"renderedLength": 199,
"gzipLength": 134,
"brotliLength": 0,
"mainUid": "9710-31"
"mainUid": "298b-31"
},
"9710-34": {
"298b-34": {
"renderedLength": 48,
"gzipLength": 65,
"brotliLength": 0,
"mainUid": "9710-33"
"mainUid": "298b-33"
},
"9710-36": {
"298b-36": {
"renderedLength": 5639,
"gzipLength": 1385,
"brotliLength": 0,
"mainUid": "9710-35"
"mainUid": "298b-35"
},
"9710-38": {
"298b-38": {
"renderedLength": 2821,
"gzipLength": 990,
"brotliLength": 0,
"mainUid": "9710-37"
"mainUid": "298b-37"
},
"9710-40": {
"298b-40": {
"renderedLength": 5705,
"gzipLength": 1352,
"brotliLength": 0,
"mainUid": "9710-39"
"mainUid": "298b-39"
},
"9710-42": {
"298b-42": {
"renderedLength": 1395,
"gzipLength": 558,
"brotliLength": 0,
"mainUid": "9710-41"
"mainUid": "298b-41"
},
"9710-44": {
"298b-44": {
"renderedLength": 3715,
"gzipLength": 1056,
"brotliLength": 0,
"mainUid": "9710-43"
"mainUid": "298b-43"
},
"9710-46": {
"298b-46": {
"renderedLength": 1384,
"gzipLength": 502,
"brotliLength": 0,
"mainUid": "9710-45"
"mainUid": "298b-45"
},
"9710-48": {
"298b-48": {
"renderedLength": 1387,
"gzipLength": 483,
"brotliLength": 0,
"mainUid": "9710-47"
"mainUid": "298b-47"
},
"9710-50": {
"renderedLength": 24817,
"gzipLength": 5702,
"298b-50": {
"renderedLength": 25117,
"gzipLength": 5749,
"brotliLength": 0,
"mainUid": "9710-49"
"mainUid": "298b-49"
},
"9710-52": {
"renderedLength": 6843,
"gzipLength": 1704,
"298b-52": {
"renderedLength": 7647,
"gzipLength": 1795,
"brotliLength": 0,
"mainUid": "9710-51"
"mainUid": "298b-51"
},
"9710-54": {
"298b-54": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "9710-53"
"mainUid": "298b-53"
}
},
"nodeMetas": {
"9710-31": {
"298b-31": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "9710-32"
"index.production.js": "298b-32"
},

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

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

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

{
"uid": "9710-53"
"uid": "298b-53"
}
]
},
"9710-35": {
"298b-35": {
"id": "/packages/router/src/history.ts",
"moduleParts": {
"index.production.js": "9710-36"
"index.production.js": "298b-36"
},

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

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

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

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

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

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

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

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

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

{
"uid": "9710-53"
"uid": "298b-53"
}
]
},
"9710-45": {
"298b-45": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "9710-46"
"index.production.js": "298b-46"
},

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

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

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

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

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

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

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

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

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

},
"9710-55": {
"298b-55": {
"id": "/packages/router/src/frameworks.ts",

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

{
"uid": "9710-53"
"uid": "298b-53"
}
]
},
"9710-56": {
"298b-56": {
"id": "/packages/router/src/link.ts",

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

{
"uid": "9710-53"
"uid": "298b-53"
}
]
},
"9710-57": {
"298b-57": {
"id": "/packages/router/src/routeInfo.ts",

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

{
"uid": "9710-53"
"uid": "298b-53"
}

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

@@ -166,6 +166,2 @@ /**

}) => Promise<any>;
interface LoaderState<TFullSearchSchema extends AnySearchSchema = {}, TAllParams extends AnyPathParams = {}> {
loadedAt: number;
loaderContext: LoaderContext<TFullSearchSchema, TAllParams>;
}
interface RouterStore<TRoutesInfo extends AnyRoutesInfo = AnyRoutesInfo, TState extends LocationState = LocationState> {

@@ -671,2 +667,2 @@ status: 'idle' | 'pending';

export { ActiveOptions, AnyContext, AnyLoaderData, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouter, AnyRoutesInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, ContextOptions, 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, MergeUnion, MetaOptions, NavigateOptions, NoInfer, OnLoadFn, ParentParams, ParsePathParams, ParseRoute, ParseRouteChild, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamMask, PathParamOptions, PendingRouteMatchInfo, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, Redirect, Register, RegisteredRouter, RegisteredRoutesInfo, RelativeToPathAutoComplete, ResolveFullSearchSchema, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteContext, 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, isRedirect, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight };
export { ActiveOptions, AnyContext, AnyLoaderData, AnyPathParams, AnyRedirect, AnyRootRoute, AnyRoute, AnyRouteMatch, AnyRouter, AnyRoutesInfo, AnySearchSchema, BuildNextOptions, CheckId, CheckIdError, CheckPath, CheckPathError, CheckRelativePath, ContextOptions, DeepAwaited, DefaultRoutesInfo, DefinedPathParamWarning, DehydratedRouter, DehydratedRouterState, Expand, FilterRoutesFn, FrameworkGenerics, FrameworkRouteOptions, FromLocation, GetFrameworkGeneric, InferFullSearchSchema, IsAny, IsAnyBoolean, IsKnown, LinkInfo, LinkOptions, ListenerFn, LoaderContext, LocationState, MatchCache, MatchCacheEntry, MatchLocation, MatchRouteOptions, MergeUnion, MetaOptions, NavigateOptions, NoInfer, OnLoadFn, ParentParams, ParsePathParams, ParseRoute, ParseRouteChild, ParseRouteChildren, ParsedLocation, ParsedPath, PathParamMask, PathParamOptions, PendingRouteMatchInfo, PickAsPartial, PickAsRequired, PickExclude, PickExtra, PickExtract, PickRequired, PickUnsafe, Redirect, Register, RegisteredRouter, RegisteredRoutesInfo, RelativeToPathAutoComplete, ResolveFullSearchSchema, ResolveRelativePath, RootRoute, RootRouteId, Route, RouteById, RouteByPath, RouteContext, 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, isRedirect, joinPaths, last, matchByPath, matchPathname, parsePathname, parseSearchWith, partialDeepEqual, pick, redirect, replaceEqualDeep, resolvePath, rootRouteId, stringifySearchWith, trimPath, trimPathLeft, trimPathRight };

@@ -1087,16 +1087,27 @@ /**

// Check each match middleware to see if the route can be accessed
await Promise.all(resolvedMatches.map(async match => {
try {
await match.route.options.beforeLoad?.({
router: this,
match
});
} catch (err) {
try {
await Promise.all(resolvedMatches.map(async match => {
try {
await match.route.options.beforeLoad?.({
router: this,
match
});
} catch (err) {
if (isRedirect(err)) {
throw err;
}
const errorHandler = match.route.options.onBeforeLoadError ?? match.route.options.onError;
errorHandler?.(err);
throw err;
}
}));
} catch (err) {
if (isRedirect(err)) {
if (!opts?.preload) {
match.route.options.onBeforeLoadError?.(err);
this.navigate(err);
}
match.route.options.onError?.(err);
throw err;
return;
}
}));
throw err;
}
const matchPromises = resolvedMatches.map(async (match, index) => {

@@ -1579,3 +1590,4 @@ const parentMatch = resolvedMatches[index - 1];

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

@@ -1593,18 +1605,23 @@ cause: err

} = this.#resolveSearchInfo(opts);
const routeContext = this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context: this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search
}) || {};
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext
};
return {
routeSearch,
search,
context,
routeContext
};
try {
const routeContext = this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context: this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search
}) || {};
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext
};
return {
routeSearch,
search,
context,
routeContext
};
} catch (err) {
this.route.options.onError?.(err);
throw err;
}
};

@@ -1618,6 +1635,7 @@ __load = async opts => {

if (isRedirect(err)) {
this.router.navigate(err);
if (!opts?.preload) {
this.router.navigate(err);
}
return;
}
this.route.options.onError?.(err);
this.__store.setState(s => ({

@@ -1698,7 +1716,25 @@ ...s,

if (isRedirect(err)) {
this.router.navigate(err);
if (!opts?.preload) {
this.router.navigate(err);
}
return;
}
this.route.options.onLoadError?.(err);
this.route.options.onError?.(err);
const errorHandler = this.route.options.onLoadError ?? this.route.options.onError;
try {
errorHandler?.(err);
} catch (errorHandlerErr) {
if (isRedirect(errorHandlerErr)) {
if (!opts?.preload) {
this.router.navigate(errorHandlerErr);
}
return;
}
this.__store.setState(s => ({
...s,
error: errorHandlerErr,
status: 'error',
updatedAt: Date.now()
}));
return;
}
this.__store.setState(s => ({

@@ -1705,0 +1741,0 @@ ...s,

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

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

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

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

"tiny-warning": "^1.0.3",
"@tanstack/store": "0.0.1-beta.62"
"@tanstack/store": "0.0.1-beta.81"
}
}

@@ -167,3 +167,4 @@ import { Store } from '@tanstack/store'

this.route.options.onValidateSearchError?.(err)
const errorHandler = this.route.options.onValidateSearchError ?? this.route.options.onError
errorHandler?.(err)
const error = new (Error as any)('Invalid search params found', {

@@ -181,21 +182,26 @@ cause: err,

const routeContext =
this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context:
this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search,
}) || ({} as any)
try {
const routeContext =
this.route.options.getContext?.({
parentContext: this.parentMatch?.routeContext ?? {},
context:
this.parentMatch?.context ?? this.router?.options.context ?? {},
params: this.params,
search,
}) || ({} as any)
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext,
} as any
return {
routeSearch,
search,
context,
routeContext,
const context = {
...(this.parentMatch?.context ?? this.router?.options.context),
...routeContext,
} as any
return {
routeSearch,
search,
context,
routeContext,
}
} catch (err) {
this.route.options.onError?.(err)
throw err
}

@@ -217,8 +223,8 @@ }

if (isRedirect(err)) {
this.router.navigate(err as any)
if (!opts?.preload) {
this.router.navigate(err as any)
}
return
}
this.route.options.onError?.(err)
this.__store.setState((s) => ({

@@ -303,7 +309,28 @@ ...s,

if (isRedirect(err)) {
this.router.navigate(err as any)
if (!opts?.preload) {
this.router.navigate(err as any)
}
return
}
this.route.options.onLoadError?.(err)
this.route.options.onError?.(err)
const errorHandler = this.route.options.onLoadError ?? this.route.options.onError
try {
errorHandler?.(err)
} catch (errorHandlerErr) {
if (isRedirect(errorHandlerErr)) {
if (!opts?.preload) {
this.router.navigate(errorHandlerErr as any)
}
return
}
this.__store.setState((s) => ({
...s,
error: errorHandlerErr,
status: 'error',
updatedAt: Date.now(),
}))
return
}
this.__store.setState((s) => ({

@@ -310,0 +337,0 @@ ...s,

@@ -28,6 +28,3 @@ import { Store } from '@tanstack/store'

Route,
AnyPathParams,
AnySearchSchema,
LoaderContext,
SearchFilter,
AnyRoute,

@@ -37,8 +34,3 @@ RootRoute,

} from './route'
import {
RoutesInfo,
AnyRoutesInfo,
RoutesById,
DefaultRoutesInfo,
} from './routeInfo'
import { RoutesInfo, AnyRoutesInfo, RoutesById } from './routeInfo'
import { AnyRouteMatch, RouteMatch, RouteMatchStore } from './routeMatch'

@@ -52,3 +44,2 @@ import { defaultParseSearch, defaultStringifySearch } from './searchParams'

PickAsRequired,
PickRequired,
Timeout,

@@ -64,3 +55,2 @@ Updater,

} from './history'
import warning from 'tiny-warning'

@@ -152,10 +142,2 @@ export interface Register {

export interface LoaderState<
TFullSearchSchema extends AnySearchSchema = {},
TAllParams extends AnyPathParams = {},
> {
loadedAt: number
loaderContext: LoaderContext<TFullSearchSchema, TAllParams>
}
export interface RouterStore<

@@ -680,21 +662,31 @@ TRoutesInfo extends AnyRoutesInfo = AnyRoutesInfo,

// Check each match middleware to see if the route can be accessed
await Promise.all(
resolvedMatches.map(async (match) => {
try {
await match.route.options.beforeLoad?.({
router: this as any,
match,
})
} catch (err) {
if (!opts?.preload) {
match.route.options.onBeforeLoadError?.(err)
try {
await Promise.all(
resolvedMatches.map(async (match) => {
try {
await match.route.options.beforeLoad?.({
router: this as any,
match,
})
} catch (err) {
if (isRedirect(err)) {
throw err
}
const errorHandler = match.route.options.onBeforeLoadError ?? match.route.options.onError
errorHandler?.(err)
throw err
}
}),
)
} catch (err) {
if (isRedirect(err)) {
if (!opts?.preload) {
this.navigate(err as any)
}
return
}
match.route.options.onError?.(err)
throw err
}
throw err
}
}),
)
const matchPromises = resolvedMatches.map(async (match, index) => {

@@ -701,0 +693,0 @@ const parentMatch = resolvedMatches[index - 1]

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