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-beta.9 to 0.0.1-beta.10

21

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

@@ -27,3 +27,3 @@ /**

router.state.actions[id] = {
pending: [],
submissions: [],
submit: async (submission, actionOpts) => {

@@ -37,14 +37,16 @@ var _actionOpts$invalidat;

const invalidate = (_actionOpts$invalidat = actionOpts == null ? void 0 : actionOpts.invalidate) != null ? _actionOpts$invalidat : true;
if (!(actionOpts != null && actionOpts.multi)) {
action.submissions = action.submissions.filter(d => d.isMulti);
}
const actionState = {
submittedAt: Date.now(),
status: 'pending',
submission
submission,
isMulti: !!(actionOpts != null && actionOpts.multi)
};
action.current = actionState;
action.latest = actionState;
action.pending.push(actionState);
router.state = _rollupPluginBabelHelpers["extends"]({}, router.state, {
currentAction: actionState,
latestAction: actionState
});
action.submissions.push(actionState);
router.notify();

@@ -71,7 +73,2 @@

} finally {
action.pending = action.pending.filter(d => d !== actionState);
router.removeActionQueue.push({
action,
actionState
});
router.notify();

@@ -78,0 +75,0 @@ }

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

invalidAt: Infinity,
// pendingActions: [],
getIsInvalid: () => {

@@ -72,13 +73,2 @@ const now = Date.now();

},
// setParentMatch: (parentMatch?: RouteMatch) => {
// routeMatch.parentMatch = parentMatch
// },
// addChildMatch: (childMatch: RouteMatch) => {
// if (
// routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
// ) {
// return
// }
// routeMatch.childMatches.push(childMatch)
// },
validate: () => {

@@ -91,5 +81,7 @@ var _routeMatch$parentMat, _routeMatch$parentMat2;

try {
var _validator;
const prevSearch = routeMatch.routeSearch;
const validator = typeof routeMatch.options.validateSearch === 'object' ? routeMatch.options.validateSearch.parse : routeMatch.options.validateSearch;
let nextSearch = utils.replaceEqualDeep(prevSearch, validator == null ? void 0 : validator(parentSearch)); // Invalidate route matches when search param stability changes
let nextSearch = utils.replaceEqualDeep(prevSearch, (_validator = validator == null ? void 0 : validator(parentSearch)) != null ? _validator : {}); // Invalidate route matches when search param stability changes

@@ -102,2 +94,9 @@ if (prevSearch !== nextSearch) {

routeMatch.search = utils.replaceEqualDeep(parentSearch, _rollupPluginBabelHelpers["extends"]({}, parentSearch, nextSearch));
elementTypes.map(async type => {
const routeElement = routeMatch.options[type];
if (typeof routeMatch.__[type] !== 'function') {
routeMatch.__[type] = routeElement;
}
});
} catch (err) {

@@ -148,3 +147,3 @@ console.error(err);

const maxAge = loaderOpts != null && loaderOpts.preload ? loaderOpts == null ? void 0 : loaderOpts.maxAge : undefined;
routeMatch.fetch({
await routeMatch.fetch({
maxAge

@@ -172,3 +171,3 @@ });

const loaderPromise = (async () => {
routeMatch.__.loaderDataPromise = (async () => {
// Load the elements and data in parallel

@@ -181,7 +180,5 @@ routeMatch.__.elementsPromise = (async () => {

if (routeMatch.__[type]) {
return;
if (typeof routeMatch.__[type] === 'function') {
routeMatch.__[type] = await router.options.createElement(routeElement);
}
routeMatch.__[type] = await router.options.createElement(routeElement);
}));

@@ -202,3 +199,3 @@ })();

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise;
return routeMatch.__.loadPromise;
}

@@ -215,3 +212,3 @@

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise;
return routeMatch.__.loadPromise;
}

@@ -233,3 +230,3 @@

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise;
return routeMatch.__.loadPromise;
}

@@ -243,3 +240,3 @@

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise;
return routeMatch.__.loadPromise;
}

@@ -256,12 +253,12 @@

routeMatch.__.loaderPromise = loaderPromise;
await loaderPromise;
await routeMatch.__.loaderDataPromise;
if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise;
return routeMatch.__.loadPromise;
}
delete routeMatch.__.loaderPromise;
delete routeMatch.__.loaderDataPromise;
});
return await routeMatch.__.loadPromise;
await routeMatch.__.loadPromise;
delete routeMatch.__.loadPromise;
}

@@ -268,0 +265,0 @@ });

@@ -30,2 +30,15 @@ /**

function getInitialRouterState() {
return {
status: 'idle',
location: null,
matches: [],
actions: {},
loaders: {},
lastUpdated: Date.now(),
isFetching: false,
isPreloading: false
};
}
function createRouter(userOptions) {

@@ -50,3 +63,2 @@ var _userOptions$stringif, _userOptions$parseSea;

listeners: [],
removeActionQueue: [],
// Resolved after construction

@@ -62,11 +74,6 @@ basepath: '',

matchCache: {},
state: {
status: 'idle',
location: null,
matches: [],
actions: {},
loaders: {},
lastUpdated: Date.now(),
isFetching: false,
isPreloading: false
state: getInitialRouterState(),
reset: () => {
router.state = getInitialRouterState();
router.notify();
},

@@ -101,9 +108,10 @@ startedLoadingAt: Date.now(),

});
matches.forEach((match, index) => {
const dehydratedMatch = dehydratedState.matches[index];
tinyInvariant["default"](dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
Object.assign(match, dehydratedMatch);
});
router.loadMatches(matches);
router.state = _rollupPluginBabelHelpers["extends"]({}, router.state, dehydratedState, {
matches: matches.map(match => {
const dehydratedMatch = dehydratedState.matches.find(d => d.matchId === match.matchId);
tinyInvariant["default"](dehydratedMatch, 'Oh no! Dehydrated route matches did not match the active state of the router 😬');
Object.assign(match, dehydratedMatch);
return match;
})
matches
});

@@ -122,8 +130,7 @@ },

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

@@ -139,10 +146,13 @@ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition

return () => {
unsub(); // Be sure to unsubscribe if a new handler is set
unsub();
window.removeEventListener('visibilitychange', router.onFocus);
window.removeEventListener('focus', router.onFocus);
if (!isServer && window.removeEventListener) {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener('visibilitychange', router.onFocus);
window.removeEventListener('focus', router.onFocus);
}
};
},
onFocus: () => {
router.loadLocation();
router.load();
},

@@ -181,3 +191,3 @@ update: opts => {

},
loadLocation: async next => {
load: async next => {
const id = Math.random();

@@ -189,21 +199,5 @@ router.startedLoadingAt = id;

router.location = next;
} // Clear out old actions
} // Cancel any pending matches
router.removeActionQueue.forEach(_ref => {
let {
action,
actionState
} = _ref;
if (router.state.currentAction === actionState) {
router.state.currentAction = undefined;
}
if (action.current === actionState) {
action.current = undefined;
}
});
router.removeActionQueue = []; // Cancel any pending matches
router.cancelMatches(); // Match the routes

@@ -244,3 +238,3 @@

exiting.forEach(d => {
var _ref2, _d$options$loaderGcMa, _ref3, _d$options$loaderMaxA;
var _ref, _d$options$loaderGcMa, _ref2, _d$options$loaderMaxA;

@@ -250,3 +244,8 @@ d.__.onExit == null ? void 0 : d.__.onExit({

search: d.routeSearch
}); // Clear idle error states when match leaves
}); // // Clear actions
// if (d.action) {
// d.action.current = undefined
// d.action.submissions = []
// }
// Clear idle error states when match leaves

@@ -258,3 +257,3 @@ if (d.status === 'error' && !d.isFetching) {

const gc = Math.max((_ref2 = (_d$options$loaderGcMa = d.options.loaderGcMaxAge) != null ? _d$options$loaderGcMa : router.options.defaultLoaderGcMaxAge) != null ? _ref2 : 0, (_ref3 = (_d$options$loaderMaxA = d.options.loaderMaxAge) != null ? _d$options$loaderMaxA : router.options.defaultLoaderMaxAge) != null ? _ref3 : 0);
const gc = Math.max((_ref = (_d$options$loaderGcMa = d.options.loaderGcMaxAge) != null ? _d$options$loaderGcMa : router.options.defaultLoaderGcMaxAge) != null ? _ref : 0, (_ref2 = (_d$options$loaderMaxA = d.options.loaderMaxAge) != null ? _d$options$loaderMaxA : router.options.defaultLoaderMaxAge) != null ? _ref2 : 0);

@@ -283,9 +282,4 @@ if (gc > 0) {

delete router.matchCache[d.matchId];
});
}); // router.notify()
if (matches.some(d => d.status === 'loading')) {
router.notify();
await Promise.all(matches.map(d => d.__.loaderPromise || Promise.resolve()));
}
if (router.startedLoadingAt !== id) {

@@ -296,2 +290,9 @@ // Ignore side-effects of match loading

matches.forEach(match => {
// Clear actions
if (match.action) {
match.action.current = undefined;
match.action.submissions = [];
}
});
router.state = _rollupPluginBabelHelpers["extends"]({}, router.state, {

@@ -337,3 +338,3 @@ location: router.location,

preloadRoute: async function preloadRoute(navigateOpts, loaderOpts) {
var _ref4, _ref5, _loaderOpts$maxAge, _ref6, _ref7, _loaderOpts$gcMaxAge;
var _ref3, _ref4, _loaderOpts$maxAge, _ref5, _ref6, _loaderOpts$gcMaxAge;

@@ -350,4 +351,4 @@ if (navigateOpts === void 0) {

preload: true,
maxAge: (_ref4 = (_ref5 = (_loaderOpts$maxAge = loaderOpts.maxAge) != null ? _loaderOpts$maxAge : router.options.defaultPreloadMaxAge) != null ? _ref5 : router.options.defaultLoaderMaxAge) != null ? _ref4 : 0,
gcMaxAge: (_ref6 = (_ref7 = (_loaderOpts$gcMaxAge = loaderOpts.gcMaxAge) != null ? _loaderOpts$gcMaxAge : router.options.defaultPreloadGcMaxAge) != null ? _ref7 : router.options.defaultLoaderGcMaxAge) != null ? _ref6 : 0
maxAge: (_ref3 = (_ref4 = (_loaderOpts$maxAge = loaderOpts.maxAge) != null ? _loaderOpts$maxAge : router.options.defaultPreloadMaxAge) != null ? _ref4 : router.options.defaultLoaderMaxAge) != null ? _ref3 : 0,
gcMaxAge: (_ref5 = (_ref6 = (_loaderOpts$gcMaxAge = loaderOpts.gcMaxAge) != null ? _loaderOpts$gcMaxAge : router.options.defaultPreloadGcMaxAge) != null ? _ref6 : router.options.defaultLoaderGcMaxAge) != null ? _ref5 : 0
});

@@ -454,5 +455,8 @@ return matches;

// If requested, start the pending timers
if (loaderOpts != null && loaderOpts.withPending) match.__.startPending(); // Wait for the first sign of activity from the match
if (loaderOpts != null && loaderOpts.withPending) match.__.startPending();
}
if (match.__.loadPromise) {
// Wait for the first sign of activity from the match
// This might be completion, error, or a pending state
await match.__.loadPromise;

@@ -508,3 +512,3 @@ }

},
navigate: async _ref8 => {
navigate: async _ref7 => {
let {

@@ -517,3 +521,3 @@ from,

params
} = _ref8;
} = _ref7;
// If this link simply reloads the current route,

@@ -542,4 +546,4 @@ // make sure it has a new key so it will trigger a data refresh

},
buildLink: _ref9 => {
var _preload, _ref10;
buildLink: _ref8 => {
var _preload, _ref9;

@@ -560,3 +564,3 @@ let {

disabled
} = _ref9;
} = _ref8;

@@ -585,3 +589,3 @@ // If this link simply reloads the current route,

preload = (_preload = preload) != null ? _preload : router.options.defaultPreload;
const preloadDelay = (_ref10 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref10 : 0; // Compare path/hash for matches
const preloadDelay = (_ref9 = userPreloadDelay != null ? userPreloadDelay : router.options.defaultPreloadDelay) != null ? _ref9 : 0; // Compare path/hash for matches

@@ -588,0 +592,0 @@ const pathIsEqual = router.state.location.pathname === next.pathname;

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

"name": "@babel/runtime/helpers/esm/extends.js",
"uid": "aba2-30"
"uid": "36ff-30"
},
{
"name": "history/index.js",
"uid": "aba2-32"
"uid": "36ff-32"
},
{
"name": "tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "aba2-34"
"uid": "36ff-34"
}

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

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

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

{
"uid": "aba2-42",
"uid": "36ff-42",
"name": "\u0000rollupPluginBabelHelpers.js"

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

"nodeParts": {
"aba2-30": {
"36ff-30": {
"renderedLength": 437,
"gzipLength": 243,
"brotliLength": 0,
"mainUid": "aba2-29"
"mainUid": "36ff-29"
},
"aba2-32": {
"36ff-32": {
"renderedLength": 20630,
"gzipLength": 3800,
"brotliLength": 0,
"mainUid": "aba2-31"
"mainUid": "36ff-31"
},
"aba2-34": {
"36ff-34": {
"renderedLength": 181,
"gzipLength": 129,
"brotliLength": 0,
"mainUid": "aba2-33"
"mainUid": "36ff-33"
},
"aba2-36": {
"36ff-36": {
"renderedLength": 2469,
"gzipLength": 983,
"brotliLength": 0,
"mainUid": "aba2-35"
"mainUid": "36ff-35"
},
"aba2-38": {
"36ff-38": {
"renderedLength": 5496,
"gzipLength": 1394,
"brotliLength": 0,
"mainUid": "aba2-37"
"mainUid": "36ff-37"
},
"aba2-40": {
"36ff-40": {
"renderedLength": 1320,
"gzipLength": 560,
"brotliLength": 0,
"mainUid": "aba2-39"
"mainUid": "36ff-39"
},
"aba2-42": {
"36ff-42": {
"renderedLength": 431,
"gzipLength": 240,
"brotliLength": 0,
"mainUid": "aba2-41"
"mainUid": "36ff-41"
},
"aba2-44": {
"renderedLength": 3668,
"36ff-44": {
"renderedLength": 3560,
"gzipLength": 932,
"brotliLength": 0,
"mainUid": "aba2-43"
"mainUid": "36ff-43"
},
"aba2-46": {
"36ff-46": {
"renderedLength": 1416,
"gzipLength": 490,
"brotliLength": 0,
"mainUid": "aba2-45"
"mainUid": "36ff-45"
},
"aba2-48": {
"renderedLength": 9301,
"gzipLength": 2208,
"36ff-48": {
"renderedLength": 9257,
"gzipLength": 2178,
"brotliLength": 0,
"mainUid": "aba2-47"
"mainUid": "36ff-47"
},
"aba2-50": {
"36ff-50": {
"renderedLength": 1262,
"gzipLength": 479,
"brotliLength": 0,
"mainUid": "aba2-49"
"mainUid": "36ff-49"
},
"aba2-52": {
"renderedLength": 29040,
"gzipLength": 6549,
"36ff-52": {
"renderedLength": 28997,
"gzipLength": 6529,
"brotliLength": 0,
"mainUid": "aba2-51"
"mainUid": "36ff-51"
},
"aba2-54": {
"36ff-54": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "aba2-53"
"mainUid": "36ff-53"
}
},
"nodeMetas": {
"aba2-29": {
"36ff-29": {
"id": "/node_modules/@babel/runtime/helpers/esm/extends.js",
"moduleParts": {
"index.production.js": "aba2-30"
"index.production.js": "36ff-30"
},

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

{
"uid": "aba2-31"
"uid": "36ff-31"
}
]
},
"aba2-31": {
"36ff-31": {
"id": "/node_modules/history/index.js",
"moduleParts": {
"index.production.js": "aba2-32"
"index.production.js": "36ff-32"
},
"imported": [
{
"uid": "aba2-29"
"uid": "36ff-29"
}

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

{
"uid": "aba2-53"
"uid": "36ff-53"
},
{
"uid": "aba2-51"
"uid": "36ff-51"
}
]
},
"aba2-33": {
"36ff-33": {
"id": "/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "aba2-34"
"index.production.js": "36ff-34"
},

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

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

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

{
"uid": "aba2-53"
"uid": "36ff-53"
},
{
"uid": "aba2-37"
"uid": "36ff-37"
},
{
"uid": "aba2-47"
"uid": "36ff-47"
},
{
"uid": "aba2-51"
"uid": "36ff-51"
}
]
},
"aba2-37": {
"36ff-37": {
"id": "/packages/router-core/src/path.ts",
"moduleParts": {
"index.production.js": "aba2-38"
"index.production.js": "36ff-38"
},
"imported": [
{
"uid": "aba2-35"
"uid": "36ff-35"
}

@@ -244,16 +244,16 @@ ],

{
"uid": "aba2-53"
"uid": "36ff-53"
},
{
"uid": "aba2-45"
"uid": "36ff-45"
},
{
"uid": "aba2-51"
"uid": "36ff-51"
}
]
},
"aba2-39": {
"36ff-39": {
"id": "/packages/router-core/src/qss.ts",
"moduleParts": {
"index.production.js": "aba2-40"
"index.production.js": "36ff-40"
},

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

{
"uid": "aba2-53"
"uid": "36ff-53"
},
{
"uid": "aba2-49"
"uid": "36ff-49"
}
]
},
"aba2-41": {
"36ff-41": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "aba2-42"
"index.production.js": "36ff-42"
},

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

{
"uid": "aba2-43"
"uid": "36ff-43"
},
{
"uid": "aba2-47"
"uid": "36ff-47"
},
{
"uid": "aba2-51"
"uid": "36ff-51"
},
{
"uid": "aba2-49"
"uid": "36ff-49"
}
]
},
"aba2-43": {
"36ff-43": {
"id": "/packages/router-core/src/route.ts",
"moduleParts": {
"index.production.js": "aba2-44"
"index.production.js": "36ff-44"
},
"imported": [
{
"uid": "aba2-41"
"uid": "36ff-41"
}

@@ -305,17 +305,17 @@ ],

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

@@ -325,17 +325,17 @@ ],

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

@@ -345,20 +345,20 @@ ],

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

@@ -368,38 +368,38 @@ ],

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

@@ -409,53 +409,53 @@ ],

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

@@ -465,3 +465,3 @@ ],

{
"uid": "aba2-53"
"uid": "36ff-53"
}

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

},
"aba2-55": {
"36ff-55": {
"id": "/packages/router-core/src/frameworks.ts",

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

{
"uid": "aba2-53"
"uid": "36ff-53"
}
]
},
"aba2-56": {
"36ff-56": {
"id": "/packages/router-core/src/link.ts",

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

{
"uid": "aba2-53"
"uid": "36ff-53"
}
]
},
"aba2-57": {
"36ff-57": {
"id": "/packages/router-core/src/routeInfo.ts",

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

{
"uid": "aba2-53"
"uid": "36ff-53"
}

@@ -503,0 +503,0 @@ ]

@@ -84,3 +84,3 @@ /**

loadPromise?: Promise<void>;
loaderPromise?: Promise<void>;
loaderDataPromise?: Promise<void>;
elementsPromise?: Promise<void>;

@@ -176,6 +176,9 @@ dataPromise?: Promise<void>;

interface Action<TPayload = unknown, TResponse = unknown> {
submit: (submission?: TPayload) => Promise<TResponse>;
submit: (submission?: TPayload, actionOpts?: {
invalidate?: boolean;
multi?: boolean;
}) => Promise<TResponse>;
current?: ActionState<TPayload, TResponse>;
latest?: ActionState<TPayload, TResponse>;
pending: ActionState<TPayload, TResponse>[];
submissions: ActionState<TPayload, TResponse>[];
}

@@ -186,2 +189,3 @@ interface ActionState<TPayload = unknown, TResponse = unknown> {

submission: TPayload;
isMulti: boolean;
data?: TResponse;

@@ -218,4 +222,2 @@ error?: unknown;

lastUpdated: number;
currentAction?: ActionState;
latestAction?: ActionState;
actions: Record<string, Action>;

@@ -277,9 +279,6 @@ loaders: Record<string, Loader>;

navigationPromise: Promise<void>;
removeActionQueue: {
action: Action;
actionState: ActionState;
}[];
startedLoadingAt: number;
resolveNavigation: () => void;
subscribe: (listener: Listener) => () => void;
reset: () => void;
notify: () => void;

@@ -291,3 +290,3 @@ mount: () => () => void;

cancelMatches: () => void;
loadLocation: (next?: Location) => Promise<void>;
load: (next?: Location) => Promise<void>;
matchCache: Record<string, MatchCacheEntry>;

@@ -294,0 +293,0 @@ cleanMatchCache: () => 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(){I(-1*r)}},I(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 I(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var M={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:I,back:function(){I(-1)},forward:function(){I(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 M}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,e){return e.reduce(((e,a)=>(e[a]=t[a],e)),{})}function P(t){return b(t.filter(Boolean).join("/"))}function b(t){return t.replace(/\/{2,}/g,"/")}function w(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function A(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function x(t){return A(w(t))}function R(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=I(e);const o=I(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 b(P([t,...n.map((t=>t.value))]))}function I(t){if(!t)return[];const e=[];if("/"===(t=b(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 P(I(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=I(t),o=I(""+(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["*"]=P(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 E(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 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 k(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],C(e.shift())):n[a]=C(e.shift());return n}function T(){return T=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},T.apply(this,arguments)}function D(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(!u)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=T({},n.state,{currentAction:r,latestAction:r}),n.notify();try{const e=await(null==u.options.action?void 0:u.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]),c=n.state.loaders[o]||(n.state.loaders[o]={pending:[],fetch:async t=>{if(!u)return;const e={loadedAt:Date.now(),loaderContext:t};c.current=e,c.latest=e,c.pending.push(e),n.notify();try{return await(null==u.options.loader?void 0:u.options.loader(t))}finally{c.pending=c.pending.filter((t=>t!==e)),n.notify()}}},n.state.loaders[o]);let u={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:n,childRoutes:void 0,parentRoute:a,action:l,loader:c,buildLink:t=>n.buildLink(T({},t,{from:s})),navigate:t=>n.navigate(T({},t,{from:s})),matchRoute:(t,e)=>n.matchRoute(T({},t,{from:s}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:u}),u}const O="__root__",F=["element","errorElement","catchElement","pendingElement"];function j(t,e,a){const n=T({},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,T({},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(),o=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0;if(null!=e&&e.preload&&o>0){if(t.state.matches.find((t=>t.matchId===n.matchId)))return;t.matchCache[n.matchId]={gc:a+e.gcMaxAge,match:n}}if("success"===n.status&&n.getIsInvalid()||"error"===n.status||"idle"===n.status){const t=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;n.fetch({maxAge:t})}},fetch: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 e=>{const a=n.options[e];n.__[e]||(n.__[e]=await t.options.createElement(a))})))})(),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=U(JSON.parse),B=H(JSON.stringify);function U(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=k(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function H(t){return e=>{(e=T({},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=E(e).toString();return a?"?"+a:""}}var G;const z="undefined"==typeof window||!(null!=(G=window.document)&&G.createElement);function K(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=f(e.loaderData,T({},n.loaderData,e.routeLoaderData)))}))}t.cleanPath=b,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(){M(-1*r)}},M(r))}}else I(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 I(t){v=t;var e=p();y=e[0],_=e[1],P.call({action:v,location:_})}function M(t){s.go(t)}null==y&&(y=0,s.replaceState(e({},s.state,{idx:y}),""));var S={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)}I(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),I(o)}},go:M,back:function(){M(-1)},forward:function(){M(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 S},t.createMemoryHistory=i,t.createRoute=D,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=x(i));const s=i||e.id;let l=P([o,s]);i===O&&(i="/"),l!==O&&(l=P(["/",l]));const c=l===O?"/":A(P([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=T({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:{},loaders:{},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=T({},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))))}),K(s.state.matches),s.listeners.forEach((t=>t(s)))},dehydrateState:()=>T({},_(s.state,["status","location","lastUpdated"]),{matches:s.state.matches.map((t=>_(t,["matchId","status","routeLoaderData","loaderData","isInvalid","invalidAt"])))}),hydrateState:t=>{const e=s.matchRoutes(s.location.pathname,{strictParseParams:!0});s.state=T({},s.state,t,{matches:e.map((e=>{const a=t.matches.find((t=>t.matchId===e.matchId));return p(a),Object.assign(e,a),e}))})},mount:()=>{const t=s.__.buildLocation({to:".",search:!0,hash:!0});t.href!==s.location.href&&s.__.commitLocation(t,!0),s.loadLocation();const e=s.history.listen((t=>{console.log(t.location),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=>{const e=(null==t?void 0:t.history)!==s.history;s.location&&!e||(null!=t&&t.history&&(s.history=t.history),s.location=s.__.parseLocation(s.history.location),s.state.location=s.location),Object.assign(s.options,t);const{basepath:a,routeConfig:n}=s.options;return s.basepath=b("/"+(null!=a?a:"")),n&&(s.routesById={},s.routeTree=s.__.buildRouteTree(n)),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(s.location.pathname,{strictParseParams:!0});if(s.state=T({},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=T({},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=T({},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:P([t,n])});o.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&i(m.childRoutes)};return i([s.routeTree]),K(o),o},loadMatches:async(t,e)=>{const a=t.map((async t=>{t.__.validate(),t.load(e),"loading"===t.status&&(null!=e&&e.withPending&&t.__.startPending(),await t.__.loadPromise)}));s.notify(),await Promise.all(a)},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)=>R(s.basepath,t,b(e)),matchRoute:(t,e)=>{var a;t=T({},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,T({},e,{to:n.pathname})):!!S(s.state.location.pathname,T({},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},y=s.buildNext(g);d=null!=(e=d)?e:s.options.defaultPreload;const _=null!=(a=null!=m?m:s.options.defaultPreloadDelay)?a:0,P=s.state.location.pathname===y.pathname,b=s.state.location.pathname.split("/"),w=y.pathname.split("/").every(((t,e)=>t===b[e])),A=s.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&&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})}),_)}},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(T({},t,{__preSearchFilters:n,__postSearchFilters:o}))},__:{buildRouteTree:t=>{const e=(t,a)=>t.map((t=>{const n=D(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=R(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=T({},null==(o=g(p))?void 0:o.params);let _=!0===(null==(r=t.params)||r)?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!=(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=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(s.location.search,w),x=s.options.stringifySearch(A);let I=!0===t.hash?s.location.hash:y(t.hash,s.location.hash);return I=I?"#"+I:"",{pathname:d,search:A,searchStr:x,state:s.location.state,hash:I,href:""+d+x+I,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.update(t),null==s.options.createRouter||s.options.createRouter(s),s},t.decode=k,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=E,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=p,t.joinPaths=P,t.last=g,t.matchByPath=L,t.matchPathname=S,t.parsePathname=I,t.parseSearchWith=U,t.pick=_,t.replaceEqualDeep=f,t.resolvePath=R,t.rootRouteId=O,t.stringifySearchWith=H,t.trimPath=x,t.trimPathLeft=w,t.trimPathRight=A,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(){A(-1*r)}},A(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 x(t,e){return[{usr:t.state,key:t.key,idx:e},b(t)]}function M(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 A(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var I={get action(){return m},get location(){return y},createHref:b,push:function t(e,n){var o=a.Push,r=w(e,n);if(M(o,r,(function(){t(e,n)}))){var l=x(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(M(o,r,(function(){t(e,n)}))){var i=x(r,g),l=i[0],c=i[1];s.replaceState(l,"",c),R(o)}},go:A,back:function(){A(-1)},forward:function(){A(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 I}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,e){return e.reduce(((e,a)=>(e[a]=t[a],e)),{})}function P(t){return b(t.filter(Boolean).join("/"))}function b(t){return t.replace(/\/{2,}/g,"/")}function w(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function x(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function M(t){return x(w(t))}function R(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=A(e);const o=A(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 b(P([t,...n.map((t=>t.value))]))}function A(t){if(!t)return[];const e=[];if("/"===(t=b(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 I(t,e,a){return P(A(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=A(t),o=A(""+(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["*"]=P(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 E(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 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 k(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],C(e.shift())):n[a]=C(e.shift());return n}function D(){return D=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},D.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]={submissions:[],submit:async(t,e)=>{var a;if(!u)return;const o=null==(a=null==e?void 0:e.invalidate)||a;null!=e&&e.multi||(l.submissions=l.submissions.filter((t=>t.isMulti)));const r={submittedAt:Date.now(),status:"pending",submission:t,isMulti:!(null==e||!e.multi)};l.current=r,l.latest=r,l.submissions.push(r),n.notify();try{const e=await(null==u.options.action?void 0:u.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{n.notify()}}},n.state.actions[o]),c=n.state.loaders[o]||(n.state.loaders[o]={pending:[],fetch:async t=>{if(!u)return;const e={loadedAt:Date.now(),loaderContext:t};c.current=e,c.latest=e,c.pending.push(e),n.notify();try{return await(null==u.options.loader?void 0:u.options.loader(t))}finally{c.pending=c.pending.filter((t=>t!==e)),n.notify()}}},n.state.loaders[o]);let u={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:n,childRoutes:void 0,parentRoute:a,action:l,loader:c,buildLink:t=>n.buildLink(D({},t,{from:s})),navigate:t=>n.navigate(D({},t,{from:s})),matchRoute:(t,e)=>n.matchRoute(D({},t,{from:s}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:u}),u}const O="__root__",F=["element","errorElement","catchElement","pendingElement"];function j(t,e,a){const n=D({},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{var r;const t=n.routeSearch,e="object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch;let a=f(t,null!=(r=null==e?void 0:e(o))?r:{});t!==a&&(n.isInvalid=!0),n.routeSearch=a,n.search=f(o,D({},o,a)),F.map((async t=>{const e=n.options[t];"function"!=typeof n.__[t]&&(n.__[t]=e)}))}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(),o=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0;if(null!=e&&e.preload&&o>0){if(t.state.matches.find((t=>t.matchId===n.matchId)))return;t.matchCache[n.matchId]={gc:a+e.gcMaxAge,match:n}}if("success"===n.status&&n.getIsInvalid()||"error"===n.status||"idle"===n.status){const t=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;await n.fetch({maxAge:t})}},fetch:async e=>{const a=""+Date.now()+Math.random();n.__.latestId=a,"idle"===n.status&&(n.status="loading"),n.isInvalid=!1,n.__.loadPromise=new Promise((async o=>{if(n.isFetching=!0,n.__.resolve=o,n.__.loaderDataPromise=(async()=>{n.__.elementsPromise=(async()=>{await Promise.all(F.map((async e=>{const a=n.options[e];"function"==typeof n.__[e]&&(n.__[e]=await t.options.createElement(a))})))})(),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.__.loadPromise;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.__.loadPromise;n.error=t,n.status="error",n.updatedAt=Date.now()}}));try{if(await Promise.all([n.__.elementsPromise,n.__.dataPromise]),a!==n.__.latestId)return n.__.loadPromise;n.__.pendingMinPromise&&(await n.__.pendingMinPromise,delete n.__.pendingMinPromise)}finally{if(a!==n.__.latestId)return n.__.loadPromise;n.__.cancelPending(),n.isPending=!1,n.isFetching=!1,n.__.notify()}})(),await n.__.loaderDataPromise,a!==n.__.latestId)return n.__.loadPromise;delete n.__.loaderDataPromise})),await n.__.loadPromise,delete n.__.loadPromise}});return n.hasLoaders()||(n.status="success"),n}const N=U(JSON.parse),B=H(JSON.stringify);function U(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=k(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function H(t){return e=>{(e=D({},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=E(e).toString();return a?"?"+a:""}}var G;const z="undefined"==typeof window||!(null!=(G=window.document)&&G.createElement);function K(){return{status:"idle",location:null,matches:[],actions:{},loaders:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1}}function V(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=f(e.loaderData,D({},n.loaderData,e.routeLoaderData)))}))}t.cleanPath=b,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(){I(-1*r)}},I(r))}}else A(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 x(t,a){return void 0===a&&(a=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function M(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 A(t){v=t;var e=p();y=e[0],_=e[1],P.call({action:v,location:_})}function I(t){s.go(t)}null==y&&(y=0,s.replaceState(e({},s.state,{idx:y}),""));var S={get action(){return v},get location(){return _},createHref:w,push:function t(e,n){var o=a.Push,r=x(e,n);if(R(o,r,(function(){t(e,n)}))){var l=M(r,y+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}A(o)}},replace:function t(e,n){var o=a.Replace,r=x(e,n);if(R(o,r,(function(){t(e,n)}))){var i=M(r,y),l=i[0],c=i[1];s.replaceState(l,"",c),A(o)}},go:I,back:function(){I(-1)},forward:function(){I(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 S},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=M(i));const s=i||e.id;let l=P([o,s]);i===O&&(i="/"),l!==O&&(l=P(["/",l]));const c=l===O?"/":x(P([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=D({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:[],basepath:"",routeTree:void 0,routesById:{},location:void 0,allRouteInfo:void 0,navigationPromise:Promise.resolve(),resolveNavigation:()=>{},matchCache:{},state:K(),reset:()=>{s.state=K(),s.notify()},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=D({},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))))}),V(s.state.matches),s.listeners.forEach((t=>t(s)))},dehydrateState:()=>D({},_(s.state,["status","location","lastUpdated"]),{matches:s.state.matches.map((t=>_(t,["matchId","status","routeLoaderData","loaderData","isInvalid","invalidAt"])))}),hydrateState:t=>{const e=s.matchRoutes(s.location.pathname,{strictParseParams:!0});e.forEach(((e,a)=>{const n=t.matches[a];p(n),Object.assign(e,n)})),s.loadMatches(e),s.state=D({},s.state,t,{matches:e})},mount:()=>{const t=s.__.buildLocation({to:".",search:!0,hash:!0});t.href!==s.location.href&&s.__.commitLocation(t,!0);const e=s.history.listen((t=>{s.load(s.__.parseLocation(t.location,s.location))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",s.onFocus,!1),window.addEventListener("focus",s.onFocus,!1)),()=>{e(),!z&&window.removeEventListener&&(window.removeEventListener("visibilitychange",s.onFocus),window.removeEventListener("focus",s.onFocus))}},onFocus:()=>{s.load()},update:t=>{const e=(null==t?void 0:t.history)!==s.history;s.location&&!e||(null!=t&&t.history&&(s.history=t.history),s.location=s.__.parseLocation(s.history.location),s.state.location=s.location),Object.assign(s.options,t);const{basepath:a,routeConfig:n}=s.options;return s.basepath=b("/"+(null!=a?a:"")),n&&(s.routesById={},s.routeTree=s.__.buildRouteTree(n)),s},cancelMatches:()=>{var t,e;[...s.state.matches,...null!=(t=null==(e=s.state.pending)?void 0:e.matches)?t:[]].forEach((t=>{t.cancel()}))},load:async t=>{const e=Math.random();s.startedLoadingAt=e,t&&(s.location=t),s.cancelMatches();const a=s.matchRoutes(s.location.pathname,{strictParseParams:!0});if(s.state=D({},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]})),s.startedLoadingAt===e&&(a.forEach((t=>{t.action&&(t.action.current=void 0,t.action.submissions=[])})),s.state=D({},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=D({},h,t)}return c&&(p=[...a,n]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((e=>{var a;const n=I(e.routePath,h),i=I(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:P([t,n])});o.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&i(m.childRoutes)};return i([s.routeTree]),V(o),o},loadMatches:async(t,e)=>{const a=t.map((async t=>{t.__.validate(),t.load(e),"loading"===t.status&&null!=e&&e.withPending&&t.__.startPending(),t.__.loadPromise&&await t.__.loadPromise}));s.notify(),await Promise.all(a)},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)=>R(s.basepath,t,b(e)),matchRoute:(t,e)=>{var a;t=D({},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,D({},e,{to:n.pathname})):!!S(s.state.location.pathname,D({},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},y=s.buildNext(g);d=null!=(e=d)?e:s.options.defaultPreload;const _=null!=(a=null!=m?m:s.options.defaultPreloadDelay)?a:0,P=s.state.location.pathname===y.pathname,b=s.state.location.pathname.split("/"),w=y.pathname.split("/").every(((t,e)=>t===b[e])),x=s.state.location.hash===y.hash,M=null!=h&&h.exact?P:w,R=null==h||!h.includeHash||x;return{type:"internal",next:y,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})}),_)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:M&&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(D({},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=R(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=D({},null==(o=g(p))?void 0:o.params);let _=!0===(null==(r=t.params)||r)?v:y(t.params,v);_&&m.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},_,t(_))})),d=I(d,null!=_?_:{});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=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,x=f(s.location.search,w),M=s.options.stringifySearch(x);let A=!0===t.hash?s.location.hash:y(t.hash,s.location.hash);return A=A?"#"+A:"",{pathname:d,search:x,searchStr:M,state:s.location.state,hash:A,href:""+d+M+A,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.update(t),null==s.options.createRouter||s.options.createRouter(s),s},t.decode=k,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=E,t.functionalUpdate=y,t.interpolatePath=I,t.invariant=p,t.joinPaths=P,t.last=g,t.matchByPath=L,t.matchPathname=S,t.parsePathname=A,t.parseSearchWith=U,t.pick=_,t.replaceEqualDeep=f,t.resolvePath=R,t.rootRouteId=O,t.stringifySearchWith=H,t.trimPath=M,t.trimPathLeft=w,t.trimPathRight=x,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-beta.9",
"version": "0.0.1-beta.10",
"license": "MIT",

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

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

} from './routeInfo'
import { RouteMatch } from './routeMatch'
import {

@@ -26,3 +25,3 @@ Action,

} from './router'
import { NoInfer, replaceEqualDeep } from './utils'
import { NoInfer } from './utils'

@@ -101,6 +100,6 @@ export interface AnyRoute extends Route<any, any> {}

router.state.actions[id] = {
pending: [],
submissions: [],
submit: async <T, U>(
submission: T,
actionOpts?: { invalidate?: boolean },
actionOpts?: { invalidate?: boolean; multi?: boolean },
) => {

@@ -113,2 +112,6 @@ if (!route) {

if (!actionOpts?.multi) {
action.submissions = action.submissions.filter((d) => d.isMulti)
}
const actionState: ActionState<T, U> = {

@@ -118,2 +121,3 @@ submittedAt: Date.now(),

submission,
isMulti: !!actionOpts?.multi,
}

@@ -123,10 +127,4 @@

action.latest = actionState
action.pending.push(actionState)
action.submissions.push(actionState)
router.state = {
...router.state,
currentAction: actionState,
latestAction: actionState,
}
router.notify()

@@ -137,2 +135,3 @@

actionState.data = res as U
if (invalidate) {

@@ -149,4 +148,2 @@ router.invalidateRoute({ to: '.', fromCurrent: true })

} finally {
action.pending = action.pending.filter((d) => d !== actionState)
router.removeActionQueue.push({ action, actionState })
router.notify()

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

import { GetFrameworkGeneric } from './frameworks'
import { Route } from './route'
import { AnyPathParams } from './routeConfig'
import {

@@ -10,3 +9,3 @@ AnyAllRouteInfo,

} from './routeInfo'
import { Router } from './router'
import { ActionState, Router } from './router'
import { replaceEqualDeep, Timeout } from './utils'

@@ -41,3 +40,3 @@

loadPromise?: Promise<void>
loaderPromise?: Promise<void>
loaderDataPromise?: Promise<void>
elementsPromise?: Promise<void>

@@ -109,2 +108,3 @@ dataPromise?: Promise<void>

invalidAt: Infinity,
// pendingActions: [],
getIsInvalid: () => {

@@ -153,14 +153,2 @@ const now = Date.now()

},
// setParentMatch: (parentMatch?: RouteMatch) => {
// routeMatch.parentMatch = parentMatch
// },
// addChildMatch: (childMatch: RouteMatch) => {
// if (
// routeMatch.childMatches.find((d) => d.matchId === childMatch.matchId)
// ) {
// return
// }
// routeMatch.childMatches.push(childMatch)
// },
validate: () => {

@@ -181,3 +169,3 @@ // Validate the search params and stabilize them

prevSearch,
validator?.(parentSearch),
validator?.(parentSearch) ?? {},
)

@@ -196,2 +184,10 @@

})
elementTypes.map(async (type) => {
const routeElement = routeMatch.options[type]
if (typeof routeMatch.__[type] !== 'function') {
routeMatch.__[type] = routeElement
}
})
} catch (err: any) {

@@ -252,3 +248,3 @@ console.error(err)

routeMatch.fetch({ maxAge })
await routeMatch.fetch({ maxAge })
}

@@ -276,3 +272,3 @@ },

const loaderPromise = (async () => {
routeMatch.__.loaderDataPromise = (async () => {
// Load the elements and data in parallel

@@ -288,9 +284,7 @@

if (routeMatch.__[type]) {
return
if (typeof routeMatch.__[type] === 'function') {
routeMatch.__[type] = await router.options.createElement!(
routeElement,
)
}
routeMatch.__[type] = await router.options.createElement!(
routeElement,
)
}),

@@ -309,3 +303,3 @@ )

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise
return routeMatch.__.loadPromise
}

@@ -330,3 +324,3 @@

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise
return routeMatch.__.loadPromise
}

@@ -349,3 +343,3 @@

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise
return routeMatch.__.loadPromise
}

@@ -359,3 +353,3 @@

if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise
return routeMatch.__.loadPromise
}

@@ -369,12 +363,14 @@ routeMatch.__.cancelPending()

routeMatch.__.loaderPromise = loaderPromise
await loaderPromise
await routeMatch.__.loaderDataPromise
if (id !== routeMatch.__.latestId) {
return routeMatch.__.loaderPromise
return routeMatch.__.loadPromise
}
delete routeMatch.__.loaderPromise
delete routeMatch.__.loaderDataPromise
})
return await routeMatch.__.loadPromise
await routeMatch.__.loadPromise
delete routeMatch.__.loadPromise
},

@@ -381,0 +377,0 @@ }

@@ -117,6 +117,9 @@ import {

> {
submit: (submission?: TPayload) => Promise<TResponse>
submit: (
submission?: TPayload,
actionOpts?: { invalidate?: boolean; multi?: boolean },
) => Promise<TResponse>
current?: ActionState<TPayload, TResponse>
latest?: ActionState<TPayload, TResponse>
pending: ActionState<TPayload, TResponse>[]
submissions: ActionState<TPayload, TResponse>[]
}

@@ -132,2 +135,3 @@

submission: TPayload
isMulti: boolean
data?: TResponse

@@ -178,4 +182,2 @@ error?: unknown

lastUpdated: number
currentAction?: ActionState
latestAction?: ActionState
actions: Record<string, Action>

@@ -268,6 +270,6 @@ loaders: Record<string, Loader>

navigationPromise: Promise<void>
removeActionQueue: { action: Action; actionState: ActionState }[]
startedLoadingAt: number
resolveNavigation: () => void
subscribe: (listener: Listener) => () => void
reset: () => void
notify: () => void

@@ -282,3 +284,3 @@ mount: () => () => void

cancelMatches: () => void
loadLocation: (next?: Location) => Promise<void>
load: (next?: Location) => Promise<void>
matchCache: Record<string, MatchCacheEntry>

@@ -353,2 +355,15 @@ cleanMatchCache: () => void

function getInitialRouterState(): RouterState {
return {
status: 'idle',
location: null!,
matches: [],
actions: {},
loaders: {},
lastUpdated: Date.now(),
isFetching: false,
isPreloading: false,
}
}
export function createRouter<

@@ -376,3 +391,2 @@ TRouteConfig extends AnyRouteConfig = RouteConfig,

listeners: [],
removeActionQueue: [],
// Resolved after construction

@@ -388,11 +402,6 @@ basepath: '',

matchCache: {},
state: {
status: 'idle',
location: null!,
matches: [],
actions: {},
loaders: {},
lastUpdated: Date.now(),
isFetching: false,
isPreloading: false,
state: getInitialRouterState(),
reset: () => {
router.state = getInitialRouterState()
router.notify()
},

@@ -448,16 +457,17 @@ startedLoadingAt: Date.now(),

matches.forEach((match, index) => {
const dehydratedMatch = dehydratedState.matches[index]
invariant(
dehydratedMatch,
'Oh no! Dehydrated route matches did not match the active state of the router 😬',
)
Object.assign(match, dehydratedMatch)
})
router.loadMatches(matches)
router.state = {
...router.state,
...dehydratedState,
matches: matches.map((match) => {
const dehydratedMatch = dehydratedState.matches.find(
(d: any) => d.matchId === match.matchId,
)
invariant(
dehydratedMatch,
'Oh no! Dehydrated route matches did not match the active state of the router 😬',
)
Object.assign(match, dehydratedMatch)
return match
}),
matches,
}

@@ -479,9 +489,6 @@ },

router.loadLocation()
// router.load()
const unsub = router.history.listen((event) => {
console.log(event.location)
router.loadLocation(
router.__.parseLocation(event.location, router.location),
)
router.load(router.__.parseLocation(event.location, router.location))
})

@@ -499,5 +506,7 @@

unsub()
// Be sure to unsubscribe if a new handler is set
window.removeEventListener('visibilitychange', router.onFocus)
window.removeEventListener('focus', router.onFocus)
if (!isServer && window.removeEventListener) {
// Be sure to unsubscribe if a new handler is set
window.removeEventListener('visibilitychange', router.onFocus)
window.removeEventListener('focus', router.onFocus)
}
}

@@ -507,3 +516,3 @@ },

onFocus: () => {
router.loadLocation()
router.load()
},

@@ -544,3 +553,3 @@

loadLocation: async (next?: Location) => {
load: async (next?: Location) => {
const id = Math.random()

@@ -554,13 +563,2 @@ router.startedLoadingAt = id

// Clear out old actions
router.removeActionQueue.forEach(({ action, actionState }) => {
if (router.state.currentAction === actionState) {
router.state.currentAction = undefined
}
if (action.current === actionState) {
action.current = undefined
}
})
router.removeActionQueue = []
// Cancel any pending matches

@@ -615,2 +613,9 @@ router.cancelMatches()

})
// // Clear actions
// if (d.action) {
// d.action.current = undefined
// d.action.submissions = []
// }
// Clear idle error states when match leaves

@@ -652,8 +657,4 @@ if (d.status === 'error' && !d.isFetching) {

if (matches.some((d) => d.status === 'loading')) {
router.notify()
await Promise.all(
matches.map((d) => d.__.loaderPromise || Promise.resolve()),
)
}
// router.notify()
if (router.startedLoadingAt !== id) {

@@ -664,2 +665,10 @@ // Ignore side-effects of match loading

matches.forEach((match) => {
// Clear actions
if (match.action) {
match.action.current = undefined
match.action.submissions = []
}
})
router.state = {

@@ -843,3 +852,5 @@ ...router.state,

if (loaderOpts?.withPending) match.__.startPending()
}
if (match.__.loadPromise) {
// Wait for the first sign of activity from the match

@@ -846,0 +857,0 @@ // This might be completion, error, or a pending state

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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