Sign In

@tanstack/router-core

Package Overview
Dependencies
Maintainers
3
Versions
489
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
1.171.18
to
1.171.19
+55
-66
dist/cjs/load-client.cjs

@@ -111,3 +111,3 @@ const require_not_found = require("./not-found.cjs");

}
async function contextualize(router, lane, options, end, planSuccessfulLane) {
async function contextualize(router, lane, options, end, planSuccessfulLane, retainedEnd) {
const [location, matches] = lane;

@@ -167,3 +167,3 @@ const signal = options[0].signal;

const previousStatus = match.status;
if (previousStatus === "success") match.status = "pending";
if (previousStatus === "success" && index >= retainedEnd) match.status = "pending";
options[8]?.();

@@ -214,3 +214,3 @@ try {

*/
function transferMatchResources(router, previous, next) {
function transferMatchResources(router, previous, next, deferSameIdFlight) {
const abort = [];

@@ -220,13 +220,3 @@ for (const match of previous) if (!next?.includes(match)) {

match._flight = void 0;
const controller = releaseOwnedFlight(router, match, flight);
if (controller) abort.push(controller);
}
for (const controller of abort) controller.abort();
}
function transferPredecessorResources(router, previous, next) {
const abort = [];
for (const match of previous) if (!next.includes(match)) {
const flight = match._flight;
match._flight = void 0;
if (flight?.[2] === 1 && router._flights?.get(match.id) === flight && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) && next.some((candidate) => candidate.id === match.id)) flight[2] = 0;
if (deferSameIdFlight && flight?.[2] === 1 && router._flights?.get(match.id) === flight && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) && next?.some((candidate) => candidate.id === match.id)) flight[2] = 0;
else {

@@ -239,10 +229,2 @@ const controller = releaseOwnedFlight(router, match, flight);

}
function releaseUnownedFlights(router) {
const abort = [];
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
router._flights.delete(id);
abort.push(flight[1]);
}
for (const controller of abort) controller.abort();
}
function acquireMatchResources(matches) {

@@ -348,3 +330,3 @@ for (const match of matches) {

}
function createLoaderTask(router, lane, index, tasks, semanticParent, options) {
function createLoaderTask(router, lane, index, tasks, semanticParent, options, retainedEnd) {
const match = lane[1][index];

@@ -395,3 +377,3 @@ const route = getRoute(router, match);

releaseOwnedFlight(router, match, acceptedFlight)?.abort();
if (match.status === "success") match.status = "pending";
if (match.status === "success" && index >= retainedEnd) match.status = "pending";
options[8]?.();

@@ -546,4 +528,5 @@ }

install();
const route = getRoute(router, match);
try {
await waitFor(outcome ? Promise.resolve().then(() => loadRouteChunk(getRoute(router, match), kind === ERROR ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(getRoute(router, match)), loadRouteChunk(getRoute(router, match), "notFoundComponent")]), controller.signal);
await waitFor(outcome ? Promise.resolve().then(() => loadRouteChunk(route, kind === ERROR ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]), controller.signal);
} catch (cause) {

@@ -601,2 +584,3 @@ if (cause === controller.signal) {

const matched = [location, matches];
const presented = router.stores.matches.get();
let plannedBoundary = matches.findIndex((match) => match._notFound);

@@ -612,2 +596,10 @@ if (router.options.notFoundMode !== "root" && plannedBoundary >= 0) {

let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1;
let retainedEnd = 0;
while (retainedEnd < end && retainedEnd !== plannedBoundary) {
const match = matches[retainedEnd];
const committed = options[3][retainedEnd];
const visible = presented[retainedEnd];
if (committed?.id !== match.id || committed.status !== "success" || committed._notFound || match.preload || visible?.id !== match.id || visible.status !== "success" || visible._notFound) break;
retainedEnd++;
}
const tasks = [];

@@ -619,6 +611,6 @@ const start = options[7] ?? 0;

if (options[0].signal.aborted) break;
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options);
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options, retainedEnd);
}
};
const failure = await contextualize(router, matched, options, end, planSuccessfulLane);
const failure = await contextualize(router, matched, options, end, planSuccessfulLane, retainedEnd);
if (failure) {

@@ -633,3 +625,10 @@ options[5] = true;

}
if (options[2]() && !options[4]) releaseUnownedFlights(router);
if (options[2]() && !options[4]) {
const abort = [];
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
router._flights.delete(id);
abort.push(flight[1]);
}
for (const controller of abort) controller.abort();
}
let reduced;

@@ -648,26 +647,2 @@ try {

/**
* Finds the first route that should show pending UI and its two timing values.
* A fallback already on screen remains selected after its route loads, so we
* do not jump to a child fallback. Matches put back into pending by invalidation
* skip pendingMs, and a route without a usable fallback blocks pending UI for deeper routes.
*/
function pendingConfig(router, matches) {
const presented = router.stores.matches.get();
for (let index = 0; index < matches.length; index++) {
const match = matches[index];
const success = match.status === "success";
const visible = success && presented[index]?.id === match.id && presented[index]?.status === "pending";
if (success && !visible) continue;
const route = getRoute(router, match);
const delay = visible || match.invalid ? 0 : route.options.pendingMs ?? router.options.defaultPendingMs;
const component = route.options.pendingComponent ?? router.options.defaultPendingComponent;
return component && typeof delay === "number" && delay !== Infinity ? [
delay,
index,
route.options.pendingMinMs ?? router.options.defaultPendingMinMs ?? 0,
component
] : void 0;
}
}
/**
* Waits for `pendingMs`, then presents the complete lane. Rendering applies the

@@ -690,16 +665,32 @@ * selected boundary cutoff while retaining every match's structural state.

}
const config = pendingConfig(router, tx[3]);
if (!config) return;
const [delay, boundary, min, component] = config;
const matchId = tx[3][boundary].id;
const matches = tx[3];
const presented = router.stores.matches.get();
let boundary = -1;
let delay;
let min;
let component;
let presentedPending = false;
for (let index = 0; index < matches.length; index++) {
const match = matches[index];
const success = match.status === "success";
presentedPending = presented[index]?.id === match.id && presented[index]?.status === "pending";
if (success && !presentedPending) continue;
const route = getRoute(router, match);
delay = success && presentedPending || match.invalid ? 0 : route.options.pendingMs ?? router.options.defaultPendingMs;
component = route.options.pendingComponent ?? router.options.defaultPendingComponent;
if (!component || typeof delay !== "number" || delay === Infinity) return;
boundary = index;
min = route.options.pendingMinMs ?? router.options.defaultPendingMinMs ?? 0;
break;
}
if (boundary < 0) return;
const matchId = matches[boundary].id;
if (!session || session[1] !== boundary || sessionMatchId !== matchId) {
clearTimeout(session?.[3]);
const presented = router.stores.matches.get()[boundary];
const visible = presented?.id === matchId && presented.status === "pending";
router._pending = session = [
tx,
boundary,
visible ? Date.now() + min : tx[4] + delay,
presentedPending ? Date.now() + min : tx[4] + delay,
void 0,
visible ? Promise.resolve(true) : void 0,
presentedPending ? Promise.resolve(true) : void 0,
component

@@ -714,5 +705,3 @@ ];

if (remaining > 0) {
session[3] = setTimeout(() => {
offerPending(router, tx);
}, remaining);
session[3] = setTimeout(() => offerPending(router, tx), remaining);
return;

@@ -722,3 +711,3 @@ }

}
const offered = tx[3].map((match) => ({
const offered = matches.map((match) => ({
...match,

@@ -1132,3 +1121,3 @@ _flight: void 0

previousOwner[0].abort();
transferPredecessorResources(router, previousOwner[3], tx[3]);
transferMatchResources(router, previousOwner[3], tx[3], true);
}

@@ -1145,3 +1134,3 @@ if (router._tx !== tx) {

});
offerPending(router, tx);
if (!resolvedLocation && !matches.some((match) => match._notFound)) offerPending(router, tx);
try {

@@ -1148,0 +1137,0 @@ await tx[5];

@@ -111,3 +111,3 @@ import { isNotFound } from "./not-found.js";

}
async function contextualize(router, lane, options, end, planSuccessfulLane) {
async function contextualize(router, lane, options, end, planSuccessfulLane, retainedEnd) {
const [location, matches] = lane;

@@ -167,3 +167,3 @@ const signal = options[0].signal;

const previousStatus = match.status;
if (previousStatus === "success") match.status = "pending";
if (previousStatus === "success" && index >= retainedEnd) match.status = "pending";
options[8]?.();

@@ -214,3 +214,3 @@ try {

*/
function transferMatchResources(router, previous, next) {
function transferMatchResources(router, previous, next, deferSameIdFlight) {
const abort = [];

@@ -220,13 +220,3 @@ for (const match of previous) if (!next?.includes(match)) {

match._flight = void 0;
const controller = releaseOwnedFlight(router, match, flight);
if (controller) abort.push(controller);
}
for (const controller of abort) controller.abort();
}
function transferPredecessorResources(router, previous, next) {
const abort = [];
for (const match of previous) if (!next.includes(match)) {
const flight = match._flight;
match._flight = void 0;
if (flight?.[2] === 1 && router._flights?.get(match.id) === flight && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) && next.some((candidate) => candidate.id === match.id)) flight[2] = 0;
if (deferSameIdFlight && flight?.[2] === 1 && router._flights?.get(match.id) === flight && !(process.env.NODE_ENV !== "production" && router._tx?.[6]) && next?.some((candidate) => candidate.id === match.id)) flight[2] = 0;
else {

@@ -239,10 +229,2 @@ const controller = releaseOwnedFlight(router, match, flight);

}
function releaseUnownedFlights(router) {
const abort = [];
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
router._flights.delete(id);
abort.push(flight[1]);
}
for (const controller of abort) controller.abort();
}
function acquireMatchResources(matches) {

@@ -348,3 +330,3 @@ for (const match of matches) {

}
function createLoaderTask(router, lane, index, tasks, semanticParent, options) {
function createLoaderTask(router, lane, index, tasks, semanticParent, options, retainedEnd) {
const match = lane[1][index];

@@ -395,3 +377,3 @@ const route = getRoute(router, match);

releaseOwnedFlight(router, match, acceptedFlight)?.abort();
if (match.status === "success") match.status = "pending";
if (match.status === "success" && index >= retainedEnd) match.status = "pending";
options[8]?.();

@@ -546,4 +528,5 @@ }

install();
const route = getRoute(router, match);
try {
await waitFor(outcome ? Promise.resolve().then(() => loadRouteChunk(getRoute(router, match), kind === ERROR ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(getRoute(router, match)), loadRouteChunk(getRoute(router, match), "notFoundComponent")]), controller.signal);
await waitFor(outcome ? Promise.resolve().then(() => loadRouteChunk(route, kind === ERROR ? "errorComponent" : "notFoundComponent")) : Promise.all([loadRouteChunk(route), loadRouteChunk(route, "notFoundComponent")]), controller.signal);
} catch (cause) {

@@ -601,2 +584,3 @@ if (cause === controller.signal) {

const matched = [location, matches];
const presented = router.stores.matches.get();
let plannedBoundary = matches.findIndex((match) => match._notFound);

@@ -612,2 +596,10 @@ if (router.options.notFoundMode !== "root" && plannedBoundary >= 0) {

let end = plannedBoundary < 0 ? matches.length : plannedBoundary + 1;
let retainedEnd = 0;
while (retainedEnd < end && retainedEnd !== plannedBoundary) {
const match = matches[retainedEnd];
const committed = options[3][retainedEnd];
const visible = presented[retainedEnd];
if (committed?.id !== match.id || committed.status !== "success" || committed._notFound || match.preload || visible?.id !== match.id || visible.status !== "success" || visible._notFound) break;
retainedEnd++;
}
const tasks = [];

@@ -619,6 +611,6 @@ const start = options[7] ?? 0;

if (options[0].signal.aborted) break;
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options);
semanticParent = createLoaderTask(router, matched, index, tasks, semanticParent, options, retainedEnd);
}
};
const failure = await contextualize(router, matched, options, end, planSuccessfulLane);
const failure = await contextualize(router, matched, options, end, planSuccessfulLane, retainedEnd);
if (failure) {

@@ -633,3 +625,10 @@ options[5] = true;

}
if (options[2]() && !options[4]) releaseUnownedFlights(router);
if (options[2]() && !options[4]) {
const abort = [];
for (const [id, flight] of router._flights ?? []) if (!flight[2]) {
router._flights.delete(id);
abort.push(flight[1]);
}
for (const controller of abort) controller.abort();
}
let reduced;

@@ -648,26 +647,2 @@ try {

/**
* Finds the first route that should show pending UI and its two timing values.
* A fallback already on screen remains selected after its route loads, so we
* do not jump to a child fallback. Matches put back into pending by invalidation
* skip pendingMs, and a route without a usable fallback blocks pending UI for deeper routes.
*/
function pendingConfig(router, matches) {
const presented = router.stores.matches.get();
for (let index = 0; index < matches.length; index++) {
const match = matches[index];
const success = match.status === "success";
const visible = success && presented[index]?.id === match.id && presented[index]?.status === "pending";
if (success && !visible) continue;
const route = getRoute(router, match);
const delay = visible || match.invalid ? 0 : route.options.pendingMs ?? router.options.defaultPendingMs;
const component = route.options.pendingComponent ?? router.options.defaultPendingComponent;
return component && typeof delay === "number" && delay !== Infinity ? [
delay,
index,
route.options.pendingMinMs ?? router.options.defaultPendingMinMs ?? 0,
component
] : void 0;
}
}
/**
* Waits for `pendingMs`, then presents the complete lane. Rendering applies the

@@ -690,16 +665,32 @@ * selected boundary cutoff while retaining every match's structural state.

}
const config = pendingConfig(router, tx[3]);
if (!config) return;
const [delay, boundary, min, component] = config;
const matchId = tx[3][boundary].id;
const matches = tx[3];
const presented = router.stores.matches.get();
let boundary = -1;
let delay;
let min;
let component;
let presentedPending = false;
for (let index = 0; index < matches.length; index++) {
const match = matches[index];
const success = match.status === "success";
presentedPending = presented[index]?.id === match.id && presented[index]?.status === "pending";
if (success && !presentedPending) continue;
const route = getRoute(router, match);
delay = success && presentedPending || match.invalid ? 0 : route.options.pendingMs ?? router.options.defaultPendingMs;
component = route.options.pendingComponent ?? router.options.defaultPendingComponent;
if (!component || typeof delay !== "number" || delay === Infinity) return;
boundary = index;
min = route.options.pendingMinMs ?? router.options.defaultPendingMinMs ?? 0;
break;
}
if (boundary < 0) return;
const matchId = matches[boundary].id;
if (!session || session[1] !== boundary || sessionMatchId !== matchId) {
clearTimeout(session?.[3]);
const presented = router.stores.matches.get()[boundary];
const visible = presented?.id === matchId && presented.status === "pending";
router._pending = session = [
tx,
boundary,
visible ? Date.now() + min : tx[4] + delay,
presentedPending ? Date.now() + min : tx[4] + delay,
void 0,
visible ? Promise.resolve(true) : void 0,
presentedPending ? Promise.resolve(true) : void 0,
component

@@ -714,5 +705,3 @@ ];

if (remaining > 0) {
session[3] = setTimeout(() => {
offerPending(router, tx);
}, remaining);
session[3] = setTimeout(() => offerPending(router, tx), remaining);
return;

@@ -722,3 +711,3 @@ }

}
const offered = tx[3].map((match) => ({
const offered = matches.map((match) => ({
...match,

@@ -1132,3 +1121,3 @@ _flight: void 0

previousOwner[0].abort();
transferPredecessorResources(router, previousOwner[3], tx[3]);
transferMatchResources(router, previousOwner[3], tx[3], true);
}

@@ -1145,3 +1134,3 @@ if (router._tx !== tx) {

});
offerPending(router, tx);
if (!resolvedLocation && !matches.some((match) => match._notFound)) offerPending(router, tx);
try {

@@ -1148,0 +1137,0 @@ await tx[5];

{
"name": "@tanstack/router-core",
"version": "1.171.18",
"version": "1.171.19",
"description": "Modern and scalable routing for React applications",

@@ -5,0 +5,0 @@ "author": "Tanner Linsley",

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

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

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