@@ -957,19 +957,17 @@ declare global {
957957}
958958
959959/**
960- * A snapshot of a history entry the router has visited, keyed by its
961- * `__TSR_index`. Used to reconstruct navigation direction (e.g. whether a
962- * link's target is the previous entry) since the browser only exposes the
963- * current entry.
960+ * A visited history entry keyed by its `__TSR_index`, used to resolve navigation
961+ * direction (the browser only exposes the current entry).
964962 */
965963export interface RouterHistoryEntry {
966964 /** The entry's `__TSR_index` in the history stack. */
967965 index : number
968- /** The parsed (basepath-stripped) pathname, comparable to `buildLocation().pathname`. */
966+ /** Parsed (basepath-stripped) pathname, comparable to `buildLocation().pathname`. */
969967 pathname : string
970- /** The search string including the leading `?`, comparable to `buildLocation().searchStr`. */
968+ /** Search string incl. leading `?`, comparable to `buildLocation().searchStr`. */
971969 searchStr : string
972- /** The full href (pathname + search + hash), without origin. */
970+ /** Full href (pathname + search + hash), without origin. */
973971 href : string
974972}
975973
@@ -1025,13 +1023,9 @@ export class RouterCore<
10251023 latestLocation ! : ParsedLocation < FullSearchSchema < TRouteTree > >
10261024 pendingBuiltLocation ?: ParsedLocation < FullSearchSchema < TRouteTree > >
10271025 /**
1028- * In-memory map of visited history entries keyed by their `__TSR_index`.
1029- *
1030- * The browser only ever exposes the *current* history entry, so to answer
1031- * "what was the previous entry?" (used by history-aware links via
1032- * {@link getHistoryEntry}) the router records every location it commits,
1033- * keyed by index. Maintained from {@link updateLatestLocation}, the single
1034- * place `latestLocation` is recomputed from history.
1026+ * Visited history entries keyed by `__TSR_index` (recorded in
1027+ * {@link updateLatestLocation}), so the router can resolve the previous entry —
1028+ * which the browser doesn't expose. Read via {@link getHistoryEntry}.
10351029 */
10361030 historyEntries = new Map < number , RouterHistoryEntry > ( )
10371031 basepath ! : string
@@ -1266,14 +1260,9 @@ export class RouterCore<
12661260 this . latestLocation ,
12671261 )
12681262
1269- // Record the committed entry by its history index. `replace` keeps the same
1270- // index, so it overwrites the slot in place; a push after going back reuses
1271- // the truncated forward slot and overwrites it on the next call. The
1272- // back-navigation decision only ever reads `index - 1` (always the true
1273- // previous entry on the current linear branch), so stale higher indices
1274- // left behind by truncation are harmless and need no pruning. We store the
1275- // parsed (basepath-stripped) pathname so it compares directly against
1276- // `buildLocation().pathname`.
1263+ // Record the committed entry by index. `replace` overwrites the same index;
1264+ // truncated forward entries are harmless since the back-decision only reads
1265+ // `index - 1`. Stored pathname/search compare directly with buildLocation().
12771266 const index = this . latestLocation . state . __TSR_index ?? 0
12781267 this . historyEntries . set ( index , {
12791268 index,
@@ -1284,12 +1273,9 @@ export class RouterCore<
12841273 }
12851274
12861275 /**
1287- * Look up a previously-visited history entry by its `__TSR_index`.
1288- *
1289- * Returns `undefined` for entries the router has not seen — e.g. entries that
1290- * existed before the app loaded (a fresh page load or deep link). Consumers
1291- * such as history-aware links should degrade gracefully when this is
1292- * `undefined`.
1276+ * Look up a visited history entry by its `__TSR_index`. Returns `undefined` for
1277+ * entries the router never recorded (e.g. a fresh page load or deep link), so
1278+ * consumers should degrade gracefully.
12931279 */
12941280 getHistoryEntry = ( index : number ) : RouterHistoryEntry | undefined =>
12951281 this . historyEntries . get ( index )
0 commit comments