44
55export interface NavigateOptions {
66 ignoreBlocker ?: boolean
7- /** When true, Transitioner should skip calling load() - commitLocation handles it */
8- skipTransitionerLoad ?: boolean
97}
108
11- /** Result of a navigation attempt (push/replace) */
12- export type NavigationResult = { type : 'SUCCESS' } | { type : 'BLOCKED' }
13-
149type SubscriberHistoryAction =
1510 | {
1611 type : Exclude < HistoryAction , 'GO' >
@@ -20,27 +15,18 @@ type SubscriberHistoryAction =
2015 index : number
2116 }
2217
23- export type SubscriberArgs = {
18+ type SubscriberArgs = {
2419 location : HistoryLocation
2520 action : SubscriberHistoryAction
26- navigateOpts ?: NavigateOptions
2721}
2822
2923export interface RouterHistory {
3024 location : HistoryLocation
3125 length : number
3226 subscribers : Set < ( opts : SubscriberArgs ) => void >
3327 subscribe : ( cb : ( opts : SubscriberArgs ) => void ) => ( ) => void
34- push : (
35- path : string ,
36- state ?: any ,
37- navigateOpts ?: NavigateOptions ,
38- ) => Promise < NavigationResult >
39- replace : (
40- path : string ,
41- state ?: any ,
42- navigateOpts ?: NavigateOptions ,
43- ) => Promise < NavigationResult >
28+ push : ( path : string , state ?: any , navigateOpts ?: NavigateOptions ) => void
29+ replace : ( path : string , state ?: any , navigateOpts ?: NavigateOptions ) => void
4430 go : ( index : number , navigateOpts ?: NavigateOptions ) => void
4531 back : ( navigateOpts ?: NavigateOptions ) => void
4632 forward : ( navigateOpts ?: NavigateOptions ) => void
@@ -70,21 +56,6 @@ export type ParsedHistoryState = HistoryState & {
7056 key ?: string // TODO: Remove in v2 - use __TSR_key instead
7157 __TSR_key ?: string
7258 __TSR_index : number
73- /** Whether to reset scroll position on this navigation (default: true) */
74- __TSR_resetScroll ?: boolean
75- /** Session id for cached TSR internals */
76- __TSR_sessionId ?: string
77- /** Match snapshot for fast-path on back/forward navigation */
78- __TSR_matches ?: {
79- routeIds : Array < string >
80- params : Record < string , string >
81- globalNotFoundRouteId ?: string
82- searchStr ?: string
83- validatedSearches ?: Array < {
84- search : Record < string , unknown >
85- strictSearch : Record < string , unknown >
86- } >
87- }
8859}
8960
9061type ShouldAllowNavigation = any
@@ -145,14 +116,9 @@ export function createHistory(opts: {
145116 let location = opts . getLocation ( )
146117 const subscribers = new Set < ( opts : SubscriberArgs ) => void > ( )
147118
148- const notify = (
149- action : SubscriberHistoryAction ,
150- navigateOpts ?: NavigateOptions ,
151- ) => {
119+ const notify = ( action : SubscriberHistoryAction ) => {
152120 location = opts . getLocation ( )
153- subscribers . forEach ( ( subscriber ) =>
154- subscriber ( { location, action, navigateOpts } ) ,
155- )
121+ subscribers . forEach ( ( subscriber ) => subscriber ( { location, action } ) )
156122 }
157123
158124 const handleIndexChange = ( action : SubscriberHistoryAction ) => {
@@ -164,11 +130,11 @@ export function createHistory(opts: {
164130 task,
165131 navigateOpts,
166132 ...actionInfo
167- } : TryNavigateArgs ) : Promise < NavigationResult > => {
133+ } : TryNavigateArgs ) => {
168134 const ignoreBlocker = navigateOpts ?. ignoreBlocker ?? false
169135 if ( ignoreBlocker ) {
170136 task ( )
171- return { type : 'SUCCESS' }
137+ return
172138 }
173139
174140 const blockers = opts . getBlockers ?.( ) ?? [ ]
@@ -184,13 +150,12 @@ export function createHistory(opts: {
184150 } )
185151 if ( isBlocked ) {
186152 opts . onBlocked ?.( )
187- return { type : 'BLOCKED' }
153+ return
188154 }
189155 }
190156 }
191157
192158 task ( )
193- return { type : 'SUCCESS' }
194159 }
195160
196161 return {
@@ -211,10 +176,10 @@ export function createHistory(opts: {
211176 push : ( path , state , navigateOpts ) => {
212177 const currentIndex = location . state [ stateIndexKey ]
213178 state = assignKeyAndIndex ( currentIndex + 1 , state )
214- return tryNavigation ( {
179+ tryNavigation ( {
215180 task : ( ) => {
216181 opts . pushState ( path , state )
217- notify ( { type : 'PUSH' } , navigateOpts )
182+ notify ( { type : 'PUSH' } )
218183 } ,
219184 navigateOpts,
220185 type : 'PUSH' ,
@@ -225,10 +190,10 @@ export function createHistory(opts: {
225190 replace : ( path , state , navigateOpts ) => {
226191 const currentIndex = location . state [ stateIndexKey ]
227192 state = assignKeyAndIndex ( currentIndex , state )
228- return tryNavigation ( {
193+ tryNavigation ( {
229194 task : ( ) => {
230195 opts . replaceState ( path , state )
231- notify ( { type : 'REPLACE' } , navigateOpts )
196+ notify ( { type : 'REPLACE' } )
232197 } ,
233198 navigateOpts,
234199 type : 'REPLACE' ,
0 commit comments