@tanstack/react-router 1.28.1 → 1.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Matches.cjs +45 -23
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/Matches.d.cts +5 -6
- package/dist/cjs/RouterProvider.cjs +2 -2
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +4 -4
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/link.d.cts +2 -0
- package/dist/cjs/redirects.cjs.map +1 -1
- package/dist/cjs/redirects.d.cts +3 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +2 -2
- package/dist/cjs/router.cjs +374 -327
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/cjs/router.d.cts +2 -2
- package/dist/cjs/utils.cjs +20 -2
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +6 -1
- package/dist/esm/Matches.d.ts +5 -6
- package/dist/esm/Matches.js +46 -24
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +2 -2
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +4 -4
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/link.d.ts +2 -0
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/redirects.d.ts +3 -1
- package/dist/esm/redirects.js.map +1 -1
- package/dist/esm/route.d.ts +2 -2
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.d.ts +2 -2
- package/dist/esm/router.js +375 -328
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/utils.d.ts +6 -1
- package/dist/esm/utils.js +20 -2
- package/dist/esm/utils.js.map +1 -1
- package/package.json +4 -2
- package/src/Matches.tsx +73 -35
- package/src/RouterProvider.tsx +2 -0
- package/src/index.tsx +0 -1
- package/src/link.tsx +2 -0
- package/src/redirects.ts +4 -2
- package/src/route.ts +2 -7
- package/src/router.ts +498 -426
- package/src/utils.ts +31 -2
package/dist/cjs/utils.d.cts
CHANGED
|
@@ -23,7 +23,6 @@ export type Updater<TPrevious, TResult = TPrevious> = TResult | ((prev?: TPrevio
|
|
|
23
23
|
export type NonNullableUpdater<TPrevious, TResult = TPrevious> = TResult | ((prev: TPrevious) => TResult);
|
|
24
24
|
type LastInUnion<T> = UnionToIntersection<T extends unknown ? (x: T) => 0 : never> extends (x: infer L) => 0 ? L : never;
|
|
25
25
|
export type UnionToTuple<T, TLast = LastInUnion<T>> = [T] extends [never] ? [] : [...UnionToTuple<Exclude<T, TLast>>, TLast];
|
|
26
|
-
export declare const isServer: boolean;
|
|
27
26
|
export declare function last<T>(arr: Array<T>): T | undefined;
|
|
28
27
|
export declare function functionalUpdate<TResult>(updater: Updater<TResult> | NonNullableUpdater<TResult>, previous: TResult): TResult;
|
|
29
28
|
export declare function pick<TValue, TKey extends keyof TValue>(parent: TValue, keys: Array<TKey>): Pick<TValue, TKey>;
|
|
@@ -56,4 +55,10 @@ export declare const useLayoutEffect: typeof React.useLayoutEffect;
|
|
|
56
55
|
export declare function escapeJSON(jsonString: string): string;
|
|
57
56
|
export declare function removeTrailingSlash(value: string): string;
|
|
58
57
|
export declare function exactPathTest(pathName1: string, pathName2: string): boolean;
|
|
58
|
+
export type ControlledPromise<T> = Promise<T> & {
|
|
59
|
+
resolve: (value: T) => void;
|
|
60
|
+
reject: (value: any) => void;
|
|
61
|
+
status: 'pending' | 'resolved' | 'rejected';
|
|
62
|
+
};
|
|
63
|
+
export declare function createControlledPromise<T>(onResolve?: () => void): ControlledPromise<T>;
|
|
59
64
|
export {};
|
package/dist/esm/Matches.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type RegisteredRouter } from './router.js';
|
|
2
3
|
import type { ResolveRelativePath, ToOptions } from './link.js';
|
|
3
4
|
import type { AnyRoute, ReactNode, RootSearchSchema, StaticDataRouteOption } from './route.js';
|
|
4
5
|
import type { AllParams, FullSearchSchema, ParseRoute, RouteById, RouteByPath, RouteIds, RoutePaths } from './routeInfo.js';
|
|
5
|
-
import type {
|
|
6
|
-
import type { DeepPartial, Expand, NoInfer, StrictOrFrom } from './utils.js';
|
|
6
|
+
import type { ControlledPromise, DeepPartial, Expand, NoInfer, StrictOrFrom } from './utils.js';
|
|
7
7
|
export declare const matchContext: React.Context<string | undefined>;
|
|
8
8
|
export interface RouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'], TReturnIntersection extends boolean = false> {
|
|
9
9
|
id: string;
|
|
@@ -12,12 +12,12 @@ export interface RouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['rout
|
|
|
12
12
|
params: TReturnIntersection extends false ? RouteById<TRouteTree, TRouteId>['types']['allParams'] : Expand<Partial<AllParams<TRouteTree>>>;
|
|
13
13
|
status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound';
|
|
14
14
|
isFetching: boolean;
|
|
15
|
-
showPending: boolean;
|
|
16
15
|
error: unknown;
|
|
17
16
|
paramsError: unknown;
|
|
18
17
|
searchError: unknown;
|
|
19
18
|
updatedAt: number;
|
|
20
|
-
loadPromise
|
|
19
|
+
loadPromise: ControlledPromise<void>;
|
|
20
|
+
loaderPromise: Promise<RouteById<TRouteTree, TRouteId>['types']['loaderData']>;
|
|
21
21
|
loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData'];
|
|
22
22
|
routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext'];
|
|
23
23
|
context: RouteById<TRouteTree, TRouteId>['types']['allContext'];
|
|
@@ -28,13 +28,13 @@ export interface RouteMatch<TRouteTree extends AnyRoute = RegisteredRouter['rout
|
|
|
28
28
|
loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps'];
|
|
29
29
|
preload: boolean;
|
|
30
30
|
invalid: boolean;
|
|
31
|
-
pendingPromise?: Promise<void>;
|
|
32
31
|
meta?: Array<JSX.IntrinsicElements['meta']>;
|
|
33
32
|
links?: Array<JSX.IntrinsicElements['link']>;
|
|
34
33
|
scripts?: Array<JSX.IntrinsicElements['script']>;
|
|
35
34
|
headers?: Record<string, string>;
|
|
36
35
|
globalNotFound?: boolean;
|
|
37
36
|
staticData: StaticDataRouteOption;
|
|
37
|
+
minPendingPromise?: ControlledPromise<void>;
|
|
38
38
|
}
|
|
39
39
|
export type AnyRouteMatch = RouteMatch<any, any>;
|
|
40
40
|
export declare function Matches(): React.JSX.Element;
|
|
@@ -57,7 +57,6 @@ export type MakeMatchRouteOptions<TRouteTree extends AnyRoute = RegisteredRouter
|
|
|
57
57
|
children?: ((params?: RouteByPath<TRouteTree, ResolveRelativePath<TFrom, NoInfer<TTo>>>['types']['allParams']) => ReactNode) | React.ReactNode;
|
|
58
58
|
};
|
|
59
59
|
export declare function MatchRoute<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> = TFrom, TMaskTo extends string = ''>(props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): any;
|
|
60
|
-
export declare function getRenderedMatches<TRouteTree extends AnyRoute = RegisteredRouter['routeTree']>(state: RouterState<TRouteTree>): RouteMatch<TRouteTree, ParseRoute<TRouteTree, TRouteTree>["id"], false>[];
|
|
61
60
|
export declare function useMatch<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>, TReturnIntersection extends boolean = false, TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>, TSelected = TRouteMatchState>(opts: StrictOrFrom<TFrom, TReturnIntersection> & {
|
|
62
61
|
select?: (match: TRouteMatchState) => TSelected;
|
|
63
62
|
}): TSelected;
|
package/dist/esm/Matches.js
CHANGED
|
@@ -5,16 +5,15 @@ import warning from "tiny-warning";
|
|
|
5
5
|
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
6
6
|
import { useRouterState } from "./useRouterState.js";
|
|
7
7
|
import { useRouter } from "./useRouter.js";
|
|
8
|
-
import { pick,
|
|
8
|
+
import { pick, createControlledPromise } from "./utils.js";
|
|
9
9
|
import { isNotFound, DefaultGlobalNotFound, CatchNotFound } from "./not-found.js";
|
|
10
10
|
import { isRedirect } from "./redirects.js";
|
|
11
11
|
const matchContext = React.createContext(void 0);
|
|
12
12
|
function Matches() {
|
|
13
|
-
useRouter();
|
|
14
13
|
const matchId = useRouterState({
|
|
15
14
|
select: (s) => {
|
|
16
15
|
var _a;
|
|
17
|
-
return (_a =
|
|
16
|
+
return (_a = s.matches[0]) == null ? void 0 : _a.id;
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
19
|
const resetKey = useRouterState({
|
|
@@ -45,7 +44,7 @@ function Match({ matchId }) {
|
|
|
45
44
|
const routeId = useRouterState({
|
|
46
45
|
select: (s) => {
|
|
47
46
|
var _a2;
|
|
48
|
-
return (_a2 =
|
|
47
|
+
return (_a2 = s.matches.find((d) => d.id === matchId)) == null ? void 0 : _a2.routeId;
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
50
|
invariant(
|
|
@@ -85,31 +84,32 @@ function Match({ matchId }) {
|
|
|
85
84
|
throw error;
|
|
86
85
|
return React.createElement(routeNotFoundComponent, error);
|
|
87
86
|
},
|
|
88
|
-
children: /* @__PURE__ */ jsx(MatchInner, { matchId
|
|
87
|
+
children: /* @__PURE__ */ jsx(MatchInner, { matchId })
|
|
89
88
|
}
|
|
90
89
|
)
|
|
91
90
|
}
|
|
92
91
|
) }) });
|
|
93
92
|
}
|
|
94
93
|
function MatchInner({
|
|
95
|
-
matchId
|
|
96
|
-
pendingElement
|
|
94
|
+
matchId
|
|
95
|
+
// pendingElement,
|
|
97
96
|
}) {
|
|
98
97
|
var _a, _b;
|
|
99
98
|
const router = useRouter();
|
|
100
99
|
const routeId = useRouterState({
|
|
101
100
|
select: (s) => {
|
|
102
101
|
var _a2;
|
|
103
|
-
return (_a2 =
|
|
102
|
+
return (_a2 = s.matches.find((d) => d.id === matchId)) == null ? void 0 : _a2.routeId;
|
|
104
103
|
}
|
|
105
104
|
});
|
|
106
105
|
const route = router.routesById[routeId];
|
|
107
106
|
const match = useRouterState({
|
|
108
|
-
select: (s) => pick(
|
|
107
|
+
select: (s) => pick(s.matches.find((d) => d.id === matchId), [
|
|
108
|
+
"id",
|
|
109
109
|
"status",
|
|
110
110
|
"error",
|
|
111
|
-
"
|
|
112
|
-
"
|
|
111
|
+
"loadPromise",
|
|
112
|
+
"minPendingPromise"
|
|
113
113
|
])
|
|
114
114
|
});
|
|
115
115
|
const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
|
|
@@ -133,7 +133,7 @@ function MatchInner({
|
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
if (match.status === "error") {
|
|
136
|
-
if (isServer) {
|
|
136
|
+
if (router.isServer) {
|
|
137
137
|
return /* @__PURE__ */ jsx(
|
|
138
138
|
RouteErrorComponent,
|
|
139
139
|
{
|
|
@@ -152,8 +152,35 @@ function MatchInner({
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
if (match.status === "pending") {
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
|
|
156
|
+
if (pendingMinMs && !match.minPendingPromise) {
|
|
157
|
+
match.minPendingPromise = createControlledPromise();
|
|
158
|
+
if (!router.isServer) {
|
|
159
|
+
Promise.resolve().then(() => {
|
|
160
|
+
router.__store.setState((s) => ({
|
|
161
|
+
...s,
|
|
162
|
+
matches: s.matches.map(
|
|
163
|
+
(d) => d.id === match.id ? { ...d, minPendingPromise: createControlledPromise() } : d
|
|
164
|
+
)
|
|
165
|
+
}));
|
|
166
|
+
});
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
router.__store.setState((s) => {
|
|
169
|
+
return {
|
|
170
|
+
...s,
|
|
171
|
+
matches: s.matches.map(
|
|
172
|
+
(d) => {
|
|
173
|
+
var _a2;
|
|
174
|
+
return d.id === match.id ? {
|
|
175
|
+
...d,
|
|
176
|
+
minPendingPromise: ((_a2 = d.minPendingPromise) == null ? void 0 : _a2.resolve(), void 0)
|
|
177
|
+
} : d;
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
}, pendingMinMs);
|
|
183
|
+
}
|
|
157
184
|
}
|
|
158
185
|
throw match.loadPromise;
|
|
159
186
|
}
|
|
@@ -175,13 +202,13 @@ const Outlet = React.memo(function Outlet2() {
|
|
|
175
202
|
const routeId = useRouterState({
|
|
176
203
|
select: (s) => {
|
|
177
204
|
var _a;
|
|
178
|
-
return (_a =
|
|
205
|
+
return (_a = s.matches.find((d) => d.id === matchId)) == null ? void 0 : _a.routeId;
|
|
179
206
|
}
|
|
180
207
|
});
|
|
181
208
|
const route = router.routesById[routeId];
|
|
182
209
|
const { parentGlobalNotFound } = useRouterState({
|
|
183
210
|
select: (s) => {
|
|
184
|
-
const matches =
|
|
211
|
+
const matches = s.matches;
|
|
185
212
|
const parentMatch = matches.find((d) => d.id === matchId);
|
|
186
213
|
invariant(
|
|
187
214
|
parentMatch,
|
|
@@ -195,7 +222,7 @@ const Outlet = React.memo(function Outlet2() {
|
|
|
195
222
|
const childMatchId = useRouterState({
|
|
196
223
|
select: (s) => {
|
|
197
224
|
var _a;
|
|
198
|
-
const matches =
|
|
225
|
+
const matches = s.matches;
|
|
199
226
|
const index = matches.findIndex((d) => d.id === matchId);
|
|
200
227
|
return (_a = matches[index + 1]) == null ? void 0 : _a.id;
|
|
201
228
|
}
|
|
@@ -246,15 +273,11 @@ function MatchRoute(props) {
|
|
|
246
273
|
}
|
|
247
274
|
return params ? props.children : null;
|
|
248
275
|
}
|
|
249
|
-
function getRenderedMatches(state) {
|
|
250
|
-
var _a;
|
|
251
|
-
return ((_a = state.pendingMatches) == null ? void 0 : _a.some((d) => d.showPending)) ? state.pendingMatches : state.matches;
|
|
252
|
-
}
|
|
253
276
|
function useMatch(opts) {
|
|
254
277
|
const nearestMatchId = React.useContext(matchContext);
|
|
255
278
|
const matchSelection = useRouterState({
|
|
256
279
|
select: (state) => {
|
|
257
|
-
const match =
|
|
280
|
+
const match = state.matches.find(
|
|
258
281
|
(d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId
|
|
259
282
|
);
|
|
260
283
|
invariant(
|
|
@@ -269,7 +292,7 @@ function useMatch(opts) {
|
|
|
269
292
|
function useMatches(opts) {
|
|
270
293
|
return useRouterState({
|
|
271
294
|
select: (state) => {
|
|
272
|
-
const matches =
|
|
295
|
+
const matches = state.matches;
|
|
273
296
|
return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
|
|
274
297
|
}
|
|
275
298
|
});
|
|
@@ -339,7 +362,6 @@ export {
|
|
|
339
362
|
Matches,
|
|
340
363
|
Outlet,
|
|
341
364
|
defaultDeserializeError,
|
|
342
|
-
getRenderedMatches,
|
|
343
365
|
isServerSideError,
|
|
344
366
|
matchContext,
|
|
345
367
|
useChildMatches,
|
package/dist/esm/Matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { isServer, pick } from './utils'\nimport { CatchNotFound, DefaultGlobalNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport type { ResolveRelativePath, ToOptions } from './link'\nimport type {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n} from './route'\nimport type {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport type { AnyRouter, RegisteredRouter, RouterState } from './router'\nimport type { DeepPartial, Expand, NoInfer, StrictOrFrom } from './utils'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: boolean\n showPending: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise?: Promise<void>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n pendingPromise?: Promise<void>\n meta?: Array<JSX.IntrinsicElements['meta']>\n links?: Array<JSX.IntrinsicElements['link']>\n scripts?: Array<JSX.IntrinsicElements['script']>\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return getRenderedMatches(s)[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.resolvedLocation.state.key!,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => resetKey}\n errorComponent={ErrorComponent}\n onCatch={(error) => {\n warning(\n false,\n `The following error wasn't caught by any route! 👇 At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n console.error(error)\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const resetKey = useRouterState({\n select: (s) => s.resolvedLocation.state.key!,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent ?? ErrorComponent}\n onCatch={(error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n console.error(error)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId} pendingElement={pendingElement} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n pendingElement,\n}: {\n matchId: string\n pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const match = useRouterState({\n select: (s) =>\n pick(getRenderedMatches(s).find((d) => d.id === matchId)!, [\n 'status',\n 'error',\n 'showPending',\n 'loadPromise',\n ]),\n })\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n warning(\n false,\n 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n )\n\n return null\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (isServer) {\n return (\n <RouteErrorComponent\n error={match.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n if (match.showPending) {\n return pendingElement\n }\n throw match.loadPromise\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (match.status === 'success') {\n const Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) =>\n getRenderedMatches(s).find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = getRenderedMatches(s)\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nfunction renderRouteNotFound(router: AnyRouter, route: AnyRoute, data: any) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent data={data} />\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,\n )\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent data={data} />\n}\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TOptions extends ToOptions<\n TRouteTree,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n TRelaxedOptions = Omit<TOptions, 'search' | 'params'> &\n DeepPartial<Pick<TOptions, 'search' | 'params'>>,\n> = TRelaxedOptions & MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n const router = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [router],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport function getRenderedMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>(state: RouterState<TRouteTree>) {\n return state.pendingMatches?.some((d) => d.showPending)\n ? state.pendingMatches\n : state.matches\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const nearestMatchId = React.useContext(matchContext)\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = getRenderedMatches(state).find((d) =>\n opts.from ? opts.from === d.routeId : d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'\n }`,\n )\n\n return opts.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as any\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = Array<TRouteMatch>,\n>(opts?: {\n select?: (matches: Array<TRouteMatch>) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = getRenderedMatches(state)\n return opts?.select\n ? opts.select(matches as Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = Array<TRouteMatch>,\n>(opts?: {\n select?: (matches: Array<TRouteMatch>) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId),\n )\n return opts?.select\n ? opts.select(matches as Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n\nexport function useChildMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = Array<TRouteMatch>,\n>(opts?: {\n select?: (matches: Array<TRouteMatch>) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId) + 1,\n )\n return opts?.select\n ? opts.select(matches as Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s.loaderDeps)\n : s.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s.loaderData as TRouteMatch)\n : s.loaderData\n },\n }) as TSelected\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n if (process.env.NODE_ENV === 'development') {\n error.stack = serializedData.stack\n }\n return error\n }\n\n return serializedData.data\n}\n"],"names":["_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aAAA,OAAO,KAAK,WAAW,aAC1B,KAAK,OAAO,EAAE,UAAU,IACxB,EAAE;AAAA,IACR;AAAA,EAAA,CACD;AACH;AAEO,SAAS,cASd,MAGW;AACX,SAAO,SAAS;AAAA,IACd,GAAG;AAAA,IACH,QAAQ,CAAC,MAAM;AACN,aAAA,OAAO,KAAK,WAAW,aAC1B,KAAK,OAAO,EAAE,UAAyB,IACvC,EAAE;AAAA,IACR;AAAA,EAAA,CACD;AACH;AAEO,SAAS,kBAAkB,OAGhC;AACA,MAAI,EAAE,OAAO,UAAU,YAAY,SAAS,UAAU;AAAe,WAAA;AACjE,MAAA,EAAE,qBAAqB,SAAS,MAAM;AAAyB,WAAA;AACnE,MAAI,EAAE,OAAO,MAAM,SAAS,YAAY,MAAM;AAAc,WAAA;AAE5D,SAAO,MAAM,oBAAoB;AACnC;AAEO,SAAS,wBAAwB,gBAAqC;AACvE,MAAA,UAAU,kBAAkB,aAAa,gBAAgB;AAC3D,UAAM,QAAQ,IAAI,MAAM,eAAe,OAAO;AAC9C,UAAM,OAAO,eAAe;AACxB,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAM,QAAQ,eAAe;AAAA,IAC/B;AACO,WAAA;AAAA,EACT;AAEA,SAAO,eAAe;AACxB;"}
|
|
1
|
+
{"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as React from 'react'\nimport invariant from 'tiny-invariant'\nimport warning from 'tiny-warning'\nimport { set } from 'zod'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { createControlledPromise, pick } from './utils'\nimport { CatchNotFound, DefaultGlobalNotFound, isNotFound } from './not-found'\nimport { isRedirect } from './redirects'\nimport {\n type AnyRouter,\n type RegisteredRouter,\n type RouterState,\n} from './router'\nimport type { ResolveRelativePath, ToOptions } from './link'\nimport type {\n AnyRoute,\n ReactNode,\n RootSearchSchema,\n StaticDataRouteOption,\n} from './route'\nimport type {\n AllParams,\n FullSearchSchema,\n ParseRoute,\n RouteById,\n RouteByPath,\n RouteIds,\n RoutePaths,\n} from './routeInfo'\nimport type {\n ControlledPromise,\n DeepPartial,\n Expand,\n NoInfer,\n StrictOrFrom,\n} from './utils'\n\nexport const matchContext = React.createContext<string | undefined>(undefined)\n\nexport interface RouteMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n> {\n id: string\n routeId: TRouteId\n pathname: string\n params: TReturnIntersection extends false\n ? RouteById<TRouteTree, TRouteId>['types']['allParams']\n : Expand<Partial<AllParams<TRouteTree>>>\n status: 'pending' | 'success' | 'error' | 'redirected' | 'notFound'\n isFetching: boolean\n error: unknown\n paramsError: unknown\n searchError: unknown\n updatedAt: number\n loadPromise: ControlledPromise<void>\n loaderPromise: Promise<RouteById<TRouteTree, TRouteId>['types']['loaderData']>\n loaderData?: RouteById<TRouteTree, TRouteId>['types']['loaderData']\n routeContext: RouteById<TRouteTree, TRouteId>['types']['routeContext']\n context: RouteById<TRouteTree, TRouteId>['types']['allContext']\n search: TReturnIntersection extends false\n ? Exclude<\n RouteById<TRouteTree, TRouteId>['types']['fullSearchSchema'],\n RootSearchSchema\n >\n : Expand<\n Partial<Omit<FullSearchSchema<TRouteTree>, keyof RootSearchSchema>>\n >\n fetchCount: number\n abortController: AbortController\n cause: 'preload' | 'enter' | 'stay'\n loaderDeps: RouteById<TRouteTree, TRouteId>['types']['loaderDeps']\n preload: boolean\n invalid: boolean\n meta?: Array<JSX.IntrinsicElements['meta']>\n links?: Array<JSX.IntrinsicElements['link']>\n scripts?: Array<JSX.IntrinsicElements['script']>\n headers?: Record<string, string>\n globalNotFound?: boolean\n staticData: StaticDataRouteOption\n minPendingPromise?: ControlledPromise<void>\n}\n\nexport type AnyRouteMatch = RouteMatch<any, any>\n\nexport function Matches() {\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.resolvedLocation.state.key!,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <CatchBoundary\n getResetKey={() => resetKey}\n errorComponent={ErrorComponent}\n onCatch={(error) => {\n warning(\n false,\n `The following error wasn't caught by any route! 👇 At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n console.error(error)\n }}\n >\n {matchId ? <Match matchId={matchId} /> : null}\n </CatchBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction SafeFragment(props: any) {\n return <>{props.children}</>\n}\n\nexport function Match({ matchId }: { matchId: string }) {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n invariant(\n routeId,\n `Could not find routeId for matchId \"${matchId}\". Please file an issue!`,\n )\n\n const route: AnyRoute = router.routesById[routeId]\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n const routeErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent\n\n const routeNotFoundComponent = route.isRoot\n ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n route.options.notFoundComponent ??\n router.options.notFoundRoute?.options.component\n : route.options.notFoundComponent\n\n const ResolvedSuspenseBoundary =\n route.options.wrapInSuspense ??\n PendingComponent ??\n route.options.component?.preload ??\n route.options.pendingComponent?.preload ??\n (route.options.errorComponent as any)?.preload\n ? React.Suspense\n : SafeFragment\n\n const ResolvedCatchBoundary = routeErrorComponent\n ? CatchBoundary\n : SafeFragment\n\n const ResolvedNotFoundBoundary = routeNotFoundComponent\n ? CatchNotFound\n : SafeFragment\n\n const resetKey = useRouterState({\n select: (s) => s.resolvedLocation.state.key!,\n })\n\n return (\n <matchContext.Provider value={matchId}>\n <ResolvedSuspenseBoundary fallback={pendingElement}>\n <ResolvedCatchBoundary\n getResetKey={() => resetKey}\n errorComponent={routeErrorComponent ?? ErrorComponent}\n onCatch={(error) => {\n // Forward not found errors (we don't want to show the error component for these)\n if (isNotFound(error)) throw error\n warning(false, `Error in route match: ${matchId}`)\n console.error(error)\n }}\n >\n <ResolvedNotFoundBoundary\n fallback={(error) => {\n // If the current not found handler doesn't exist or it has a\n // route ID which doesn't match the current route, rethrow the error\n if (\n !routeNotFoundComponent ||\n (error.routeId && error.routeId !== routeId) ||\n (!error.routeId && !route.isRoot)\n )\n throw error\n\n return React.createElement(routeNotFoundComponent, error as any)\n }}\n >\n <MatchInner matchId={matchId} />\n </ResolvedNotFoundBoundary>\n </ResolvedCatchBoundary>\n </ResolvedSuspenseBoundary>\n </matchContext.Provider>\n )\n}\n\nfunction MatchInner({\n matchId,\n // pendingElement,\n}: {\n matchId: string\n // pendingElement: any\n}): any {\n const router = useRouter()\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const match = useRouterState({\n select: (s) =>\n pick(s.matches.find((d) => d.id === matchId)!, [\n 'id',\n 'status',\n 'error',\n 'loadPromise',\n 'minPendingPromise',\n ]),\n })\n\n const RouteErrorComponent =\n (route.options.errorComponent ?? router.options.defaultErrorComponent) ||\n ErrorComponent\n\n if (match.status === 'notFound') {\n let error: unknown\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n\n error = deserializeError(match.error.data)\n } else {\n error = match.error\n }\n\n invariant(isNotFound(error), 'Expected a notFound error')\n\n return renderRouteNotFound(router, route, error)\n }\n\n if (match.status === 'redirected') {\n // Redirects should be handled by the router transition. If we happen to\n // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n invariant(isRedirect(match.error), 'Expected a redirect error')\n\n warning(\n false,\n 'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n )\n\n return null\n }\n\n if (match.status === 'error') {\n // If we're on the server, we need to use React's new and super\n // wonky api for throwing errors from a server side render inside\n // of a suspense boundary. This is the only way to get\n // renderToPipeableStream to not hang indefinitely.\n // We'll serialize the error and rethrow it on the client.\n if (router.isServer) {\n return (\n <RouteErrorComponent\n error={match.error}\n info={{\n componentStack: '',\n }}\n />\n )\n }\n\n if (isServerSideError(match.error)) {\n const deserializeError =\n router.options.errorSerializer?.deserialize ?? defaultDeserializeError\n throw deserializeError(match.error.data)\n } else {\n throw match.error\n }\n }\n\n if (match.status === 'pending') {\n // We're pending, and if we have a minPendingMs, we need to wait for it\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n\n if (pendingMinMs && !match.minPendingPromise) {\n // Create a promise that will resolve after the minPendingMs\n\n match.minPendingPromise = createControlledPromise()\n\n if (!router.isServer) {\n Promise.resolve().then(() => {\n router.__store.setState((s) => ({\n ...s,\n matches: s.matches.map((d) =>\n d.id === match.id\n ? { ...d, minPendingPromise: createControlledPromise() }\n : d,\n ),\n }))\n })\n\n setTimeout(() => {\n // We've handled the minPendingPromise, so we can delete it\n router.__store.setState((s) => {\n return {\n ...s,\n matches: s.matches.map((d) =>\n d.id === match.id\n ? {\n ...d,\n minPendingPromise:\n (d.minPendingPromise?.resolve(), undefined),\n }\n : d,\n ),\n }\n })\n }, pendingMinMs)\n }\n }\n\n throw match.loadPromise\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (match.status === 'success') {\n const Comp = route.options.component ?? router.options.defaultComponent\n\n if (Comp) {\n return <Comp />\n }\n\n return <Outlet />\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n}\n\nexport const Outlet = React.memo(function Outlet() {\n const router = useRouter()\n const matchId = React.useContext(matchContext)\n const routeId = useRouterState({\n select: (s) => s.matches.find((d) => d.id === matchId)?.routeId as string,\n })\n\n const route = router.routesById[routeId]!\n\n const { parentGlobalNotFound } = useRouterState({\n select: (s) => {\n const matches = s.matches\n const parentMatch = matches.find((d) => d.id === matchId)\n invariant(\n parentMatch,\n `Could not find parent match for matchId \"${matchId}\"`,\n )\n return {\n parentGlobalNotFound: parentMatch.globalNotFound,\n }\n },\n })\n\n const childMatchId = useRouterState({\n select: (s) => {\n const matches = s.matches\n const index = matches.findIndex((d) => d.id === matchId)\n return matches[index + 1]?.id\n },\n })\n\n if (parentGlobalNotFound) {\n return renderRouteNotFound(router, route, undefined)\n }\n\n if (!childMatchId) {\n return null\n }\n\n return <Match matchId={childMatchId} />\n})\n\nfunction renderRouteNotFound(router: AnyRouter, route: AnyRoute, data: any) {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return <router.options.defaultNotFoundComponent data={data} />\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`,\n )\n }\n\n return <DefaultGlobalNotFound />\n }\n\n return <route.options.notFoundComponent data={data} />\n}\n\nexport interface MatchRouteOptions {\n pending?: boolean\n caseSensitive?: boolean\n includeSearch?: boolean\n fuzzy?: boolean\n}\n\nexport type UseMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TOptions extends ToOptions<\n TRouteTree,\n TFrom,\n TTo,\n TMaskFrom,\n TMaskTo\n > = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n TRelaxedOptions = Omit<TOptions, 'search' | 'params'> &\n DeepPartial<Pick<TOptions, 'search' | 'params'>>,\n> = TRelaxedOptions & MatchRouteOptions\n\nexport function useMatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n>() {\n const router = useRouter()\n\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n TResolved extends string = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n >(\n opts: UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): false | RouteById<TRouteTree, TResolved>['types']['allParams'] => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n },\n [router],\n )\n}\n\nexport type MakeMatchRouteOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ((\n params?: RouteByPath<\n TRouteTree,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => ReactNode)\n | React.ReactNode\n}\n\nexport function MatchRoute<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = TFrom,\n TMaskTo extends string = '',\n>(\n props: MakeMatchRouteOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport function useMatch<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TReturnIntersection extends boolean = false,\n TRouteMatchState = RouteMatch<TRouteTree, TFrom, TReturnIntersection>,\n TSelected = TRouteMatchState,\n>(\n opts: StrictOrFrom<TFrom, TReturnIntersection> & {\n select?: (match: TRouteMatchState) => TSelected\n },\n): TSelected {\n const nearestMatchId = React.useContext(matchContext)\n\n const matchSelection = useRouterState({\n select: (state) => {\n const match = state.matches.find((d) =>\n opts.from ? opts.from === d.routeId : d.id === nearestMatchId,\n )\n\n invariant(\n match,\n `Could not find ${\n opts.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'\n }`,\n )\n\n return opts.select ? opts.select(match as any) : match\n },\n })\n\n return matchSelection as TSelected\n}\n\nexport function useMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = Array<TRouteMatch>,\n>(opts?: {\n select?: (matches: Array<TRouteMatch>) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n return useRouterState({\n select: (state) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n\nexport function useParentMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = Array<TRouteMatch>,\n>(opts?: {\n select?: (matches: Array<TRouteMatch>) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId),\n )\n return opts?.select\n ? opts.select(matches as Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n\nexport function useChildMatches<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TRouteId extends RouteIds<TRouteTree> = ParseRoute<TRouteTree>['id'],\n TReturnIntersection extends boolean = false,\n TRouteMatch = RouteMatch<TRouteTree, TRouteId, TReturnIntersection>,\n T = Array<TRouteMatch>,\n>(opts?: {\n select?: (matches: Array<TRouteMatch>) => T\n experimental_returnIntersection?: TReturnIntersection\n}): T {\n const contextMatchId = React.useContext(matchContext)\n\n return useMatches({\n select: (matches) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId) + 1,\n )\n return opts?.select\n ? opts.select(matches as Array<TRouteMatch>)\n : (matches as T)\n },\n })\n}\n\nexport function useLoaderDeps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderDeps'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s.loaderDeps)\n : s.loaderDeps\n },\n })\n}\n\nexport function useLoaderData<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RouteIds<TRouteTree> = RouteIds<TRouteTree>,\n TRouteMatch extends RouteMatch<TRouteTree, TFrom> = RouteMatch<\n TRouteTree,\n TFrom\n >,\n TSelected = Required<TRouteMatch>['loaderData'],\n>(\n opts: StrictOrFrom<TFrom> & {\n select?: (match: TRouteMatch) => TSelected\n },\n): TSelected {\n return useMatch({\n ...opts,\n select: (s) => {\n return typeof opts.select === 'function'\n ? opts.select(s.loaderData as TRouteMatch)\n : s.loaderData\n },\n }) as TSelected\n}\n\nexport function isServerSideError(error: unknown): error is {\n __isServerError: true\n data: Record<string, any>\n} {\n if (!(typeof error === 'object' && error && 'data' in error)) return false\n if (!('__isServerError' in error && error.__isServerError)) return false\n if (!(typeof error.data === 'object' && error.data)) return false\n\n return error.__isServerError === true\n}\n\nexport function defaultDeserializeError(serializedData: Record<string, any>) {\n if ('name' in serializedData && 'message' in serializedData) {\n const error = new Error(serializedData.message)\n error.name = serializedData.name\n if (process.env.NODE_ENV === 'development') {\n error.stack = serializedData.stack\n }\n return error\n }\n\n return serializedData.data\n}\n"],"names":["_a","Outlet"],"mappings":";;;;;;;;;;AAuCa,MAAA,eAAe,MAAM,cAAkC,MAAS;AAiDtE,SAAS,UAAU;AACxB,QAAM,UAAU,eAAe;AAAA,IAC7B,QAAQ,CAAC,MAAM;;AACN,cAAA,OAAE,QAAQ,CAAC,MAAX,mBAAc;AAAA,IACvB;AAAA,EAAA,CACD;AAED,QAAM,WAAW,eAAe;AAAA,IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,MAAM;AAAA,EAAA,CACzC;AAED,SACG,oBAAA,aAAa,UAAb,EAAsB,OAAO,SAC5B,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,aAAa,MAAM;AAAA,MACnB,gBAAgB;AAAA,MAChB,SAAS,CAAC,UAAU;AAClB;AAAA,UACE;AAAA,UACA;AAAA,QAAA;AAEF,gBAAQ,MAAM,KAAK;AAAA,MACrB;AAAA,MAEC,UAAU,UAAA,oBAAC,OAAM,EAAA,QAAkB,CAAA,IAAK;AAAA,IAAA;AAAA,EAE7C,EAAA,CAAA;AAEJ;AAEA,SAAS,aAAa,OAAY;AACzB,SAAA,oBAAA,UAAA,EAAG,gBAAM,SAAS,CAAA;AAC3B;AAEgB,SAAA,MAAM,EAAE,WAAgC;;AACtD,QAAM,SAAS;AACf,QAAM,UAAU,eAAe;AAAA,IAC7B,QAAQ,CAAC;;AAAM,cAAAA,MAAA,EAAE,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,OAAO,MAAtC,gBAAAA,IAAyC;AAAA;AAAA,EAAA,CACzD;AAED;AAAA,IACE;AAAA,IACA,uCAAuC,OAAO;AAAA,EAAA;AAG1C,Q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AA;AAE5D,SAAO,MAAM,oBAAoB;AACnC;AAEO,SAAS,wBAAwB,gBAAqC;AACvE,MAAA,UAAU,kBAAkB,aAAa,gBAAgB;AAC3D,UAAM,QAAQ,IAAI,MAAM,eAAe,OAAO;AAC9C,UAAM,OAAO,eAAe;AACxB,QAAA,QAAQ,IAAI,aAAa,eAAe;AAC1C,YAAM,QAAQ,eAAe;AAAA,IAC/B;AACO,WAAA;AAAA,EACT;AAEA,SAAO,eAAe;AACxB;"}
|
|
@@ -25,10 +25,10 @@ function RouterProvider({ router, ...rest }) {
|
|
|
25
25
|
});
|
|
26
26
|
const matches = router.options.InnerWrap ? /* @__PURE__ */ jsx(router.options.InnerWrap, { children: /* @__PURE__ */ jsx(Matches, {}) }) : /* @__PURE__ */ jsx(Matches, {});
|
|
27
27
|
const routerContext = getRouterContext();
|
|
28
|
-
const provider = /* @__PURE__ */ jsxs(routerContext.Provider, { value: router, children: [
|
|
28
|
+
const provider = /* @__PURE__ */ jsx(React.Suspense, { fallback: null, children: /* @__PURE__ */ jsxs(routerContext.Provider, { value: router, children: [
|
|
29
29
|
matches,
|
|
30
30
|
/* @__PURE__ */ jsx(Transitioner, {})
|
|
31
|
-
] });
|
|
31
|
+
] }) });
|
|
32
32
|
if (router.options.Wrap) {
|
|
33
33
|
return /* @__PURE__ */ jsx(router.options.Wrap, { children: provider });
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { pick, useLayoutEffect } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { getRouterContext } from './routerContext'\nimport type { NavigateOptions, ToOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { AnyRoute } from './route'\nimport type { RoutePaths } from './routeInfo'\nimport type {\n RegisteredRouter,\n Router,\n RouterOptions,\n RouterState,\n} from './router'\n\nimport type { RouteMatch } from './Matches'\n\nconst useTransition =\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n React.useTransition ||\n (() => [\n false,\n (cb) => {\n cb()\n },\n ])\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n startTransition?: boolean\n}\n\nexport interface MatchLocation {\n to?: string | number | null\n fuzzy?: boolean\n caseSensitive?: boolean\n from?: string\n}\n\nexport type NavigateFn = <\n TTo extends string,\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Promise<void>\n\nexport type BuildLocationFn<TRouteTree extends AnyRoute> = <\n TTo extends string,\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n leaveParams?: boolean\n },\n) => ParsedLocation\n\nexport type InjectedHtmlEntry = string | (() => Promise<string> | string)\n\nexport function RouterProvider<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n } as any)\n\n const matches = router.options.InnerWrap ? (\n <router.options.InnerWrap>\n <Matches />\n </router.options.InnerWrap>\n ) : (\n <Matches />\n )\n\n const routerContext = getRouterContext()\n\n const provider = (\n <routerContext.Provider value={router}>\n {matches}\n <Transitioner />\n </routerContext.Provider>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\nfunction Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n const routerState = useRouterState({\n select: (s) =>\n pick(s, ['isLoading', 'location', 'resolvedLocation', 'isTransitioning']),\n })\n\n const [isTransitioning, startReactTransition] = useTransition()\n\n router.startReactTransition = startReactTransition\n\n React.useEffect(() => {\n if (isTransitioning) {\n router.__store.setState((s) => ({\n ...s,\n isTransitioning,\n }))\n }\n }, [isTransitioning, router])\n\n const tryLoad = () => {\n const apply = (cb: () => void) => {\n if (!routerState.isTransitioning) {\n startReactTransition(() => cb())\n } else {\n cb()\n }\n }\n\n apply(() => {\n try {\n router.load()\n } catch (err) {\n console.error(err)\n }\n })\n }\n\n useLayoutEffect(() => {\n const unsub = router.history.subscribe(() => {\n router.latestLocation = router.parseLocation(router.latestLocation)\n if (router.state.location !== router.latestLocation) {\n tryLoad()\n }\n })\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n })\n\n if (routerState.location.href !== nextLocation.href) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [router, router.history])\n\n useLayoutEffect(() => {\n if (\n (React.useTransition as any)\n ? routerState.isTransitioning && !isTransitioning\n : !routerState.isLoading &&\n routerState.resolvedLocation !== routerState.location\n ) {\n router.emit({\n type: 'onResolved',\n fromLocation: routerState.resolvedLocation,\n toLocation: routerState.location,\n pathChanged:\n routerState.location.href !== routerState.resolvedLocation.href,\n })\n\n if ((document as any).querySelector) {\n if (routerState.location.hash !== '') {\n const el = document.getElementById(routerState.location.hash)\n if (el) {\n el.scrollIntoView()\n }\n }\n }\n\n router.__store.setState((s) => ({\n ...s,\n isTransitioning: false,\n resolvedLocation: s.location,\n }))\n }\n }, [\n routerState.isTransitioning,\n isTransitioning,\n routerState.isLoading,\n routerState.resolvedLocation,\n routerState.location,\n router,\n ])\n\n useLayoutEffect(() => {\n if (\n window.__TSR_DEHYDRATED__ ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n tryLoad()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [router])\n\n return null\n}\n\nexport function getRouteMatch<TRouteTree extends AnyRoute>(\n state: RouterState<TRouteTree>,\n id: string,\n): undefined | RouteMatch<TRouteTree> {\n return [\n ...state.cachedMatches,\n ...(state.pendingMatches ?? []),\n ...state.matches,\n ].find((d) => d.id === id)\n}\n\nexport type RouterProps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {\n router: Router<TRouteTree>\n context?: Partial<RouterOptions<TRouteTree, TDehydrated>['context']>\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM;AAAA;AAAA,EAEJ,MAAM,kBACL,MAAM;AAAA,IACL;AAAA,IACA,CAAC,OAAO;AACH;IACL;AAAA,EAAA;AAAA;AAuCG,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA8C;AAE3D,SAAO,OAAO;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,OAAO,QAAQ;AAAA,MAClB,GAAG,KAAK;AAAA,IACV;AAAA,EAAA,CACM;AAER,QAAM,UAAU,OAAO,QAAQ,gCAC5B,OAAO,QAAQ,WAAf,EACC,UAAC,oBAAA,SAAA,EAAQ,EACX,CAAA,wBAEC,SAAQ,CAAA,CAAA;AAGX,QAAM,gBAAgB;AAEtB,QAAM,
|
|
1
|
+
{"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Matches } from './Matches'\nimport { pick, useLayoutEffect } from './utils'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { getRouterContext } from './routerContext'\nimport type { NavigateOptions, ToOptions } from './link'\nimport type { ParsedLocation } from './location'\nimport type { AnyRoute } from './route'\nimport type { RoutePaths } from './routeInfo'\nimport type {\n RegisteredRouter,\n Router,\n RouterOptions,\n RouterState,\n} from './router'\n\nimport type { RouteMatch } from './Matches'\n\nconst useTransition =\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n React.useTransition ||\n (() => [\n false,\n (cb) => {\n cb()\n },\n ])\n\nexport interface CommitLocationOptions {\n replace?: boolean\n resetScroll?: boolean\n startTransition?: boolean\n}\n\nexport interface MatchLocation {\n to?: string | number | null\n fuzzy?: boolean\n caseSensitive?: boolean\n from?: string\n}\n\nexport type NavigateFn = <\n TTo extends string,\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Promise<void>\n\nexport type BuildLocationFn<TRouteTree extends AnyRoute> = <\n TTo extends string,\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n opts: ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n leaveParams?: boolean\n },\n) => ParsedLocation\n\nexport type InjectedHtmlEntry = string | (() => Promise<string> | string)\n\nexport function RouterProvider<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouteTree, TDehydrated>) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n } as any)\n\n const matches = router.options.InnerWrap ? (\n <router.options.InnerWrap>\n <Matches />\n </router.options.InnerWrap>\n ) : (\n <Matches />\n )\n\n const routerContext = getRouterContext()\n\n const provider = (\n <React.Suspense fallback={null}>\n <routerContext.Provider value={router}>\n {matches}\n <Transitioner />\n </routerContext.Provider>\n </React.Suspense>\n )\n\n if (router.options.Wrap) {\n return <router.options.Wrap>{provider}</router.options.Wrap>\n }\n\n return provider\n}\n\nfunction Transitioner() {\n const router = useRouter()\n const mountLoadForRouter = React.useRef({ router, mounted: false })\n const routerState = useRouterState({\n select: (s) =>\n pick(s, ['isLoading', 'location', 'resolvedLocation', 'isTransitioning']),\n })\n\n const [isTransitioning, startReactTransition] = useTransition()\n\n router.startReactTransition = startReactTransition\n\n React.useEffect(() => {\n if (isTransitioning) {\n router.__store.setState((s) => ({\n ...s,\n isTransitioning,\n }))\n }\n }, [isTransitioning, router])\n\n const tryLoad = () => {\n const apply = (cb: () => void) => {\n if (!routerState.isTransitioning) {\n startReactTransition(() => cb())\n } else {\n cb()\n }\n }\n\n apply(() => {\n try {\n router.load()\n } catch (err) {\n console.error(err)\n }\n })\n }\n\n useLayoutEffect(() => {\n const unsub = router.history.subscribe(() => {\n router.latestLocation = router.parseLocation(router.latestLocation)\n if (router.state.location !== router.latestLocation) {\n tryLoad()\n }\n })\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n })\n\n if (routerState.location.href !== nextLocation.href) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n return () => {\n unsub()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [router, router.history])\n\n useLayoutEffect(() => {\n if (\n (React.useTransition as any)\n ? routerState.isTransitioning && !isTransitioning\n : !routerState.isLoading &&\n routerState.resolvedLocation !== routerState.location\n ) {\n router.emit({\n type: 'onResolved',\n fromLocation: routerState.resolvedLocation,\n toLocation: routerState.location,\n pathChanged:\n routerState.location.href !== routerState.resolvedLocation.href,\n })\n\n if ((document as any).querySelector) {\n if (routerState.location.hash !== '') {\n const el = document.getElementById(routerState.location.hash)\n if (el) {\n el.scrollIntoView()\n }\n }\n }\n\n router.__store.setState((s) => ({\n ...s,\n isTransitioning: false,\n resolvedLocation: s.location,\n }))\n }\n }, [\n routerState.isTransitioning,\n isTransitioning,\n routerState.isLoading,\n routerState.resolvedLocation,\n routerState.location,\n router,\n ])\n\n useLayoutEffect(() => {\n if (\n window.__TSR_DEHYDRATED__ ||\n (mountLoadForRouter.current.router === router &&\n mountLoadForRouter.current.mounted)\n ) {\n return\n }\n mountLoadForRouter.current = { router, mounted: true }\n tryLoad()\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [router])\n\n return null\n}\n\nexport function getRouteMatch<TRouteTree extends AnyRoute>(\n state: RouterState<TRouteTree>,\n id: string,\n): undefined | RouteMatch<TRouteTree> {\n return [\n ...state.cachedMatches,\n ...(state.pendingMatches ?? []),\n ...state.matches,\n ].find((d) => d.id === id)\n}\n\nexport type RouterProps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & {\n router: Router<TRouteTree>\n context?: Partial<RouterOptions<TRouteTree, TDehydrated>['context']>\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM;AAAA;AAAA,EAEJ,MAAM,kBACL,MAAM;AAAA,IACL;AAAA,IACA,CAAC,OAAO;AACH;IACL;AAAA,EAAA;AAAA;AAuCG,SAAS,eAGd,EAAE,QAAQ,GAAG,QAA8C;AAE3D,SAAO,OAAO;AAAA,IACZ,GAAG,OAAO;AAAA,IACV,GAAG;AAAA,IACH,SAAS;AAAA,MACP,GAAG,OAAO,QAAQ;AAAA,MAClB,GAAG,KAAK;AAAA,IACV;AAAA,EAAA,CACM;AAER,QAAM,UAAU,OAAO,QAAQ,gCAC5B,OAAO,QAAQ,WAAf,EACC,UAAC,oBAAA,SAAA,EAAQ,EACX,CAAA,wBAEC,SAAQ,CAAA,CAAA;AAGX,QAAM,gBAAgB;AAEtB,QAAM,WACJ,oBAAC,MAAM,UAAN,EAAe,UAAU,MAC1B,UAAA,qBAAC,cAAc,UAAd,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AG,MAAM;AAAA,IACT,GAAI,MAAM,kBAAkB,CAAC;AAAA,IAC7B,GAAG,MAAM;AAAA,EAAA,EACT,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE;AAC3B;"}
|
package/dist/esm/fileRoute.d.ts
CHANGED
|
@@ -39,12 +39,12 @@ export declare function createFileRoute<TFilePath extends keyof FileRoutesByPath
|
|
|
39
39
|
meta?: ((ctx: {
|
|
40
40
|
params: TAllParams;
|
|
41
41
|
loaderData: TLoaderData;
|
|
42
|
-
}) => import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]
|
|
42
|
+
}) => import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]) | undefined;
|
|
43
43
|
links?: (() => import("react").DetailedHTMLProps<import("react").LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>[]) | undefined;
|
|
44
44
|
scripts?: (() => import("react").DetailedHTMLProps<import("react").ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>[]) | undefined;
|
|
45
45
|
headers?: ((ctx: {
|
|
46
46
|
loaderData: TLoaderData;
|
|
47
|
-
}) => Record<string, string>
|
|
47
|
+
}) => Record<string, string>) | undefined;
|
|
48
48
|
} & {
|
|
49
49
|
staticData?: import("./route").StaticDataRouteOption | undefined;
|
|
50
50
|
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren>;
|
|
@@ -80,12 +80,12 @@ export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParent
|
|
|
80
80
|
meta?: ((ctx: {
|
|
81
81
|
params: TAllParams;
|
|
82
82
|
loaderData: TLoaderData;
|
|
83
|
-
}) => import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]
|
|
83
|
+
}) => import("react").DetailedHTMLProps<import("react").MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>[]) | undefined;
|
|
84
84
|
links?: (() => import("react").DetailedHTMLProps<import("react").LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>[]) | undefined;
|
|
85
85
|
scripts?: (() => import("react").DetailedHTMLProps<import("react").ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>[]) | undefined;
|
|
86
86
|
headers?: ((ctx: {
|
|
87
87
|
loaderData: TLoaderData;
|
|
88
|
-
}) => Record<string, string>
|
|
88
|
+
}) => Record<string, string>) | undefined;
|
|
89
89
|
} & {
|
|
90
90
|
staticData?: import("./route").StaticDataRouteOption | undefined;
|
|
91
91
|
}) | undefined) => Route<TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchSchemaInput, TSearchSchema, TSearchSchemaUsed, TFullSearchSchemaInput, TFullSearchSchema, TParams, TAllParams, TRouteContextReturn, TRouteContext, TAllContext, TRouterContext, TLoaderDeps, TLoaderDataReturn, TLoaderData, TChildren>;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './history.js';
|
|
|
9
9
|
export { lazyRouteComponent } from './lazyRouteComponent.js';
|
|
10
10
|
export { useLinkProps, createLink, Link, type CleanPath, type Split, type ParsePathParams, type Join, type Last, type RemoveTrailingSlashes, type RemoveLeadingSlashes, type SearchPaths, type SearchRelativePathAutoComplete, type RelativeToParentPathAutoComplete, type RelativeToCurrentPathAutoComplete, type AbsolutePathAutoComplete, type RelativeToPathAutoComplete, type NavigateOptions, type ToOptions, type ToMaskOptions, type ToSubOptions, type ResolveRoute, type ParamOptions, type SearchParamOptions, type PathParamOptions, type ToPathOption, type ActiveOptions, type LinkOptions, type CheckPath, type ResolveRelativePath, type UseLinkPropsOptions, type ActiveLinkOptions, type LinkProps, type LinkComponent, } from './link.js';
|
|
11
11
|
export { type ParsedLocation } from './location.js';
|
|
12
|
-
export { matchContext, Matches, Match, Outlet, useMatchRoute, MatchRoute, useMatch, useMatches, useParentMatches, useChildMatches, useLoaderDeps, useLoaderData, isServerSideError, defaultDeserializeError,
|
|
12
|
+
export { matchContext, Matches, Match, Outlet, useMatchRoute, MatchRoute, useMatch, useMatches, useParentMatches, useChildMatches, useLoaderDeps, useLoaderData, isServerSideError, defaultDeserializeError, type RouteMatch, type AnyRouteMatch, type MatchRouteOptions, type UseMatchRouteOptions, type MakeMatchRouteOptions, } from './Matches.js';
|
|
13
13
|
export { joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, removeBasepath, matchByPath, type Segment, } from './path.js';
|
|
14
14
|
export { encode, decode } from './qss.js';
|
|
15
15
|
export { redirect, isRedirect, type AnyRedirect, type Redirect, type ResolvedRedirect, } from './redirects.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
|
7
7
|
import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileRoute, createLazyRoute } from "./fileRoute.js";
|
|
8
8
|
import { lazyRouteComponent } from "./lazyRouteComponent.js";
|
|
9
9
|
import { Link, createLink, useLinkProps } from "./link.js";
|
|
10
|
-
import { Match, MatchRoute, Matches, Outlet, defaultDeserializeError,
|
|
10
|
+
import { Match, MatchRoute, Matches, Outlet, defaultDeserializeError, isServerSideError, matchContext, useChildMatches, useLoaderData, useLoaderDeps, useMatch, useMatchRoute, useMatches, useParentMatches } from "./Matches.js";
|
|
11
11
|
import { cleanPath, interpolatePath, joinPaths, matchByPath, matchPathname, parsePathname, removeBasepath, resolvePath, trimPath, trimPathLeft, trimPathRight } from "./path.js";
|
|
12
12
|
import { decode, encode } from "./qss.js";
|
|
13
13
|
import { isRedirect, redirect } from "./redirects.js";
|
|
@@ -77,7 +77,6 @@ export {
|
|
|
77
77
|
escapeJSON,
|
|
78
78
|
functionalUpdate,
|
|
79
79
|
getInitialRouterState,
|
|
80
|
-
getRenderedMatches,
|
|
81
80
|
getRouteApi,
|
|
82
81
|
getRouteMatch,
|
|
83
82
|
getRouterContext,
|
package/dist/esm/link.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import type { ParsedLocation } from '.';
|
|
2
3
|
import type { HistoryState } from '@tanstack/history';
|
|
3
4
|
import type { Trim } from './fileRoute.js';
|
|
4
5
|
import type { AnyRoute, RootSearchSchema } from './route.js';
|
|
@@ -30,6 +31,7 @@ export type NavigateOptions<TRouteTree extends AnyRoute = RegisteredRouter['rout
|
|
|
30
31
|
startTransition?: boolean;
|
|
31
32
|
};
|
|
32
33
|
export type ToOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TFrom, TTo> & {
|
|
34
|
+
_fromLocation?: ParsedLocation;
|
|
33
35
|
mask?: ToMaskOptions<TRouteTree, TMaskFrom, TMaskTo>;
|
|
34
36
|
};
|
|
35
37
|
export type ToMaskOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TMaskFrom extends RoutePaths<TRouteTree> | string = string, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {
|