Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
eb6ea067
Unverified
Commit
eb6ea067
authored
Jan 07, 2025
by
Jiachi Liu
Committed by
GitHub
Jan 07, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[metadata] Change the array head to single node in flight data (#74299)
parent
15bb8ce5
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
77 additions
and
124 deletions
+77
-124
app-router.tsx
packages/next/src/client/components/app-router.tsx
+1
-1
layout-router.tsx
packages/next/src/client/components/layout-router.tsx
+1
-1
aliased-prefetch-navigations.ts
...components/router-reducer/aliased-prefetch-navigations.ts
+2
-2
clear-cache-node-data-for-segment-path.test.tsx
...r-reducer/clear-cache-node-data-for-segment-path.test.tsx
+8
-20
clear-cache-node-data-for-segment-path.ts
.../router-reducer/clear-cache-node-data-for-segment-path.ts
+2
-2
create-initial-router-state.test.tsx
...nents/router-reducer/create-initial-router-state.test.tsx
+5
-9
create-initial-router-state.ts
.../components/router-reducer/create-initial-router-state.ts
+1
-1
fill-cache-with-new-subtree-data.test.tsx
.../router-reducer/fill-cache-with-new-subtree-data.test.tsx
+10
-15
fill-cache-with-new-subtree-data.ts
...onents/router-reducer/fill-cache-with-new-subtree-data.ts
+1
-1
fill-lazy-items-till-leaf-with-head.test.tsx
...uter-reducer/fill-lazy-items-till-leaf-with-head.test.tsx
+9
-14
fill-lazy-items-till-leaf-with-head.ts
...nts/router-reducer/fill-lazy-items-till-leaf-with-head.ts
+6
-9
invalidate-cache-below-flight-segmentpath.test.tsx
...educer/invalidate-cache-below-flight-segmentpath.test.tsx
+8
-8
invalidate-cache-by-router-state.test.tsx
.../router-reducer/invalidate-cache-by-router-state.test.tsx
+5
-5
ppr-navigations.ts
...t/src/client/components/router-reducer/ppr-navigations.ts
+4
-14
find-head-in-cache.test.tsx
...nents/router-reducer/reducers/find-head-in-cache.test.tsx
+5
-16
cache.ts
packages/next/src/client/components/segment-cache/cache.ts
+1
-1
flight-data-helpers.ts
packages/next/src/client/flight-data-helpers.ts
+1
-1
types.ts
packages/next/src/server/app-render/types.ts
+5
-2
app-router-context.shared-runtime.ts
.../next/src/shared/lib/app-router-context.shared-runtime.ts
+2
-2
No files found.
packages/next/src/client/components/app-router.tsx
View file @
eb6ea067
...
...
@@ -145,7 +145,7 @@ export function createEmptyCacheNode(): CacheNode {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
packages/next/src/client/components/layout-router.tsx
View file @
eb6ea067
...
...
@@ -549,7 +549,7 @@ export default function OuterLayoutRouter({
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
packages/next/src/client/components/router-reducer/aliased-prefetch-navigations.ts
View file @
eb6ea067
...
...
@@ -172,7 +172,7 @@ function fillNewTreeWithOnlyLoadingSegments(
// copy the layout but null the page segment as that's not meant to be used
rsc
:
segmentForParallelRoute
.
includes
(
PAGE_SEGMENT_KEY
)
?
null
:
rsc
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
,
...
...
@@ -184,7 +184,7 @@ function fillNewTreeWithOnlyLoadingSegments(
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
packages/next/src/client/components/router-reducer/clear-cache-node-data-for-segment-path.test.tsx
View file @
eb6ea067
...
...
@@ -16,7 +16,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
@@ -25,7 +25,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData
:
null
,
rsc
:
<>
Root layout
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -38,7 +38,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData
:
null
,
rsc
:
<>
Linking
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -51,7 +51,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
lazyData
:
null
,
rsc
:
<>
Page
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
@@ -71,28 +71,19 @@ describe('clearCacheNodeDataForSegmentPath', () => {
expect
(
cache
).
toMatchInlineSnapshot
(
`
{
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {
"children" => Map {
"" => {
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {},
...
...
@@ -111,10 +102,7 @@ describe('clearCacheNodeDataForSegmentPath', () => {
</React.Fragment>,
},
"dashboard" => {
"head": [
null,
null,
],
"head": null,
"lazyData": null,
"loading": null,
"parallelRoutes": Map {},
...
...
packages/next/src/client/components/router-reducer/clear-cache-node-data-for-segment-path.ts
View file @
eb6ea067
...
...
@@ -40,7 +40,7 @@ export function clearCacheNodeDataForSegmentPath(
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
@@ -56,7 +56,7 @@ export function clearCacheNodeDataForSegmentPath(
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
packages/next/src/client/components/router-reducer/create-initial-router-state.test.tsx
View file @
eb6ea067
...
...
@@ -32,9 +32,7 @@ describe('createInitialRouterState', () => {
const
initialParallelRoutes
:
CacheNode
[
'parallelRoutes'
]
=
new
Map
()
const
state
=
createInitialRouterState
({
initialFlightData
:
[
[
initialTree
,
[
''
,
children
,
{},
null
],
<
title
>
Test
</
title
>],
],
initialFlightData
:
[[
initialTree
,
[
''
,
children
,
{},
null
]]],
initialCanonicalUrlParts
:
initialCanonicalUrl
.
split
(
'/'
),
initialParallelRoutes
,
location
:
new
URL
(
'/linking'
,
'https://localhost'
)
as
any
,
...
...
@@ -44,9 +42,7 @@ describe('createInitialRouterState', () => {
})
const
state2
=
createInitialRouterState
({
initialFlightData
:
[
[
initialTree
,
[
''
,
children
,
{},
null
],
<
title
>
Test
</
title
>],
],
initialFlightData
:
[[
initialTree
,
[
''
,
children
,
{},
null
]]],
initialCanonicalUrlParts
:
initialCanonicalUrl
.
split
(
'/'
),
initialParallelRoutes
,
location
:
new
URL
(
'/linking'
,
'https://localhost'
)
as
any
,
...
...
@@ -59,7 +55,7 @@ describe('createInitialRouterState', () => {
lazyData
:
null
,
rsc
:
children
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -81,7 +77,7 @@ describe('createInitialRouterState', () => {
prefetchRsc
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
head
:
[
null
,
<
title
>
Test
</
title
>]
,
head
:
null
,
prefetchHead
:
null
,
},
],
...
...
@@ -91,7 +87,7 @@ describe('createInitialRouterState', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
},
...
...
packages/next/src/client/components/router-reducer/create-initial-router-state.ts
View file @
eb6ea067
...
...
@@ -48,7 +48,7 @@ export function createInitialRouterState({
lazyData
:
null
,
rsc
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
// The cache gets seeded during the first render. `initialParallelRoutes` ensures the cache from the first render is there during the second render.
parallelRoutes
:
isServer
?
new
Map
()
:
initialParallelRoutes
,
...
...
packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.test.tsx
View file @
eb6ea067
...
...
@@ -10,7 +10,7 @@ const getFlightData = (): NormalizedFlightData[] => {
segment
:
'about'
,
tree
:
[
'about'
,
{
children
:
[
''
,
{}]
}],
seedData
:
[
'about'
,
<
h1
>
SubTreeData Injected!
</
h1
>,
{},
null
,
false
],
head
:
[
null
,
'<title>Head Injected!</title>'
]
,
head
:
null
,
isHeadPartial
:
false
,
isRootRender
:
false
,
},
...
...
@@ -23,7 +23,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -32,7 +32,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData
:
null
,
rsc
:
<>
Root layout
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -45,7 +45,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData
:
null
,
rsc
:
<>
Linking
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -58,7 +58,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData
:
null
,
rsc
:
<>
Page
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -89,7 +89,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -102,7 +102,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData
:
null
,
rsc
:
<>
Linking
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -116,7 +116,7 @@ describe('fillCacheWithNewSubtreeData', () => {
lazyData
:
null
,
rsc
:
<>
Page
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -126,7 +126,7 @@ describe('fillCacheWithNewSubtreeData', () => {
'about'
,
{
lazyData
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -142,12 +142,7 @@ describe('fillCacheWithNewSubtreeData', () => {
parallelRoutes
:
new
Map
(),
prefetchHead
:
null
,
loading
:
null
,
head
:
[
null
,
<>
<
title
>
Head Injected!
</
title
>
</>,
],
head
:
null
,
},
],
]),
...
...
packages/next/src/client/components/router-reducer/fill-cache-with-new-subtree-data.ts
View file @
eb6ea067
...
...
@@ -71,7 +71,7 @@ function fillCacheHelper(
rsc
:
fillLazyItems
||
incomingSegment
!==
PAGE_SEGMENT_KEY
?
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
,
parallelRoutes
:
...
...
packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.test.tsx
View file @
eb6ea067
...
...
@@ -39,7 +39,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
@@ -48,7 +48,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData
:
null
,
rsc
:
<>
Root layout
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -61,7 +61,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData
:
null
,
rsc
:
<>
Linking
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -74,7 +74,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData
:
null
,
rsc
:
<>
Page
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -114,7 +114,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -127,7 +127,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -152,12 +152,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
head
:
[
null
,
<>
<
title
>
About page!
</
title
>
</>,
],
head
:
null
,
},
],
]),
...
...
@@ -165,7 +160,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
]),
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
},
],
...
...
@@ -175,7 +170,7 @@ describe('fillLazyItemsTillLeafWithHead', () => {
lazyData
:
null
,
rsc
:
<>
Page
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
packages/next/src/client/components/router-reducer/fill-lazy-items-till-leaf-with-head.ts
View file @
eb6ea067
import
type
{
CacheNode
,
HeadData
,
}
from
'../../../shared/lib/app-router-context.shared-runtime'
import
type
{
CacheNode
}
from
'../../../shared/lib/app-router-context.shared-runtime'
import
type
{
FlightRouterState
,
CacheNodeSeedData
,
...
...
@@ -17,7 +14,7 @@ export function fillLazyItemsTillLeafWithHead(
existingCache
:
CacheNode
|
undefined
,
routerState
:
FlightRouterState
,
cacheNodeSeedData
:
CacheNodeSeedData
|
null
,
head
:
HeadData
,
head
:
React
.
ReactNode
,
prefetchEntry
:
PrefetchCacheEntry
|
undefined
):
void
{
const
isLastSegment
=
Object
.
keys
(
routerState
[
1
]).
length
===
0
...
...
@@ -69,7 +66,7 @@ export function fillLazyItemsTillLeafWithHead(
// `prefetchRsc`. As an incremental step, we'll just de-opt to the
// old behavior — no PPR value.
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
,
parallelRoutes
:
new
Map
(
existingCacheNode
?.
parallelRoutes
),
...
...
@@ -96,7 +93,7 @@ export function fillLazyItemsTillLeafWithHead(
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(
existingCacheNode
?.
parallelRoutes
),
loading
:
null
,
...
...
@@ -129,7 +126,7 @@ export function fillLazyItemsTillLeafWithHead(
lazyData
:
null
,
rsc
:
seedNode
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
,
...
...
@@ -141,7 +138,7 @@ export function fillLazyItemsTillLeafWithHead(
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
parallelRoutes
:
new
Map
(),
loading
:
null
,
...
...
packages/next/src/client/components/router-reducer/invalidate-cache-below-flight-segmentpath.test.tsx
View file @
eb6ea067
...
...
@@ -12,7 +12,7 @@ const getFlightData = (): NormalizedFlightData[] => {
segment
:
'about'
,
tree
:
[
'about'
,
{
children
:
[
''
,
{}]
}],
seedData
:
[
'about'
,
<
h1
>
About Page!
</
h1
>,
{},
null
,
false
],
head
:
[
null
,
'<title>About page!</title>'
]
,
head
:
null
,
isHeadPartial
:
false
,
isRootRender
:
false
,
},
...
...
@@ -25,7 +25,7 @@ describe('invalidateCacheBelowFlightSegmentPath', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -34,7 +34,7 @@ describe('invalidateCacheBelowFlightSegmentPath', () => {
lazyData
:
null
,
rsc
:
<>
Root layout
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -47,7 +47,7 @@ describe('invalidateCacheBelowFlightSegmentPath', () => {
lazyData
:
null
,
rsc
:
<>
Linking
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -60,7 +60,7 @@ describe('invalidateCacheBelowFlightSegmentPath', () => {
lazyData
:
null
,
rsc
:
<>
Page
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -100,7 +100,7 @@ describe('invalidateCacheBelowFlightSegmentPath', () => {
const
expectedCache
:
CacheNode
=
{
lazyData
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -111,7 +111,7 @@ describe('invalidateCacheBelowFlightSegmentPath', () => {
'linking'
,
{
lazyData
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -126,7 +126,7 @@ describe('invalidateCacheBelowFlightSegmentPath', () => {
parallelRoutes
:
new
Map
(),
rsc
:
<
React
.
Fragment
>
Page
</
React
.
Fragment
>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
},
],
...
...
packages/next/src/client/components/router-reducer/invalidate-cache-by-router-state.test.tsx
View file @
eb6ea067
...
...
@@ -8,7 +8,7 @@ describe('invalidateCacheByRouterState', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -17,7 +17,7 @@ describe('invalidateCacheByRouterState', () => {
lazyData
:
null
,
rsc
:
<>
Root layout
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -30,7 +30,7 @@ describe('invalidateCacheByRouterState', () => {
lazyData
:
null
,
rsc
:
<>
Linking
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -43,7 +43,7 @@ describe('invalidateCacheByRouterState', () => {
lazyData
:
null
,
rsc
:
<>
Page
</>,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
...
...
@@ -85,7 +85,7 @@ describe('invalidateCacheByRouterState', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([[
'children'
,
new
Map
()]]),
...
...
packages/next/src/client/components/router-reducer/ppr-navigations.ts
View file @
eb6ea067
...
...
@@ -387,10 +387,7 @@ function createCacheNodeOnNavigation(
// `prefetchRsc` field.
rsc
,
prefetchRsc
:
null
,
head
:
(
isLeafSegment
?
possiblyPartialPrefetchHead
:
null
)
??
[
null
,
null
,
],
head
:
isLeafSegment
?
possiblyPartialPrefetchHead
:
null
,
prefetchHead
:
null
,
loading
,
parallelRoutes
:
cacheNodeChildren
,
...
...
@@ -698,14 +695,7 @@ function createPendingCacheNode(
// Create a deferred promise. This will be fulfilled once the dynamic
// response is received from the server.
rsc
:
createDeferredRsc
()
as
React
.
ReactNode
,
head
:
isLeafSegment
?
[
// TODO: change head back to ReactNode when metadata
// is stably rendered in body
createDeferredRsc
()
as
React
.
ReactNode
,
null
,
]
:
[
null
,
null
],
head
:
isLeafSegment
?
(
createDeferredRsc
()
as
React
.
ReactNode
)
:
null
,
}
}
...
...
@@ -810,8 +800,8 @@ function finishPendingCacheNode(
// TODO: change head back to ReactNode when metadata
// is stably rendered in body
// Handle head[0] - viewport
if
(
isDeferredRsc
(
head
[
0
]
))
{
head
[
0
].
resolve
(
dynamicHead
[
0
]
)
if
(
isDeferredRsc
(
head
))
{
head
.
resolve
(
dynamicHead
)
}
}
...
...
packages/next/src/client/components/router-reducer/reducers/find-head-in-cache.test.tsx
View file @
eb6ea067
import
React
from
'react'
import
type
{
FlightRouterState
}
from
'../../../../server/app-render/types'
import
type
{
CacheNode
}
from
'../../../../shared/lib/app-router-context.shared-runtime'
import
{
findHeadInCache
}
from
'./find-head-in-cache'
...
...
@@ -29,7 +28,7 @@ describe('findHeadInCache', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -42,7 +41,7 @@ describe('findHeadInCache', () => {
lazyData
:
null
,
rsc
:
null
,
prefetchRsc
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -53,7 +52,7 @@ describe('findHeadInCache', () => {
'about'
,
{
lazyData
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
([
...
...
@@ -69,12 +68,7 @@ describe('findHeadInCache', () => {
prefetchHead
:
null
,
loading
:
null
,
parallelRoutes
:
new
Map
(),
head
:
[
null
,
<>
<
title
>
About page!
</
title
>
</>,
],
head
:
null
,
},
],
]),
...
...
@@ -108,12 +102,7 @@ describe('findHeadInCache', () => {
expect
(
result
).
not
.
toBeNull
()
const
[
cacheNode
,
key
]
=
result
!
expect
(
cacheNode
.
head
[
0
]).
toBe
(
null
)
expect
(
cacheNode
.
head
[
1
]).
toMatchObject
(
<>
<
title
>
About page!
</
title
>
</>
)
expect
(
cacheNode
.
head
).
toBe
(
null
)
expect
(
key
).
toBe
(
'/linking/about/'
)
})
})
packages/next/src/client/components/segment-cache/cache.ts
View file @
eb6ea067
...
...
@@ -313,7 +313,7 @@ export function readOrCreateRouteCacheEntry(
status
:
EntryStatus
.
Empty
,
blockedTasks
:
null
,
tree
:
null
,
head
:
[
null
,
null
]
,
head
:
null
,
isHeadPartial
:
true
,
// Since this is an empty entry, there's no reason to ever evict it. It will
// be updated when the data is populated.
...
...
packages/next/src/client/flight-data-helpers.ts
View file @
eb6ea067
...
...
@@ -32,7 +32,7 @@ export type NormalizedFlightData = {
export
function
getFlightDataPartsFromPath
(
flightDataPath
:
FlightDataPath
):
NormalizedFlightData
{
// Pick the last 4 items from the `FlightDataPath` to get the [tree, seedData,
[viewport, metadata]
, isHeadPartial].
// Pick the last 4 items from the `FlightDataPath` to get the [tree, seedData,
viewport
, isHeadPartial].
const
flightDataPathLength
=
4
// tree, seedData, and head are *always* the last three items in the `FlightDataPath`.
const
[
tree
,
seedData
,
head
,
isHeadPartial
]
=
...
...
packages/next/src/server/app-render/types.ts
View file @
eb6ea067
...
...
@@ -6,7 +6,10 @@ import type { NextFontManifest } from '../../build/webpack/plugins/next-font-man
import
type
{
ParsedUrlQuery
}
from
'querystring'
import
type
{
AppPageModule
}
from
'../route-modules/app-page/module'
import
type
{
ExpireTime
}
from
'../lib/revalidate'
import
type
{
LoadingModuleData
}
from
'../../shared/lib/app-router-context.shared-runtime'
import
type
{
HeadData
,
LoadingModuleData
,
}
from
'../../shared/lib/app-router-context.shared-runtime'
import
type
{
DeepReadonly
}
from
'../../shared/lib/deep-readonly'
import
type
{
__ApiPreviewProps
}
from
'../api-utils'
...
...
@@ -131,7 +134,7 @@ export type FlightDataSegment = [
/* segment of the rendered slice: */
Segment
,
/* treePatch */
FlightRouterState
,
/* cacheNodeSeedData */
CacheNodeSeedData
|
null
,
// Can be null during prefetch if there's no loading component
/* head:
[viewport, metadata] */
[
React
.
ReactNode
,
React
.
ReactNode
]
,
/* head:
viewport */
HeadData
,
/* isHeadPartial */
boolean
,
]
...
...
packages/next/src/shared/lib/app-router-context.shared-runtime.ts
View file @
eb6ea067
...
...
@@ -23,8 +23,8 @@ export type LoadingModuleData =
|
[
React
.
JSX
.
Element
,
React
.
ReactNode
,
React
.
ReactNode
]
|
null
/**
metadata cache nodes: [viewport, metadata]
*/
export
type
HeadData
=
[
React
.
ReactNode
,
React
.
ReactNode
]
/**
viewport metadata node
*/
export
type
HeadData
=
React
.
ReactNode
export
type
LazyCacheNode
=
{
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment