@tanstack/history
Advanced tools
+8
-11
@@ -9,7 +9,5 @@ "use strict"; | ||
| const subscribers = /* @__PURE__ */ new Set(); | ||
| const notify = (action, navigateOpts) => { | ||
| const notify = (action) => { | ||
| location = opts.getLocation(); | ||
| subscribers.forEach( | ||
| (subscriber) => subscriber({ location, action, navigateOpts }) | ||
| ); | ||
| subscribers.forEach((subscriber) => subscriber({ location, action })); | ||
| }; | ||
@@ -28,3 +26,3 @@ const handleIndexChange = (action) => { | ||
| task(); | ||
| return { type: "SUCCESS" }; | ||
| return; | ||
| } | ||
@@ -43,3 +41,3 @@ const blockers = opts.getBlockers?.() ?? []; | ||
| opts.onBlocked?.(); | ||
| return { type: "BLOCKED" }; | ||
| return; | ||
| } | ||
@@ -49,3 +47,2 @@ } | ||
| task(); | ||
| return { type: "SUCCESS" }; | ||
| }; | ||
@@ -69,6 +66,6 @@ return { | ||
| state = assignKeyAndIndex(currentIndex + 1, state); | ||
| return tryNavigation({ | ||
| tryNavigation({ | ||
| task: () => { | ||
| opts.pushState(path, state); | ||
| notify({ type: "PUSH" }, navigateOpts); | ||
| notify({ type: "PUSH" }); | ||
| }, | ||
@@ -84,6 +81,6 @@ navigateOpts, | ||
| state = assignKeyAndIndex(currentIndex, state); | ||
| return tryNavigation({ | ||
| tryNavigation({ | ||
| task: () => { | ||
| opts.replaceState(path, state); | ||
| notify({ type: "REPLACE" }, navigateOpts); | ||
| notify({ type: "REPLACE" }); | ||
| }, | ||
@@ -90,0 +87,0 @@ navigateOpts, |
+3
-27
| export interface NavigateOptions { | ||
| ignoreBlocker?: boolean; | ||
| /** When true, Transitioner should skip calling load() - commitLocation handles it */ | ||
| skipTransitionerLoad?: boolean; | ||
| } | ||
| /** Result of a navigation attempt (push/replace) */ | ||
| export type NavigationResult = { | ||
| type: 'SUCCESS'; | ||
| } | { | ||
| type: 'BLOCKED'; | ||
| }; | ||
| type SubscriberHistoryAction = { | ||
@@ -18,6 +10,5 @@ type: Exclude<HistoryAction, 'GO'>; | ||
| }; | ||
| export type SubscriberArgs = { | ||
| type SubscriberArgs = { | ||
| location: HistoryLocation; | ||
| action: SubscriberHistoryAction; | ||
| navigateOpts?: NavigateOptions; | ||
| }; | ||
@@ -29,4 +20,4 @@ export interface RouterHistory { | ||
| subscribe: (cb: (opts: SubscriberArgs) => void) => () => void; | ||
| push: (path: string, state?: any, navigateOpts?: NavigateOptions) => Promise<NavigationResult>; | ||
| replace: (path: string, state?: any, navigateOpts?: NavigateOptions) => Promise<NavigationResult>; | ||
| push: (path: string, state?: any, navigateOpts?: NavigateOptions) => void; | ||
| replace: (path: string, state?: any, navigateOpts?: NavigateOptions) => void; | ||
| go: (index: number, navigateOpts?: NavigateOptions) => void; | ||
@@ -58,17 +49,2 @@ back: (navigateOpts?: NavigateOptions) => void; | ||
| __TSR_index: number; | ||
| /** Whether to reset scroll position on this navigation (default: true) */ | ||
| __TSR_resetScroll?: boolean; | ||
| /** Session id for cached TSR internals */ | ||
| __TSR_sessionId?: string; | ||
| /** Match snapshot for fast-path on back/forward navigation */ | ||
| __TSR_matches?: { | ||
| routeIds: Array<string>; | ||
| params: Record<string, string>; | ||
| globalNotFoundRouteId?: string; | ||
| searchStr?: string; | ||
| validatedSearches?: Array<{ | ||
| search: Record<string, unknown>; | ||
| strictSearch: Record<string, unknown>; | ||
| }>; | ||
| }; | ||
| }; | ||
@@ -75,0 +51,0 @@ type ShouldAllowNavigation = any; |
+3
-27
| export interface NavigateOptions { | ||
| ignoreBlocker?: boolean; | ||
| /** When true, Transitioner should skip calling load() - commitLocation handles it */ | ||
| skipTransitionerLoad?: boolean; | ||
| } | ||
| /** Result of a navigation attempt (push/replace) */ | ||
| export type NavigationResult = { | ||
| type: 'SUCCESS'; | ||
| } | { | ||
| type: 'BLOCKED'; | ||
| }; | ||
| type SubscriberHistoryAction = { | ||
@@ -18,6 +10,5 @@ type: Exclude<HistoryAction, 'GO'>; | ||
| }; | ||
| export type SubscriberArgs = { | ||
| type SubscriberArgs = { | ||
| location: HistoryLocation; | ||
| action: SubscriberHistoryAction; | ||
| navigateOpts?: NavigateOptions; | ||
| }; | ||
@@ -29,4 +20,4 @@ export interface RouterHistory { | ||
| subscribe: (cb: (opts: SubscriberArgs) => void) => () => void; | ||
| push: (path: string, state?: any, navigateOpts?: NavigateOptions) => Promise<NavigationResult>; | ||
| replace: (path: string, state?: any, navigateOpts?: NavigateOptions) => Promise<NavigationResult>; | ||
| push: (path: string, state?: any, navigateOpts?: NavigateOptions) => void; | ||
| replace: (path: string, state?: any, navigateOpts?: NavigateOptions) => void; | ||
| go: (index: number, navigateOpts?: NavigateOptions) => void; | ||
@@ -58,17 +49,2 @@ back: (navigateOpts?: NavigateOptions) => void; | ||
| __TSR_index: number; | ||
| /** Whether to reset scroll position on this navigation (default: true) */ | ||
| __TSR_resetScroll?: boolean; | ||
| /** Session id for cached TSR internals */ | ||
| __TSR_sessionId?: string; | ||
| /** Match snapshot for fast-path on back/forward navigation */ | ||
| __TSR_matches?: { | ||
| routeIds: Array<string>; | ||
| params: Record<string, string>; | ||
| globalNotFoundRouteId?: string; | ||
| searchStr?: string; | ||
| validatedSearches?: Array<{ | ||
| search: Record<string, unknown>; | ||
| strictSearch: Record<string, unknown>; | ||
| }>; | ||
| }; | ||
| }; | ||
@@ -75,0 +51,0 @@ type ShouldAllowNavigation = any; |
+8
-11
@@ -7,7 +7,5 @@ const stateIndexKey = "__TSR_index"; | ||
| const subscribers = /* @__PURE__ */ new Set(); | ||
| const notify = (action, navigateOpts) => { | ||
| const notify = (action) => { | ||
| location = opts.getLocation(); | ||
| subscribers.forEach( | ||
| (subscriber) => subscriber({ location, action, navigateOpts }) | ||
| ); | ||
| subscribers.forEach((subscriber) => subscriber({ location, action })); | ||
| }; | ||
@@ -26,3 +24,3 @@ const handleIndexChange = (action) => { | ||
| task(); | ||
| return { type: "SUCCESS" }; | ||
| return; | ||
| } | ||
@@ -41,3 +39,3 @@ const blockers = opts.getBlockers?.() ?? []; | ||
| opts.onBlocked?.(); | ||
| return { type: "BLOCKED" }; | ||
| return; | ||
| } | ||
@@ -47,3 +45,2 @@ } | ||
| task(); | ||
| return { type: "SUCCESS" }; | ||
| }; | ||
@@ -67,6 +64,6 @@ return { | ||
| state = assignKeyAndIndex(currentIndex + 1, state); | ||
| return tryNavigation({ | ||
| tryNavigation({ | ||
| task: () => { | ||
| opts.pushState(path, state); | ||
| notify({ type: "PUSH" }, navigateOpts); | ||
| notify({ type: "PUSH" }); | ||
| }, | ||
@@ -82,6 +79,6 @@ navigateOpts, | ||
| state = assignKeyAndIndex(currentIndex, state); | ||
| return tryNavigation({ | ||
| tryNavigation({ | ||
| task: () => { | ||
| opts.replaceState(path, state); | ||
| notify({ type: "REPLACE" }, navigateOpts); | ||
| notify({ type: "REPLACE" }); | ||
| }, | ||
@@ -88,0 +85,0 @@ navigateOpts, |
+1
-1
| { | ||
| "name": "@tanstack/history", | ||
| "version": "1.154.7", | ||
| "version": "1.154.14", | ||
| "description": "Modern and scalable routing for React applications", | ||
@@ -5,0 +5,0 @@ "author": "Tanner Linsley", |
+12
-47
@@ -7,9 +7,4 @@ // While the public API was clearly inspired by the "history" npm package, | ||
| ignoreBlocker?: boolean | ||
| /** When true, Transitioner should skip calling load() - commitLocation handles it */ | ||
| skipTransitionerLoad?: boolean | ||
| } | ||
| /** Result of a navigation attempt (push/replace) */ | ||
| export type NavigationResult = { type: 'SUCCESS' } | { type: 'BLOCKED' } | ||
| type SubscriberHistoryAction = | ||
@@ -24,6 +19,5 @@ | { | ||
| export type SubscriberArgs = { | ||
| type SubscriberArgs = { | ||
| location: HistoryLocation | ||
| action: SubscriberHistoryAction | ||
| navigateOpts?: NavigateOptions | ||
| } | ||
@@ -36,12 +30,4 @@ | ||
| subscribe: (cb: (opts: SubscriberArgs) => void) => () => void | ||
| push: ( | ||
| path: string, | ||
| state?: any, | ||
| navigateOpts?: NavigateOptions, | ||
| ) => Promise<NavigationResult> | ||
| replace: ( | ||
| path: string, | ||
| state?: any, | ||
| navigateOpts?: NavigateOptions, | ||
| ) => Promise<NavigationResult> | ||
| push: (path: string, state?: any, navigateOpts?: NavigateOptions) => void | ||
| replace: (path: string, state?: any, navigateOpts?: NavigateOptions) => void | ||
| go: (index: number, navigateOpts?: NavigateOptions) => void | ||
@@ -76,17 +62,2 @@ back: (navigateOpts?: NavigateOptions) => void | ||
| __TSR_index: number | ||
| /** Whether to reset scroll position on this navigation (default: true) */ | ||
| __TSR_resetScroll?: boolean | ||
| /** Session id for cached TSR internals */ | ||
| __TSR_sessionId?: string | ||
| /** Match snapshot for fast-path on back/forward navigation */ | ||
| __TSR_matches?: { | ||
| routeIds: Array<string> | ||
| params: Record<string, string> | ||
| globalNotFoundRouteId?: string | ||
| searchStr?: string | ||
| validatedSearches?: Array<{ | ||
| search: Record<string, unknown> | ||
| strictSearch: Record<string, unknown> | ||
| }> | ||
| } | ||
| } | ||
@@ -152,10 +123,5 @@ | ||
| const notify = ( | ||
| action: SubscriberHistoryAction, | ||
| navigateOpts?: NavigateOptions, | ||
| ) => { | ||
| const notify = (action: SubscriberHistoryAction) => { | ||
| location = opts.getLocation() | ||
| subscribers.forEach((subscriber) => | ||
| subscriber({ location, action, navigateOpts }), | ||
| ) | ||
| subscribers.forEach((subscriber) => subscriber({ location, action })) | ||
| } | ||
@@ -172,7 +138,7 @@ | ||
| ...actionInfo | ||
| }: TryNavigateArgs): Promise<NavigationResult> => { | ||
| }: TryNavigateArgs) => { | ||
| const ignoreBlocker = navigateOpts?.ignoreBlocker ?? false | ||
| if (ignoreBlocker) { | ||
| task() | ||
| return { type: 'SUCCESS' } | ||
| return | ||
| } | ||
@@ -193,3 +159,3 @@ | ||
| opts.onBlocked?.() | ||
| return { type: 'BLOCKED' } | ||
| return | ||
| } | ||
@@ -200,3 +166,2 @@ } | ||
| task() | ||
| return { type: 'SUCCESS' } | ||
| } | ||
@@ -222,6 +187,6 @@ | ||
| state = assignKeyAndIndex(currentIndex + 1, state) | ||
| return tryNavigation({ | ||
| tryNavigation({ | ||
| task: () => { | ||
| opts.pushState(path, state) | ||
| notify({ type: 'PUSH' }, navigateOpts) | ||
| notify({ type: 'PUSH' }) | ||
| }, | ||
@@ -237,6 +202,6 @@ navigateOpts, | ||
| state = assignKeyAndIndex(currentIndex, state) | ||
| return tryNavigation({ | ||
| tryNavigation({ | ||
| task: () => { | ||
| opts.replaceState(path, state) | ||
| notify({ type: 'REPLACE' }, navigateOpts) | ||
| notify({ type: 'REPLACE' }) | ||
| }, | ||
@@ -243,0 +208,0 @@ navigateOpts, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
116464
-4.66%1581
-3.89%