@tanstack/react-router 1.81.14 → 1.82.1
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.map +1 -1
- package/dist/cjs/Matches.d.cts +3 -3
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +11 -9
- package/dist/cjs/router.cjs +17 -12
- package/dist/cjs/router.cjs.map +1 -1
- package/dist/esm/Matches.d.ts +3 -3
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/route.d.ts +11 -9
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +17 -12
- package/dist/esm/router.js.map +1 -1
- package/package.json +1 -1
- package/src/Matches.tsx +3 -3
- package/src/route.ts +11 -8
- package/src/router.ts +17 -11
package/package.json
CHANGED
package/src/Matches.tsx
CHANGED
|
@@ -170,9 +170,9 @@ export interface RouteMatch<
|
|
|
170
170
|
loaderDeps: TLoaderDeps
|
|
171
171
|
preload: boolean
|
|
172
172
|
invalid: boolean
|
|
173
|
-
meta?: Array<React.JSX.IntrinsicElements['meta']>
|
|
174
|
-
links?: Array<React.JSX.IntrinsicElements['link']>
|
|
175
|
-
scripts?: Array<React.JSX.IntrinsicElements['script']>
|
|
173
|
+
meta?: Array<React.JSX.IntrinsicElements['meta'] | undefined>
|
|
174
|
+
links?: Array<React.JSX.IntrinsicElements['link'] | undefined>
|
|
175
|
+
scripts?: Array<React.JSX.IntrinsicElements['script'] | undefined>
|
|
176
176
|
headers?: Record<string, string>
|
|
177
177
|
globalNotFound?: boolean
|
|
178
178
|
staticData: StaticDataRouteOption
|
package/src/route.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type * as React from 'react'
|
|
|
17
17
|
import type { RootRouteId } from './root'
|
|
18
18
|
import type { UseNavigateResult } from './useNavigate'
|
|
19
19
|
import type {
|
|
20
|
+
AnyRouteMatch,
|
|
20
21
|
MakeRouteMatchFromRoute,
|
|
21
22
|
MakeRouteMatchUnion,
|
|
22
23
|
RouteMatch,
|
|
@@ -434,7 +435,10 @@ export interface UpdatableRouteOptions<
|
|
|
434
435
|
TLoaderDeps
|
|
435
436
|
>,
|
|
436
437
|
) => void
|
|
437
|
-
|
|
438
|
+
headers?: (ctx: {
|
|
439
|
+
loaderData: ResolveLoaderData<TLoaderFn>
|
|
440
|
+
}) => Record<string, string>
|
|
441
|
+
head?: (ctx: {
|
|
438
442
|
matches: Array<
|
|
439
443
|
RouteMatch<
|
|
440
444
|
TRouteId,
|
|
@@ -466,13 +470,12 @@ export interface UpdatableRouteOptions<
|
|
|
466
470
|
TLoaderDeps
|
|
467
471
|
>
|
|
468
472
|
params: ResolveAllParamsFromParent<TParentRoute, TParams>
|
|
469
|
-
loaderData: ResolveLoaderData<TLoaderFn>
|
|
470
|
-
}) =>
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}) => Record<string, string>
|
|
473
|
+
loaderData: ResolveLoaderData<TLoaderFn> | undefined
|
|
474
|
+
}) => {
|
|
475
|
+
links?: AnyRouteMatch['links']
|
|
476
|
+
scripts?: AnyRouteMatch['scripts']
|
|
477
|
+
meta?: AnyRouteMatch['meta']
|
|
478
|
+
}
|
|
476
479
|
ssr?: boolean
|
|
477
480
|
}
|
|
478
481
|
|
package/src/router.ts
CHANGED
|
@@ -1298,25 +1298,30 @@ export class Router<
|
|
|
1298
1298
|
: loaderDeps,
|
|
1299
1299
|
invalid: false,
|
|
1300
1300
|
preload: false,
|
|
1301
|
-
links:
|
|
1302
|
-
scripts:
|
|
1301
|
+
links: undefined,
|
|
1302
|
+
scripts: undefined,
|
|
1303
|
+
meta: undefined,
|
|
1303
1304
|
staticData: route.options.staticData || {},
|
|
1304
1305
|
loadPromise: createControlledPromise(),
|
|
1305
1306
|
fullPath: route.fullPath,
|
|
1306
1307
|
}
|
|
1307
1308
|
}
|
|
1308
1309
|
|
|
1309
|
-
|
|
1310
|
+
const headFnContent = route.options.head?.({
|
|
1311
|
+
matches,
|
|
1312
|
+
match,
|
|
1313
|
+
params: match.params,
|
|
1314
|
+
loaderData: match.loaderData ?? undefined,
|
|
1315
|
+
})
|
|
1316
|
+
|
|
1317
|
+
match.links = headFnContent?.links
|
|
1318
|
+
match.scripts = headFnContent?.scripts
|
|
1319
|
+
match.meta = headFnContent?.meta
|
|
1320
|
+
|
|
1321
|
+
// If it's already a success, update the headers
|
|
1310
1322
|
// These may get updated again if the match is refreshed
|
|
1311
1323
|
// due to being stale
|
|
1312
1324
|
if (match.status === 'success') {
|
|
1313
|
-
match.meta = route.options.meta?.({
|
|
1314
|
-
matches,
|
|
1315
|
-
match,
|
|
1316
|
-
params: match.params,
|
|
1317
|
-
loaderData: match.loaderData,
|
|
1318
|
-
})
|
|
1319
|
-
|
|
1320
1325
|
match.headers = route.options.headers?.({
|
|
1321
1326
|
loaderData: match.loaderData,
|
|
1322
1327
|
})
|
|
@@ -2516,12 +2521,13 @@ export class Router<
|
|
|
2516
2521
|
|
|
2517
2522
|
await potentialPendingMinPromise()
|
|
2518
2523
|
|
|
2519
|
-
const
|
|
2524
|
+
const headFnContent = route.options.head?.({
|
|
2520
2525
|
matches,
|
|
2521
2526
|
match: this.getMatch(matchId)!,
|
|
2522
2527
|
params: this.getMatch(matchId)!.params,
|
|
2523
2528
|
loaderData,
|
|
2524
2529
|
})
|
|
2530
|
+
const meta = headFnContent?.meta
|
|
2525
2531
|
|
|
2526
2532
|
const headers = route.options.headers?.({
|
|
2527
2533
|
loaderData,
|