Unverified Commit d70cac3e authored by rauno's avatar rauno Committed by GitHub

[Error Overlay] Comprehensive refinement (#75471)

This PR adds a lot of polish to the experimental Error Overlay:


https://github.com/user-attachments/assets/2540b966-c61d-43eb-b816-5ef25f3ecb11

### Motion
- Stacked layers transition smoothly when switching between errors
- Height transition for the dialog panel to complement the stacked
layers transition
- Dialog contents and the backdrop fade in as per Geist Motion
Guidelines (`scale`, `opacity`)

### Design
- New language icon based on file extension à la (`app.tsx`)
- Shadows are clipped with translucent borders to visually be more crisp
- Use `backdrop-filter: blur()` for backdrop to blend with application
content
- Use `font-variant-numeric: tabular-nums` for ←→ switcher to avoid
layout shift
- Misc alignment improvements

### Interactions
- Focus is now trapped in the dialog, <kbd>Escape</kbd> will un-trap and
re-focus the last `root.activeElement`
- Focus states for all interactive elements
- Fluid reveal & collapse of ignored Call Stack items ↓




https://github.com/user-attachments/assets/59a81cea-24ec-4fe4-be00-b911ab484757

Closes NDX-711
Closes NDX-744

---------
Co-authored-by: 's avatardevjiwonchoi <devjiwonchoi@gmail.com>
Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
parent 0783eb80
...@@ -13,7 +13,7 @@ const preview: Preview = { ...@@ -13,7 +13,7 @@ const preview: Preview = {
}, },
backgrounds: { backgrounds: {
values: [ values: [
{ name: 'backdrop', value: 'rgb(44, 44, 46);' }, { name: 'backdrop', value: 'rgba(250, 250, 250, 0.80)' },
{ name: 'background-100-light', value: '#ffffff' }, { name: 'background-100-light', value: '#ffffff' },
{ name: 'background-200-light', value: '#fafafa' }, { name: 'background-200-light', value: '#fafafa' },
{ name: 'background-100-dark', value: '#0a0a0a' }, { name: 'background-100-dark', value: '#0a0a0a' },
......
...@@ -4,6 +4,9 @@ import type { OverlayState } from '../../shared' ...@@ -4,6 +4,9 @@ import type { OverlayState } from '../../shared'
import ReactDevOverlay from './react-dev-overlay' import ReactDevOverlay from './react-dev-overlay'
import { ACTION_UNHANDLED_ERROR } from '../../shared' import { ACTION_UNHANDLED_ERROR } from '../../shared'
// @ts-expect-error
import imgApp from './app.png'
const meta: Meta<typeof ReactDevOverlay> = { const meta: Meta<typeof ReactDevOverlay> = {
component: ReactDevOverlay, component: ReactDevOverlay,
parameters: { parameters: {
...@@ -80,6 +83,17 @@ const state: OverlayState = { ...@@ -80,6 +83,17 @@ const state: OverlayState = {
export const Default: Story = { export const Default: Story = {
args: { args: {
state, state,
children: <div>Application Content</div>, children: (
<div>
<img
src={imgApp}
style={{
width: '100%',
height: '100%',
objectFit: 'contain',
}}
/>
</div>
),
}, },
} }
...@@ -9,7 +9,8 @@ import { noop as css } from '../../helpers/noop-template' ...@@ -9,7 +9,8 @@ import { noop as css } from '../../helpers/noop-template'
export const CallStackFrame: React.FC<{ export const CallStackFrame: React.FC<{
frame: OriginalStackFrame frame: OriginalStackFrame
}> = function CallStackFrame({ frame }) { index: number
}> = function CallStackFrame({ frame, index }) {
// TODO: ability to expand resolved frames // TODO: ability to expand resolved frames
// TODO: render error or external indicator // TODO: render error or external indicator
...@@ -32,19 +33,32 @@ export const CallStackFrame: React.FC<{ ...@@ -32,19 +33,32 @@ export const CallStackFrame: React.FC<{
// Formatted file source could be empty. e.g. <anonymous> will be formatted to empty string, // Formatted file source could be empty. e.g. <anonymous> will be formatted to empty string,
// we'll skip rendering the frame in this case. // we'll skip rendering the frame in this case.
const fileSource = getFrameSource(f) const fileSource = getFrameSource(f)
if (!fileSource) { if (!fileSource) {
return null return null
} }
const props = {
...(hasSource && {
role: 'button',
tabIndex: 0,
'aria-label': 'Click to open in your editor',
title: 'Click to open in your editor',
onClick: open,
}),
}
return ( return (
<div <div
data-nextjs-call-stack-frame data-nextjs-call-stack-frame
data-nextjs-call-stack-frame-ignored={!hasSource} data-nextjs-call-stack-frame-ignored={!hasSource}
onClick={hasSource ? open : undefined} data-animate={frame.ignored}
role="button" {...props}
tabIndex={0} style={
aria-label={hasSource ? 'Click to open in your editor' : undefined} {
title={hasSource ? 'Click to open in your editor' : undefined} '--index': index,
} as React.CSSProperties
}
> >
<span <span
data-nextjs-frame-expanded={!frame.ignored} data-nextjs-frame-expanded={!frame.ignored}
...@@ -86,18 +100,25 @@ export const CALL_STACK_FRAME_STYLES = css` ...@@ -86,18 +100,25 @@ export const CALL_STACK_FRAME_STYLES = css`
margin-bottom: var(--size-1); margin-bottom: var(--size-1);
border-radius: var(--rounded-lg); border-radius: var(--rounded-lg);
transition: background 100ms ease-out;
&[data-animate='true'] {
filter: blur(4px);
animation: fadeIn 250ms var(--timing-swift) forwards
calc(var(--index) * 25ms);
}
&:not(:disabled):hover { &:not(:disabled)[role='button']:hover {
background: var(--color-gray-alpha-100); background: var(--color-gray-alpha-100);
cursor: pointer; cursor: pointer;
} }
&:not(:disabled):active { &:not(:disabled)[role='button']:active {
background: var(--color-gray-alpha-200); background: var(--color-gray-alpha-200);
} }
&:focus { &:focus-visible {
outline: none; outline: var(--focus-ring);
} }
} }
...@@ -107,6 +128,7 @@ export const CALL_STACK_FRAME_STYLES = css` ...@@ -107,6 +128,7 @@ export const CALL_STACK_FRAME_STYLES = css`
gap: var(--size-1); gap: var(--size-1);
margin-bottom: var(--size-1); margin-bottom: var(--size-1);
font-family: var(--font-stack-monospace);
color: var(--color-gray-1000); color: var(--color-gray-1000);
font-size: var(--size-font-small); font-size: var(--size-font-small);
...@@ -119,4 +141,10 @@ export const CALL_STACK_FRAME_STYLES = css` ...@@ -119,4 +141,10 @@ export const CALL_STACK_FRAME_STYLES = css`
font-size: var(--size-font-small); font-size: var(--size-font-small);
line-height: var(--size-5); line-height: var(--size-5);
} }
@keyframes fadeIn {
to {
filter: blur(0px);
}
}
` `
...@@ -58,25 +58,26 @@ export function CodeFrame({ stackFrame, codeFrame }: CodeFrameProps) { ...@@ -58,25 +58,26 @@ export function CodeFrame({ stackFrame, codeFrame }: CodeFrameProps) {
column: stackFrame.column, column: stackFrame.column,
}) })
const fileExtension = stackFrame?.file?.split('.').pop()
// TODO: make the caret absolute // TODO: make the caret absolute
return ( return (
<div data-nextjs-codeframe> <div data-nextjs-codeframe>
<div className="code-frame-header"> <button
<p aria-label="Open error location in editor"
role="link" className="code-frame-header"
onClick={open} onClick={open}
tabIndex={1} >
title="Click to open in your editor" <p className="code-frame-link">
> <span className="code-frame-icon">
<span> <FileIcon lang={fileExtension} />
<FileIcon />
{getFrameSource(stackFrame)} @{' '} {getFrameSource(stackFrame)} @{' '}
<HotlinkedText text={stackFrame.methodName} /> <HotlinkedText text={stackFrame.methodName} />
</span> </span>
<ExternalIcon width={16} height={16} /> <ExternalIcon width={16} height={16} />
</p> </p>
</div> </button>
<pre> <pre className="code-frame-pre">
{decoded.map((entry, index) => ( {decoded.map((entry, index) => (
<span <span
key={`frame-${index}`} key={`frame-${index}`}
...@@ -99,11 +100,6 @@ export function CodeFrame({ stackFrame, codeFrame }: CodeFrameProps) { ...@@ -99,11 +100,6 @@ export function CodeFrame({ stackFrame, codeFrame }: CodeFrameProps) {
export const CODE_FRAME_STYLES = css` export const CODE_FRAME_STYLES = css`
[data-nextjs-codeframe] { [data-nextjs-codeframe] {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
flex: 1 0 0;
background-color: var(--color-background-200); background-color: var(--color-background-200);
overflow: hidden; overflow: hidden;
color: var(--color-gray-1000); color: var(--color-gray-1000);
...@@ -116,12 +112,35 @@ export const CODE_FRAME_STYLES = css` ...@@ -116,12 +112,35 @@ export const CODE_FRAME_STYLES = css`
border-radius: var(--size-2); border-radius: var(--size-2);
} }
[data-nextjs-codeframe] pre { .code-frame-link,
.code-frame-pre {
padding: 12px;
}
.code-frame-pre {
white-space: pre-wrap; white-space: pre-wrap;
} }
.code-frame-header { .code-frame-header {
width: 100%;
cursor: pointer;
border-bottom: 1px solid var(--color-gray-400); border-bottom: 1px solid var(--color-gray-400);
transition: background 100ms ease-out;
&:focus-visible {
outline: var(--focus-ring);
outline-offset: -2px;
}
&:hover {
background: var(--color-gray-100);
}
}
.code-frame-icon {
display: flex;
align-items: center;
gap: 6px;
} }
[data-nextjs-codeframe]::selection, [data-nextjs-codeframe]::selection,
...@@ -137,20 +156,16 @@ export const CODE_FRAME_STYLES = css` ...@@ -137,20 +156,16 @@ export const CODE_FRAME_STYLES = css`
[data-nextjs-codeframe] > * { [data-nextjs-codeframe] > * {
margin: 0; margin: 0;
padding: calc(var(--size-gap) + var(--size-gap-half))
calc(var(--size-gap-double) + var(--size-gap-half));
} }
[data-nextjs-codeframe] > div > p { .code-frame-link {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
cursor: pointer;
margin: 0; margin: 0;
outline: 0;
} }
[data-nextjs-codeframe] > div > p:hover {
text-decoration: underline dotted;
}
[data-nextjs-codeframe] div > pre { [data-nextjs-codeframe] div > pre {
overflow: hidden; overflow: hidden;
display: inline-block; display: inline-block;
...@@ -158,6 +173,5 @@ export const CODE_FRAME_STYLES = css` ...@@ -158,6 +173,5 @@ export const CODE_FRAME_STYLES = css`
[data-nextjs-codeframe] svg { [data-nextjs-codeframe] svg {
color: var(--color-gray-900); color: var(--color-gray-900);
margin-right: 6px;
} }
` `
...@@ -252,10 +252,6 @@ export const COPY_BUTTON_STYLES = css` ...@@ -252,10 +252,6 @@ export const COPY_BUTTON_STYLES = css`
.nextjs-data-runtime-error-copy-button--initial:hover { .nextjs-data-runtime-error-copy-button--initial:hover {
cursor: pointer; cursor: pointer;
} }
.nextjs-data-runtime-error-copy-button[aria-disabled='true'] {
opacity: 0.3;
cursor: not-allowed;
}
.nextjs-data-runtime-error-copy-button--error, .nextjs-data-runtime-error-copy-button--error,
.nextjs-data-runtime-error-copy-button--error:hover { .nextjs-data-runtime-error-copy-button--error:hover {
color: var(--color-ansi-red); color: var(--color-ansi-red);
......
import * as React from 'react' import * as React from 'react'
import { useOnClickOutside } from '../../hooks/use-on-click-outside' import { useOnClickOutside } from '../../hooks/use-on-click-outside'
import { useMeasureHeight } from '../../hooks/use-measure-height'
export type DialogProps = { export type DialogProps = {
children?: React.ReactNode children?: React.ReactNode
...@@ -8,6 +9,7 @@ export type DialogProps = { ...@@ -8,6 +9,7 @@ export type DialogProps = {
'aria-describedby': string 'aria-describedby': string
className?: string className?: string
onClose?: () => void onClose?: () => void
dialogResizerRef?: React.RefObject<HTMLDivElement | null>
} }
const CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE = [ const CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE = [
...@@ -21,6 +23,9 @@ const Dialog: React.FC<DialogProps> = function Dialog({ ...@@ -21,6 +23,9 @@ const Dialog: React.FC<DialogProps> = function Dialog({
type, type,
className, className,
onClose, onClose,
'aria-labelledby': ariaLabelledBy,
'aria-describedby': ariaDescribedBy,
dialogResizerRef,
...props ...props
}) { }) {
const [dialog, setDialog] = React.useState<HTMLDivElement | null>(null) const [dialog, setDialog] = React.useState<HTMLDivElement | null>(null)
...@@ -29,69 +34,84 @@ const Dialog: React.FC<DialogProps> = function Dialog({ ...@@ -29,69 +34,84 @@ const Dialog: React.FC<DialogProps> = function Dialog({
? 'dialog' ? 'dialog'
: undefined : undefined
) )
const ref = React.useRef<HTMLDivElement | null>(null)
const [height, pristine] = useMeasureHeight(ref)
const onDialog = React.useCallback((node: HTMLDivElement | null) => { const onDialog = React.useCallback((node: HTMLDivElement | null) => {
setDialog(node) setDialog(node)
}, []) }, [])
useOnClickOutside(dialog, CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE, (e) => { useOnClickOutside(dialog, CSS_SELECTORS_TO_EXCLUDE_ON_CLICK_OUTSIDE, (e) => {
e.preventDefault() e.preventDefault()
return onClose?.() return onClose?.()
}) })
// Make HTMLElements with `role=link` accessible to be triggered by the
// keyboard, i.e. [Enter].
React.useEffect(() => { React.useEffect(() => {
if (dialog == null) { if (dialog == null) {
return return
} }
const root = dialog.getRootNode()
// Always true, but we do this for TypeScript:
if (!(root instanceof ShadowRoot)) {
return
}
const shadowRoot = root
function handler(e: KeyboardEvent) {
const el = shadowRoot.activeElement
if (
e.key === 'Enter' &&
el instanceof HTMLElement &&
el.getAttribute('role') === 'link'
) {
e.preventDefault()
e.stopPropagation()
el.click()
}
}
function handleFocus() { function handleFocus() {
// safari will force itself as the active application when a background page triggers any sort of autofocus // safari will force itself as the active application when a background page triggers any sort of autofocus
// this is a workaround to only set the dialog role if the document has focus // this is a workaround to only set the dialog role if the document has focus
setRole(document.hasFocus() ? 'dialog' : undefined) setRole(document.hasFocus() ? 'dialog' : undefined)
} }
shadowRoot.addEventListener('keydown', handler as EventListener)
window.addEventListener('focus', handleFocus) window.addEventListener('focus', handleFocus)
window.addEventListener('blur', handleFocus) window.addEventListener('blur', handleFocus)
return () => { return () => {
shadowRoot.removeEventListener('keydown', handler as EventListener)
window.removeEventListener('focus', handleFocus) window.removeEventListener('focus', handleFocus)
window.removeEventListener('blur', handleFocus) window.removeEventListener('blur', handleFocus)
} }
}, [dialog]) }, [dialog])
React.useEffect(() => {
const root = dialog?.getRootNode()
const activeElement =
root instanceof ShadowRoot ? (root?.activeElement as HTMLElement) : null
// Trap focus within the dialog
dialog?.focus()
return () => {
// Blur first to avoid getting stuck, in case `activeElement` is missing
dialog?.blur()
// Restore focus to the previously active element
activeElement?.focus()
}
}, [dialog])
return ( return (
<div <div
ref={onDialog} ref={onDialog}
data-nextjs-dialog data-nextjs-dialog
tabIndex={-1} tabIndex={1}
role={role} role={role}
aria-labelledby={props['aria-labelledby']} aria-labelledby={ariaLabelledBy}
aria-describedby={props['aria-describedby']} aria-describedby={ariaDescribedBy}
aria-modal="true" aria-modal="true"
className={className} className={className}
onKeyDown={(e) => {
if (e.key === 'Escape') {
onClose?.()
}
}}
{...props}
> >
{children} <div
ref={dialogResizerRef}
data-nextjs-dialog-sizer
// [x] Don't animate on initial load
// [x] No duplicate elements
// [x] Responds to content growth
style={{
height,
transition: pristine ? undefined : 'height 250ms var(--timing-swift)',
}}
>
<div ref={ref}>{children}</div>
</div>
</div> </div>
) )
} }
......
import { noop as css } from '../../helpers/noop-template' import { noop as css } from '../../helpers/noop-template'
const styles = css` const styles = css`
[data-nextjs-dialog] { [data-nextjs-dialog-root] {
--next-dialog-radius: var(--rounded-xl);
--next-dialog-footer-height: 48px;
--next-dialog-max-width: 960px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
max-height: calc(100% - 56px); max-height: calc(100% - 56px);
max-width: var(--next-dialog-max-width);
margin-right: auto; margin-right: auto;
margin-left: auto; margin-left: auto;
outline: none; scale: 0.98;
overflow-y: hidden; opacity: 0;
} transition-property: scale, opacity;
transition-duration: var(--transition-duration);
transition-timing-function: var(--timing-overlay);
@media (max-height: 812px) { &[data-rendered='true'] {
[data-nextjs-dialog-overlay] { opacity: 1;
max-height: calc(100% - 15px); scale: 1;
} }
} }
@media (min-width: 576px) { [data-nextjs-dialog] {
[data-nextjs-dialog] { outline: none;
max-width: 540px;
}
} }
@media (min-width: 768px) { /* Place overflow: hidden on this so we can break out from [data-nextjs-dialog] */
[data-nextjs-dialog] { [data-nextjs-dialog-sizer] {
max-width: 720px; overflow: hidden;
} border-radius: inherit;
} }
@media (min-width: 992px) { [data-nextjs-dialog-backdrop] {
[data-nextjs-dialog] { opacity: 0;
max-width: 960px; transition: opacity var(--transition-duration) var(--timing-overlay);
} }
[data-nextjs-dialog-overlay][data-rendered='true']
[data-nextjs-dialog-backdrop] {
opacity: 1;
} }
[data-nextjs-dialog-content] { [data-nextjs-dialog-content] {
overflow-y: auto;
border: none; border: none;
margin: 0; margin: 0;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
/* Account for the footer height, when present */
[data-nextjs-dialog-body]:has(~ [data-nextjs-dialog-footer]) {
margin-bottom: calc(var(--next-dialog-footer-height) + 2px);
}
[data-nextjs-dialog-content] > [data-nextjs-dialog-header] { [data-nextjs-dialog-content] > [data-nextjs-dialog-header] {
flex-shrink: 0; flex-shrink: 0;
padding: var(--size-4); padding: var(--size-4);
} }
[data-nextjs-dialog-content] > [data-nextjs-dialog-body] { [data-nextjs-dialog-content] > [data-nextjs-dialog-body] {
position: relative; position: relative;
flex: 1 1 auto; flex: 1 1 auto;
} }
[data-nextjs-dialog-footer] {
width: 100%;
/* We make this element absolute to fix it to the bottom during the height transition */
position: absolute;
bottom: 0;
min-height: var(--next-dialog-footer-height);
border-radius: 0 0 var(--next-dialog-radius) var(--next-dialog-radius);
overflow: hidden;
> * {
height: 100%;
}
}
@media (max-height: 812px) {
[data-nextjs-dialog-overlay] {
max-height: calc(100% - 15px);
}
}
@media (min-width: 576px) {
[data-nextjs-dialog-root] {
--next-dialog-max-width: 540px;
}
}
@media (min-width: 768px) {
[data-nextjs-dialog-root] {
--next-dialog-max-width: 720px;
}
}
@media (min-width: 992px) {
[data-nextjs-dialog-root] {
--next-dialog-max-width: 960px;
}
}
` `
export { styles } export { styles }
import type { OriginalStackFrame } from '../../../../../internal/helpers/stack-frame' import type { OriginalStackFrame } from '../../../../../internal/helpers/stack-frame'
import { useMemo, useState } from 'react' import { useMemo, useState, useRef } from 'react'
import { CallStackFrame } from '../../call-stack-frame/call-stack-frame' import { CallStackFrame } from '../../call-stack-frame/call-stack-frame'
import { noop as css } from '../../../helpers/noop-template' import { noop as css } from '../../../helpers/noop-template'
import { useMeasureHeight } from '../../../hooks/use-measure-height'
type CallStackProps = { interface CallStackProps {
frames: OriginalStackFrame[] frames: OriginalStackFrame[]
dialogResizerRef: React.RefObject<HTMLDivElement | null>
} }
export function CallStack({ frames }: CallStackProps) { export function CallStack({ frames, dialogResizerRef }: CallStackProps) {
const ignoreListRef = useRef<HTMLDivElement | null>(null)
const initialDialogHeight = useRef<number>(NaN)
const [isIgnoreListOpen, setIsIgnoreListOpen] = useState(false) const [isIgnoreListOpen, setIsIgnoreListOpen] = useState(false)
const [ignoreListHeight] = useMeasureHeight(ignoreListRef)
const { filteredFrames, ignoreListLength } = useMemo(() => { const { visibleFrames, ignoredFrames, ignoreListLength } = useMemo(() => {
const filtered = [] const visible: OriginalStackFrame[] = []
let ignoredLength = 0 const ignored: OriginalStackFrame[] = []
for (const frame of frames) { for (const frame of frames) {
if (isIgnoreListOpen || !frame.ignored) { if (!frame.ignored) {
filtered.push(frame) visible.push(frame)
} }
if (frame.ignored) { if (frame.ignored) {
ignoredLength++ ignored.push(frame)
} }
} }
return { return {
filteredFrames: filtered, visibleFrames: visible,
ignoreListLength: ignoredLength, ignoredFrames: ignored,
ignoreListLength: ignored.length,
} }
}, [frames, isIgnoreListOpen]) }, [frames])
function onToggleIgnoreList() {
const dialog = dialogResizerRef?.current as HTMLElement
if (!dialog) {
return
}
const { height: currentHeight } = dialog?.getBoundingClientRect()
if (!initialDialogHeight.current) {
initialDialogHeight.current = currentHeight
}
if (isIgnoreListOpen) {
function onTransitionEnd() {
setIsIgnoreListOpen(false)
dialog.removeEventListener('transitionend', onTransitionEnd)
}
dialog.style.height = `${initialDialogHeight.current}px`
dialog.addEventListener('transitionend', onTransitionEnd)
} else {
dialog.style.height = `${initialDialogHeight.current + ignoreListHeight}px`
setIsIgnoreListOpen(!isIgnoreListOpen)
}
}
return ( return (
<div className="error-overlay-call-stack-container"> <div className="error-overlay-call-stack-container">
...@@ -42,19 +74,34 @@ export function CallStack({ frames }: CallStackProps) { ...@@ -42,19 +74,34 @@ export function CallStack({ frames }: CallStackProps) {
<button <button
data-expand-ignore-button={isIgnoreListOpen} data-expand-ignore-button={isIgnoreListOpen}
className="error-overlay-call-stack-ignored-list-toggle-button" className="error-overlay-call-stack-ignored-list-toggle-button"
onClick={() => setIsIgnoreListOpen(!isIgnoreListOpen)} onClick={onToggleIgnoreList}
> >
{`${isIgnoreListOpen ? 'Hide' : 'Show'} ${ignoreListLength} Ignore-listed Frames`} {`${isIgnoreListOpen ? 'Hide' : 'Show'} ${ignoreListLength} Ignored-listed Frames`}
<ChevronUpDown /> <ChevronUpDown />
</button> </button>
)} )}
</div> </div>
{filteredFrames.map((frame, frameIndex) => ( <div className="error-overlay-call-stack-body">
<CallStackFrame {visibleFrames.map((frame, frameIndex) => (
key={`call-stack-leading-${frameIndex}`} <CallStackFrame
frame={frame} key={`call-stack-leading-${frameIndex}`}
/> frame={frame}
))} index={frameIndex}
/>
))}
{isIgnoreListOpen && (
<div ref={ignoreListRef}>
{ignoredFrames.map((frame, frameIndex) => (
<CallStackFrame
key={`call-stack-ignored-${frameIndex}`}
frame={frame}
index={frameIndex}
/>
))}
</div>
)}
</div>
</div> </div>
) )
} }
...@@ -81,17 +128,34 @@ function ChevronUpDown() { ...@@ -81,17 +128,34 @@ function ChevronUpDown() {
export const CALL_STACK_STYLES = css` export const CALL_STACK_STYLES = css`
.error-overlay-call-stack-container { .error-overlay-call-stack-container {
border-top: 1px solid var(--color-gray-400); border-top: 1px solid var(--color-gray-400);
position: relative;
}
.error-overlay-call-stack-body {
padding: var(--size-4) var(--size-3); padding: var(--size-4) var(--size-3);
padding-top: 0;
/* To optically align last item */
padding-bottom: 8px;
} }
.error-overlay-call-stack-header { .error-overlay-call-stack-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
min-height: 28px;
margin-bottom: var(--size-3); padding: var(--size-4) var(--size-5) var(--size-3) var(--size-4);
background: rgba(255, 255, 255, 0.7);
padding: 0 var(--size-2); mask-image: linear-gradient(to top, transparent, #000 12%);
backdrop-filter: blur(8px);
width: 100%;
position: fixed;
position: sticky;
top: 0;
z-index: 2;
@media (prefers-color-scheme: dark) {
background: #0a0a0a70;
}
} }
.error-overlay-call-stack-title { .error-overlay-call-stack-title {
...@@ -113,9 +177,8 @@ export const CALL_STACK_STYLES = css` ...@@ -113,9 +177,8 @@ export const CALL_STACK_STYLES = css`
justify-content: center; justify-content: center;
align-items: center; align-items: center;
width: var(--size-5); width: 20px;
height: var(--size-5); height: 20px;
padding: var(--size-0_5) var(--size-1_5);
gap: var(--size-1); gap: var(--size-1);
color: var(--color-gray-1000); color: var(--color-gray-1000);
...@@ -130,12 +193,23 @@ export const CALL_STACK_STYLES = css` ...@@ -130,12 +193,23 @@ export const CALL_STACK_STYLES = css`
.error-overlay-call-stack-ignored-list-toggle-button { .error-overlay-call-stack-ignored-list-toggle-button {
all: unset; all: unset;
display: flex;
align-items: center;
gap: 6px;
color: var(--color-gray-900); color: var(--color-gray-900);
font-size: var(--size-font-small); font-size: var(--size-font-small);
line-height: var(--size-5); line-height: var(--size-5);
border-radius: 6px;
padding: 4px 6px;
margin-right: -6px;
transition: background 150ms ease;
&:hover {
background: var(--color-gray-100);
}
&:focus { &:focus {
outline: none; outline: var(--focus-ring);
} }
} }
` `
...@@ -6,9 +6,9 @@ import { Toast } from '../../toast' ...@@ -6,9 +6,9 @@ import { Toast } from '../../toast'
import { NextLogo } from './internal/next-logo' import { NextLogo } from './internal/next-logo'
import { useIsDevBuilding } from '../../../../../../../dev/dev-build-indicator/internal/initialize-for-new-overlay' import { useIsDevBuilding } from '../../../../../../../dev/dev-build-indicator/internal/initialize-for-new-overlay'
import { useIsDevRendering } from './internal/dev-render-indicator' import { useIsDevRendering } from './internal/dev-render-indicator'
import { useDelayedRender } from './internal/use-delayed-render'
import { useKeyboardShortcut } from '../../../hooks/use-keyboard-shortcut' import { useKeyboardShortcut } from '../../../hooks/use-keyboard-shortcut'
import { MODIFIERS } from '../../../hooks/use-keyboard-shortcut' import { MODIFIERS } from '../../../hooks/use-keyboard-shortcut'
import { useDelayedRender } from '../../../hooks/use-delayed-render'
// TODO: add E2E tests to cover different scenarios // TODO: add E2E tests to cover different scenarios
...@@ -80,6 +80,7 @@ function DevToolsPopover({ ...@@ -80,6 +80,7 @@ function DevToolsPopover({
const [isMenuOpen, setIsMenuOpen] = useState(false) const [isMenuOpen, setIsMenuOpen] = useState(false)
const [selectedIndex, setSelectedIndex] = useState(-1) const [selectedIndex, setSelectedIndex] = useState(-1)
// This hook lets us do an exit animation before unmounting the component
const { mounted, rendered } = useDelayedRender(isMenuOpen, { const { mounted, rendered } = useDelayedRender(isMenuOpen, {
// Intentionally no fade in, makes the UI feel more immediate // Intentionally no fade in, makes the UI feel more immediate
enterDelay: 0, enterDelay: 0,
...@@ -370,7 +371,16 @@ function useFocusTrap( ...@@ -370,7 +371,16 @@ function useFocusTrap(
if (isMenuOpen) { if (isMenuOpen) {
menuRef.current?.focus() menuRef.current?.focus()
} else { } else {
triggerRef.current?.focus() const root = triggerRef.current?.getRootNode()
const activeElement =
root instanceof ShadowRoot ? (root?.activeElement as HTMLElement) : null
// Only restore focus if the focus was previously on the menu.
// This avoids us accidentally focusing on mount when the
// user could want to interact with their own app instead.
if (menuRef.current?.contains(activeElement)) {
triggerRef.current?.focus()
}
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isMenuOpen]) }, [isMenuOpen])
......
...@@ -175,7 +175,7 @@ export const NextLogo = forwardRef(function NextLogo( ...@@ -175,7 +175,7 @@ export const NextLogo = forwardRef(function NextLogo(
width: fit-content; width: fit-content;
height: 100%; height: 100%;
display: flex; display: flex;
gap: 8px; gap: 2px;
align-items: center; align-items: center;
margin: 0; margin: 0;
line-height: 36px; line-height: 36px;
......
import { useState, useRef, useCallback } from 'react'
interface Options {
enterDelay?: number
exitDelay?: number
onUnmount?: () => void
}
/** Useful to perform CSS animations on React components */
export function useDelayedRender(
active: boolean = false,
options: Options = {}
) {
const [, force] = useState<any>()
const mounted = useRef(active)
const rendered = useRef(false)
const renderTimer = useRef<NodeJS.Timeout | null>(null)
const unmountTimer = useRef<NodeJS.Timeout | null>(null)
const prevActive = useRef(active)
const recalculate = useCallback(() => {
const { enterDelay = 1, exitDelay = 0 } = options
if (prevActive.current) {
// Mount immediately
mounted.current = true
if (unmountTimer.current) clearTimeout(unmountTimer.current)
if (enterDelay <= 0) {
// Render immediately
rendered.current = true
} else {
if (renderTimer.current) return
// Render after a delay
renderTimer.current = setTimeout(() => {
rendered.current = true
renderTimer.current = null
force({})
}, enterDelay)
}
} else {
// Immediately set to unrendered
rendered.current = false
if (exitDelay <= 0) {
mounted.current = false
} else {
if (unmountTimer.current) return
// Unmount after a delay
unmountTimer.current = setTimeout(() => {
mounted.current = false
unmountTimer.current = null
force({})
}, exitDelay)
}
}
}, [options])
// When the active prop changes, need to re-calculate
if (active !== prevActive.current) {
prevActive.current = active
// We want to do this synchronously with the render, not in an effect
// this way when active → true, mounted → true in the same pass
recalculate()
}
return {
mounted: mounted.current,
rendered: rendered.current,
}
}
...@@ -20,7 +20,6 @@ export const styles = css` ...@@ -20,7 +20,6 @@ export const styles = css`
opacity: 0; opacity: 0;
outline: 0; outline: 0;
min-width: 248px; min-width: 248px;
background: var(--color-background-100);
transition: opacity var(--animate-out-duration-ms) transition: opacity var(--animate-out-duration-ms)
var(--animate-out-timing-function); var(--animate-out-timing-function);
......
...@@ -5,12 +5,14 @@ type ErrorOverlayDialogProps = { ...@@ -5,12 +5,14 @@ type ErrorOverlayDialogProps = {
isTurbopack?: boolean isTurbopack?: boolean
children?: React.ReactNode children?: React.ReactNode
onClose?: () => void onClose?: () => void
dialogResizerRef?: React.RefObject<HTMLDivElement | null>
} }
export function ErrorOverlayDialog({ export function ErrorOverlayDialog({
isTurbopack, isTurbopack,
children, children,
onClose, onClose,
...props
}: ErrorOverlayDialogProps) { }: ErrorOverlayDialogProps) {
return ( return (
<Dialog <Dialog
...@@ -18,7 +20,9 @@ export function ErrorOverlayDialog({ ...@@ -18,7 +20,9 @@ export function ErrorOverlayDialog({
aria-labelledby="nextjs__container_errors_label" aria-labelledby="nextjs__container_errors_label"
aria-describedby="nextjs__container_errors_desc" aria-describedby="nextjs__container_errors_desc"
onClose={onClose} onClose={onClose}
className={`error-overlay-dialog ${isTurbopack ? 'nextjs-error-overlay-dialog-turbopack-background' : ''}`} className="error-overlay-dialog"
data-turbo={isTurbopack}
{...props}
> >
{children} {children}
</Dialog> </Dialog>
...@@ -27,23 +31,39 @@ export function ErrorOverlayDialog({ ...@@ -27,23 +31,39 @@ export function ErrorOverlayDialog({
export const DIALOG_STYLES = css` export const DIALOG_STYLES = css`
.error-overlay-dialog { .error-overlay-dialog {
overflow-y: auto;
-webkit-font-smoothing: antialiased;
background: var(--color-background-100); background: var(--color-background-100);
border: 1px solid var(--color-gray-400); background-clip: padding-box;
border-radius: var(--rounded-xl); border: 1px solid var(--color-gray-alpha-400);
box-shadow: var(--shadow-md); border-radius: var(--next-dialog-radius);
} box-shadow: var(--shadow-menu);
position: relative;
@media (prefers-color-scheme: dark) {
border-color: var(--color-gray-400);
}
.nextjs-error-overlay-dialog-turbopack-background { &[data-turbo='true']::after {
border: 1px solid transparent; content: '';
background: --size: 1px;
linear-gradient(var(--color-background-100), var(--color-background-100)) --gradient: linear-gradient(
padding-box, to right top,
linear-gradient( transparent 75%,
to right top, var(--color-turbopack-border-blue) 87.5%,
var(--color-gray-400) 75%, var(--color-turbopack-border-red) 100%
var(--color-turbopack-border-blue) 87.5%, );
var(--color-turbopack-border-red) 100% position: absolute;
) inset: -1px;
border-box; pointer-events: none;
border-radius: var(--next-dialog-radius);
padding: var(--size);
background: var(--gradient);
mask:
linear-gradient(black, black) content-box,
linear-gradient(black, black);
-webkit-mask-composite: xor;
mask-composite: exclude;
}
} }
` `
import { noop as css } from '../../../helpers/noop-template'
export function ErrorOverlayBottomStack({
count,
activeIdx,
}: {
count: number
activeIdx: number
}) {
let stackCount = '0'
if (count > 1) {
stackCount = '1'
}
if (count > 2) {
stackCount = '2'
}
if (activeIdx === 1) {
stackCount = '1'
}
if (activeIdx > 1) {
stackCount = '0'
}
return (
<div aria-hidden className="error-overlay-bottom-stack">
<div className="stack" data-stack-count={stackCount}>
<div className="layer layer1">1</div>
<div className="layer layer2">2</div>
</div>
</div>
)
}
export const styles = css`
.layer {
width: 100%;
height: var(--stack-layer-height);
position: relative;
border: 1px solid var(--color-gray-400);
border-radius: var(--rounded-xl);
background: var(--color-background-200);
transition:
translate 350ms var(--timing-swift),
box-shadow 350ms var(--timing-swift);
}
.layer1 {
width: calc(100% - var(--size-6));
}
.layer2 {
width: calc(100% - var(--size-12));
z-index: -1;
}
.error-overlay-bottom-stack {
width: 100%;
position: absolute;
bottom: -1px;
height: 0;
overflow: visible;
}
.stack {
--stack-layer-height: 44px;
--stack-layer-height-half: calc(var(--stack-layer-height) / 2);
--stack-layer-trim: 13px;
--shadow: 0px 0.925px 0.925px 0px rgba(0, 0, 0, 0.02),
0px 3.7px 7.4px -3.7px rgba(0, 0, 0, 0.04),
0px 14.8px 22.2px -7.4px rgba(0, 0, 0, 0.06);
display: grid;
place-items: center center;
width: 100%;
position: fixed;
overflow: hidden;
z-index: -1;
max-width: var(--next-dialog-max-width);
.layer {
grid-area: 1 / 1;
/* Hide */
translate: 0 calc(var(--stack-layer-height) * -1);
}
&[data-stack-count='1'],
&[data-stack-count='2'] {
.layer1 {
translate: 0
calc(var(--stack-layer-height-half) * -1 - var(--stack-layer-trim));
}
}
&[data-stack-count='2'] {
.layer2 {
translate: 0 calc(var(--stack-layer-trim) * -1 * 2);
}
}
/* Only the bottom stack should have the shadow */
&[data-stack-count='1'] .layer1 {
box-shadow: var(--shadow);
}
&[data-stack-count='2'] {
.layer2 {
box-shadow: var(--shadow);
}
}
}
@media (prefers-color-scheme: dark) {
.layer {
border-color: var(--color-gray-400);
}
}
`
import type { Meta, StoryObj } from '@storybook/react'
import { ErrorOverlayBottomStacks } from './error-overlay-bottom-stacks'
import { withShadowPortal } from '../../../storybook/with-shadow-portal'
const meta: Meta<typeof ErrorOverlayBottomStacks> = {
component: ErrorOverlayBottomStacks,
parameters: {
layout: 'fullscreen',
},
decorators: [withShadowPortal],
}
export default meta
type Story = StoryObj<typeof ErrorOverlayBottomStacks>
export const SingleStack: Story = {
args: {
errorsCount: 2,
activeIdx: 0,
},
}
export const DoubleStacks: Story = {
args: {
errorsCount: 3,
activeIdx: 0,
},
}
import { noop as css } from '../../../helpers/noop-template'
export type ErrorOverlayBottomStacksProps = {
errorsCount: number
activeIdx: number
}
export function ErrorOverlayBottomStacks({
errorsCount,
activeIdx,
}: ErrorOverlayBottomStacksProps) {
return (
<div className="error-overlay-bottom-stacks-wrapper">
{errorsCount > 1 && (
<div
className={`error-overlay-bottom-stack-1 ${
errorsCount - activeIdx > 1 ? '' : 'stack-slide-up'
}`}
aria-hidden="true"
/>
)}
{errorsCount > 2 && (
<div
className={`error-overlay-bottom-stack-2 ${
errorsCount - activeIdx > 2 ? '' : 'stack-slide-up'
}`}
aria-hidden="true"
/>
)}
</div>
)
}
export const styles = css`
.error-overlay-bottom-stacks-wrapper {
display: flex;
flex-direction: column;
width: 100%;
outline: none;
z-index: -1;
position: fixed;
@media (min-width: 576px) {
max-width: 540px;
}
@media (min-width: 768px) {
max-width: 720px;
}
@media (min-width: 992px) {
max-width: 960px;
}
}
.error-overlay-bottom-stack-1,
.error-overlay-bottom-stack-2 {
padding: var(--size-3);
align-self: center;
border: 1px solid var(--color-gray-400);
border-radius: var(--rounded-xl);
box-shadow: var(--shadow-md);
background: var(--color-background-200);
animation: stack-slide-down 0.3s ease-out forwards;
}
.error-overlay-bottom-stack-1 {
width: calc(100% - var(--size-6));
margin-top: calc(-1 * var(--size-3));
}
.error-overlay-bottom-stack-2 {
width: calc(100% - var(--size-12));
margin-top: calc(-1 * var(--size-3_5));
z-index: -2;
}
@keyframes stack-slide-down {
from {
opacity: 0;
transform: translateY(-50%);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.stack-slide-up {
animation: stack-slide-up 0.3s ease-out forwards;
}
@keyframes stack-slide-up {
from {
opacity: 1;
transform: translateY(0);
}
to {
opacity: 0;
transform: translateY(-50%);
}
}
`
...@@ -47,17 +47,6 @@ export const styles = css` ...@@ -47,17 +47,6 @@ export const styles = css`
transform: translateY(calc(-1 * var(--size-10_5))); transform: translateY(calc(-1 * var(--size-10_5)));
outline: none; outline: none;
max-width: var(--next-dialog-max-width);
@media (min-width: 576px) {
max-width: 540px;
}
@media (min-width: 768px) {
max-width: 720px;
}
@media (min-width: 992px) {
max-width: 960px;
}
} }
` `
...@@ -68,7 +68,13 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) { ...@@ -68,7 +68,13 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) {
className={`feedback-button ${voted === false ? 'voted' : ''}`} className={`feedback-button ${voted === false ? 'voted' : ''}`}
type="button" type="button"
> >
<ThumbsDown aria-hidden="true" /> <ThumbsDown
aria-hidden="true"
// Optical alignment
style={{
translate: '1px 1px',
}}
/>
</button> </button>
</> </>
)} )}
...@@ -79,12 +85,14 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) { ...@@ -79,12 +85,14 @@ export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) {
export const styles = css` export const styles = css`
.error-feedback { .error-feedback {
display: flex; display: flex;
align-items: center;
gap: var(--size-gap); gap: var(--size-gap);
white-space: nowrap; white-space: nowrap;
color: var(--color-gray-900);
} }
.error-feedback-thanks { .error-feedback-thanks {
height: 1.5rem; /* 24px */ height: 24px;
display: flex; display: flex;
align-items: center; align-items: center;
padding-right: 4px; /* To match the 4px inner padding of the thumbs up and down icons */ padding-right: 4px; /* To match the 4px inner padding of the thumbs up and down icons */
...@@ -94,15 +102,15 @@ export const styles = css` ...@@ -94,15 +102,15 @@ export const styles = css`
background: none; background: none;
border: none; border: none;
border-radius: var(--rounded-md); border-radius: var(--rounded-md);
padding: var(--size-gap-half); width: 24px;
width: 1.5rem; /* 24px */ height: 24px;
height: 1.5rem; /* 24px */
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center;
cursor: pointer; cursor: pointer;
&:focus { &:focus {
outline: none; outline: var(--focus-ring);
} }
&:hover { &:hover {
......
...@@ -37,20 +37,18 @@ export const styles = css` ...@@ -37,20 +37,18 @@ export const styles = css`
.error-feedback { .error-feedback {
margin-left: auto; margin-left: auto;
}
.error-overlay-footer p { p {
color: var(--color-gray-900); font-size: 14px;
margin: 0; font-weight: 500;
font-size: 14px; margin: 0;
font-weight: 500; }
line-height: 20px;
} }
.error-overlay-footer-message { .error-overlay-footer-message {
color: var(--color-gray-900); color: var(--color-gray-900);
margin: 0; margin: 0;
font-size: var(--size-font-small); font-size: 14px;
font-weight: 400; font-weight: 400;
line-height: var(--size-font-big); line-height: var(--size-font-big);
} }
......
...@@ -14,6 +14,12 @@ jest.mock('../../../components/overlay/maintain--tab-focus', () => ({ ...@@ -14,6 +14,12 @@ jest.mock('../../../components/overlay/maintain--tab-focus', () => ({
})), })),
})) }))
global.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}))
const renderTestComponent = () => { const renderTestComponent = () => {
return render( return render(
<ErrorOverlayLayout <ErrorOverlayLayout
...@@ -23,6 +29,13 @@ const renderTestComponent = () => { ...@@ -23,6 +29,13 @@ const renderTestComponent = () => {
error={new Error('Sample error')} error={new Error('Sample error')}
isBuildError={true} isBuildError={true}
onClose={() => {}} onClose={() => {}}
rendered={true}
transitionDurationMs={200}
isTurbopack={false}
versionInfo={{
installed: '15.0.0',
staleness: 'fresh',
}}
> >
Module not found: Cannot find module './missing-module' Module not found: Cannot find module './missing-module'
</ErrorOverlayLayout> </ErrorOverlayLayout>
......
import type { DebugInfo } from '../../../../../types' import type { DebugInfo } from '../../../../../types'
import type { VersionInfo } from '../../../../../../../../server/dev/parse-version-info'
import type { ErrorMessageType } from '../error-message/error-message' import type { ErrorMessageType } from '../error-message/error-message'
import type { ErrorType } from '../error-type-label/error-type-label' import type { ErrorType } from '../error-type-label/error-type-label'
...@@ -8,7 +7,6 @@ import { ...@@ -8,7 +7,6 @@ import {
ErrorOverlayToolbar, ErrorOverlayToolbar,
styles as toolbarStyles, styles as toolbarStyles,
} from '../error-overlay-toolbar/error-overlay-toolbar' } from '../error-overlay-toolbar/error-overlay-toolbar'
import { ErrorOverlayBottomStacks } from '../error-overlay-bottom-stacks/error-overlay-bottom-stacks'
import { ErrorOverlayFooter } from '../error-overlay-footer/error-overlay-footer' import { ErrorOverlayFooter } from '../error-overlay-footer/error-overlay-footer'
import { noop as css } from '../../../helpers/noop-template' import { noop as css } from '../../../helpers/noop-template'
import { import {
...@@ -32,9 +30,11 @@ import { ...@@ -32,9 +30,11 @@ import {
import { ErrorOverlayDialogBody, DIALOG_BODY_STYLES } from '../dialog/body' import { ErrorOverlayDialogBody, DIALOG_BODY_STYLES } from '../dialog/body'
import { CALL_STACK_STYLES } from '../call-stack/call-stack' import { CALL_STACK_STYLES } from '../call-stack/call-stack'
import { OVERLAY_STYLES, ErrorOverlayOverlay } from '../overlay/overlay' import { OVERLAY_STYLES, ErrorOverlayOverlay } from '../overlay/overlay'
import { ErrorOverlayBottomStack } from '../error-overlay-bottom-stack'
import type { ErrorBaseProps } from '../error-overlay/error-overlay'
import type { ReadyRuntimeError } from '../../../../../internal/helpers/get-error-by-type' import type { ReadyRuntimeError } from '../../../../../internal/helpers/get-error-by-type'
type ErrorOverlayLayoutProps = { interface ErrorOverlayLayoutProps extends ErrorBaseProps {
errorMessage: ErrorMessageType errorMessage: ErrorMessageType
errorType: ErrorType errorType: ErrorType
children?: React.ReactNode children?: React.ReactNode
...@@ -43,13 +43,12 @@ type ErrorOverlayLayoutProps = { ...@@ -43,13 +43,12 @@ type ErrorOverlayLayoutProps = {
debugInfo?: DebugInfo debugInfo?: DebugInfo
isBuildError?: boolean isBuildError?: boolean
onClose?: () => void onClose?: () => void
versionInfo?: VersionInfo
// TODO: better handle receiving // TODO: better handle receiving
readyErrors?: ReadyRuntimeError[] readyErrors?: ReadyRuntimeError[]
activeIdx?: number activeIdx?: number
setActiveIndex?: (index: number) => void setActiveIndex?: (index: number) => void
footerMessage?: string footerMessage?: string
isTurbopack?: boolean dialogResizerRef?: React.RefObject<HTMLDivElement | null>
} }
export function ErrorOverlayLayout({ export function ErrorOverlayLayout({
...@@ -67,45 +66,67 @@ export function ErrorOverlayLayout({ ...@@ -67,45 +66,67 @@ export function ErrorOverlayLayout({
setActiveIndex, setActiveIndex,
footerMessage, footerMessage,
isTurbopack, isTurbopack,
dialogResizerRef,
// This prop is used to animate the dialog, it comes from a parent component (<ErrorOverlay>)
// If it's not being passed, we should just render the component as it is being
// used without the context of a parent component that controls its state (e.g. Storybook).
rendered = true,
transitionDurationMs,
}: ErrorOverlayLayoutProps) { }: ErrorOverlayLayoutProps) {
const animationProps = {
'data-rendered': rendered,
style: {
'--transition-duration': `${transitionDurationMs}ms`,
} as React.CSSProperties,
}
return ( return (
<ErrorOverlayOverlay fixed={isBuildError}> <ErrorOverlayOverlay fixed={isBuildError} {...animationProps}>
<ErrorOverlayDialog onClose={onClose} isTurbopack={isTurbopack}> <div data-nextjs-dialog-root {...animationProps}>
<DialogContent> <ErrorOverlayDialog
<ErrorOverlayFloatingHeader onClose={onClose}
readyErrors={readyErrors} isTurbopack={isTurbopack}
activeIdx={activeIdx} dialogResizerRef={dialogResizerRef}
setActiveIndex={setActiveIndex} >
versionInfo={versionInfo} <DialogContent>
isTurbopack={isTurbopack} <ErrorOverlayFloatingHeader
/> readyErrors={readyErrors}
activeIdx={activeIdx}
setActiveIndex={setActiveIndex}
versionInfo={versionInfo}
isTurbopack={isTurbopack}
/>
<ErrorOverlayDialogHeader isTurbopack={isTurbopack}> <ErrorOverlayDialogHeader isTurbopack={isTurbopack}>
<div <div
className="nextjs__container_errors__error_title" className="nextjs__container_errors__error_title"
// allow assertion in tests before error rating is implemented // allow assertion in tests before error rating is implemented
data-nextjs-error-code={errorCode} data-nextjs-error-code={errorCode}
> >
<ErrorTypeLabel errorType={errorType} /> <ErrorTypeLabel errorType={errorType} />
<ErrorOverlayToolbar error={error} debugInfo={debugInfo} /> <ErrorOverlayToolbar error={error} debugInfo={debugInfo} />
</div> </div>
<ErrorMessage errorMessage={errorMessage} /> <ErrorMessage errorMessage={errorMessage} />
</ErrorOverlayDialogHeader> </ErrorOverlayDialogHeader>
<ErrorOverlayDialogBody>{children}</ErrorOverlayDialogBody> <ErrorOverlayDialogBody>{children}</ErrorOverlayDialogBody>
<DialogFooter> {(footerMessage || errorCode) && (
<ErrorOverlayFooter <DialogFooter>
footerMessage={footerMessage} <ErrorOverlayFooter
errorCode={errorCode} footerMessage={footerMessage}
/> errorCode={errorCode}
<ErrorOverlayBottomStacks />
errorsCount={readyErrors?.length ?? 0} </DialogFooter>
)}
<ErrorOverlayBottomStack
count={readyErrors?.length ?? 0}
activeIdx={activeIdx ?? 0} activeIdx={activeIdx ?? 0}
/> />
</DialogFooter> </DialogContent>
</DialogContent> </ErrorOverlayDialog>
</ErrorOverlayDialog> </div>
</ErrorOverlayOverlay> </ErrorOverlayOverlay>
) )
} }
......
...@@ -33,7 +33,6 @@ export function ErrorOverlayPagination({ ...@@ -33,7 +33,6 @@ export function ErrorOverlayPagination({
const buttonLeft = useRef<HTMLButtonElement | null>(null) const buttonLeft = useRef<HTMLButtonElement | null>(null)
const buttonRight = useRef<HTMLButtonElement | null>(null) const buttonRight = useRef<HTMLButtonElement | null>(null)
const buttonClose = useRef<HTMLButtonElement | null>(null)
const [nav, setNav] = useState<HTMLElement | null>(null) const [nav, setNav] = useState<HTMLElement | null>(null)
const onNav = useCallback((el: HTMLElement) => { const onNav = useCallback((el: HTMLElement) => {
...@@ -63,18 +62,6 @@ export function ErrorOverlayPagination({ ...@@ -63,18 +62,6 @@ export function ErrorOverlayPagination({
buttonRight.current.focus() buttonRight.current.focus()
} }
handleNext && handleNext() handleNext && handleNext()
} else if (e.key === 'Escape') {
e.preventDefault()
e.stopPropagation()
if (root instanceof ShadowRoot) {
const a = root.activeElement
if (a && a !== buttonClose.current && a instanceof HTMLElement) {
a.blur()
return
}
}
close?.()
} }
} }
...@@ -159,6 +146,7 @@ export function ErrorOverlayPagination({ ...@@ -159,6 +146,7 @@ export function ErrorOverlayPagination({
export const styles = css` export const styles = css`
.error-overlay-pagination { .error-overlay-pagination {
-webkit-font-smoothing: antialiased;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
...@@ -166,9 +154,9 @@ export const styles = css` ...@@ -166,9 +154,9 @@ export const styles = css`
padding: 4px; padding: 4px;
gap: 8px; gap: 8px;
background: var(--color-background-100); background: var(--color-background-100);
box-shadow: var(--shadow-sm); background-clip: padding-box;
box-shadow: var(--shadow-small);
border: 1px solid var(--color-gray-400); border: 1px solid var(--color-gray-alpha-400);
border-radius: var(--rounded-full); border-radius: var(--rounded-full);
} }
...@@ -178,6 +166,7 @@ export const styles = css` ...@@ -178,6 +166,7 @@ export const styles = css`
font-size: var(--size-font-small); font-size: var(--size-font-small);
font-weight: 500; font-weight: 500;
line-height: 16px; line-height: 16px;
font-variant-numeric: tabular-nums;
} }
.error-overlay-pagination-button { .error-overlay-pagination-button {
......
...@@ -37,17 +37,16 @@ export const styles = css` ...@@ -37,17 +37,16 @@ export const styles = css`
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin: 0; width: 32px;
width: var(--size-8); height: 32px;
padding: var(--size-1_5);
background: var(--color-background-100); background: var(--color-background-100);
box-shadow: var(--shadow-sm); background-clip: padding-box;
border: 1px solid var(--color-gray-alpha-400);
box-shadow: var(--shadow-small);
border-radius: var(--rounded-full); border-radius: var(--rounded-full);
border: 1px solid var(--color-gray-400);
&:focus { &:focus {
outline: none; outline: var(--focus-ring);
} }
&:not(:disabled):hover { &:not(:disabled):hover {
...@@ -59,7 +58,6 @@ export const styles = css` ...@@ -59,7 +58,6 @@ export const styles = css`
} }
&:disabled { &:disabled {
opacity: 0.7;
cursor: not-allowed; cursor: not-allowed;
} }
} }
......
...@@ -3,8 +3,18 @@ import type { OverlayState } from '../../../../../shared' ...@@ -3,8 +3,18 @@ import type { OverlayState } from '../../../../../shared'
import { BuildError } from '../../../container/build-error' import { BuildError } from '../../../container/build-error'
import { Errors } from '../../../container/errors' import { Errors } from '../../../container/errors'
import { RootLayoutMissingTagsError } from '../../../container/root-layout-missing-tags-error' import { RootLayoutMissingTagsError } from '../../../container/root-layout-missing-tags-error'
import { useDelayedRender } from '../../../hooks/use-delayed-render'
import type { ReadyRuntimeError } from '../../../../../internal/helpers/get-error-by-type' import type { ReadyRuntimeError } from '../../../../../internal/helpers/get-error-by-type'
const transitionDurationMs = 200
export interface ErrorBaseProps {
rendered: boolean
transitionDurationMs: number
isTurbopack: boolean
versionInfo: OverlayState['versionInfo']
}
export function ErrorOverlay({ export function ErrorOverlay({
state, state,
readyErrors, readyErrors,
...@@ -18,24 +28,29 @@ export function ErrorOverlay({ ...@@ -18,24 +28,29 @@ export function ErrorOverlay({
}) { }) {
const isTurbopack = !!process.env.TURBOPACK const isTurbopack = !!process.env.TURBOPACK
// This hook lets us do an exit animation before unmounting the component
const { mounted, rendered } = useDelayedRender(isErrorOverlayOpen, {
exitDelay: transitionDurationMs,
})
const commonProps = {
rendered,
transitionDurationMs,
isTurbopack,
versionInfo: state.versionInfo,
}
if (!!state.rootLayoutMissingTags?.length) { if (!!state.rootLayoutMissingTags?.length) {
return ( return (
<RootLayoutMissingTagsError <RootLayoutMissingTagsError
isTurbopack={isTurbopack}
missingTags={state.rootLayoutMissingTags} missingTags={state.rootLayoutMissingTags}
versionInfo={state.versionInfo} {...commonProps}
/> />
) )
} }
if (state.buildError !== null) { if (state.buildError !== null) {
return ( return <BuildError message={state.buildError} {...commonProps} />
<BuildError
isTurbopack={isTurbopack}
message={state.buildError}
versionInfo={state.versionInfo}
/>
)
} }
// No Runtime Errors. // No Runtime Errors.
...@@ -43,19 +58,18 @@ export function ErrorOverlay({ ...@@ -43,19 +58,18 @@ export function ErrorOverlay({
return null return null
} }
if (!isErrorOverlayOpen) { if (!mounted) {
return null return null
} }
return ( return (
<Errors <Errors
debugInfo={state.debugInfo} debugInfo={state.debugInfo}
isTurbopack={isTurbopack}
readyErrors={readyErrors} readyErrors={readyErrors}
versionInfo={state.versionInfo}
onClose={() => { onClose={() => {
setIsErrorOverlayOpen(false) setIsErrorOverlayOpen(false)
}} }}
{...commonProps}
/> />
) )
} }
...@@ -26,7 +26,6 @@ export const styles = css` ...@@ -26,7 +26,6 @@ export const styles = css`
.nextjs__container_errors_label { .nextjs__container_errors_label {
padding: var(--size-0_5) var(--size-1_5); padding: var(--size-0_5) var(--size-1_5);
margin: 0; margin: 0;
margin-bottom: var(--size-3);
/* used --size instead of --rounded because --rounded is missing 6px */ /* used --size instead of --rounded because --rounded is missing 6px */
border-radius: var(--size-1_5); border-radius: var(--size-1_5);
background: var(--color-red-100); background: var(--color-red-100);
......
...@@ -12,6 +12,7 @@ const Overlay: React.FC<OverlayProps> = function Overlay({ ...@@ -12,6 +12,7 @@ const Overlay: React.FC<OverlayProps> = function Overlay({
className, className,
children, children,
fixed, fixed,
...props
}) { }) {
React.useEffect(() => { React.useEffect(() => {
lock() lock()
...@@ -37,7 +38,12 @@ const Overlay: React.FC<OverlayProps> = function Overlay({ ...@@ -37,7 +38,12 @@ const Overlay: React.FC<OverlayProps> = function Overlay({
}, [overlay]) }, [overlay])
return ( return (
<div data-nextjs-dialog-overlay className={className} ref={onOverlay}> <div
data-nextjs-dialog-overlay
className={className}
ref={onOverlay}
{...props}
>
<div <div
data-nextjs-dialog-backdrop data-nextjs-dialog-backdrop
data-nextjs-dialog-backdrop-fixed={fixed ? true : undefined} data-nextjs-dialog-backdrop-fixed={fixed ? true : undefined}
......
...@@ -7,7 +7,6 @@ const styles = css` ...@@ -7,7 +7,6 @@ const styles = css`
right: 0; right: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
overflow: auto;
z-index: 9000; z-index: 9000;
display: flex; display: flex;
...@@ -30,6 +29,7 @@ const styles = css` ...@@ -30,6 +29,7 @@ const styles = css`
bottom: 0; bottom: 0;
left: 0; left: 0;
background-color: var(--color-backdrop); background-color: var(--color-backdrop);
backdrop-filter: blur(10px);
pointer-events: all; pointer-events: all;
z-index: -1; z-index: -1;
} }
......
...@@ -89,24 +89,25 @@ export const Terminal: React.FC<TerminalProps> = function Terminal({ ...@@ -89,24 +89,25 @@ export const Terminal: React.FC<TerminalProps> = function Terminal({
column: file?.location?.column ?? null, column: file?.location?.column ?? null,
} }
const fileExtension = stackFrame?.file?.split('.').pop()
return ( return (
<div data-nextjs-terminal> <div data-nextjs-terminal>
<div className="terminal-header"> <button
<p aria-label="Open in editor"
role="link" className="code-frame-header"
onClick={open} onClick={open}
tabIndex={1} >
title="Click to open in your editor" <div className="code-frame-link">
> <span className="code-frame-icon">
<span> <FileIcon lang={fileExtension} />
<FileIcon />
{getFrameSource(stackFrame)} {getFrameSource(stackFrame)}
{/* TODO: Unlike the CodeFrame component, the `methodName` is unavailable. */} {/* TODO: Unlike the CodeFrame component, the `methodName` is unavailable. */}
</span> </span>
<ExternalIcon width={16} height={16} /> <ExternalIcon width={16} height={16} />
</p> </div>
</div> </button>
<pre> <pre className="code-frame-pre">
{decoded.map((entry, index) => ( {decoded.map((entry, index) => (
<span <span
key={`terminal-entry-${index}`} key={`terminal-entry-${index}`}
...@@ -136,11 +137,6 @@ export const Terminal: React.FC<TerminalProps> = function Terminal({ ...@@ -136,11 +137,6 @@ export const Terminal: React.FC<TerminalProps> = function Terminal({
export const TERMINAL_STYLES = css` export const TERMINAL_STYLES = css`
[data-nextjs-terminal] { [data-nextjs-terminal] {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
flex: 1 0 0;
background-color: var(--color-background-200); background-color: var(--color-background-200);
overflow: hidden; overflow: hidden;
color: var(--color-gray-1000); color: var(--color-gray-1000);
...@@ -150,13 +146,13 @@ export const TERMINAL_STYLES = css` ...@@ -150,13 +146,13 @@ export const TERMINAL_STYLES = css`
line-height: 16px; line-height: 16px;
} }
[data-nextjs-terminal] pre { .code-frame-link {
white-space: pre-wrap; padding: 12px;
} }
.terminal-header { .terminal-source {
border-top: 1px solid var(--color-gray-400); display: flex;
border-bottom: 1px solid var(--color-gray-400); align-items: center;
} }
[data-nextjs-terminal]::selection, [data-nextjs-terminal]::selection,
...@@ -170,12 +166,6 @@ export const TERMINAL_STYLES = css` ...@@ -170,12 +166,6 @@ export const TERMINAL_STYLES = css`
font-family: var(--font-stack-monospace); font-family: var(--font-stack-monospace);
} }
[data-nextjs-terminal] > * {
margin: 0;
padding: calc(var(--size-gap) + var(--size-gap-half))
calc(var(--size-gap-double) + var(--size-gap-half));
}
[data-nextjs-terminal] > div > p { [data-nextjs-terminal] > div > p {
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -190,9 +180,4 @@ export const TERMINAL_STYLES = css` ...@@ -190,9 +180,4 @@ export const TERMINAL_STYLES = css`
overflow: hidden; overflow: hidden;
display: inline-block; display: inline-block;
} }
[data-nextjs-terminal] svg {
color: var(--color-gray-900);
margin-right: 6px;
}
` `
...@@ -80,20 +80,22 @@ export function getStaleness({ installed, staleness, expected }: VersionInfo) { ...@@ -80,20 +80,22 @@ export function getStaleness({ installed, staleness, expected }: VersionInfo) {
export const styles = css` export const styles = css`
.nextjs-container-build-error-version-status { .nextjs-container-build-error-version-status {
-webkit-font-smoothing: antialiased;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
gap: var(--size-1); gap: var(--size-1);
padding: var(--size-1_5) var(--size-2); height: 28px;
padding: 6px 8px 6px 6px;
background: var(--color-background-100); background: var(--color-background-100);
box-shadow: var(--shadow-sm); background-clip: padding-box;
box-shadow: var(--shadow-small);
border: 1px solid var(--color-gray-400); border: 1px solid var(--color-gray-alpha-400);
border-radius: var(--rounded-full); border-radius: var(--rounded-full);
color: var(--color-gray-900); color: var(--color-gray-900);
font-size: var(--size-font-11); font-size: 12px;
font-weight: 500; font-weight: 500;
line-height: var(--size-4); line-height: var(--size-4);
} }
......
import * as React from 'react' import * as React from 'react'
import type { VersionInfo } from '../../../../../../server/dev/parse-version-info'
import { Terminal } from '../components/terminal' import { Terminal } from '../components/terminal'
import { noop as css } from '../helpers/noop-template' import { noop as css } from '../helpers/noop-template'
import { ErrorOverlayLayout } from '../components/errors/error-overlay-layout/error-overlay-layout' import { ErrorOverlayLayout } from '../components/errors/error-overlay-layout/error-overlay-layout'
import type { ErrorBaseProps } from '../components/errors/error-overlay/error-overlay'
export type BuildErrorProps = { export interface BuildErrorProps extends ErrorBaseProps {
message: string message: string
isTurbopack: boolean
versionInfo?: VersionInfo
} }
export const BuildError: React.FC<BuildErrorProps> = function BuildError({ export const BuildError: React.FC<BuildErrorProps> = function BuildError({
message, message,
versionInfo, ...props
isTurbopack,
}) { }) {
const noop = React.useCallback(() => {}, []) const noop = React.useCallback(() => {}, [])
return ( return (
...@@ -21,9 +18,8 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({ ...@@ -21,9 +18,8 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({
errorType="Build Error" errorType="Build Error"
errorMessage="Failed to compile" errorMessage="Failed to compile"
onClose={noop} onClose={noop}
versionInfo={versionInfo}
footerMessage="This error occurred during the build process and can only be dismissed by fixing the error." footerMessage="This error occurred during the build process and can only be dismissed by fixing the error."
isTurbopack={isTurbopack} {...props}
> >
<Terminal content={message} /> <Terminal content={message} />
</ErrorOverlayLayout> </ErrorOverlayLayout>
......
...@@ -41,21 +41,58 @@ const originalStackFrame = { ...@@ -41,21 +41,58 @@ const originalStackFrame = {
ignored: false, ignored: false,
} }
const frame = {
originalStackFrame: {
file: './app/page.tsx',
methodName: 'MyComponent',
arguments: [],
lineNumber: 10,
column: 5,
ignored: false,
},
sourceStackFrame: {
file: './app/page.tsx',
methodName: 'MyComponent',
arguments: [],
lineNumber: 10,
column: 5,
},
originalCodeFrame: 'export default function MyComponent() {',
error: false,
reason: null,
external: false,
ignored: false,
}
const ignoredFrame = {
...frame,
ignored: true,
}
const readyErrors: ReadyRuntimeError[] = [ const readyErrors: ReadyRuntimeError[] = [
{ {
id: 1, id: 1,
runtime: true, runtime: true,
error: new Error('First error message'), error: new Error('First error message'),
frames: [ frames: [
frame,
{ {
error: true, ...frame,
reason: 'First error message', originalStackFrame: {
external: false, ...frame.originalStackFrame,
ignored: false, methodName: 'ParentComponent',
sourceStackFrame, lineNumber: 5,
originalStackFrame, },
originalCodeFrame: originalCodeFrame('First error message'), },
{
...frame,
originalStackFrame: {
...frame.originalStackFrame,
methodName: 'GrandparentComponent',
lineNumber: 1,
},
}, },
...Array(20).fill(ignoredFrame),
], ],
}, },
{ {
......
import { useState, useMemo, useEffect } from 'react' import { useState, useMemo, useEffect, useRef } from 'react'
import type { DebugInfo } from '../../../types' import type { DebugInfo } from '../../../types'
import { Overlay } from '../components/overlay' import { Overlay } from '../components/overlay'
import { noop as css } from '../helpers/noop-template' import { noop as css } from '../helpers/noop-template'
import { RuntimeError } from './runtime-error' import { RuntimeError } from './runtime-error'
import type { VersionInfo } from '../../../../../../server/dev/parse-version-info'
import { getErrorSource } from '../../../../../../shared/lib/error-source' import { getErrorSource } from '../../../../../../shared/lib/error-source'
import { HotlinkedText } from '../components/hot-linked-text' import { HotlinkedText } from '../components/hot-linked-text'
import { PseudoHtmlDiff } from './runtime-error/component-stack-pseudo-html' import { PseudoHtmlDiff } from './runtime-error/component-stack-pseudo-html'
...@@ -18,11 +17,10 @@ import { ...@@ -18,11 +17,10 @@ import {
import { extractNextErrorCode } from '../../../../../../lib/error-telemetry-utils' import { extractNextErrorCode } from '../../../../../../lib/error-telemetry-utils'
import { ErrorOverlayLayout } from '../components/errors/error-overlay-layout/error-overlay-layout' import { ErrorOverlayLayout } from '../components/errors/error-overlay-layout/error-overlay-layout'
import type { ReadyRuntimeError } from '../../../internal/helpers/get-error-by-type' import type { ReadyRuntimeError } from '../../../internal/helpers/get-error-by-type'
import type { ErrorBaseProps } from '../components/errors/error-overlay/error-overlay'
export type ErrorsProps = { export interface ErrorsProps extends ErrorBaseProps {
readyErrors: ReadyRuntimeError[] readyErrors: ReadyRuntimeError[]
isTurbopack: boolean
versionInfo: VersionInfo
debugInfo: DebugInfo debugInfo: DebugInfo
onClose: () => void onClose: () => void
} }
...@@ -74,10 +72,11 @@ function ErrorDescription({ ...@@ -74,10 +72,11 @@ function ErrorDescription({
export function Errors({ export function Errors({
readyErrors, readyErrors,
debugInfo, debugInfo,
versionInfo,
isTurbopack,
onClose, onClose,
...props
}: ErrorsProps) { }: ErrorsProps) {
const dialogResizerRef = useRef<HTMLDivElement | null>(null)
useEffect(() => { useEffect(() => {
// Close the error overlay when pressing escape // Close the error overlay when pressing escape
function handleKeyDown(event: KeyboardEvent) { function handleKeyDown(event: KeyboardEvent) {
...@@ -157,8 +156,8 @@ export function Errors({ ...@@ -157,8 +156,8 @@ export function Errors({
activeIdx={activeIdx} activeIdx={activeIdx}
setActiveIndex={setActiveIndex} setActiveIndex={setActiveIndex}
footerMessage={footerMessage} footerMessage={footerMessage}
versionInfo={versionInfo} dialogResizerRef={dialogResizerRef}
isTurbopack={isTurbopack} {...props}
> >
<div className="error-overlay-notes-container"> <div className="error-overlay-notes-container">
{notes ? ( {notes ? (
...@@ -193,7 +192,11 @@ export function Errors({ ...@@ -193,7 +192,11 @@ export function Errors({
reactOutputComponentDiff={errorDetails.reactOutputComponentDiff} reactOutputComponentDiff={errorDetails.reactOutputComponentDiff}
/> />
) : null} ) : null}
<RuntimeError key={activeError.id.toString()} error={activeError} /> <RuntimeError
key={activeError.id.toString()}
error={activeError}
dialogResizerRef={dialogResizerRef}
/>
</ErrorOverlayLayout> </ErrorOverlayLayout>
) )
} }
...@@ -203,6 +206,8 @@ export const styles = css` ...@@ -203,6 +206,8 @@ export const styles = css`
bottom: calc(var(--size-gap-double) * 4.5); bottom: calc(var(--size-gap-double) * 4.5);
} }
p.nextjs__container_errors__link { p.nextjs__container_errors__link {
color: var(--color-red-900);
font-weight: 600;
font-size: 14px; font-size: 14px;
} }
p.nextjs__container_errors__notes { p.nextjs__container_errors__notes {
......
import type { VersionInfo } from '../../../../../../server/dev/parse-version-info'
import { useCallback } from 'react' import { useCallback } from 'react'
import { HotlinkedText } from '../components/hot-linked-text' import { HotlinkedText } from '../components/hot-linked-text'
import { ErrorOverlayLayout } from '../components/errors/error-overlay-layout/error-overlay-layout' import { ErrorOverlayLayout } from '../components/errors/error-overlay-layout/error-overlay-layout'
import type { ErrorBaseProps } from '../components/errors/error-overlay/error-overlay'
type RootLayoutMissingTagsErrorProps = { interface RootLayoutMissingTagsErrorProps extends ErrorBaseProps {
missingTags: string[] missingTags: string[]
isTurbopack: boolean
versionInfo?: VersionInfo
} }
export function RootLayoutMissingTagsError({ export function RootLayoutMissingTagsError({
missingTags, missingTags,
isTurbopack, ...props
versionInfo,
}: RootLayoutMissingTagsErrorProps) { }: RootLayoutMissingTagsErrorProps) {
const noop = useCallback(() => {}, []) const noop = useCallback(() => {}, [])
return ( return (
...@@ -28,8 +25,7 @@ export function RootLayoutMissingTagsError({ ...@@ -28,8 +25,7 @@ export function RootLayoutMissingTagsError({
/> />
} }
onClose={noop} onClose={noop}
versionInfo={versionInfo} {...props}
isTurbopack={isTurbopack}
/> />
) )
} }
...@@ -3,11 +3,14 @@ import { CodeFrame } from '../../components/code-frame/code-frame' ...@@ -3,11 +3,14 @@ import { CodeFrame } from '../../components/code-frame/code-frame'
import { CallStack } from '../../components/errors/call-stack/call-stack' import { CallStack } from '../../components/errors/call-stack/call-stack'
import { noop as css } from '../../helpers/noop-template' import { noop as css } from '../../helpers/noop-template'
import { PSEUDO_HTML_DIFF_STYLES } from './component-stack-pseudo-html' import { PSEUDO_HTML_DIFF_STYLES } from './component-stack-pseudo-html'
import type { ReadyRuntimeError } from '../../../../internal/helpers/get-error-by-type' import type { ReadyRuntimeError } from '../../../../internal/helpers/get-error-by-type'
export type RuntimeErrorProps = { error: ReadyRuntimeError }
export function RuntimeError({ error }: RuntimeErrorProps) { export type RuntimeErrorProps = {
error: ReadyRuntimeError
dialogResizerRef: React.RefObject<HTMLDivElement | null>
}
export function RuntimeError({ error, dialogResizerRef }: RuntimeErrorProps) {
const firstFrame = useMemo(() => { const firstFrame = useMemo(() => {
const firstFirstPartyFrameIndex = error.frames.findIndex( const firstFirstPartyFrameIndex = error.frames.findIndex(
(entry) => (entry) =>
...@@ -28,7 +31,9 @@ export function RuntimeError({ error }: RuntimeErrorProps) { ...@@ -28,7 +31,9 @@ export function RuntimeError({ error }: RuntimeErrorProps) {
/> />
)} )}
{error.frames.length > 0 && <CallStack frames={error.frames} />} {error.frames.length > 0 && (
<CallStack dialogResizerRef={dialogResizerRef} frames={error.frames} />
)}
</> </>
) )
} }
......
import { useState, useRef, useCallback, useEffect } from 'react'
interface Options {
enterDelay?: number
exitDelay?: number
onUnmount?: () => void
}
/**
* Useful to perform CSS transitions on React components without
* using libraries like Framer Motion. This hook will defer the
* unmount of a React component until after a delay.
*
* @param active - Whether the component should be rendered
* @param options - Options for the delayed render
* @param options.enterDelay - Delay before rendering the component
* @param options.exitDelay - Delay before unmounting the component
*
* const Modal = ({ active }) => {
* const { mounted, rendered } = useDelayedRender(active, {
* exitDelay: 2000,
* })
*
* if (!mounted) return null
*
* return (
* <Portal>
* <div className={rendered ? 'modal visible' : 'modal'}>...</div>
* </Portal>
* )
*}
*
* */
export function useDelayedRender(active = false, options: Options = {}) {
const [mounted, setMounted] = useState(active)
const [rendered, setRendered] = useState(false)
const renderTimerRef = useRef<number | null>(null)
const unmountTimerRef = useRef<number | null>(null)
const clearTimers = useCallback(() => {
if (renderTimerRef.current !== null) {
window.clearTimeout(renderTimerRef.current)
renderTimerRef.current = null
}
if (unmountTimerRef.current !== null) {
window.clearTimeout(unmountTimerRef.current)
unmountTimerRef.current = null
}
}, [])
useEffect(() => {
const { enterDelay = 1, exitDelay = 0 } = options
clearTimers()
if (active) {
setMounted(true)
if (enterDelay <= 0) {
setRendered(true)
} else {
renderTimerRef.current = window.setTimeout(() => {
setRendered(true)
}, enterDelay)
}
} else {
setRendered(false)
if (exitDelay <= 0) {
setMounted(false)
} else {
unmountTimerRef.current = window.setTimeout(() => {
setMounted(false)
}, exitDelay)
}
}
return clearTimers
}, [active, options, clearTimers])
return { mounted, rendered }
}
import { useEffect, useState } from 'react'
export function useMeasureHeight(
ref: React.RefObject<HTMLDivElement | null>
): [number, boolean] {
const [pristine, setPristine] = useState<boolean>(true)
const [height, setHeight] = useState<number>(0)
useEffect(() => {
const el = ref.current
if (!el) {
return
}
const observer = new ResizeObserver(() => {
const { height: h } = el.getBoundingClientRect()
setHeight((prevHeight) => {
if (prevHeight !== 0) {
setPristine(false)
}
return h
})
})
observer.observe(el)
return () => {
observer.disconnect()
setPristine(true)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
return [height, pristine]
}
...@@ -5,7 +5,7 @@ export function Base() { ...@@ -5,7 +5,7 @@ export function Base() {
return ( return (
<style> <style>
{css` {css`
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;900&family=Geist+Mono:wght@400;900&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600&family=Geist+Mono:wght@400;500;600&display=swap');
:host { :host {
${ ${
...@@ -32,7 +32,7 @@ export function Base() { ...@@ -32,7 +32,7 @@ export function Base() {
--color-background: white; --color-background: white;
--color-font: #757575; --color-font: #757575;
--color-backdrop: rgba(17, 17, 17, 0.2); --color-backdrop: rgba(250, 250, 250, 0.8);
--color-border-shadow: rgba(0, 0, 0, 0.145); --color-border-shadow: rgba(0, 0, 0, 0.145);
--color-title-color: #1f1f1f; --color-title-color: #1f1f1f;
...@@ -74,6 +74,12 @@ export function Base() { ...@@ -74,6 +74,12 @@ export function Base() {
0px 4px 8px -4px rgba(0, 0, 0, 0.04), 0px 4px 8px -4px rgba(0, 0, 0, 0.04),
0px 16px 24px -8px rgba(0, 0, 0, 0.06); 0px 16px 24px -8px rgba(0, 0, 0, 0.06);
--focus-color: var(--color-blue-800);
--focus-ring: 2px solid var(--focus-color);
--timing-swift: cubic-bezier(0.23, 0.88, 0.26, 0.92);
--timing-overlay: cubic-bezier(0.175, 0.885, 0.32, 1.1);
--rounded-none: 0px; --rounded-none: 0px;
--rounded-sm: 0.125rem; /* 2px */ --rounded-sm: 0.125rem; /* 2px */
--rounded-md: 0.25rem; /* 4px */ --rounded-md: 0.25rem; /* 4px */
...@@ -115,7 +121,7 @@ export function Base() { ...@@ -115,7 +121,7 @@ export function Base() {
:host { :host {
--color-background: rgb(28, 28, 30); --color-background: rgb(28, 28, 30);
--color-font: white; --color-font: white;
--color-backdrop: rgb(44, 44, 46); --color-backdrop: rgb(0, 0, 0, 0.8);
--color-border-shadow: rgba(255, 255, 255, 0.145); --color-border-shadow: rgba(255, 255, 255, 0.145);
--color-title-color: #fafafa; --color-title-color: #fafafa;
......
import { CODE_FRAME_STYLES } from '../components/code-frame/code-frame' import { CODE_FRAME_STYLES } from '../components/code-frame/code-frame'
import { styles as dialog } from '../components/dialog' import { styles as dialog } from '../components/dialog'
import { styles as errorLayout } from '../components/errors/error-overlay-layout/error-overlay-layout' import { styles as errorLayout } from '../components/errors/error-overlay-layout/error-overlay-layout'
import { styles as bottomStacks } from '../components/errors/error-overlay-bottom-stacks/error-overlay-bottom-stacks' import { styles as bottomStack } from '../components/errors/error-overlay-bottom-stack'
import { styles as pagination } from '../components/errors/error-overlay-pagination/error-overlay-pagination' import { styles as pagination } from '../components/errors/error-overlay-pagination/error-overlay-pagination'
import { styles as overlay } from '../components/overlay/styles' import { styles as overlay } from '../components/overlay/styles'
import { styles as footer } from '../components/errors/error-overlay-footer/error-overlay-footer' import { styles as footer } from '../components/errors/error-overlay-footer/error-overlay-footer'
...@@ -28,7 +28,7 @@ export function ComponentStyles() { ...@@ -28,7 +28,7 @@ export function ComponentStyles() {
${dialog} ${dialog}
${errorLayout} ${errorLayout}
${footer} ${footer}
${bottomStacks} ${bottomStack}
${pagination} ${pagination}
${CODE_FRAME_STYLES} ${CODE_FRAME_STYLES}
${TERMINAL_STYLES} ${TERMINAL_STYLES}
......
...@@ -11,13 +11,6 @@ describe('app-dir - async-client-component', () => { ...@@ -11,13 +11,6 @@ describe('app-dir - async-client-component', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
it('app router server component async module', async () => {
const browser = await next.browser('/server')
await assertNoRedbox(browser)
expect(await browser.elementByCss('#app-router-value').text()).toBe('hello')
})
it('app router client component async module', async () => { it('app router client component async module', async () => {
const browser = await next.browser('/client') const browser = await next.browser('/client')
...@@ -39,4 +32,12 @@ describe('app-dir - async-client-component', () => { ...@@ -39,4 +32,12 @@ describe('app-dir - async-client-component', () => {
} }
`) `)
}) })
it('app router server component async module', async () => {
const browser = await next.browser('/server')
await assertNoRedbox(browser)
expect(await browser.elementByCss('#app-router-value').text()).toBe('hello')
})
}) })
...@@ -24,21 +24,21 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -24,21 +24,21 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at span (<anonymous> (0:0)) "at span (<anonymous> (0:0))
at <anonymous> (app/rsc/page.tsx (7:10)) at <anonymous> (app/rsc/page.tsx (7:10))
at Page (app/rsc/page.tsx (6:13))" at Page (app/rsc/page.tsx (6:13))"
`) `)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.tsx (7:10) @ <anonymous> "app/rsc/page.tsx (7:10) @ <anonymous>
5 | <div> 5 | <div>
6 | {list.map((item, index) => ( 6 | {list.map((item, index) => (
> 7 | <span>{item}</span> > 7 | <span>{item}</span>
| ^ | ^
8 | ))} 8 | ))}
9 | </div> 9 | </div>
10 | )" 10 | )"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at span (<anonymous> (0:0)) "at span (<anonymous> (0:0))
......
...@@ -28,64 +28,63 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => { ...@@ -28,64 +28,63 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => {
if (isNewDevOverlay) { if (isNewDevOverlay) {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(redbox.source).toMatchInlineSnapshot(` expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js (3:23) "./app/page.js (3:23)
Ecmascript file had an error Ecmascript file had an error
1 | import dynamic from 'next/dynamic' 1 | import dynamic from 'next/dynamic'
2 | 2 |
> 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false }) > 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | 4 |
5 | export default function Page() { 5 | export default function Page() {
6 | return <DynamicClient /> 6 | return <DynamicClient />
\`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component." \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component."
`) `)
} else { } else {
expect(redbox.source).toMatchInlineSnapshot(` expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js "./app/page.js
Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component.
Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component. ,-[3:1]
,-[3:1] 1 | import dynamic from 'next/dynamic'
1 | import dynamic from 'next/dynamic' 2 |
2 | 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false }) : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 |
4 | 5 | export default function Page() {
5 | export default function Page() { 6 | return <DynamicClient />
6 | return <DynamicClient /> \`----"
\`----" `)
`)
} }
} else { } else {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(redbox.source).toMatchInlineSnapshot(` expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js:3:23 "./app/page.js:3:23
Ecmascript file had an error Ecmascript file had an error
1 | import dynamic from 'next/dynamic' 1 | import dynamic from 'next/dynamic'
2 | 2 |
> 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false }) > 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | 4 |
5 | export default function Page() { 5 | export default function Page() {
6 | return <DynamicClient /> 6 | return <DynamicClient />
\`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component." \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component."
`) `)
} else { } else {
expect(redbox.source).toMatchInlineSnapshot(` expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js "./app/page.js
Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component. Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component.
,-[3:1] ,-[3:1]
1 | import dynamic from 'next/dynamic' 1 | import dynamic from 'next/dynamic'
2 | 2 |
3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false }) 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | 4 |
5 | export default function Page() { 5 | export default function Page() {
6 | return <DynamicClient /> 6 | return <DynamicClient />
\`----" \`----"
`) `)
} }
} }
}) })
......
...@@ -397,55 +397,54 @@ describe('react-dom/server in React Server environment', () => { ...@@ -397,55 +397,54 @@ describe('react-dom/server in React Server environment', () => {
// TODO(jiwon): Remove this once we have a new dev overlay at stable. // TODO(jiwon): Remove this once we have a new dev overlay at stable.
if (isNewDevOverlay) { if (isNewDevOverlay) {
expect(redbox).toMatchInlineSnapshot(` expect(redbox).toMatchInlineSnapshot(`
{ {
"description": "Failed to compile", "description": "Failed to compile",
"source": "./app/exports/app-code/react-dom-server-node-implicit/page.js "source": "./app/exports/app-code/react-dom-server-node-implicit/page.js
Error: x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
Error: x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering ,-[1:1]
,-[1:1] 1 | import * as ReactDOMServerNode from 'react-dom/server'
1 | import * as ReactDOMServerNode from 'react-dom/server' : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | // Fine to drop once React is on ESM
2 | // Fine to drop once React is on ESM 3 | import ReactDOMServerNodeDefault from 'react-dom/server'
3 | import ReactDOMServerNodeDefault from 'react-dom/server' \`----
\`---- x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering ,-[3:1]
,-[3:1] 1 | import * as ReactDOMServerNode from 'react-dom/server'
1 | import * as ReactDOMServerNode from 'react-dom/server' 2 | // Fine to drop once React is on ESM
2 | // Fine to drop once React is on ESM 3 | import ReactDOMServerNodeDefault from 'react-dom/server'
3 | import ReactDOMServerNodeDefault from 'react-dom/server' : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 |
4 | 5 | export const runtime = 'nodejs'
5 | export const runtime = 'nodejs' \`----",
\`----", }
} `)
`)
} else { } else {
expect(redbox).toMatchInlineSnapshot(` expect(redbox).toMatchInlineSnapshot(`
{ {
"description": "Failed to compile", "description": "Failed to compile",
"source": "./app/exports/app-code/react-dom-server-node-implicit/page.js "source": "./app/exports/app-code/react-dom-server-node-implicit/page.js
Error: x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. Error: x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
,-[1:1] ,-[1:1]
1 | import * as ReactDOMServerNode from 'react-dom/server' 1 | import * as ReactDOMServerNode from 'react-dom/server'
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | // Fine to drop once React is on ESM 2 | // Fine to drop once React is on ESM
3 | import ReactDOMServerNodeDefault from 'react-dom/server' 3 | import ReactDOMServerNodeDefault from 'react-dom/server'
\`---- \`----
x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
,-[3:1] ,-[3:1]
1 | import * as ReactDOMServerNode from 'react-dom/server' 1 | import * as ReactDOMServerNode from 'react-dom/server'
2 | // Fine to drop once React is on ESM 2 | // Fine to drop once React is on ESM
3 | import ReactDOMServerNodeDefault from 'react-dom/server' 3 | import ReactDOMServerNodeDefault from 'react-dom/server'
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | 4 |
5 | export const runtime = 'nodejs' 5 | export const runtime = 'nodejs'
\`----", \`----",
} }
`) `)
} }
} }
}) })
......
...@@ -30,66 +30,65 @@ describe('app-dir - error-on-next-codemod-comment', () => { ...@@ -30,66 +30,65 @@ describe('app-dir - error-on-next-codemod-comment', () => {
if (isNewDevOverlay) { if (isNewDevOverlay) {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx (2:2) "./app/page.tsx (2:2)
Ecmascript file had an error Ecmascript file had an error
1 | export default function Page() {
> 2 | // @next-codemod-error remove jsx of next line
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | return <p>hello world</p>
4 | }
5 |
You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can be taken."
`)
} else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx
Error: x You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
| After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can
| be taken.
|
,-[2:1]
1 | export default function Page() { 1 | export default function Page() {
> 2 | // @next-codemod-error remove jsx of next line 2 | // @next-codemod-error remove jsx of next line
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | return <p>hello world</p> 3 | return <p>hello world</p>
4 | } 4 | }
5 | \`----"
`)
You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can be taken."
`)
} else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx
Error: x You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
| After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can
| be taken.
|
,-[2:1]
1 | export default function Page() {
2 | // @next-codemod-error remove jsx of next line
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | return <p>hello world</p>
4 | }
\`----"
`)
} }
} else { } else {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx:2:2 "./app/page.tsx:2:2
Ecmascript file had an error Ecmascript file had an error
1 | export default function Page() { 1 | export default function Page() {
> 2 | // @next-codemod-error remove jsx of next line > 2 | // @next-codemod-error remove jsx of next line
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | return <p>hello world</p> 3 | return <p>hello world</p>
4 | } 4 | }
5 | 5 |
You have an unresolved @next/codemod comment "remove jsx of next line" that needs review. You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can be taken." After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can be taken."
`) `)
} else { } else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx "./app/page.tsx
Error: x You have an unresolved @next/codemod comment "remove jsx of next line" that needs review. Error: x You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
| After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can | After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can
| be taken. | be taken.
| |
,-[2:1] ,-[2:1]
1 | export default function Page() { 1 | export default function Page() {
2 | // @next-codemod-error remove jsx of next line 2 | // @next-codemod-error remove jsx of next line
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | return <p>hello world</p> 3 | return <p>hello world</p>
4 | } 4 | }
\`----" \`----"
`) `)
} }
} }
}) })
......
...@@ -108,7 +108,6 @@ describe('use-cache-unknown-cache-kind', () => { ...@@ -108,7 +108,6 @@ describe('use-cache-unknown-cache-kind', () => {
} else { } else {
expect(errorSource).toMatchInlineSnapshot(` expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx "./app/page.tsx
Error: x Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config. Error: x Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config.
| |
,-[1:1] ,-[1:1]
......
...@@ -109,7 +109,6 @@ describe('use-cache-without-experimental-flag', () => { ...@@ -109,7 +109,6 @@ describe('use-cache-without-experimental-flag', () => {
} else { } else {
expect(errorSource).toMatchInlineSnapshot(` expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx "./app/page.tsx
Error: x To use "use cache", please enable the experimental feature flag "useCache" in your Next.js config. Error: x To use "use cache", please enable the experimental feature flag "useCache" in your Next.js config.
| |
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage | Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment