Socket
Socket
Sign inDemoInstall

@tanstack/router-core

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/router-core - npm Package Compare versions

Comparing version 0.0.1-alpha.9 to 0.0.1-alpha.10

18

build/cjs/packages/router-core/src/routeMatch.js

@@ -123,3 +123,3 @@ /**

hasLoaders: () => {
return !!(route.options.loader || route.options.import || elementTypes.some(d => typeof route.options[d] === 'function'));
return !!(route.options.loader || elementTypes.some(d => typeof route.options[d] === 'function'));
},

@@ -145,17 +145,3 @@ load: async opts => {

const loaderPromise = (async () => {
const importer = routeMatch.options.import; // First, run any importers
if (importer) {
routeMatch.__.importPromise = importer({
params: routeMatch.params // search: routeMatch.search,
}).then(imported => {
routeMatch.__ = _rollupPluginBabelHelpers["extends"]({}, routeMatch.__, imported);
});
} // Wait for the importer to finish before
// attempting to load elements and data
await routeMatch.__.importPromise; // Next, load the elements and data in parallel
// Load the elements and data in parallel
routeMatch.__.elementsPromise = (async () => {

@@ -162,0 +148,0 @@ // then run all element and data loaders in parallel

346

build/cjs/packages/router-core/src/router.js

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

let router = {
history,
options: originalOptions,

@@ -89,3 +90,3 @@ listeners: [],

mount: () => {
const next = router.buildLocation({
const next = router.__.buildLocation({
to: '.',

@@ -97,4 +98,5 @@ search: true,

if (next.href !== router.location.href) {
router.commitLocation(next, true);
router.__.commitLocation(next, true);
} else {

@@ -105,3 +107,3 @@ router.loadLocation();

const unsub = history.listen(event => {
router.loadLocation(router.parseLocation(event.location, router.location));
router.loadLocation(router.__.parseLocation(event.location, router.location));
}); // addEventListener does not exist in React Native, but window does

@@ -136,3 +138,3 @@ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

router.routesById = {};
router.routeTree = router.buildRouteTree(routeConfig);
router.routeTree = router.__.buildRouteTree(routeConfig);
}

@@ -142,160 +144,2 @@

},
buildRouteTree: rootRouteConfig => {
const recurseRoutes = (routeConfigs, parent) => {
return routeConfigs.map(routeConfig => {
const routeOptions = routeConfig.options;
const route$1 = route.createRoute(routeConfig, routeOptions, parent, router); // {
// pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
// pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
// }
const existingRoute = router.routesById[route$1.routeId];
if (existingRoute) {
if (process.env.NODE_ENV !== 'production') {
console.warn("Duplicate routes found with id: " + String(route$1.routeId), router.routesById, route$1);
}
throw new Error();
}
router.routesById[route$1.routeId] = route$1;
const children = routeConfig.children;
route$1.childRoutes = children != null && children.length ? recurseRoutes(children, route$1) : undefined;
return route$1;
});
};
const routes = recurseRoutes([rootRouteConfig]);
return routes[0];
},
parseLocation: (location, previousLocation) => {
var _location$hash$split$;
const parsedSearch = router.options.parseSearch(location.search);
return {
pathname: location.pathname,
searchStr: location.search,
search: utils.replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
hash: (_location$hash$split$ = location.hash.split('#').reverse()[0]) != null ? _location$hash$split$ : '',
href: "" + location.pathname + location.search + location.hash,
state: location.state,
key: location.key
};
},
buildLocation: function buildLocation(dest) {
var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
if (dest === void 0) {
dest = {};
}
// const resolvedFrom: Location = {
// ...router.location,
const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
let pathname = path.resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
const fromMatches = router.matchRoutes(router.location.pathname, {
strictParseParams: true
});
const toMatches = router.matchRoutes(pathname);
const prevParams = _rollupPluginBabelHelpers["extends"]({}, (_last = utils.last(fromMatches)) == null ? void 0 : _last.params);
let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : utils.functionalUpdate(dest.params, prevParams);
if (nextParams) {
toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
Object.assign({}, nextParams, fn(nextParams));
});
}
pathname = path.interpolatePath(pathname, nextParams != null ? nextParams : {}); // Pre filters first
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.location.search) : router.location.search; // Then the link/navigate function
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
: dest.search ? (_functionalUpdate = utils.functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
: (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
: {}; // Then post filters
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
const search = utils.replaceEqualDeep(router.location.search, postFilteredSearch);
const searchStr = router.options.stringifySearch(search);
let hash = dest.hash === true ? router.location.hash : utils.functionalUpdate(dest.hash, router.location.hash);
hash = hash ? "#" + hash : '';
return {
pathname,
search,
searchStr,
state: router.location.state,
hash,
href: "" + pathname + searchStr + hash,
key: dest.key
};
},
commitLocation: (next, replace) => {
const id = '' + Date.now() + Math.random();
if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
let nextAction = 'replace';
if (!replace) {
nextAction = 'push';
}
const isSameUrl = router.parseLocation(history.location).href === next.href;
if (isSameUrl && !next.key) {
nextAction = 'replace';
}
if (nextAction === 'replace') {
history.replace({
pathname: next.pathname,
hash: next.hash,
search: next.searchStr
}, {
id
});
} else {
history.push({
pathname: next.pathname,
hash: next.hash,
search: next.searchStr
}, {
id
});
}
router.navigationPromise = new Promise(resolve => {
const previousNavigationResolve = router.resolveNavigation;
router.resolveNavigation = () => {
previousNavigationResolve();
resolve();
};
});
return router.navigationPromise;
},
buildNext: opts => {
const next = router.buildLocation(opts);
const matches = router.matchRoutes(next.pathname);
const __preSearchFilters = matches.map(match => {
var _match$options$preSea;
return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
}).flat().filter(Boolean);
const __postSearchFilters = matches.map(match => {
var _match$options$postSe;
return (_match$options$postSe = match.options.postSearchFilters) != null ? _match$options$postSe : [];
}).flat().filter(Boolean);
return router.buildLocation(_rollupPluginBabelHelpers["extends"]({}, opts, {
__preSearchFilters,
__postSearchFilters
}));
},
cancelMatches: () => {

@@ -403,2 +247,3 @@ var _router$state$pending, _router$state$pending2;

});
delete router.matchCache[d.matchId];
});

@@ -612,3 +457,3 @@

},
reload: () => router._navigate({
reload: () => router.__.navigate({
fromCurrent: true,

@@ -646,6 +491,2 @@ replace: true,

},
_navigate: location => {
const next = router.buildNext(location);
return router.commitLocation(next, location.replace);
},
navigate: async _ref8 => {

@@ -674,3 +515,3 @@ let {

tinyInvariant["default"](!isExternal, 'Attempting to navigate to external url with router.navigate!');
return router._navigate({
return router.__.navigate({
from: fromString,

@@ -747,3 +588,3 @@ to: toString,

router._navigate(nextOpts);
router.__.navigate(nextOpts);
}

@@ -799,5 +640,170 @@ }; // The click handler

};
},
buildNext: opts => {
const next = router.__.buildLocation(opts);
const matches = router.matchRoutes(next.pathname);
const __preSearchFilters = matches.map(match => {
var _match$options$preSea;
return (_match$options$preSea = match.options.preSearchFilters) != null ? _match$options$preSea : [];
}).flat().filter(Boolean);
const __postSearchFilters = matches.map(match => {
var _match$options$postSe;
return (_match$options$postSe = match.options.postSearchFilters) != null ? _match$options$postSe : [];
}).flat().filter(Boolean);
return router.__.buildLocation(_rollupPluginBabelHelpers["extends"]({}, opts, {
__preSearchFilters,
__postSearchFilters
}));
},
__: {
buildRouteTree: rootRouteConfig => {
const recurseRoutes = (routeConfigs, parent) => {
return routeConfigs.map(routeConfig => {
const routeOptions = routeConfig.options;
const route$1 = route.createRoute(routeConfig, routeOptions, parent, router); // {
// pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
// pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
// }
const existingRoute = router.routesById[route$1.routeId];
if (existingRoute) {
if (process.env.NODE_ENV !== 'production') {
console.warn("Duplicate routes found with id: " + String(route$1.routeId), router.routesById, route$1);
}
throw new Error();
}
router.routesById[route$1.routeId] = route$1;
const children = routeConfig.children;
route$1.childRoutes = children != null && children.length ? recurseRoutes(children, route$1) : undefined;
return route$1;
});
};
const routes = recurseRoutes([rootRouteConfig]);
return routes[0];
},
parseLocation: (location, previousLocation) => {
var _location$hash$split$;
const parsedSearch = router.options.parseSearch(location.search);
return {
pathname: location.pathname,
searchStr: location.search,
search: utils.replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
hash: (_location$hash$split$ = location.hash.split('#').reverse()[0]) != null ? _location$hash$split$ : '',
href: "" + location.pathname + location.search + location.hash,
state: location.state,
key: location.key
};
},
navigate: location => {
const next = router.buildNext(location);
return router.__.commitLocation(next, location.replace);
},
buildLocation: function buildLocation(dest) {
var _dest$from, _router$basepath, _dest$to, _last, _dest$params, _dest$__preSearchFilt, _functionalUpdate, _dest$__preSearchFilt2, _dest$__postSearchFil;
if (dest === void 0) {
dest = {};
}
// const resolvedFrom: Location = {
// ...router.location,
const fromPathname = dest.fromCurrent ? router.location.pathname : (_dest$from = dest.from) != null ? _dest$from : router.location.pathname;
let pathname = path.resolvePath((_router$basepath = router.basepath) != null ? _router$basepath : '/', fromPathname, "" + ((_dest$to = dest.to) != null ? _dest$to : '.'));
const fromMatches = router.matchRoutes(router.location.pathname, {
strictParseParams: true
});
const toMatches = router.matchRoutes(pathname);
const prevParams = _rollupPluginBabelHelpers["extends"]({}, (_last = utils.last(fromMatches)) == null ? void 0 : _last.params);
let nextParams = ((_dest$params = dest.params) != null ? _dest$params : true) === true ? prevParams : utils.functionalUpdate(dest.params, prevParams);
if (nextParams) {
toMatches.map(d => d.options.stringifyParams).filter(Boolean).forEach(fn => {
Object.assign({}, nextParams, fn(nextParams));
});
}
pathname = path.interpolatePath(pathname, nextParams != null ? nextParams : {}); // Pre filters first
const preFilteredSearch = (_dest$__preSearchFilt = dest.__preSearchFilters) != null && _dest$__preSearchFilt.length ? dest.__preSearchFilters.reduce((prev, next) => next(prev), router.location.search) : router.location.search; // Then the link/navigate function
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
: dest.search ? (_functionalUpdate = utils.functionalUpdate(dest.search, preFilteredSearch)) != null ? _functionalUpdate : {} // Updater
: (_dest$__preSearchFilt2 = dest.__preSearchFilters) != null && _dest$__preSearchFilt2.length ? preFilteredSearch // Preserve resolvedFrom filters
: {}; // Then post filters
const postFilteredSearch = (_dest$__postSearchFil = dest.__postSearchFilters) != null && _dest$__postSearchFil.length ? dest.__postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
const search = utils.replaceEqualDeep(router.location.search, postFilteredSearch);
const searchStr = router.options.stringifySearch(search);
let hash = dest.hash === true ? router.location.hash : utils.functionalUpdate(dest.hash, router.location.hash);
hash = hash ? "#" + hash : '';
return {
pathname,
search,
searchStr,
state: router.location.state,
hash,
href: "" + pathname + searchStr + hash,
key: dest.key
};
},
commitLocation: (next, replace) => {
const id = '' + Date.now() + Math.random();
if (router.navigateTimeout) clearTimeout(router.navigateTimeout);
let nextAction = 'replace';
if (!replace) {
nextAction = 'push';
}
const isSameUrl = router.__.parseLocation(history.location).href === next.href;
if (isSameUrl && !next.key) {
nextAction = 'replace';
}
if (nextAction === 'replace') {
history.replace({
pathname: next.pathname,
hash: next.hash,
search: next.searchStr
}, {
id
});
} else {
history.push({
pathname: next.pathname,
hash: next.hash,
search: next.searchStr
}, {
id
});
}
router.navigationPromise = new Promise(resolve => {
const previousNavigationResolve = router.resolveNavigation;
router.resolveNavigation = () => {
previousNavigationResolve();
resolve();
};
});
return router.navigationPromise;
}
}
};
router.location = router.parseLocation(history.location);
router.location = router.__.parseLocation(history.location);
router.state.location = router.location;

@@ -804,0 +810,0 @@ router.update(userOptions); // Allow frameworks to hook into the router creation

@@ -14,11 +14,11 @@ {

"name": "@babel/runtime/helpers/esm/extends.js",
"uid": "72d9-30"
"uid": "55de-30"
},
{
"name": "history/index.js",
"uid": "72d9-32"
"uid": "55de-32"
},
{
"name": "tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "72d9-34"
"uid": "55de-34"
}

@@ -31,35 +31,35 @@ ]

{
"uid": "72d9-36",
"uid": "55de-36",
"name": "utils.ts"
},
{
"uid": "72d9-38",
"uid": "55de-38",
"name": "path.ts"
},
{
"uid": "72d9-40",
"uid": "55de-40",
"name": "qss.ts"
},
{
"uid": "72d9-44",
"uid": "55de-44",
"name": "route.ts"
},
{
"uid": "72d9-46",
"uid": "55de-46",
"name": "routeConfig.ts"
},
{
"uid": "72d9-48",
"uid": "55de-48",
"name": "routeMatch.ts"
},
{
"uid": "72d9-50",
"uid": "55de-50",
"name": "searchParams.ts"
},
{
"uid": "72d9-52",
"uid": "55de-52",
"name": "router.ts"
},
{
"uid": "72d9-54",
"uid": "55de-54",
"name": "index.ts"

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

{
"uid": "72d9-42",
"uid": "55de-42",
"name": "\u0000rollupPluginBabelHelpers.js"

@@ -80,86 +80,86 @@ }

"nodeParts": {
"72d9-30": {
"55de-30": {
"renderedLength": 437,
"gzipLength": 243,
"brotliLength": 0,
"mainUid": "72d9-29"
"mainUid": "55de-29"
},
"72d9-32": {
"55de-32": {
"renderedLength": 20630,
"gzipLength": 3800,
"brotliLength": 0,
"mainUid": "72d9-31"
"mainUid": "55de-31"
},
"72d9-34": {
"55de-34": {
"renderedLength": 181,
"gzipLength": 129,
"brotliLength": 0,
"mainUid": "72d9-33"
"mainUid": "55de-33"
},
"72d9-36": {
"55de-36": {
"renderedLength": 2334,
"gzipLength": 933,
"brotliLength": 0,
"mainUid": "72d9-35"
"mainUid": "55de-35"
},
"72d9-38": {
"55de-38": {
"renderedLength": 5496,
"gzipLength": 1394,
"brotliLength": 0,
"mainUid": "72d9-37"
"mainUid": "55de-37"
},
"72d9-40": {
"55de-40": {
"renderedLength": 1277,
"gzipLength": 544,
"brotliLength": 0,
"mainUid": "72d9-39"
"mainUid": "55de-39"
},
"72d9-42": {
"55de-42": {
"renderedLength": 431,
"gzipLength": 240,
"brotliLength": 0,
"mainUid": "72d9-41"
"mainUid": "55de-41"
},
"72d9-44": {
"55de-44": {
"renderedLength": 2922,
"gzipLength": 877,
"brotliLength": 0,
"mainUid": "72d9-43"
"mainUid": "55de-43"
},
"72d9-46": {
"55de-46": {
"renderedLength": 1416,
"gzipLength": 490,
"brotliLength": 0,
"mainUid": "72d9-45"
"mainUid": "55de-45"
},
"72d9-48": {
"renderedLength": 8908,
"gzipLength": 2111,
"55de-48": {
"renderedLength": 8366,
"gzipLength": 1974,
"brotliLength": 0,
"mainUid": "72d9-47"
"mainUid": "55de-47"
},
"72d9-50": {
"55de-50": {
"renderedLength": 1262,
"gzipLength": 479,
"brotliLength": 0,
"mainUid": "72d9-49"
"mainUid": "55de-49"
},
"72d9-52": {
"renderedLength": 28505,
"gzipLength": 6469,
"55de-52": {
"renderedLength": 28853,
"gzipLength": 6508,
"brotliLength": 0,
"mainUid": "72d9-51"
"mainUid": "55de-51"
},
"72d9-54": {
"55de-54": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "72d9-53"
"mainUid": "55de-53"
}
},
"nodeMetas": {
"72d9-29": {
"55de-29": {
"id": "/node_modules/@babel/runtime/helpers/esm/extends.js",
"moduleParts": {
"index.production.js": "72d9-30"
"index.production.js": "55de-30"
},

@@ -169,14 +169,14 @@ "imported": [],

{
"uid": "72d9-31"
"uid": "55de-31"
}
]
},
"72d9-31": {
"55de-31": {
"id": "/node_modules/history/index.js",
"moduleParts": {
"index.production.js": "72d9-32"
"index.production.js": "55de-32"
},
"imported": [
{
"uid": "72d9-29"
"uid": "55de-29"
}

@@ -186,13 +186,13 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-51"
"uid": "55de-51"
}
]
},
"72d9-33": {
"55de-33": {
"id": "/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "72d9-34"
"index.production.js": "55de-34"
},

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

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-51"
"uid": "55de-51"
}
]
},
"72d9-35": {
"55de-35": {
"id": "/packages/router-core/src/utils.ts",
"moduleParts": {
"index.production.js": "72d9-36"
"index.production.js": "55de-36"
},

@@ -218,26 +218,26 @@ "imported": [],

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-37"
"uid": "55de-37"
},
{
"uid": "72d9-43"
"uid": "55de-43"
},
{
"uid": "72d9-47"
"uid": "55de-47"
},
{
"uid": "72d9-51"
"uid": "55de-51"
}
]
},
"72d9-37": {
"55de-37": {
"id": "/packages/router-core/src/path.ts",
"moduleParts": {
"index.production.js": "72d9-38"
"index.production.js": "55de-38"
},
"imported": [
{
"uid": "72d9-35"
"uid": "55de-35"
}

@@ -247,16 +247,16 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-45"
"uid": "55de-45"
},
{
"uid": "72d9-51"
"uid": "55de-51"
}
]
},
"72d9-39": {
"55de-39": {
"id": "/packages/router-core/src/qss.ts",
"moduleParts": {
"index.production.js": "72d9-40"
"index.production.js": "55de-40"
},

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

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-49"
"uid": "55de-49"
}
]
},
"72d9-41": {
"55de-41": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "72d9-42"
"index.production.js": "55de-42"
},

@@ -282,26 +282,26 @@ "imported": [],

{
"uid": "72d9-43"
"uid": "55de-43"
},
{
"uid": "72d9-47"
"uid": "55de-47"
},
{
"uid": "72d9-51"
"uid": "55de-51"
},
{
"uid": "72d9-49"
"uid": "55de-49"
}
]
},
"72d9-43": {
"55de-43": {
"id": "/packages/router-core/src/route.ts",
"moduleParts": {
"index.production.js": "72d9-44"
"index.production.js": "55de-44"
},
"imported": [
{
"uid": "72d9-41"
"uid": "55de-41"
},
{
"uid": "72d9-35"
"uid": "55de-35"
}

@@ -311,17 +311,17 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-51"
"uid": "55de-51"
}
]
},
"72d9-45": {
"55de-45": {
"id": "/packages/router-core/src/routeConfig.ts",
"moduleParts": {
"index.production.js": "72d9-46"
"index.production.js": "55de-46"
},
"imported": [
{
"uid": "72d9-37"
"uid": "55de-37"
}

@@ -331,17 +331,17 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
}
]
},
"72d9-47": {
"55de-47": {
"id": "/packages/router-core/src/routeMatch.ts",
"moduleParts": {
"index.production.js": "72d9-48"
"index.production.js": "55de-48"
},
"imported": [
{
"uid": "72d9-41"
"uid": "55de-41"
},
{
"uid": "72d9-35"
"uid": "55de-35"
}

@@ -351,20 +351,20 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-51"
"uid": "55de-51"
}
]
},
"72d9-49": {
"55de-49": {
"id": "/packages/router-core/src/searchParams.ts",
"moduleParts": {
"index.production.js": "72d9-50"
"index.production.js": "55de-50"
},
"imported": [
{
"uid": "72d9-41"
"uid": "55de-41"
},
{
"uid": "72d9-39"
"uid": "55de-39"
}

@@ -374,38 +374,38 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-51"
"uid": "55de-51"
}
]
},
"72d9-51": {
"55de-51": {
"id": "/packages/router-core/src/router.ts",
"moduleParts": {
"index.production.js": "72d9-52"
"index.production.js": "55de-52"
},
"imported": [
{
"uid": "72d9-41"
"uid": "55de-41"
},
{
"uid": "72d9-31"
"uid": "55de-31"
},
{
"uid": "72d9-33"
"uid": "55de-33"
},
{
"uid": "72d9-37"
"uid": "55de-37"
},
{
"uid": "72d9-43"
"uid": "55de-43"
},
{
"uid": "72d9-47"
"uid": "55de-47"
},
{
"uid": "72d9-49"
"uid": "55de-49"
},
{
"uid": "72d9-35"
"uid": "55de-35"
}

@@ -415,53 +415,53 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
}
]
},
"72d9-53": {
"55de-53": {
"id": "/packages/router-core/src/index.ts",
"moduleParts": {
"index.production.js": "72d9-54"
"index.production.js": "55de-54"
},
"imported": [
{
"uid": "72d9-31"
"uid": "55de-31"
},
{
"uid": "72d9-33"
"uid": "55de-33"
},
{
"uid": "72d9-55"
"uid": "55de-55"
},
{
"uid": "72d9-53"
"uid": "55de-53"
},
{
"uid": "72d9-56"
"uid": "55de-56"
},
{
"uid": "72d9-37"
"uid": "55de-37"
},
{
"uid": "72d9-39"
"uid": "55de-39"
},
{
"uid": "72d9-43"
"uid": "55de-43"
},
{
"uid": "72d9-45"
"uid": "55de-45"
},
{
"uid": "72d9-57"
"uid": "55de-57"
},
{
"uid": "72d9-47"
"uid": "55de-47"
},
{
"uid": "72d9-51"
"uid": "55de-51"
},
{
"uid": "72d9-49"
"uid": "55de-49"
},
{
"uid": "72d9-35"
"uid": "55de-35"
}

@@ -471,3 +471,3 @@ ],

{
"uid": "72d9-53"
"uid": "55de-53"
}

@@ -477,3 +477,3 @@ ],

},
"72d9-55": {
"55de-55": {
"id": "/packages/router-core/src/frameworks.ts",

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

{
"uid": "72d9-53"
"uid": "55de-53"
}
]
},
"72d9-56": {
"55de-56": {
"id": "/packages/router-core/src/link.ts",

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

{
"uid": "72d9-53"
"uid": "55de-53"
}
]
},
"72d9-57": {
"55de-57": {
"id": "/packages/router-core/src/routeInfo.ts",

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

{
"uid": "72d9-53"
"uid": "55de-53"
}

@@ -509,0 +509,0 @@ ]

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

interface Router<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>> {
history: BrowserHistory | MemoryHistory | HashHistory;
options: PickAsRequired<RouterOptions<TRouteConfig>, 'stringifySearch' | 'parseSearch'>;

@@ -188,6 +189,2 @@ basepath: string;

update: <TRouteConfig extends RouteConfig = RouteConfig>(opts?: RouterOptions<TRouteConfig>) => Router<TRouteConfig>;
buildRouteTree: (routeConfig: RouteConfig) => Route<TAllRouteInfo, AnyRouteInfo>;
parseLocation: (location: History['location'], previousLocation?: Location) => Location;
buildLocation: (dest: BuildNextOptions) => Location;
commitLocation: (next: Location, replace?: boolean) => Promise<void>;
buildNext: (opts: BuildNextOptions) => Location;

@@ -221,8 +218,14 @@ cancelMatches: () => void;

resolvePath: (from: string, path: string) => string;
_navigate: (location: BuildNextOptions & {
replace?: boolean;
}) => Promise<void>;
navigate: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: NavigateOptionsAbsolute<TAllRouteInfo, TFrom, TTo>) => Promise<void>;
matchRoute: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(matchLocation: ToOptions<TAllRouteInfo, TFrom, TTo>, opts?: MatchRouteOptions) => boolean;
buildLink: <TFrom extends ValidFromPath<TAllRouteInfo> = '/', TTo extends string = '.'>(opts: LinkOptions<TAllRouteInfo, TFrom, TTo>) => LinkInfo;
__: {
buildRouteTree: (routeConfig: RouteConfig) => Route<TAllRouteInfo, AnyRouteInfo>;
parseLocation: (location: History['location'], previousLocation?: Location) => Location;
buildLocation: (dest: BuildNextOptions) => Location;
commitLocation: (next: Location, replace?: boolean) => Promise<void>;
navigate: (location: BuildNextOptions & {
replace?: boolean;
}) => Promise<void>;
};
}

@@ -256,3 +259,2 @@ declare function createRouter<TRouteConfig extends AnyRouteConfig = RouteConfig, TAllRouteInfo extends AnyAllRouteInfo = AllRouteInfo<TRouteConfig>>(userOptions?: RouterOptions<TRouteConfig>): Router<TRouteConfig, TAllRouteInfo>;

loaderPromise?: Promise<void>;
importPromise?: Promise<void>;
elementsPromise?: Promise<void>;

@@ -259,0 +261,0 @@ dataPromise?: Promise<void>;

@@ -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(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},e.apply(this,arguments)}var a;!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(a||(a={}));var n="beforeunload",o="popstate";function r(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=i.location,e=t.pathname,a=t.search,n=t.hash,o=s.state||{};return[o.idx,{pathname:e,search:a,hash:n,state:o.usr||null,key:o.key||"default"}]}var f=null;i.addEventListener(o,(function(){if(f)P.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(P.length){if(null!=n){var r=g-n;r&&(f={action:t,location:o,retry:function(){M(-1*r)}},M(r))}}else R(t)}}));var m=a.Pop,v=p(),g=v[0],y=v[1],_=c(),P=c();function b(t){return"string"==typeof t?t:h(t)}function w(t,a){return void 0===a&&(a=null),e({pathname:y.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function A(t,e){return[{usr:t.state,key:t.key,idx:e},b(t)]}function x(t,e,a){return!P.length||(P.call({action:t,location:e,retry:a}),!1)}function R(t){m=t;var e=p();g=e[0],y=e[1],_.call({action:m,location:y})}function M(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var S={get action(){return m},get location(){return y},createHref:b,push:function t(e,n){var o=a.Push,r=w(e,n);if(x(o,r,(function(){t(e,n)}))){var l=A(r,g+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}R(o)}},replace:function t(e,n){var o=a.Replace,r=w(e,n);if(x(o,r,(function(){t(e,n)}))){var i=A(r,g),l=i[0],c=i[1];s.replaceState(l,"",c),R(o)}},go:M,back:function(){M(-1)},forward:function(){M(1)},listen:function(t){return _.push(t)},block:function(t){var e=P.push(t);return 1===P.length&&i.addEventListener(n,l),function(){e(),P.length||i.removeEventListener(n,l)}}};return S}function i(t){void 0===t&&(t={});var n=t,o=n.initialEntries,r=void 0===o?["/"]:o,i=n.initialIndex,l=r.map((function(t){return e({pathname:"/",search:"",hash:"",state:null,key:u()},"string"==typeof t?d(t):t)})),p=s(null==i?l.length-1:i,0,l.length-1),f=a.Pop,m=l[p],v=c(),g=c();function y(t,a){return void 0===a&&(a=null),e({pathname:m.pathname,search:"",hash:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function _(t,e,a){return!g.length||(g.call({action:t,location:e,retry:a}),!1)}function P(t,e){f=t,m=e,v.call({action:f,location:m})}function b(t){var e=s(p+t,0,l.length-1),n=a.Pop,o=l[e];_(n,o,(function(){b(t)}))&&(p=e,P(n,o))}var w={get index(){return p},get action(){return f},get location(){return m},createHref:function(t){return"string"==typeof t?t:h(t)},push:function t(e,n){var o=a.Push,r=y(e,n);_(o,r,(function(){t(e,n)}))&&(p+=1,l.splice(p,l.length,r),P(o,r))},replace:function t(e,n){var o=a.Replace,r=y(e,n);_(o,r,(function(){t(e,n)}))&&(l[p]=r,P(o,r))},go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(t){return v.push(t)},block:function(t){return g.push(t)}};return w}function s(t,e,a){return Math.min(Math.max(t,e),a)}function l(t){t.preventDefault(),t.returnValue=""}function c(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}},call:function(e){t.forEach((function(t){return t&&t(e)}))}}}function u(){return Math.random().toString(36).substr(2,8)}function h(t){var e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,i=void 0===r?"":r;return o&&"?"!==o&&(a+="?"===o.charAt(0)?o:"?"+o),i&&"#"!==i&&(a+="#"===i.charAt(0)?i:"#"+i),a}function d(t){var e={};if(t){var a=t.indexOf("#");a>=0&&(e.hash=t.substr(a),t=t.substr(0,a));var n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function p(t,e){if(!t)throw new Error("Invariant failed")}function f(t,e){if(t===e)return t;const a=Array.isArray(t)&&Array.isArray(e);if(a||m(t)&&m(e)){const n=a?t.length:Object.keys(t).length,o=a?e:Object.keys(e),r=o.length,i=a?[]:{};let s=0;for(let n=0;n<r;n++){const r=a?n:o[n];i[r]=f(t[r],e[r]),i[r]===t[r]&&s++}return n===r&&s===n?t:i}return e}function m(t){if(!v(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!v(a)&&!!a.hasOwnProperty("isPrototypeOf")}function v(t){return"[object Object]"===Object.prototype.toString.call(t)}function g(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function _(t){return P(t.filter(Boolean).join("/"))}function P(t){return t.replace(/\/{2,}/g,"/")}function b(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function w(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function A(t){return w(b(t))}function x(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=R(e);const o=R(a);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&n.push(t):n=[t];else if(".."===t.value){var a;n.length>1&&"/"===(null==(a=g(n))?void 0:a.value)&&n.pop(),n.pop()}else{if("."===t.value)return;n.push(t)}}));return P(_([t,...n.map((t=>t.value))]))}function R(t){if(!t)return[];const e=[];if("/"===(t=P(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.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 M(t,e,a){return _(R(t).map((t=>{return"*"!==t.value||a?"param"===t.type?null!=(n=e[t.value.substring(1)])?n:"":t.value:"";var n})))}function S(t,e){const a=L(t,e);if(!e.to||a)return null!=a?a:{}}function L(t,e){var a;const n=R(t),o=R(""+(null!=(a=e.to)?a:"*")),r={};return(()=>{for(let t=0;t<Math.max(n.length,o.length);t++){const a=n[t],i=o[t],s=t===o.length-1,l=t===n.length-1;if(i){if("wildcard"===i.type)return!(null==a||!a.value)&&(r["*"]=_(n.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&(null==a||!a.value))return!0;if(a)if(e.caseSensitive){if(i.value!==a.value)return!1}else if(i.value.toLowerCase()!==a.value.toLowerCase())return!1}if(!a)return!1;if("param"===i.type){if("/"===(null==a?void 0:a.value))return!1;a.value.startsWith(":")||(r[i.value.substring(1)]=a.value)}}if(s&&!l)return!!e.fuzzy}return!0})()?r:void 0}function I(t,e){var a,n,o,r="";for(a in t)if(void 0!==(o=t[a]))if(Array.isArray(o))for(n=0;n<o.length;n++)r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o[n]);else r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o);return(e||"")+r}function E(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0?+e:e))}function C(t){for(var e,a,n={},o=t.split("&");e=o.shift();)void 0!==n[a=(e=e.split("=")).shift()]?n[a]=[].concat(n[a],E(e.shift())):n[a]=E(e.shift());return n}function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},k.apply(this,arguments)}function T(t,e,a,n){const{id:o,routeId:r,path:i,fullPath:s}=t,l=n.state.actions[o]||(n.state.actions[o]={pending:[],submit:async(t,e)=>{var a;if(!c)return;const o=null==(a=null==e?void 0:e.invalidate)||a,r={submittedAt:Date.now(),status:"pending",submission:t};l.current=r,l.latest=r,l.pending.push(r),n.state=k({},n.state,{currentAction:r,latestAction:r}),n.notify();try{const e=await(null==c.options.action?void 0:c.options.action(t));return r.data=e,o&&(n.invalidateRoute({to:".",fromCurrent:!0}),await n.reload()),r.status="success",e}catch(t){console.error(t),r.error=t,r.status="error"}finally{l.pending=l.pending.filter((t=>t!==r)),n.removeActionQueue.push({action:l,actionState:r}),n.notify()}}},n.state.actions[o]);let c={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:n,childRoutes:void 0,parentRoute:a,action:l,buildLink:t=>n.buildLink(k({},t,{from:s})),navigate:t=>n.navigate(k({},t,{from:s})),matchRoute:(t,e)=>n.matchRoute(k({},t,{from:s}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:c}),c}function D(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=f(e.loaderData,k({},n.loaderData,e.routeLoaderData)))}))}const O="__root__",F=["element","errorElement","catchElement","pendingElement"];function j(t,e,a){const n=k({},e,a,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isPending:!1,isFetching:!1,isInvalid:!1,invalidAt:1/0,getIsInvalid:()=>{const t=Date.now();return n.isInvalid||n.invalidAt<t},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{n.__.resolve(),n.router.notify()},startPending:()=>{var e,a;const o=null!=(e=n.options.pendingMs)?e:t.options.defaultPendingMs,r=null!=(a=n.options.pendingMinMs)?a:t.options.defaultPendingMinMs;n.__.pendingTimeout||"loading"!==n.status||void 0===o||(n.__.pendingTimeout=setTimeout((()=>{n.isPending=!0,n.__.resolve(),void 0!==r&&(n.__.pendingMinPromise=new Promise((t=>n.__.pendingMinTimeout=setTimeout(t,r))))}),o))},cancelPending:()=>{n.isPending=!1,clearTimeout(n.__.pendingTimeout),clearTimeout(n.__.pendingMinTimeout),delete n.__.pendingMinPromise},validate:()=>{var e,a;const o=null!=(e=null==(a=n.parentMatch)?void 0:a.search)?e:t.location.search;try{const t=n.routeSearch,e="object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch;let a=f(t,null==e?void 0:e(o));t!==a&&(n.isInvalid=!0),n.routeSearch=a,n.search=f(o,k({},o,a))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",n.status="error",void(n.error=e)}}},cancel:()=>{var t;null==(t=n.__.abortController)||t.abort(),n.__.cancelPending()},invalidate:()=>{n.isInvalid=!0},hasLoaders:()=>!!(e.options.loader||e.options.import||F.some((t=>"function"==typeof e.options[t]))),load:async e=>{const a=""+Date.now()+Math.random();return n.__.latestId=a,"idle"===n.status&&(n.status="loading"),n.isInvalid=!1,n.__.loadPromise=new Promise((async o=>{n.isFetching=!0,n.__.resolve=o;const r=(async()=>{const o=n.options.import;o&&(n.__.importPromise=o({params:n.params}).then((t=>{n.__=k({},n.__,t)}))),await n.__.importPromise,n.__.elementsPromise=(async()=>{await Promise.all(F.map((async t=>{const e=n.options[t];if(!n.__[t])if("function"==typeof e){const a=await e(n);n.__[t]=a}else n.__[t]=n.options[t]})))})(),n.__.dataPromise=Promise.resolve().then((async()=>{try{var o,r,i;if(n.options.loader){const t=await n.options.loader({params:n.params,search:n.routeSearch,signal:n.__.abortController.signal});if(a!==n.__.latestId)return n.__.loaderPromise;n.routeLoaderData=f(n.routeLoaderData,t)}n.error=void 0,n.status="success",n.updatedAt=Date.now(),n.invalidAt=n.updatedAt+(null!=(o=null!=(r=null!=(i=null==e?void 0:e.maxAge)?i:n.options.loaderMaxAge)?r:t.options.defaultLoaderMaxAge)?o:0)}catch(t){if(a!==n.__.latestId)return n.__.loaderPromise;n.error=t,n.status="error",n.updatedAt=Date.now()}}));try{if(await Promise.all([n.__.elementsPromise,n.__.dataPromise]),a!==n.__.latestId)return n.__.loaderPromise;n.__.pendingMinPromise&&(await n.__.pendingMinPromise,delete n.__.pendingMinPromise)}finally{if(a!==n.__.latestId)return n.__.loaderPromise;n.__.cancelPending(),n.isPending=!1,n.isFetching=!1,n.__.notify()}})();if(n.__.loaderPromise=r,await r,a!==n.__.latestId)return n.__.loaderPromise;delete n.__.loaderPromise})),await n.__.loadPromise}});return n.hasLoaders()||(n.status="success"),n}const N=H(JSON.parse),B=U(JSON.stringify);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=C(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function U(t){return e=>{(e=k({},e))&&Object.keys(e).forEach((a=>{const n=e[a];if(void 0===n||void 0===n)delete e[a];else if(n&&"object"==typeof n&&null!==n)try{e[a]=t(n)}catch(t){}}));const a=I(e).toString();return a?"?"+a:""}}var G;const z=Boolean("undefined"==typeof window||!(null!=(G=window.document)&&G.createElement));t.cascadeLoaderData=D,t.cleanPath=P,t.createBrowserHistory=r,t.createHashHistory=function(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=d(i.location.hash.substr(1)),e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,l=void 0===r?"":r,c=s.state||{};return[c.idx,{pathname:a,search:o,hash:l,state:c.usr||null,key:c.key||"default"}]}var f=null;function m(){if(f)b.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(b.length){if(null!=n){var r=y-n;r&&(f={action:t,location:o,retry:function(){S(-1*r)}},S(r))}}else M(t)}}i.addEventListener(o,m),i.addEventListener("hashchange",(function(){h(p()[1])!==h(_)&&m()}));var v=a.Pop,g=p(),y=g[0],_=g[1],P=c(),b=c();function w(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var a=i.location.href,n=a.indexOf("#");e=-1===n?a:a.slice(0,n)}return e}()+"#"+("string"==typeof t?t:h(t))}function A(t,a){return void 0===a&&(a=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function x(t,e){return[{usr:t.state,key:t.key,idx:e},w(t)]}function R(t,e,a){return!b.length||(b.call({action:t,location:e,retry:a}),!1)}function M(t){v=t;var e=p();y=e[0],_=e[1],P.call({action:v,location:_})}function S(t){s.go(t)}null==y&&(y=0,s.replaceState(e({},s.state,{idx:y}),""));var L={get action(){return v},get location(){return _},createHref:w,push:function t(e,n){var o=a.Push,r=A(e,n);if(R(o,r,(function(){t(e,n)}))){var l=x(r,y+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}M(o)}},replace:function t(e,n){var o=a.Replace,r=A(e,n);if(R(o,r,(function(){t(e,n)}))){var i=x(r,y),l=i[0],c=i[1];s.replaceState(l,"",c),M(o)}},go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(t){return P.push(t)},block:function(t){var e=b.push(t);return 1===b.length&&i.addEventListener(n,l),function(){e(),b.length||i.removeEventListener(n,l)}}};return L},t.createMemoryHistory=i,t.createRoute=T,t.createRouteConfig=function t(e,a,n,o,r){void 0===e&&(e={}),void 0===n&&(n=!0),n&&(e.path=O),o===O&&(o="");let i=n?O:e.path;i&&"/"!==i&&(i=A(i));const s=i||e.id;let l=_([o,s]);i===O&&(i="/"),l!==O&&(l=_(["/",l]));const c=l===O?"/":w(_([r,i]));return{id:l,routeId:s,path:i,fullPath:c,options:e,children:a,createChildren:a=>t(e,a((e=>t(e,void 0,!1,l,c))),!1,o,r),addChildren:a=>t(e,a,!1,o,r),createRoute:e=>t(e,void 0,!1,l,c)}},t.createRouteMatch=j,t.createRouter=function(t){var e,a;const n=(null==t?void 0:t.history)||(z?i():r());let o={options:k({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:B,parseSearch:null!=(a=null==t?void 0:t.parseSearch)?a:N}),listeners:[],removeActionQueue:[],basepath:"",routeTree:void 0,routesById:{},location:void 0,allRouteInfo:void 0,navigationPromise:Promise.resolve(),resolveNavigation:()=>{},matchCache:{},state:{status:"idle",location:null,matches:[],actions:{},loaderData:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1},startedLoadingAt:Date.now(),subscribe:t=>(o.listeners.push(t),()=>{o.listeners=o.listeners.filter((e=>e!==t))}),getRoute:t=>o.routesById[t],notify:()=>{o.state=k({},o.state,{isFetching:"loading"===o.state.status||o.state.matches.some((t=>t.isFetching)),isPreloading:Object.values(o.matchCache).some((t=>t.match.isFetching&&!o.state.matches.find((e=>e.matchId===t.match.matchId))))}),D(o.state.matches),o.listeners.forEach((t=>t()))},mount:()=>{const t=o.buildLocation({to:".",search:!0,hash:!0});t.href!==o.location.href?o.commitLocation(t,!0):o.loadLocation();const e=n.listen((t=>{o.loadLocation(o.parseLocation(t.location,o.location))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",o.onFocus,!1),window.addEventListener("focus",o.onFocus,!1)),()=>{e(),window.removeEventListener("visibilitychange",o.onFocus),window.removeEventListener("focus",o.onFocus)}},onFocus:()=>{o.loadLocation()},update:t=>{Object.assign(o.options,t);const{basepath:e,routeConfig:a}=o.options;return o.basepath=P("/"+(null!=e?e:"")),a&&(o.routesById={},o.routeTree=o.buildRouteTree(a)),o},buildRouteTree:t=>{const e=(t,a)=>t.map((t=>{const n=T(t,t.options,a,o);if(o.routesById[n.routeId])throw new Error;o.routesById[n.routeId]=n;const r=t.children;return n.childRoutes=null!=r&&r.length?e(r,n):void 0,n}));return e([t])[0]},parseLocation:(t,e)=>{var a;const n=o.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:f(null==e?void 0:e.search,n),hash:null!=(a=t.hash.split("#").reverse()[0])?a:"",href:""+t.pathname+t.search+t.hash,state:t.state,key:t.key}},buildLocation:function(t){var e,a,n,r,i,s,l,c,u;void 0===t&&(t={});const h=t.fromCurrent?o.location.pathname:null!=(e=t.from)?e:o.location.pathname;let d=x(null!=(a=o.basepath)?a:"/",h,""+(null!=(n=t.to)?n:"."));const p=o.matchRoutes(o.location.pathname,{strictParseParams:!0}),m=o.matchRoutes(d),v=k({},null==(r=g(p))?void 0:r.params);let _=!0===(null==(i=t.params)||i)?v:y(t.params,v);_&&m.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},_,t(_))})),d=M(d,null!=_?_:{});const P=null!=(s=t.__preSearchFilters)&&s.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),o.location.search):o.location.search,b=!0===t.search?P:t.search?null!=(l=y(t.search,P))?l:{}:null!=(c=t.__preSearchFilters)&&c.length?P:{},w=null!=(u=t.__postSearchFilters)&&u.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),b):b,A=f(o.location.search,w),R=o.options.stringifySearch(A);let S=!0===t.hash?o.location.hash:y(t.hash,o.location.hash);return S=S?"#"+S:"",{pathname:d,search:A,searchStr:R,state:o.location.state,hash:S,href:""+d+R+S,key:t.key}},commitLocation:(t,e)=>{const a=""+Date.now()+Math.random();o.navigateTimeout&&clearTimeout(o.navigateTimeout);let r="replace";e||(r="push");return o.parseLocation(n.location).href===t.href&&!t.key&&(r="replace"),"replace"===r?n.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}):n.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}),o.navigationPromise=new Promise((t=>{const e=o.resolveNavigation;o.resolveNavigation=()=>{e(),t()}})),o.navigationPromise},buildNext:t=>{const e=o.buildLocation(t),a=o.matchRoutes(e.pathname),n=a.map((t=>{var e;return null!=(e=t.options.preSearchFilters)?e:[]})).flat().filter(Boolean),r=a.map((t=>{var e;return null!=(e=t.options.postSearchFilters)?e:[]})).flat().filter(Boolean);return o.buildLocation(k({},t,{__preSearchFilters:n,__postSearchFilters:r}))},cancelMatches:()=>{var t,e;[...o.state.matches,...null!=(t=null==(e=o.state.pending)?void 0:e.matches)?t:[]].forEach((t=>{t.cancel()}))},loadLocation:async t=>{const e=Math.random();o.startedLoadingAt=e,t&&(o.location=t),o.removeActionQueue.forEach((t=>{let{action:e,actionState:a}=t;o.state.currentAction===a&&(o.state.currentAction=void 0),e.current===a&&(e.current=void 0)})),o.removeActionQueue=[],o.cancelMatches();const a=o.matchRoutes(location.pathname,{strictParseParams:!0});if(o.state=k({},o.state,{pending:{matches:a,location:o.location},status:"loading"}),o.notify(),await o.loadMatches(a,{withPending:!0}),o.startedLoadingAt!==e)return o.navigationPromise;const n=o.state.matches,r=[],i=[];n.forEach((t=>{a.find((e=>e.matchId===t.matchId))?i.push(t):r.push(t)}));const s=Date.now();r.forEach((t=>{var e,a,n,r;null==t.__.onExit||t.__.onExit({params:t.params,search:t.routeSearch}),"error"!==t.status||t.isFetching||(t.status="idle",t.error=void 0);const i=Math.max(null!=(e=null!=(a=t.options.loaderGcMaxAge)?a:o.options.defaultLoaderGcMaxAge)?e:0,null!=(n=null!=(r=t.options.loaderMaxAge)?r:o.options.defaultLoaderMaxAge)?n:0);i>0&&(o.matchCache[t.matchId]={gc:i==1/0?Number.MAX_SAFE_INTEGER:s+i,match:t})})),i.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})}));a.filter((t=>!n.find((e=>e.matchId===t.matchId)))).forEach((t=>{t.__.onExit=null==t.options.onMatch?void 0:t.options.onMatch({params:t.params,search:t.search})})),a.some((t=>"loading"===t.status))&&(o.notify(),await Promise.all(a.map((t=>t.__.loaderPromise||Promise.resolve())))),o.startedLoadingAt===e&&(o.state=k({},o.state,{location:o.location,matches:a,pending:void 0,status:"idle"}),o.notify(),o.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(o.matchCache).forEach((e=>{const a=o.matchCache[e];"loading"!==a.match.status&&(a.gc>0&&a.gc>t||delete o.matchCache[e])}))},loadRoute:async function(t){void 0===t&&(t=o.location);const e=o.buildNext(t),a=o.matchRoutes(e.pathname,{strictParseParams:!0});return await o.loadMatches(a),a},preloadRoute:async function(t,e){var a,n,r,i,s,l;void 0===t&&(t=o.location);const c=o.buildNext(t),u=o.matchRoutes(c.pathname,{strictParseParams:!0});return await o.loadMatches(u,{preload:!0,maxAge:null!=(a=null!=(n=null!=(r=e.maxAge)?r:o.options.defaultPreloadMaxAge)?n:o.options.defaultLoaderMaxAge)?a:0,gcMaxAge:null!=(i=null!=(s=null!=(l=e.gcMaxAge)?l:o.options.defaultPreloadGcMaxAge)?s:o.options.defaultLoaderGcMaxAge)?i:0}),u},matchRoutes:(t,e)=>{var a,n;o.cleanMatchCache();const r=[];if(!o.routeTree)return r;const i=[...o.state.matches,...null!=(a=null==(n=o.state.pending)?void 0:n.matches)?a:[]],s=async a=>{var n,l,c;const u=g(r);let h=null!=(n=null==u?void 0:u.params)?n:{};const d=null!=(l=null==o.options.filterRoutes?void 0:o.options.filterRoutes(a))?l:a;let p=[];const f=(a,n)=>(n.some((n=>{var r,i,s;if(!n.routePath&&null!=(r=n.childRoutes)&&r.length)return f([...p,n],n.childRoutes);const l=!!("/"!==n.routePath||null!=(i=n.childRoutes)&&i.length),c=S(t,{to:n.fullPath,fuzzy:l,caseSensitive:null!=(s=n.options.caseSensitive)?s:o.options.caseSensitive});if(c){let t;try{var u;t=null!=(u=null==n.options.parseParams?void 0:n.options.parseParams(c))?u:c}catch(t){if(null!=e&&e.strictParseParams)throw t}h=k({},h,t)}return c&&(p=[...a,n]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((e=>{var a;const n=M(e.routePath,h),s=M(e.routeId,h,!0),l=i.find((t=>t.matchId===s))||(null==(a=o.matchCache[s])?void 0:a.match)||j(o,e,{matchId:s,params:h,pathname:_([t,n])});r.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&s(m.childRoutes)};return s([o.routeTree]),D(r),r},loadMatches:async(t,e)=>{const a=Date.now(),n=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0,r=t.map((async t=>{if(t.__.validate(),null!=e&&e.preload&&n>0){if(o.state.matches.find((e=>e.matchId===t.matchId)))return;o.matchCache[t.matchId]={gc:a+e.gcMaxAge,match:t}}if("success"===t.status&&t.getIsInvalid()||"error"===t.status||"idle"===t.status){const a=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;t.load({maxAge:a})}"loading"===t.status&&(null!=e&&e.withPending&&t.__.startPending(),await t.__.loadPromise)}));o.notify(),await Promise.all(r)},invalidateRoute:t=>{var e,a;const n=o.buildNext(t),r=o.matchRoutes(n.pathname).map((t=>t.matchId));[...o.state.matches,...null!=(e=null==(a=o.state.pending)?void 0:a.matches)?e:[]].forEach((t=>{r.includes(t.matchId)&&t.invalidate()}))},reload:()=>o._navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>x(o.basepath,t,P(e)),matchRoute:(t,e)=>{var a;t=k({},t,{to:t.to?o.resolvePath(null!=(a=t.from)?a:"",t.to):void 0});const n=o.buildNext(t);var r;return null!=e&&e.pending?!(null==(r=o.state.pending)||!r.location)&&!!S(o.state.pending.location.pathname,k({},e,{to:n.pathname})):!!S(o.state.location.pathname,k({},e,{to:n.pathname}))},_navigate:t=>{const e=o.buildNext(t);return o.commitLocation(e,t.replace)},navigate:async t=>{let{from:e,to:a=".",search:n,hash:r,replace:i,params:s}=t;const l=String(a),c=String(e);let u;try{new URL(""+l),u=!0}catch(t){}return p(!u),o._navigate({from:c,to:l,search:n,hash:r,replace:i,params:s})},buildLink:t=>{var e,a;let{from:n,to:r=".",search:i,params:s,hash:l,target:c,replace:u,activeOptions:h,preload:d,preloadMaxAge:p,preloadGcMaxAge:f,preloadDelay:m,disabled:v}=t;try{return new URL(""+r),{type:"external",href:r}}catch(t){}const g={from:n,to:r,search:i,params:s,hash:l,replace:u},y=o.buildNext(g);d=null!=(e=d)?e:o.options.defaultPreload;const _=null!=(a=null!=m?m:o.options.defaultPreloadDelay)?a:0,P=o.state.location.pathname===y.pathname,b=o.state.location.pathname.split("/"),w=y.pathname.split("/").every(((t,e)=>t===b[e])),A=o.state.location.hash===y.hash,x=null!=h&&h.exact?P:w,R=null==h||!h.includeHash||A;return{type:"internal",next:y,handleFocus:t=>{d&&o.preloadRoute(g,{maxAge:p,gcMaxAge:f})},handleClick:t=>{v||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||c&&"_self"!==c||0!==t.button||(t.preventDefault(),!P||i||l||o.invalidateRoute(g),o._navigate(g))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,o.preloadRoute(g,{maxAge:p,gcMaxAge:f})}),_)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:x&&R,disabled:v}}};return o.location=o.parseLocation(n.location),o.state.location=o.location,o.update(t),null==o.options.createRouter||o.options.createRouter(o),o},t.decode=C,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=I,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=p,t.joinPaths=_,t.last=g,t.matchByPath=L,t.matchPathname=S,t.parsePathname=R,t.parseSearchWith=H,t.replaceEqualDeep=f,t.resolvePath=x,t.rootRouteId=O,t.stringifySearchWith=U,t.trimPath=A,t.trimPathLeft=b,t.trimPathRight=w,t.warning=function(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch(t){}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
!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(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},e.apply(this,arguments)}var a;!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(a||(a={}));var n="beforeunload",o="popstate";function r(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=i.location,e=t.pathname,a=t.search,n=t.hash,o=s.state||{};return[o.idx,{pathname:e,search:a,hash:n,state:o.usr||null,key:o.key||"default"}]}var f=null;i.addEventListener(o,(function(){if(f)P.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(P.length){if(null!=n){var r=g-n;r&&(f={action:t,location:o,retry:function(){M(-1*r)}},M(r))}}else R(t)}}));var m=a.Pop,v=p(),g=v[0],_=v[1],y=c(),P=c();function b(t){return"string"==typeof t?t:h(t)}function w(t,a){return void 0===a&&(a=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function A(t,e){return[{usr:t.state,key:t.key,idx:e},b(t)]}function x(t,e,a){return!P.length||(P.call({action:t,location:e,retry:a}),!1)}function R(t){m=t;var e=p();g=e[0],_=e[1],y.call({action:m,location:_})}function M(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var S={get action(){return m},get location(){return _},createHref:b,push:function t(e,n){var o=a.Push,r=w(e,n);if(x(o,r,(function(){t(e,n)}))){var l=A(r,g+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}R(o)}},replace:function t(e,n){var o=a.Replace,r=w(e,n);if(x(o,r,(function(){t(e,n)}))){var i=A(r,g),l=i[0],c=i[1];s.replaceState(l,"",c),R(o)}},go:M,back:function(){M(-1)},forward:function(){M(1)},listen:function(t){return y.push(t)},block:function(t){var e=P.push(t);return 1===P.length&&i.addEventListener(n,l),function(){e(),P.length||i.removeEventListener(n,l)}}};return S}function i(t){void 0===t&&(t={});var n=t,o=n.initialEntries,r=void 0===o?["/"]:o,i=n.initialIndex,l=r.map((function(t){return e({pathname:"/",search:"",hash:"",state:null,key:u()},"string"==typeof t?d(t):t)})),p=s(null==i?l.length-1:i,0,l.length-1),f=a.Pop,m=l[p],v=c(),g=c();function _(t,a){return void 0===a&&(a=null),e({pathname:m.pathname,search:"",hash:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function y(t,e,a){return!g.length||(g.call({action:t,location:e,retry:a}),!1)}function P(t,e){f=t,m=e,v.call({action:f,location:m})}function b(t){var e=s(p+t,0,l.length-1),n=a.Pop,o=l[e];y(n,o,(function(){b(t)}))&&(p=e,P(n,o))}var w={get index(){return p},get action(){return f},get location(){return m},createHref:function(t){return"string"==typeof t?t:h(t)},push:function t(e,n){var o=a.Push,r=_(e,n);y(o,r,(function(){t(e,n)}))&&(p+=1,l.splice(p,l.length,r),P(o,r))},replace:function t(e,n){var o=a.Replace,r=_(e,n);y(o,r,(function(){t(e,n)}))&&(l[p]=r,P(o,r))},go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(t){return v.push(t)},block:function(t){return g.push(t)}};return w}function s(t,e,a){return Math.min(Math.max(t,e),a)}function l(t){t.preventDefault(),t.returnValue=""}function c(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}},call:function(e){t.forEach((function(t){return t&&t(e)}))}}}function u(){return Math.random().toString(36).substr(2,8)}function h(t){var e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,i=void 0===r?"":r;return o&&"?"!==o&&(a+="?"===o.charAt(0)?o:"?"+o),i&&"#"!==i&&(a+="#"===i.charAt(0)?i:"#"+i),a}function d(t){var e={};if(t){var a=t.indexOf("#");a>=0&&(e.hash=t.substr(a),t=t.substr(0,a));var n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function p(t,e){if(!t)throw new Error("Invariant failed")}function f(t,e){if(t===e)return t;const a=Array.isArray(t)&&Array.isArray(e);if(a||m(t)&&m(e)){const n=a?t.length:Object.keys(t).length,o=a?e:Object.keys(e),r=o.length,i=a?[]:{};let s=0;for(let n=0;n<r;n++){const r=a?n:o[n];i[r]=f(t[r],e[r]),i[r]===t[r]&&s++}return n===r&&s===n?t:i}return e}function m(t){if(!v(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!v(a)&&!!a.hasOwnProperty("isPrototypeOf")}function v(t){return"[object Object]"===Object.prototype.toString.call(t)}function g(t){return t[t.length-1]}function _(t,e){return"function"==typeof t?t(e):t}function y(t){return P(t.filter(Boolean).join("/"))}function P(t){return t.replace(/\/{2,}/g,"/")}function b(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function w(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function A(t){return w(b(t))}function x(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=R(e);const o=R(a);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&n.push(t):n=[t];else if(".."===t.value){var a;n.length>1&&"/"===(null==(a=g(n))?void 0:a.value)&&n.pop(),n.pop()}else{if("."===t.value)return;n.push(t)}}));return P(y([t,...n.map((t=>t.value))]))}function R(t){if(!t)return[];const e=[];if("/"===(t=P(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.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 M(t,e,a){return y(R(t).map((t=>{return"*"!==t.value||a?"param"===t.type?null!=(n=e[t.value.substring(1)])?n:"":t.value:"";var n})))}function S(t,e){const a=I(t,e);if(!e.to||a)return null!=a?a:{}}function I(t,e){var a;const n=R(t),o=R(""+(null!=(a=e.to)?a:"*")),r={};return(()=>{for(let t=0;t<Math.max(n.length,o.length);t++){const a=n[t],i=o[t],s=t===o.length-1,l=t===n.length-1;if(i){if("wildcard"===i.type)return!(null==a||!a.value)&&(r["*"]=y(n.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&(null==a||!a.value))return!0;if(a)if(e.caseSensitive){if(i.value!==a.value)return!1}else if(i.value.toLowerCase()!==a.value.toLowerCase())return!1}if(!a)return!1;if("param"===i.type){if("/"===(null==a?void 0:a.value))return!1;a.value.startsWith(":")||(r[i.value.substring(1)]=a.value)}}if(s&&!l)return!!e.fuzzy}return!0})()?r:void 0}function L(t,e){var a,n,o,r="";for(a in t)if(void 0!==(o=t[a]))if(Array.isArray(o))for(n=0;n<o.length;n++)r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o[n]);else r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o);return(e||"")+r}function E(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0?+e:e))}function C(t){for(var e,a,n={},o=t.split("&");e=o.shift();)void 0!==n[a=(e=e.split("=")).shift()]?n[a]=[].concat(n[a],E(e.shift())):n[a]=E(e.shift());return n}function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},k.apply(this,arguments)}function T(t,e,a,n){const{id:o,routeId:r,path:i,fullPath:s}=t,l=n.state.actions[o]||(n.state.actions[o]={pending:[],submit:async(t,e)=>{var a;if(!c)return;const o=null==(a=null==e?void 0:e.invalidate)||a,r={submittedAt:Date.now(),status:"pending",submission:t};l.current=r,l.latest=r,l.pending.push(r),n.state=k({},n.state,{currentAction:r,latestAction:r}),n.notify();try{const e=await(null==c.options.action?void 0:c.options.action(t));return r.data=e,o&&(n.invalidateRoute({to:".",fromCurrent:!0}),await n.reload()),r.status="success",e}catch(t){console.error(t),r.error=t,r.status="error"}finally{l.pending=l.pending.filter((t=>t!==r)),n.removeActionQueue.push({action:l,actionState:r}),n.notify()}}},n.state.actions[o]);let c={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:n,childRoutes:void 0,parentRoute:a,action:l,buildLink:t=>n.buildLink(k({},t,{from:s})),navigate:t=>n.navigate(k({},t,{from:s})),matchRoute:(t,e)=>n.matchRoute(k({},t,{from:s}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:c}),c}function D(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=f(e.loaderData,k({},n.loaderData,e.routeLoaderData)))}))}const O="__root__",F=["element","errorElement","catchElement","pendingElement"];function j(t,e,a){const n=k({},e,a,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isPending:!1,isFetching:!1,isInvalid:!1,invalidAt:1/0,getIsInvalid:()=>{const t=Date.now();return n.isInvalid||n.invalidAt<t},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{n.__.resolve(),n.router.notify()},startPending:()=>{var e,a;const o=null!=(e=n.options.pendingMs)?e:t.options.defaultPendingMs,r=null!=(a=n.options.pendingMinMs)?a:t.options.defaultPendingMinMs;n.__.pendingTimeout||"loading"!==n.status||void 0===o||(n.__.pendingTimeout=setTimeout((()=>{n.isPending=!0,n.__.resolve(),void 0!==r&&(n.__.pendingMinPromise=new Promise((t=>n.__.pendingMinTimeout=setTimeout(t,r))))}),o))},cancelPending:()=>{n.isPending=!1,clearTimeout(n.__.pendingTimeout),clearTimeout(n.__.pendingMinTimeout),delete n.__.pendingMinPromise},validate:()=>{var e,a;const o=null!=(e=null==(a=n.parentMatch)?void 0:a.search)?e:t.location.search;try{const t=n.routeSearch,e="object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch;let a=f(t,null==e?void 0:e(o));t!==a&&(n.isInvalid=!0),n.routeSearch=a,n.search=f(o,k({},o,a))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",n.status="error",void(n.error=e)}}},cancel:()=>{var t;null==(t=n.__.abortController)||t.abort(),n.__.cancelPending()},invalidate:()=>{n.isInvalid=!0},hasLoaders:()=>!(!e.options.loader&&!F.some((t=>"function"==typeof e.options[t]))),load:async e=>{const a=""+Date.now()+Math.random();return n.__.latestId=a,"idle"===n.status&&(n.status="loading"),n.isInvalid=!1,n.__.loadPromise=new Promise((async o=>{n.isFetching=!0,n.__.resolve=o;const r=(async()=>{n.__.elementsPromise=(async()=>{await Promise.all(F.map((async t=>{const e=n.options[t];if(!n.__[t])if("function"==typeof e){const a=await e(n);n.__[t]=a}else n.__[t]=n.options[t]})))})(),n.__.dataPromise=Promise.resolve().then((async()=>{try{var o,r,i;if(n.options.loader){const t=await n.options.loader({params:n.params,search:n.routeSearch,signal:n.__.abortController.signal});if(a!==n.__.latestId)return n.__.loaderPromise;n.routeLoaderData=f(n.routeLoaderData,t)}n.error=void 0,n.status="success",n.updatedAt=Date.now(),n.invalidAt=n.updatedAt+(null!=(o=null!=(r=null!=(i=null==e?void 0:e.maxAge)?i:n.options.loaderMaxAge)?r:t.options.defaultLoaderMaxAge)?o:0)}catch(t){if(a!==n.__.latestId)return n.__.loaderPromise;n.error=t,n.status="error",n.updatedAt=Date.now()}}));try{if(await Promise.all([n.__.elementsPromise,n.__.dataPromise]),a!==n.__.latestId)return n.__.loaderPromise;n.__.pendingMinPromise&&(await n.__.pendingMinPromise,delete n.__.pendingMinPromise)}finally{if(a!==n.__.latestId)return n.__.loaderPromise;n.__.cancelPending(),n.isPending=!1,n.isFetching=!1,n.__.notify()}})();if(n.__.loaderPromise=r,await r,a!==n.__.latestId)return n.__.loaderPromise;delete n.__.loaderPromise})),await n.__.loadPromise}});return n.hasLoaders()||(n.status="success"),n}const N=H(JSON.parse),B=U(JSON.stringify);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=C(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function U(t){return e=>{(e=k({},e))&&Object.keys(e).forEach((a=>{const n=e[a];if(void 0===n||void 0===n)delete e[a];else if(n&&"object"==typeof n&&null!==n)try{e[a]=t(n)}catch(t){}}));const a=L(e).toString();return a?"?"+a:""}}var G;const z=Boolean("undefined"==typeof window||!(null!=(G=window.document)&&G.createElement));t.cascadeLoaderData=D,t.cleanPath=P,t.createBrowserHistory=r,t.createHashHistory=function(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=d(i.location.hash.substr(1)),e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,l=void 0===r?"":r,c=s.state||{};return[c.idx,{pathname:a,search:o,hash:l,state:c.usr||null,key:c.key||"default"}]}var f=null;function m(){if(f)b.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(b.length){if(null!=n){var r=_-n;r&&(f={action:t,location:o,retry:function(){S(-1*r)}},S(r))}}else M(t)}}i.addEventListener(o,m),i.addEventListener("hashchange",(function(){h(p()[1])!==h(y)&&m()}));var v=a.Pop,g=p(),_=g[0],y=g[1],P=c(),b=c();function w(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var a=i.location.href,n=a.indexOf("#");e=-1===n?a:a.slice(0,n)}return e}()+"#"+("string"==typeof t?t:h(t))}function A(t,a){return void 0===a&&(a=null),e({pathname:y.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function x(t,e){return[{usr:t.state,key:t.key,idx:e},w(t)]}function R(t,e,a){return!b.length||(b.call({action:t,location:e,retry:a}),!1)}function M(t){v=t;var e=p();_=e[0],y=e[1],P.call({action:v,location:y})}function S(t){s.go(t)}null==_&&(_=0,s.replaceState(e({},s.state,{idx:_}),""));var I={get action(){return v},get location(){return y},createHref:w,push:function t(e,n){var o=a.Push,r=A(e,n);if(R(o,r,(function(){t(e,n)}))){var l=x(r,_+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}M(o)}},replace:function t(e,n){var o=a.Replace,r=A(e,n);if(R(o,r,(function(){t(e,n)}))){var i=x(r,_),l=i[0],c=i[1];s.replaceState(l,"",c),M(o)}},go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(t){return P.push(t)},block:function(t){var e=b.push(t);return 1===b.length&&i.addEventListener(n,l),function(){e(),b.length||i.removeEventListener(n,l)}}};return I},t.createMemoryHistory=i,t.createRoute=T,t.createRouteConfig=function t(e,a,n,o,r){void 0===e&&(e={}),void 0===n&&(n=!0),n&&(e.path=O),o===O&&(o="");let i=n?O:e.path;i&&"/"!==i&&(i=A(i));const s=i||e.id;let l=y([o,s]);i===O&&(i="/"),l!==O&&(l=y(["/",l]));const c=l===O?"/":w(y([r,i]));return{id:l,routeId:s,path:i,fullPath:c,options:e,children:a,createChildren:a=>t(e,a((e=>t(e,void 0,!1,l,c))),!1,o,r),addChildren:a=>t(e,a,!1,o,r),createRoute:e=>t(e,void 0,!1,l,c)}},t.createRouteMatch=j,t.createRouter=function(t){var e,a;const n=(null==t?void 0:t.history)||(z?i():r()),o=k({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:B,parseSearch:null!=(a=null==t?void 0:t.parseSearch)?a:N});let s={history:n,options:o,listeners:[],removeActionQueue:[],basepath:"",routeTree:void 0,routesById:{},location:void 0,allRouteInfo:void 0,navigationPromise:Promise.resolve(),resolveNavigation:()=>{},matchCache:{},state:{status:"idle",location:null,matches:[],actions:{},loaderData:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1},startedLoadingAt:Date.now(),subscribe:t=>(s.listeners.push(t),()=>{s.listeners=s.listeners.filter((e=>e!==t))}),getRoute:t=>s.routesById[t],notify:()=>{s.state=k({},s.state,{isFetching:"loading"===s.state.status||s.state.matches.some((t=>t.isFetching)),isPreloading:Object.values(s.matchCache).some((t=>t.match.isFetching&&!s.state.matches.find((e=>e.matchId===t.match.matchId))))}),D(s.state.matches),s.listeners.forEach((t=>t()))},mount:()=>{const t=s.__.buildLocation({to:".",search:!0,hash:!0});t.href!==s.location.href?s.__.commitLocation(t,!0):s.loadLocation();const e=n.listen((t=>{s.loadLocation(s.__.parseLocation(t.location,s.location))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",s.onFocus,!1),window.addEventListener("focus",s.onFocus,!1)),()=>{e(),window.removeEventListener("visibilitychange",s.onFocus),window.removeEventListener("focus",s.onFocus)}},onFocus:()=>{s.loadLocation()},update:t=>{Object.assign(s.options,t);const{basepath:e,routeConfig:a}=s.options;return s.basepath=P("/"+(null!=e?e:"")),a&&(s.routesById={},s.routeTree=s.__.buildRouteTree(a)),s},cancelMatches:()=>{var t,e;[...s.state.matches,...null!=(t=null==(e=s.state.pending)?void 0:e.matches)?t:[]].forEach((t=>{t.cancel()}))},loadLocation:async t=>{const e=Math.random();s.startedLoadingAt=e,t&&(s.location=t),s.removeActionQueue.forEach((t=>{let{action:e,actionState:a}=t;s.state.currentAction===a&&(s.state.currentAction=void 0),e.current===a&&(e.current=void 0)})),s.removeActionQueue=[],s.cancelMatches();const a=s.matchRoutes(location.pathname,{strictParseParams:!0});if(s.state=k({},s.state,{pending:{matches:a,location:s.location},status:"loading"}),s.notify(),await s.loadMatches(a,{withPending:!0}),s.startedLoadingAt!==e)return s.navigationPromise;const n=s.state.matches,o=[],r=[];n.forEach((t=>{a.find((e=>e.matchId===t.matchId))?r.push(t):o.push(t)}));const i=Date.now();o.forEach((t=>{var e,a,n,o;null==t.__.onExit||t.__.onExit({params:t.params,search:t.routeSearch}),"error"!==t.status||t.isFetching||(t.status="idle",t.error=void 0);const r=Math.max(null!=(e=null!=(a=t.options.loaderGcMaxAge)?a:s.options.defaultLoaderGcMaxAge)?e:0,null!=(n=null!=(o=t.options.loaderMaxAge)?o:s.options.defaultLoaderMaxAge)?n:0);r>0&&(s.matchCache[t.matchId]={gc:r==1/0?Number.MAX_SAFE_INTEGER:i+r,match:t})})),r.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})}));a.filter((t=>!n.find((e=>e.matchId===t.matchId)))).forEach((t=>{t.__.onExit=null==t.options.onMatch?void 0:t.options.onMatch({params:t.params,search:t.search}),delete s.matchCache[t.matchId]})),a.some((t=>"loading"===t.status))&&(s.notify(),await Promise.all(a.map((t=>t.__.loaderPromise||Promise.resolve())))),s.startedLoadingAt===e&&(s.state=k({},s.state,{location:s.location,matches:a,pending:void 0,status:"idle"}),s.notify(),s.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(s.matchCache).forEach((e=>{const a=s.matchCache[e];"loading"!==a.match.status&&(a.gc>0&&a.gc>t||delete s.matchCache[e])}))},loadRoute:async function(t){void 0===t&&(t=s.location);const e=s.buildNext(t),a=s.matchRoutes(e.pathname,{strictParseParams:!0});return await s.loadMatches(a),a},preloadRoute:async function(t,e){var a,n,o,r,i,l;void 0===t&&(t=s.location);const c=s.buildNext(t),u=s.matchRoutes(c.pathname,{strictParseParams:!0});return await s.loadMatches(u,{preload:!0,maxAge:null!=(a=null!=(n=null!=(o=e.maxAge)?o:s.options.defaultPreloadMaxAge)?n:s.options.defaultLoaderMaxAge)?a:0,gcMaxAge:null!=(r=null!=(i=null!=(l=e.gcMaxAge)?l:s.options.defaultPreloadGcMaxAge)?i:s.options.defaultLoaderGcMaxAge)?r:0}),u},matchRoutes:(t,e)=>{var a,n;s.cleanMatchCache();const o=[];if(!s.routeTree)return o;const r=[...s.state.matches,...null!=(a=null==(n=s.state.pending)?void 0:n.matches)?a:[]],i=async a=>{var n,l,c;const u=g(o);let h=null!=(n=null==u?void 0:u.params)?n:{};const d=null!=(l=null==s.options.filterRoutes?void 0:s.options.filterRoutes(a))?l:a;let p=[];const f=(a,n)=>(n.some((n=>{var o,r,i;if(!n.routePath&&null!=(o=n.childRoutes)&&o.length)return f([...p,n],n.childRoutes);const l=!!("/"!==n.routePath||null!=(r=n.childRoutes)&&r.length),c=S(t,{to:n.fullPath,fuzzy:l,caseSensitive:null!=(i=n.options.caseSensitive)?i:s.options.caseSensitive});if(c){let t;try{var u;t=null!=(u=null==n.options.parseParams?void 0:n.options.parseParams(c))?u:c}catch(t){if(null!=e&&e.strictParseParams)throw t}h=k({},h,t)}return c&&(p=[...a,n]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((e=>{var a;const n=M(e.routePath,h),i=M(e.routeId,h,!0),l=r.find((t=>t.matchId===i))||(null==(a=s.matchCache[i])?void 0:a.match)||j(s,e,{matchId:i,params:h,pathname:y([t,n])});o.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&i(m.childRoutes)};return i([s.routeTree]),D(o),o},loadMatches:async(t,e)=>{const a=Date.now(),n=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0,o=t.map((async t=>{if(t.__.validate(),null!=e&&e.preload&&n>0){if(s.state.matches.find((e=>e.matchId===t.matchId)))return;s.matchCache[t.matchId]={gc:a+e.gcMaxAge,match:t}}if("success"===t.status&&t.getIsInvalid()||"error"===t.status||"idle"===t.status){const a=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;t.load({maxAge:a})}"loading"===t.status&&(null!=e&&e.withPending&&t.__.startPending(),await t.__.loadPromise)}));s.notify(),await Promise.all(o)},invalidateRoute:t=>{var e,a;const n=s.buildNext(t),o=s.matchRoutes(n.pathname).map((t=>t.matchId));[...s.state.matches,...null!=(e=null==(a=s.state.pending)?void 0:a.matches)?e:[]].forEach((t=>{o.includes(t.matchId)&&t.invalidate()}))},reload:()=>s.__.navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>x(s.basepath,t,P(e)),matchRoute:(t,e)=>{var a;t=k({},t,{to:t.to?s.resolvePath(null!=(a=t.from)?a:"",t.to):void 0});const n=s.buildNext(t);var o;return null!=e&&e.pending?!(null==(o=s.state.pending)||!o.location)&&!!S(s.state.pending.location.pathname,k({},e,{to:n.pathname})):!!S(s.state.location.pathname,k({},e,{to:n.pathname}))},navigate:async t=>{let{from:e,to:a=".",search:n,hash:o,replace:r,params:i}=t;const l=String(a),c=String(e);let u;try{new URL(""+l),u=!0}catch(t){}return p(!u),s.__.navigate({from:c,to:l,search:n,hash:o,replace:r,params:i})},buildLink:t=>{var e,a;let{from:n,to:o=".",search:r,params:i,hash:l,target:c,replace:u,activeOptions:h,preload:d,preloadMaxAge:p,preloadGcMaxAge:f,preloadDelay:m,disabled:v}=t;try{return new URL(""+o),{type:"external",href:o}}catch(t){}const g={from:n,to:o,search:r,params:i,hash:l,replace:u},_=s.buildNext(g);d=null!=(e=d)?e:s.options.defaultPreload;const y=null!=(a=null!=m?m:s.options.defaultPreloadDelay)?a:0,P=s.state.location.pathname===_.pathname,b=s.state.location.pathname.split("/"),w=_.pathname.split("/").every(((t,e)=>t===b[e])),A=s.state.location.hash===_.hash,x=null!=h&&h.exact?P:w,R=null==h||!h.includeHash||A;return{type:"internal",next:_,handleFocus:t=>{d&&s.preloadRoute(g,{maxAge:p,gcMaxAge:f})},handleClick:t=>{v||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||c&&"_self"!==c||0!==t.button||(t.preventDefault(),!P||r||l||s.invalidateRoute(g),s.__.navigate(g))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,s.preloadRoute(g,{maxAge:p,gcMaxAge:f})}),y)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:x&&R,disabled:v}},buildNext:t=>{const e=s.__.buildLocation(t),a=s.matchRoutes(e.pathname),n=a.map((t=>{var e;return null!=(e=t.options.preSearchFilters)?e:[]})).flat().filter(Boolean),o=a.map((t=>{var e;return null!=(e=t.options.postSearchFilters)?e:[]})).flat().filter(Boolean);return s.__.buildLocation(k({},t,{__preSearchFilters:n,__postSearchFilters:o}))},__:{buildRouteTree:t=>{const e=(t,a)=>t.map((t=>{const n=T(t,t.options,a,s);if(s.routesById[n.routeId])throw new Error;s.routesById[n.routeId]=n;const o=t.children;return n.childRoutes=null!=o&&o.length?e(o,n):void 0,n}));return e([t])[0]},parseLocation:(t,e)=>{var a;const n=s.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:f(null==e?void 0:e.search,n),hash:null!=(a=t.hash.split("#").reverse()[0])?a:"",href:""+t.pathname+t.search+t.hash,state:t.state,key:t.key}},navigate:t=>{const e=s.buildNext(t);return s.__.commitLocation(e,t.replace)},buildLocation:function(t){var e,a,n,o,r,i,l,c,u;void 0===t&&(t={});const h=t.fromCurrent?s.location.pathname:null!=(e=t.from)?e:s.location.pathname;let d=x(null!=(a=s.basepath)?a:"/",h,""+(null!=(n=t.to)?n:"."));const p=s.matchRoutes(s.location.pathname,{strictParseParams:!0}),m=s.matchRoutes(d),v=k({},null==(o=g(p))?void 0:o.params);let y=!0===(null==(r=t.params)||r)?v:_(t.params,v);y&&m.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},y,t(y))})),d=M(d,null!=y?y:{});const P=null!=(i=t.__preSearchFilters)&&i.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),s.location.search):s.location.search,b=!0===t.search?P:t.search?null!=(l=_(t.search,P))?l:{}:null!=(c=t.__preSearchFilters)&&c.length?P:{},w=null!=(u=t.__postSearchFilters)&&u.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),b):b,A=f(s.location.search,w),R=s.options.stringifySearch(A);let S=!0===t.hash?s.location.hash:_(t.hash,s.location.hash);return S=S?"#"+S:"",{pathname:d,search:A,searchStr:R,state:s.location.state,hash:S,href:""+d+R+S,key:t.key}},commitLocation:(t,e)=>{const a=""+Date.now()+Math.random();s.navigateTimeout&&clearTimeout(s.navigateTimeout);let o="replace";e||(o="push");return s.__.parseLocation(n.location).href===t.href&&!t.key&&(o="replace"),"replace"===o?n.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}):n.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}),s.navigationPromise=new Promise((t=>{const e=s.resolveNavigation;s.resolveNavigation=()=>{e(),t()}})),s.navigationPromise}}};return s.location=s.__.parseLocation(n.location),s.state.location=s.location,s.update(t),null==s.options.createRouter||s.options.createRouter(s),s},t.decode=C,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=L,t.functionalUpdate=_,t.interpolatePath=M,t.invariant=p,t.joinPaths=y,t.last=g,t.matchByPath=I,t.matchPathname=S,t.parsePathname=R,t.parseSearchWith=H,t.replaceEqualDeep=f,t.resolvePath=x,t.rootRouteId=O,t.stringifySearchWith=U,t.trimPath=A,t.trimPathLeft=b,t.trimPathRight=w,t.warning=function(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch(t){}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/router-core",
"author": "Tanner Linsley",
"version": "0.0.1-alpha.9",
"version": "0.0.1-alpha.10",
"license": "MIT",

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

@@ -41,3 +41,2 @@ import { GetFrameworkGeneric } from './frameworks'

loaderPromise?: Promise<void>
importPromise?: Promise<void>
elementsPromise?: Promise<void>

@@ -210,3 +209,2 @@ dataPromise?: Promise<void>

route.options.loader ||
route.options.import ||
elementTypes.some((d) => typeof route.options[d] === 'function')

@@ -236,23 +234,4 @@ )

const loaderPromise = (async () => {
const importer = routeMatch.options.import
// Load the elements and data in parallel
// First, run any importers
if (importer) {
routeMatch.__.importPromise = importer({
params: routeMatch.params,
// search: routeMatch.search,
}).then((imported) => {
routeMatch.__ = {
...routeMatch.__,
...imported,
}
})
}
// Wait for the importer to finish before
// attempting to load elements and data
await routeMatch.__.importPromise
// Next, load the elements and data in parallel
routeMatch.__.elementsPromise = (async () => {

@@ -259,0 +238,0 @@ // then run all element and data loaders in parallel

@@ -188,2 +188,3 @@ import {

> {
history: BrowserHistory | MemoryHistory | HashHistory
options: PickAsRequired<

@@ -215,11 +216,3 @@ RouterOptions<TRouteConfig>,

) => Router<TRouteConfig>
buildRouteTree: (
routeConfig: RouteConfig,
) => Route<TAllRouteInfo, AnyRouteInfo>
parseLocation: (
location: History['location'],
previousLocation?: Location,
) => Location
buildLocation: (dest: BuildNextOptions) => Location
commitLocation: (next: Location, replace?: boolean) => Promise<void>
buildNext: (opts: BuildNextOptions) => Location

@@ -252,5 +245,2 @@ cancelMatches: () => void

resolvePath: (from: string, path: string) => string
_navigate: (
location: BuildNextOptions & { replace?: boolean },
) => Promise<void>
navigate: <

@@ -275,2 +265,16 @@ TFrom extends ValidFromPath<TAllRouteInfo> = '/',

) => LinkInfo
__: {
buildRouteTree: (
routeConfig: RouteConfig,
) => Route<TAllRouteInfo, AnyRouteInfo>
parseLocation: (
location: History['location'],
previousLocation?: Location,
) => Location
buildLocation: (dest: BuildNextOptions) => Location
commitLocation: (next: Location, replace?: boolean) => Promise<void>
navigate: (
location: BuildNextOptions & { replace?: boolean },
) => Promise<void>
}
}

@@ -306,2 +310,3 @@

let router: Router<TRouteConfig, TAllRouteInfo> = {
history,
options: originalOptions,

@@ -358,3 +363,3 @@ listeners: [],

mount: () => {
const next = router.buildLocation({
const next = router.__.buildLocation({
to: '.',

@@ -368,3 +373,3 @@ search: true,

if (next.href !== router.location.href) {
router.commitLocation(next, true)
router.__.commitLocation(next, true)
} else {

@@ -376,3 +381,3 @@ router.loadLocation()

router.loadLocation(
router.parseLocation(event.location, router.location),
router.__.parseLocation(event.location, router.location),
)

@@ -410,3 +415,3 @@ })

router.routesById = {} as any
router.routeTree = router.buildRouteTree(routeConfig)
router.routeTree = router.__.buildRouteTree(routeConfig)
}

@@ -417,225 +422,2 @@

buildRouteTree: (rootRouteConfig: RouteConfig) => {
const recurseRoutes = (
routeConfigs: RouteConfig[],
parent?: Route<TAllRouteInfo, any>,
): Route<TAllRouteInfo, any>[] => {
return routeConfigs.map((routeConfig) => {
const routeOptions = routeConfig.options
const route = createRoute(routeConfig, routeOptions, parent, router)
// {
// pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
// pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
// }
const existingRoute = (router.routesById as any)[route.routeId]
if (existingRoute) {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`Duplicate routes found with id: ${String(route.routeId)}`,
router.routesById,
route,
)
}
throw new Error()
}
;(router.routesById as any)[route.routeId] = route
const children = routeConfig.children as RouteConfig[]
route.childRoutes = children?.length
? recurseRoutes(children, route)
: undefined
return route
})
}
const routes = recurseRoutes([rootRouteConfig])
return routes[0]!
},
parseLocation: (
location: History['location'],
previousLocation?: Location,
): Location => {
const parsedSearch = router.options.parseSearch(location.search)
return {
pathname: location.pathname,
searchStr: location.search,
search: replaceEqualDeep(previousLocation?.search, parsedSearch),
hash: location.hash.split('#').reverse()[0] ?? '',
href: `${location.pathname}${location.search}${location.hash}`,
state: location.state as LocationState,
key: location.key,
}
},
buildLocation: (dest: BuildNextOptions = {}): Location => {
// const resolvedFrom: Location = {
// ...router.location,
const fromPathname = dest.fromCurrent
? router.location.pathname
: dest.from ?? router.location.pathname
let pathname = resolvePath(
router.basepath ?? '/',
fromPathname,
`${dest.to ?? '.'}`,
)
const fromMatches = router.matchRoutes(router.location.pathname, {
strictParseParams: true,
})
const toMatches = router.matchRoutes(pathname)
const prevParams = { ...last(fromMatches)?.params }
let nextParams =
(dest.params ?? true) === true
? prevParams
: functionalUpdate(dest.params!, prevParams)
if (nextParams) {
toMatches
.map((d) => d.options.stringifyParams)
.filter(Boolean)
.forEach((fn) => {
Object.assign({}, nextParams!, fn!(nextParams!))
})
}
pathname = interpolatePath(pathname, nextParams ?? {})
// Pre filters first
const preFilteredSearch = dest.__preSearchFilters?.length
? dest.__preSearchFilters.reduce(
(prev, next) => next(prev),
router.location.search,
)
: router.location.search
// Then the link/navigate function
const destSearch =
dest.search === true
? preFilteredSearch // Preserve resolvedFrom true
: dest.search
? functionalUpdate(dest.search, preFilteredSearch) ?? {} // Updater
: dest.__preSearchFilters?.length
? preFilteredSearch // Preserve resolvedFrom filters
: {}
// Then post filters
const postFilteredSearch = dest.__postSearchFilters?.length
? dest.__postSearchFilters.reduce(
(prev, next) => next(prev),
destSearch,
)
: destSearch
const search = replaceEqualDeep(
router.location.search,
postFilteredSearch,
)
const searchStr = router.options.stringifySearch(search)
let hash =
dest.hash === true
? router.location.hash
: functionalUpdate(dest.hash!, router.location.hash)
hash = hash ? `#${hash}` : ''
return {
pathname,
search,
searchStr,
state: router.location.state,
hash,
href: `${pathname}${searchStr}${hash}`,
key: dest.key,
}
},
commitLocation: (next: Location, replace?: boolean): Promise<void> => {
const id = '' + Date.now() + Math.random()
if (router.navigateTimeout) clearTimeout(router.navigateTimeout)
let nextAction: 'push' | 'replace' = 'replace'
if (!replace) {
nextAction = 'push'
}
const isSameUrl =
router.parseLocation(history.location).href === next.href
if (isSameUrl && !next.key) {
nextAction = 'replace'
}
if (nextAction === 'replace') {
history.replace(
{
pathname: next.pathname,
hash: next.hash,
search: next.searchStr,
},
{
id,
},
)
} else {
history.push(
{
pathname: next.pathname,
hash: next.hash,
search: next.searchStr,
},
{
id,
},
)
}
router.navigationPromise = new Promise((resolve) => {
const previousNavigationResolve = router.resolveNavigation
router.resolveNavigation = () => {
previousNavigationResolve()
resolve()
}
})
return router.navigationPromise
},
buildNext: (opts: BuildNextOptions) => {
const next = router.buildLocation(opts)
const matches = router.matchRoutes(next.pathname)
const __preSearchFilters = matches
.map((match) => match.options.preSearchFilters ?? [])
.flat()
.filter(Boolean)
const __postSearchFilters = matches
.map((match) => match.options.postSearchFilters ?? [])
.flat()
.filter(Boolean)
return router.buildLocation({
...opts,
__preSearchFilters,
__postSearchFilters,
})
},
cancelMatches: () => {

@@ -752,2 +534,3 @@ ;[

})
delete router.matchCache[d.matchId]
})

@@ -1000,3 +783,3 @@

reload: () =>
router._navigate({
router.__.navigate({
fromCurrent: true,

@@ -1039,7 +822,2 @@ replace: true,

_navigate: (location: BuildNextOptions & { replace?: boolean }) => {
const next = router.buildNext(location)
return router.commitLocation(next, location.replace)
},
navigate: async ({ from, to = '.', search, hash, replace, params }) => {

@@ -1066,3 +844,3 @@ // If this link simply reloads the current route,

return router._navigate({
return router.__.navigate({
from: fromString,

@@ -1151,3 +929,3 @@ to: toString,

// All is well? Navigate!)
router._navigate(nextOpts)
router.__.navigate(nextOpts)
}

@@ -1204,5 +982,234 @@ }

},
buildNext: (opts: BuildNextOptions) => {
const next = router.__.buildLocation(opts)
const matches = router.matchRoutes(next.pathname)
const __preSearchFilters = matches
.map((match) => match.options.preSearchFilters ?? [])
.flat()
.filter(Boolean)
const __postSearchFilters = matches
.map((match) => match.options.postSearchFilters ?? [])
.flat()
.filter(Boolean)
return router.__.buildLocation({
...opts,
__preSearchFilters,
__postSearchFilters,
})
},
__: {
buildRouteTree: (rootRouteConfig: RouteConfig) => {
const recurseRoutes = (
routeConfigs: RouteConfig[],
parent?: Route<TAllRouteInfo, any>,
): Route<TAllRouteInfo, any>[] => {
return routeConfigs.map((routeConfig) => {
const routeOptions = routeConfig.options
const route = createRoute(routeConfig, routeOptions, parent, router)
// {
// pendingMs: routeOptions.pendingMs ?? router.defaultPendingMs,
// pendingMinMs: routeOptions.pendingMinMs ?? router.defaultPendingMinMs,
// }
const existingRoute = (router.routesById as any)[route.routeId]
if (existingRoute) {
if (process.env.NODE_ENV !== 'production') {
console.warn(
`Duplicate routes found with id: ${String(route.routeId)}`,
router.routesById,
route,
)
}
throw new Error()
}
;(router.routesById as any)[route.routeId] = route
const children = routeConfig.children as RouteConfig[]
route.childRoutes = children?.length
? recurseRoutes(children, route)
: undefined
return route
})
}
const routes = recurseRoutes([rootRouteConfig])
return routes[0]!
},
parseLocation: (
location: History['location'],
previousLocation?: Location,
): Location => {
const parsedSearch = router.options.parseSearch(location.search)
return {
pathname: location.pathname,
searchStr: location.search,
search: replaceEqualDeep(previousLocation?.search, parsedSearch),
hash: location.hash.split('#').reverse()[0] ?? '',
href: `${location.pathname}${location.search}${location.hash}`,
state: location.state as LocationState,
key: location.key,
}
},
navigate: (location: BuildNextOptions & { replace?: boolean }) => {
const next = router.buildNext(location)
return router.__.commitLocation(next, location.replace)
},
buildLocation: (dest: BuildNextOptions = {}): Location => {
// const resolvedFrom: Location = {
// ...router.location,
const fromPathname = dest.fromCurrent
? router.location.pathname
: dest.from ?? router.location.pathname
let pathname = resolvePath(
router.basepath ?? '/',
fromPathname,
`${dest.to ?? '.'}`,
)
const fromMatches = router.matchRoutes(router.location.pathname, {
strictParseParams: true,
})
const toMatches = router.matchRoutes(pathname)
const prevParams = { ...last(fromMatches)?.params }
let nextParams =
(dest.params ?? true) === true
? prevParams
: functionalUpdate(dest.params!, prevParams)
if (nextParams) {
toMatches
.map((d) => d.options.stringifyParams)
.filter(Boolean)
.forEach((fn) => {
Object.assign({}, nextParams!, fn!(nextParams!))
})
}
pathname = interpolatePath(pathname, nextParams ?? {})
// Pre filters first
const preFilteredSearch = dest.__preSearchFilters?.length
? dest.__preSearchFilters.reduce(
(prev, next) => next(prev),
router.location.search,
)
: router.location.search
// Then the link/navigate function
const destSearch =
dest.search === true
? preFilteredSearch // Preserve resolvedFrom true
: dest.search
? functionalUpdate(dest.search, preFilteredSearch) ?? {} // Updater
: dest.__preSearchFilters?.length
? preFilteredSearch // Preserve resolvedFrom filters
: {}
// Then post filters
const postFilteredSearch = dest.__postSearchFilters?.length
? dest.__postSearchFilters.reduce(
(prev, next) => next(prev),
destSearch,
)
: destSearch
const search = replaceEqualDeep(
router.location.search,
postFilteredSearch,
)
const searchStr = router.options.stringifySearch(search)
let hash =
dest.hash === true
? router.location.hash
: functionalUpdate(dest.hash!, router.location.hash)
hash = hash ? `#${hash}` : ''
return {
pathname,
search,
searchStr,
state: router.location.state,
hash,
href: `${pathname}${searchStr}${hash}`,
key: dest.key,
}
},
commitLocation: (next: Location, replace?: boolean): Promise<void> => {
const id = '' + Date.now() + Math.random()
if (router.navigateTimeout) clearTimeout(router.navigateTimeout)
let nextAction: 'push' | 'replace' = 'replace'
if (!replace) {
nextAction = 'push'
}
const isSameUrl =
router.__.parseLocation(history.location).href === next.href
if (isSameUrl && !next.key) {
nextAction = 'replace'
}
if (nextAction === 'replace') {
history.replace(
{
pathname: next.pathname,
hash: next.hash,
search: next.searchStr,
},
{
id,
},
)
} else {
history.push(
{
pathname: next.pathname,
hash: next.hash,
search: next.searchStr,
},
{
id,
},
)
}
router.navigationPromise = new Promise((resolve) => {
const previousNavigationResolve = router.resolveNavigation
router.resolveNavigation = () => {
previousNavigationResolve()
resolve()
}
})
return router.navigationPromise
},
},
}
router.location = router.parseLocation(history.location)
router.location = router.__.parseLocation(history.location)
router.state.location = router.location

@@ -1209,0 +1216,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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