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
06f01e59
Commit
06f01e59
authored
Feb 28, 2024
by
JJ Kasper
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'next-14-1' of github.com:vercel/next.js into next-14-1
parents
c1edac79
6aee03de
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
158 additions
and
13 deletions
+158
-13
app-router.tsx
packages/next/src/client/components/app-router.tsx
+1
-1
layout-router.tsx
packages/next/src/client/components/layout-router.tsx
+14
-8
navigate-reducer.test.tsx
...ponents/router-reducer/reducers/navigate-reducer.test.tsx
+5
-0
server-patch-reducer.test.tsx
...nts/router-reducer/reducers/server-patch-reducer.test.tsx
+2
-0
app-router-context.shared-runtime.ts
.../next/src/shared/lib/app-router-context.shared-runtime.ts
+10
-0
action-queue.ts
packages/next/src/shared/lib/router/action-queue.ts
+2
-2
page.js
...p/nested-folder/(foo)/product-category/[...slugs]/page.js
+1
-1
loading.js
...r/navigation/app/metadata-await-promise/nested/loading.js
+3
-0
page.js
...-dir/navigation/app/metadata-await-promise/nested/page.js
+18
-0
page.js
...e2e/app-dir/navigation/app/metadata-await-promise/page.js
+9
-0
action.ts
.../app-dir/navigation/app/popstate-revalidate/foo/action.ts
+8
-0
page.tsx
...e/app-dir/navigation/app/popstate-revalidate/foo/page.tsx
+20
-0
page.tsx
test/e2e/app-dir/navigation/app/popstate-revalidate/page.tsx
+12
-0
navigation.test.ts
test/e2e/app-dir/navigation/navigation.test.ts
+53
-1
No files found.
packages/next/src/client/components/app-router.tsx
View file @
06f01e59
...
...
@@ -153,6 +153,7 @@ export function createEmptyCacheNode(): CacheNode {
rsc
:
null
,
prefetchRsc
:
null
,
parallelRoutes
:
new
Map
(),
lazyDataResolved
:
false
,
}
}
...
...
@@ -541,7 +542,6 @@ function Router({
return
}
// @ts-ignore useTransition exists
// TODO-APP: Ideally the back button should not use startTransition as it should apply the updates synchronously
// Without startTransition works if the cache is there for this path
startTransition
(()
=>
{
...
...
packages/next/src/client/components/layout-router.tsx
View file @
06f01e59
...
...
@@ -355,6 +355,7 @@ function InnerLayoutRouter({
prefetchRsc
:
null
,
head
:
null
,
parallelRoutes
:
new
Map
(),
lazyDataResolved
:
false
,
}
/**
...
...
@@ -411,6 +412,7 @@ function InnerLayoutRouter({
context
.
nextUrl
,
buildId
)
childNode
.
lazyDataResolved
=
false
}
/**
...
...
@@ -419,15 +421,19 @@ function InnerLayoutRouter({
// When the data has not resolved yet `use` will suspend here.
const
[
flightData
,
overrideCanonicalUrl
]
=
use
(
lazyData
)
// segmentPath from the server does not match the layout's segmentPath
childNode
.
lazyData
=
null
// setTimeout is used to start a new transition during render, this is an intentional hack around React.
setTimeout
(()
=>
{
startTransition
(()
=>
{
changeByServerResponse
(
fullTree
,
flightData
,
overrideCanonicalUrl
)
if
(
!
childNode
.
lazyDataResolved
)
{
// setTimeout is used to start a new transition during render, this is an intentional hack around React.
setTimeout
(()
=>
{
startTransition
(()
=>
{
changeByServerResponse
(
fullTree
,
flightData
,
overrideCanonicalUrl
)
})
})
})
// It's important that we mark this as resolved, in case this branch is replayed, we don't want to continously re-apply
// the patch to the tree.
childNode
.
lazyDataResolved
=
true
}
// Suspend infinitely as `changeByServerResponse` will cause a different part of the tree to be rendered.
use
(
createInfinitePromise
())
as
never
}
...
...
packages/next/src/client/components/router-reducer/reducers/navigate-reducer.test.tsx
View file @
06f01e59
...
...
@@ -183,6 +183,7 @@ describe('navigateReducer', () => {
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
...
...
@@ -377,6 +378,7 @@ describe('navigateReducer', () => {
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
...
...
@@ -1040,6 +1042,7 @@ describe('navigateReducer', () => {
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
...
...
@@ -1278,6 +1281,7 @@ describe('navigateReducer', () => {
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"parallel-tab-bar" => {
...
...
@@ -1637,6 +1641,7 @@ describe('navigateReducer', () => {
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
...
...
packages/next/src/client/components/router-reducer/reducers/server-patch-reducer.test.tsx
View file @
06f01e59
...
...
@@ -166,6 +166,7 @@ describe('serverPatchReducer', () => {
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
...
...
@@ -349,6 +350,7 @@ describe('serverPatchReducer', () => {
"buildId": "development",
"cache": {
"lazyData": null,
"lazyDataResolved": false,
"parallelRoutes": Map {
"children" => Map {
"linking" => {
...
...
packages/next/src/shared/lib/app-router-context.shared-runtime.ts
View file @
06f01e59
...
...
@@ -19,6 +19,11 @@ export type ChildSegmentMap = Map<string, CacheNode>
export
type
CacheNode
=
ReadyCacheNode
|
LazyCacheNode
export
type
LazyCacheNode
=
{
/**
* Whether the lazy cache node data promise has been resolved.
* This value is only true after we've called `use` on the promise (and applied the data to the tree).
*/
lazyDataResolved
?:
boolean
/**
* When rsc is null, this is a lazily-initialized cache node.
*
...
...
@@ -61,6 +66,11 @@ export type LazyCacheNode = {
}
export
type
ReadyCacheNode
=
{
/**
* Whether the lazy cache node data promise has been resolved.
* This value is only true after we've called `use` on the promise (and applied the data to the tree).
*/
lazyDataResolved
?:
boolean
/**
* When rsc is not null, it represents the RSC data for the
* corresponding segment.
...
...
packages/next/src/shared/lib/router/action-queue.ts
View file @
06f01e59
...
...
@@ -140,8 +140,8 @@ function dispatchAction(
const
newAction
:
ActionQueueNode
=
{
payload
,
next
:
null
,
resolve
:
resolvers
!
.
resolve
,
reject
:
resolvers
!
.
reject
,
resolve
:
resolvers
.
resolve
,
reject
:
resolvers
.
reject
,
}
// Check if the queue is empty
...
...
test/e2e/app-dir/actions-navigation/app/nested-folder/(foo)/product-category/[...slugs]/page.js
View file @
06f01e59
...
...
@@ -12,7 +12,7 @@ function SubmitButton() {
)
}
export
default
async
function
Page
()
{
export
default
function
Page
()
{
return
(
<>
<
h1
>
Add
to
cart
<
/h1
>
...
...
test/e2e/app-dir/navigation/app/metadata-await-promise/nested/loading.js
0 → 100644
View file @
06f01e59
export
default
function
Loading
()
{
return
<
div
id
=
"loading"
>
Loading
<
/div
>
}
test/e2e/app-dir/navigation/app/metadata-await-promise/nested/page.js
0 → 100644
View file @
06f01e59
import
React
from
'react'
// ensure this page is dynamically rendered so we always trigger a loading state
export
const
dynamic
=
'force-dynamic'
export
default
function
page
()
{
return
<
div
id
=
"page-content"
>
Content
<
/div
>
}
async
function
getTitle
()
{
return
await
new
Promise
((
resolve
)
=>
setTimeout
(()
=>
resolve
(
'Async Title'
),
1000
)
)
}
export
async
function
generateMetadata
()
{
return
{
title
:
await
getTitle
()
}
}
test/e2e/app-dir/navigation/app/metadata-await-promise/page.js
0 → 100644
View file @
06f01e59
import
Link
from
'next/link'
export
default
function
page
()
{
return
(
<
div
>
<
Link
href
=
"/metadata-await-promise/nested"
>
Link
to
nested
<
/Link
>
<
/div
>
)
}
test/e2e/app-dir/navigation/app/popstate-revalidate/foo/action.ts
0 → 100644
View file @
06f01e59
'use server'
import
{
revalidatePath
}
from
'next/cache'
export
async
function
action
()
{
revalidatePath
(
'/'
,
'layout'
)
return
true
}
test/e2e/app-dir/navigation/app/popstate-revalidate/foo/page.tsx
0 → 100644
View file @
06f01e59
'use client'
import
{
useFormState
}
from
'react-dom'
import
{
action
}
from
'./action'
export
default
function
Page
()
{
const
[
submitted
,
formAction
]
=
useFormState
(
action
,
false
)
if
(
submitted
)
{
return
<
div
>
Form Submitted.
</
div
>
}
return
(
<
div
>
<
h1
>
Form
</
h1
>
<
form
action=
{
formAction
}
>
<
button
id=
"submit-button"
>
Push this button to submit the form
</
button
>
</
form
>
</
div
>
)
}
test/e2e/app-dir/navigation/app/popstate-revalidate/page.tsx
0 → 100644
View file @
06f01e59
import
Link
from
'next/link'
export
default
async
function
Home
()
{
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
1500
))
return
(
<
div
>
<
h1
>
Home
</
h1
>
<
Link
href=
"/popstate-revalidate/foo"
>
To /foo
</
Link
>
</
div
>
)
}
test/e2e/app-dir/navigation/navigation.test.ts
View file @
06f01e59
...
...
@@ -7,7 +7,7 @@ createNextDescribe(
{
files
:
__dirname
,
},
({
next
,
isNextDev
,
isNextDeploy
})
=>
{
({
next
,
isNextDev
,
isNextDeploy
,
isNextStart
})
=>
{
describe
(
'query string'
,
()
=>
{
it
(
'should set query correctly'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
...
...
@@ -788,5 +788,57 @@ createNextDescribe(
expect
(
newScrollPosition
).
toEqual
(
scrollPosition
)
})
})
describe
(
'navigating to a page with async metadata'
,
()
=>
{
it
(
'should render the final state of the page with correct metadata'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/metadata-await-promise'
)
// dev + PPR doesn't trigger the loading boundary as it's not prefetched
if
(
isNextDev
&&
process
.
env
.
__NEXT_EXPERIMENTAL_PPR
)
{
await
browser
.
elementByCss
(
"[href='/metadata-await-promise/nested']"
)
.
click
()
}
else
{
const
loadingText
=
await
browser
.
elementByCss
(
"[href='/metadata-await-promise/nested']"
)
.
click
()
.
waitForElementByCss
(
'#loading'
)
.
text
()
expect
(
loadingText
).
toBe
(
'Loading'
)
}
await
retry
(
async
()
=>
{
expect
(
await
browser
.
elementById
(
'page-content'
).
text
()).
toBe
(
'Content'
)
expect
(
await
browser
.
elementByCss
(
'title'
).
text
()).
toBe
(
'Async Title'
)
})
})
})
describe
(
'browser back to a revalidated page'
,
()
=>
{
it
(
'should load the page'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/popstate-revalidate'
)
expect
(
await
browser
.
elementByCss
(
'h1'
).
text
()).
toBe
(
'Home'
)
await
browser
.
elementByCss
(
"[href='/popstate-revalidate/foo']"
).
click
()
await
browser
.
waitForElementByCss
(
'#submit-button'
)
expect
(
await
browser
.
elementByCss
(
'h1'
).
text
()).
toBe
(
'Form'
)
await
browser
.
elementById
(
'submit-button'
).
click
()
await
retry
(
async
()
=>
{
expect
(
await
browser
.
elementByCss
(
'body'
).
text
()).
toContain
(
'Form Submitted.'
)
})
await
browser
.
back
()
await
retry
(
async
()
=>
{
expect
(
await
browser
.
elementByCss
(
'h1'
).
text
()).
toBe
(
'Home'
)
})
})
})
}
)
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