Unverified Commit 48ea532b authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[devtools] Remove unused code (#82299)

parent 8890a5ed
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
parseLineNumberFromCodeFrameLine, parseLineNumberFromCodeFrameLine,
} from './parse-code-frame' } from './parse-code-frame'
export type CodeFrameProps = { type CodeFrameProps = {
stackFrame: StackFrame stackFrame: StackFrame
codeFrame: string codeFrame: string
} }
......
import { useState, useEffect } from 'react'
export function useSessionState<T extends string>(
key: string,
initialValue: T
): [T, (value: T) => void] {
const [value, setValue] = useState<T>(() => {
if (
typeof window !== 'undefined' &&
typeof sessionStorage !== 'undefined'
) {
const stored = sessionStorage.getItem(key)
return (stored as T) ?? initialValue
}
return initialValue
})
useEffect(() => {
if (
typeof window !== 'undefined' &&
typeof sessionStorage !== 'undefined'
) {
sessionStorage.setItem(key, value)
}
}, [key, value])
return [value, setValue]
}
import * as React from 'react' import * as React from 'react'
export type DialogBodyProps = { type DialogBodyProps = {
children?: React.ReactNode children?: React.ReactNode
className?: string className?: string
} & React.HTMLAttributes<HTMLDivElement> } & React.HTMLAttributes<HTMLDivElement>
......
import * as React from 'react' import * as React from 'react'
export type DialogContentProps = { type DialogContentProps = {
children?: React.ReactNode children?: React.ReactNode
className?: string className?: string
} & React.HTMLAttributes<HTMLDivElement> } & React.HTMLAttributes<HTMLDivElement>
......
export type DialogHeaderProps = React.HTMLAttributes<HTMLDivElement> type DialogHeaderProps = React.HTMLAttributes<HTMLDivElement>
export function DialogHeader(props: DialogHeaderProps) { export function DialogHeader(props: DialogHeaderProps) {
return ( return (
......
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'
export type DialogProps = { type DialogProps = {
children?: React.ReactNode children?: React.ReactNode
'aria-labelledby': string 'aria-labelledby': string
'aria-describedby': string 'aria-describedby': string
......
export { Dialog } from './dialog'
export { DialogBody } from './dialog-body' export { DialogBody } from './dialog-body'
export { DialogContent } from './dialog-content' export { DialogContent } from './dialog-content'
export { DialogHeader } from './dialog-header'
export { styles } from './styles' export { styles } from './styles'
import { useRef } from 'react'
import {
MENU_DURATION_MS,
useClickOutsideAndEscape,
useFocusTrap,
} from '../utils'
import { useDelayedRender } from '../../../../hooks/use-delayed-render'
import { css } from '../../../../utils/css'
export interface DevToolsInfoPropsCore {
isOpen: boolean
triggerRef: React.RefObject<HTMLButtonElement | null>
close: () => void
}
export interface DevToolsInfoProps extends DevToolsInfoPropsCore {
title: React.ReactNode
children: React.ReactNode
learnMoreLink?: string
}
export function DevToolsInfo({
title,
children,
learnMoreLink,
isOpen,
triggerRef,
close,
...props
}: DevToolsInfoProps) {
const ref = useRef<HTMLDivElement | null>(null)
const closeButtonRef = useRef<HTMLButtonElement | null>(null)
const { mounted, rendered } = useDelayedRender(isOpen, {
// Intentionally no fade in, makes the UI feel more immediate
enterDelay: 0,
// Graceful fade out to confirm that the UI did not break
exitDelay: MENU_DURATION_MS,
})
useFocusTrap(ref, triggerRef, isOpen, () => {
// Bring focus to close button, so the user can easily close the overlay
closeButtonRef.current?.focus()
})
useClickOutsideAndEscape(ref, triggerRef, mounted, close)
if (!mounted) {
return null
}
return (
<div
tabIndex={-1}
role="dialog"
ref={ref}
data-info-popover
{...props}
data-rendered={rendered}
>
<div className="dev-tools-info-container">
<div className="dev-tools-info-header">
<button
ref={closeButtonRef}
className="dev-tools-info-close-button"
onClick={close}
aria-label="Close dialog"
>
<IconChevronLeft />
</button>
<h3 className="dev-tools-info-title">{title}</h3>
</div>
<div className="dev-tools-info-body">
{children}
{learnMoreLink && (
<div className="dev-tools-info-button-container">
<a
className="dev-tools-info-learn-more-button"
href={learnMoreLink}
target="_blank"
rel="noreferrer noopener"
>
Learn More
</a>
</div>
)}
</div>
</div>
</div>
)
}
export const DEV_TOOLS_INFO_STYLES = css`
[data-info-popover] {
display: flex;
flex-direction: column;
align-items: flex-start;
background: var(--color-background-100);
border: 1px solid var(--color-gray-alpha-400);
background-clip: padding-box;
box-shadow: var(--shadow-menu);
border-radius: var(--rounded-xl);
position: absolute;
font-family: var(--font-stack-sans);
z-index: 3;
overflow: hidden;
opacity: 0;
outline: 0;
min-width: 350px;
transition: opacity var(--animate-out-duration-ms)
var(--animate-out-timing-function);
&[data-rendered='true'] {
opacity: 1;
scale: 1;
}
button:focus-visible {
outline: var(--focus-ring);
}
}
.dev-tools-info-container {
width: 100%;
}
.dev-tools-info-body {
padding: 16px;
}
.dev-tools-info-header {
height: 48px;
display: flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border-bottom: 1px solid var(--color-gray-alpha-400);
}
.dev-tools-info-close-button {
all: unset;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
color: var(--color-gray-900);
transition: color 150ms ease;
translate: 0 1px;
border-radius: 3px;
&:hover {
color: var(--color-gray-1000);
}
}
.dev-tools-info-title {
color: var(--color-gray-1000);
font-size: var(--size-14);
font-weight: 500;
line-height: var(--size-20);
margin: 0;
}
.dev-tools-info-section-title {
padding: 8px 0px;
color: var(--color-gray-1000);
font-size: var(--size-16);
font-weight: 600;
line-height: var(--size-20);
margin: 0;
}
.dev-tools-info-article {
padding: 8px 6px;
color: var(--color-gray-1000);
font-size: var(--size-14);
line-height: var(--size-20);
margin: 0;
}
.dev-tools-info-paragraph {
&:last-child {
margin-bottom: 0;
}
}
.dev-tools-info-button-container {
display: flex;
justify-content: space-between;
align-items: center;
}
.dev-tools-info-learn-more-button {
align-content: center;
padding: 0 8px;
height: var(--size-28);
font-size: var(--size-14);
font-weight: 500;
line-height: var(--size-20);
transition: background var(--duration-short) ease;
color: var(--color-background-100);
border-radius: var(--rounded-md-2);
background: var(--color-gray-1000);
margin-left: auto;
}
.dev-tools-info-learn-more-button:hover {
text-decoration: none;
color: var(--color-background-100);
opacity: 0.9;
}
`
function IconChevronLeft() {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5.14645 8.70703C4.75595 8.31651 4.75595 7.68349 5.14645 7.29297L10.5 1.93945L11.5605 3L6.56051 8L11.5605 13L10.5 14.0605L5.14645 8.70703Z"
fill="currentColor"
/>
</svg>
)
}
import type { ComponentProps, HTMLProps, RefObject } from 'react' import type { ComponentProps } from 'react'
import { DevToolsInfo } from './dev-tools-info'
function StaticRouteContent({ function StaticRouteContent({
routerType, routerType,
...@@ -130,37 +129,4 @@ export function RouteInfoBody({ ...@@ -130,37 +129,4 @@ export function RouteInfoBody({
) )
} }
export function RouteInfo({
isOpen,
close,
routerType,
routeType,
triggerRef,
...props
}: {
isOpen: boolean
close: () => void
routerType: 'pages' | 'app'
routeType: 'Static' | 'Dynamic'
triggerRef: RefObject<HTMLButtonElement | null>
} & HTMLProps<HTMLDivElement>) {
const isStaticRoute = routeType === 'Static'
const learnMore = isStaticRoute
? learnMoreLink[routerType].static
: learnMoreLink[routerType].dynamic
return (
<DevToolsInfo
title={`${routeType} Route`}
learnMoreLink={learnMore}
close={close}
isOpen={isOpen}
triggerRef={triggerRef}
{...props}
>
<RouteInfoBody routerType={routerType} isStaticRoute={isStaticRoute} />
</DevToolsInfo>
)
}
export const DEV_TOOLS_INFO_ROUTE_INFO_STYLES = `` export const DEV_TOOLS_INFO_ROUTE_INFO_STYLES = ``
...@@ -505,15 +505,15 @@ function testPlatform(re: RegExp): boolean | undefined { ...@@ -505,15 +505,15 @@ function testPlatform(re: RegExp): boolean | undefined {
: undefined : undefined
} }
export function isMac(): boolean | undefined { function isMac(): boolean | undefined {
return testPlatform(/^Mac/) return testPlatform(/^Mac/)
} }
export function isIPhone(): boolean | undefined { function isIPhone(): boolean | undefined {
return testPlatform(/^iPhone/) return testPlatform(/^iPhone/)
} }
export function isIPad(): boolean | undefined { function isIPad(): boolean | undefined {
return ( return (
testPlatform(/^iPad/) || testPlatform(/^iPad/) ||
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support. // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
...@@ -521,10 +521,6 @@ export function isIPad(): boolean | undefined { ...@@ -521,10 +521,6 @@ export function isIPad(): boolean | undefined {
) )
} }
export function isIOS(): boolean | undefined { function isApple(): boolean | undefined {
return isIPhone() || isIPad()
}
export function isApple(): boolean | undefined {
return isMac() || isIPhone() || isIPad() return isMac() || isIPhone() || isIPad()
} }
import { DevToolsInfo, type DevToolsInfoPropsCore } from './dev-tools-info'
import { CopyButton } from '../../../copy-button' import { CopyButton } from '../../../copy-button'
import type { HTMLProps } from 'react'
export function TurbopackInfoBody(props: React.ComponentProps<'div'>) { export function TurbopackInfoBody(props: React.ComponentProps<'div'>) {
return ( return (
...@@ -94,20 +92,6 @@ export function TurbopackInfoBody(props: React.ComponentProps<'div'>) { ...@@ -94,20 +92,6 @@ export function TurbopackInfoBody(props: React.ComponentProps<'div'>) {
) )
} }
export function TurbopackInfo(
props: DevToolsInfoPropsCore & HTMLProps<HTMLDivElement>
) {
return (
<DevToolsInfo
title="Turbopack"
learnMoreLink="https://nextjs.org/docs/app/api-reference/turbopack"
{...props}
>
<TurbopackInfoBody />
</DevToolsInfo>
)
}
export const DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES = ` export const DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES = `
.dev-tools-info-code { .dev-tools-info-code {
background: var(--color-gray-400); background: var(--color-gray-400);
......
import type { HTMLProps } from 'react'
import type { import type {
DevToolsIndicatorPosition, DevToolsIndicatorPosition,
DevToolsScale, DevToolsScale,
...@@ -11,49 +10,10 @@ import { NEXT_DEV_TOOLS_SCALE } from '../../../../shared' ...@@ -11,49 +10,10 @@ import { NEXT_DEV_TOOLS_SCALE } from '../../../../shared'
import LightIcon from '../../../../icons/light-icon' import LightIcon from '../../../../icons/light-icon'
import DarkIcon from '../../../../icons/dark-icon' import DarkIcon from '../../../../icons/dark-icon'
import SystemIcon from '../../../../icons/system-icon' import SystemIcon from '../../../../icons/system-icon'
import type { DevToolsInfoPropsCore } from './dev-tools-info'
import { DevToolsInfo } from './dev-tools-info'
import { ShortcutRecorder } from './shortcut-recorder' import { ShortcutRecorder } from './shortcut-recorder'
import { useRestartServer } from '../../error-overlay-toolbar/use-restart-server' import { useRestartServer } from '../../error-overlay-toolbar/use-restart-server'
import { saveDevToolsConfig } from '../../../../utils/save-devtools-config' import { saveDevToolsConfig } from '../../../../utils/save-devtools-config'
export function UserPreferences({
theme,
hide,
hideShortcut,
setHideShortcut,
setScale,
scale,
position,
setPosition,
...props
}: {
theme: 'dark' | 'light' | 'system'
hide: () => void
hideShortcut: string | null
setHideShortcut: (value: string | null) => void
setPosition: (position: DevToolsIndicatorPosition) => void
position: DevToolsIndicatorPosition
scale: DevToolsScale
setScale: (value: DevToolsScale) => void
} & DevToolsInfoPropsCore &
Omit<HTMLProps<HTMLDivElement>, 'size'>) {
return (
<DevToolsInfo title="Preferences" {...props}>
<UserPreferencesBody
theme={theme}
scale={scale}
position={position}
setPosition={setPosition}
setScale={setScale}
hide={hide}
hideShortcut={hideShortcut}
setHideShortcut={setHideShortcut}
/>
</DevToolsInfo>
)
}
export function UserPreferencesBody({ export function UserPreferencesBody({
theme, theme,
hide, hide,
......
...@@ -175,7 +175,7 @@ interface Velocity { ...@@ -175,7 +175,7 @@ interface Velocity {
timestamp: number timestamp: number
} }
export function useDrag(options: UseDragOptions) { function useDrag(options: UseDragOptions) {
const ref = useRef<HTMLDivElement>(null) const ref = useRef<HTMLDivElement>(null)
const machine = useRef< const machine = useRef<
| { state: 'idle' | 'press' | 'drag-end' } | { state: 'idle' | 'press' | 'drag-end' }
......
import { ErrorFeedback } from './error-feedback/error-feedback' import { ErrorFeedback } from './error-feedback/error-feedback'
import { styles as feedbackStyles } from './error-feedback/error-feedback' import { styles as feedbackStyles } from './error-feedback/error-feedback'
export type ErrorOverlayFooterProps = { type ErrorOverlayFooterProps = {
errorCode: string | undefined errorCode: string | undefined
} }
......
export type OverlayBackdropProps = { type OverlayBackdropProps = {
fixed?: boolean fixed?: boolean
} & React.HTMLAttributes<HTMLDivElement> } & React.HTMLAttributes<HTMLDivElement>
......
...@@ -99,7 +99,7 @@ function SegmentExplorerFooter({ ...@@ -99,7 +99,7 @@ function SegmentExplorerFooter({
) )
} }
export function FilePill({ function FilePill({
type, type,
isBuiltin, isBuiltin,
isOverridden, isOverridden,
...@@ -441,7 +441,7 @@ function PageSegmentTreeLayerPresentation({ ...@@ -441,7 +441,7 @@ function PageSegmentTreeLayerPresentation({
) )
} }
export function openInEditor({ filePath }: { filePath: string }) { function openInEditor({ filePath }: { filePath: string }) {
const params = new URLSearchParams({ const params = new URLSearchParams({
file: filePath, file: filePath,
// Mark the file path is relative to the app directory, // Mark the file path is relative to the app directory,
...@@ -491,7 +491,7 @@ function BackArrowIcon() { ...@@ -491,7 +491,7 @@ function BackArrowIcon() {
) )
} }
export function CodeIcon(props: React.SVGProps<SVGSVGElement>) { function CodeIcon(props: React.SVGProps<SVGSVGElement>) {
return ( return (
<svg <svg
width="12" width="12"
......
import { ChevronDownIcon } from '../../icons/chevron-down'
export function Select({
children,
prefix,
...props
}: {
prefix?: React.ReactNode
} & Omit<React.HTMLProps<HTMLSelectElement>, 'prefix'>) {
return (
<div data-nextjs-select>
{prefix}
<select {...props}>{children}</select>
<ChevronDownIcon width={16} height={16} />
</div>
)
}
...@@ -7,7 +7,7 @@ import { getFrameSource, type StackFrame } from '../../../shared/stack-frame' ...@@ -7,7 +7,7 @@ import { getFrameSource, type StackFrame } from '../../../shared/stack-frame'
import { useOpenInEditor } from '../../utils/use-open-in-editor' import { useOpenInEditor } from '../../utils/use-open-in-editor'
import { FileIcon } from '../../icons/file' import { FileIcon } from '../../icons/file'
export type TerminalProps = { content: string } type TerminalProps = { content: string }
function getFile(lines: string[]) { function getFile(lines: string[]) {
const contentFileName = lines.shift() const contentFileName = lines.shift()
......
import * as React from 'react' import * as React from 'react'
import { cx } from '../../utils/cx' import { cx } from '../../utils/cx'
export type ToastProps = React.HTMLProps<HTMLDivElement> & { type ToastProps = React.HTMLProps<HTMLDivElement> & {
children?: React.ReactNode children?: React.ReactNode
onClick?: () => void onClick?: () => void
className?: string className?: string
......
...@@ -4,11 +4,11 @@ import { Terminal } from '../components/terminal' ...@@ -4,11 +4,11 @@ import { Terminal } from '../components/terminal'
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' import type { ErrorBaseProps } from '../components/errors/error-overlay/error-overlay'
export interface BuildErrorProps extends ErrorBaseProps { interface BuildErrorProps extends ErrorBaseProps {
message: string message: string
} }
export const getErrorTextFromBuildErrorMessage = (multiLineMessage: string) => { const getErrorTextFromBuildErrorMessage = (multiLineMessage: string) => {
const lines = multiLineMessage.split('\n') const lines = multiLineMessage.split('\n')
// The multi-line build error message looks like: // The multi-line build error message looks like:
// <file path>:<line number>:<column number> // <file path>:<line number>:<column number>
......
...@@ -22,7 +22,7 @@ import { useActiveRuntimeError } from '../hooks/use-active-runtime-error' ...@@ -22,7 +22,7 @@ import { useActiveRuntimeError } from '../hooks/use-active-runtime-error'
import { formatCodeFrame } from '../components/code-frame/parse-code-frame' import { formatCodeFrame } from '../components/code-frame/parse-code-frame'
import stripAnsi from 'next/dist/compiled/strip-ansi' import stripAnsi from 'next/dist/compiled/strip-ansi'
export interface ErrorsProps extends ErrorBaseProps { interface ErrorsProps extends ErrorBaseProps {
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
runtimeErrors: ReadyRuntimeError[] runtimeErrors: ReadyRuntimeError[]
debugInfo: DebugInfo debugInfo: DebugInfo
...@@ -33,11 +33,11 @@ function isNextjsLink(text: string): boolean { ...@@ -33,11 +33,11 @@ function isNextjsLink(text: string): boolean {
return text.startsWith('https://nextjs.org') return text.startsWith('https://nextjs.org')
} }
export function HydrationErrorDescription({ message }: { message: string }) { function HydrationErrorDescription({ message }: { message: string }) {
return <HotlinkedText text={message} matcher={isNextjsLink} /> return <HotlinkedText text={message} matcher={isNextjsLink} />
} }
export function GenericErrorDescription({ error }: { error: Error }) { function GenericErrorDescription({ error }: { error: Error }) {
const environmentName = const environmentName =
'environmentName' in error ? error.environmentName : '' 'environmentName' in error ? error.environmentName : ''
const envPrefix = environmentName ? `[ ${environmentName} ] ` : '' const envPrefix = environmentName ? `[ ${environmentName} ] ` : ''
......
import { css } from '../../utils/css'
export function ErrorContentSkeleton() {
return (
<>
<div data-nextjs-codeframe-skeleton>
<div data-nextjs-codeframe-skeleton-header>
<div data-nextjs-codeframe-skeleton-icon />
<div
data-nextjs-codeframe-skeleton-line
data-nextjs-codeframe-skeleton-header-bar
/>
</div>
<div data-nextjs-codeframe-skeleton-content>
<div
data-nextjs-codeframe-skeleton-line
data-nextjs-codeframe-skeleton-line-1
/>
<div
data-nextjs-codeframe-skeleton-line
data-nextjs-codeframe-skeleton-line-2
/>
<div
data-nextjs-codeframe-skeleton-line
data-nextjs-codeframe-skeleton-line-3
/>
</div>
</div>
<div data-nextjs-call-stack-container>
<div data-nextjs-call-stack-header>
<p data-nextjs-call-stack-title>
Call Stack{' '}
<span
data-nextjs-call-stack-count
data-nextjs-call-stack-count-skeleton
></span>
</p>
<button
data-nextjs-call-stack-ignored-list-toggle-button
data-nextjs-call-stack-ignored-list-toggle-button-skeleton
aria-hidden="true"
>
<div data-nextjs-call-stack-skeleton-bar />
</button>
</div>
</div>
</>
)
}
export const ERROR_CONTENT_SKELETON_STYLES = css`
[data-nextjs-codeframe-skeleton] {
margin: 8px 0;
border-radius: 8px;
background-color: var(--color-background-200);
border: 1px solid var(--color-gray-400);
overflow: hidden;
}
[data-nextjs-codeframe-skeleton-header] {
display: flex;
align-items: center;
padding: 12px;
border-bottom: 1px solid var(--color-gray-400);
border-radius: 8px 8px 0 0;
gap: 6px;
}
[data-nextjs-codeframe-skeleton-icon] {
width: var(--size-16);
height: var(--size-16);
border-radius: 4px;
background: linear-gradient(
90deg,
var(--color-gray-200) 25%,
var(--color-gray-100) 50%,
var(--color-gray-200) 75%
);
background-size: 200% 100%;
animation: skeleton-shimmer 1.5s ease-in-out infinite;
flex-shrink: 0;
}
[data-nextjs-codeframe-skeleton-header-bar] {
width: 42.9%;
}
[data-nextjs-codeframe-skeleton-button] {
width: var(--size-16);
height: var(--size-16);
border-radius: var(--rounded-full);
background: linear-gradient(
90deg,
var(--color-gray-200) 25%,
var(--color-gray-100) 50%,
var(--color-gray-200) 75%
);
background-size: 200% 100%;
animation: skeleton-shimmer 1.5s ease-in-out infinite;
flex-shrink: 0;
}
[data-nextjs-codeframe-skeleton-content] {
padding: 12px;
}
[data-nextjs-codeframe-skeleton-line] {
height: var(--size-16);
border-radius: 100px;
background: linear-gradient(
90deg,
var(--color-gray-200) 25%,
var(--color-gray-100) 50%,
var(--color-gray-200) 75%
);
background-size: 200% 100%;
animation: skeleton-shimmer 1.5s ease-in-out infinite;
margin-bottom: 8px;
}
[data-nextjs-codeframe-skeleton-line]:last-child {
margin-bottom: 0;
}
[data-nextjs-codeframe-skeleton-line-1] {
width: 32.5%;
}
[data-nextjs-codeframe-skeleton-line-2] {
width: 56.8%;
}
[data-nextjs-codeframe-skeleton-line-3] {
width: 29.6%;
}
[data-nextjs-call-stack-container] {
position: relative;
margin-top: 8px;
}
[data-nextjs-call-stack-count-skeleton] {
display: flex;
justify-content: center;
align-items: center;
width: var(--size-20);
height: var(--size-20);
border-radius: var(--rounded-full);
background: linear-gradient(
90deg,
var(--color-gray-200) 25%,
var(--color-gray-100) 50%,
var(--color-gray-200) 75%
);
background-size: 200% 100%;
animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
[data-nextjs-call-stack-ignored-list-toggle-button-skeleton] {
all: unset;
display: flex;
align-items: center;
border-radius: 6px;
padding: 4px 6px;
margin-right: -6px;
}
[data-nextjs-call-stack-skeleton-bar] {
height: var(--size-12);
width: 148px;
border-radius: 100px;
background: linear-gradient(
90deg,
var(--color-gray-200) 25%,
var(--color-gray-100) 50%,
var(--color-gray-200) 75%
);
background-size: 200% 100%;
animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
0% {
background-position: -200% 0;
}
100% {
background-position: 200% 0;
}
}
/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
[data-nextjs-codeframe-skeleton-icon],
[data-nextjs-codeframe-skeleton-header-bar],
[data-nextjs-codeframe-skeleton-button],
[data-nextjs-codeframe-skeleton-line],
[data-nextjs-call-stack-count-skeleton],
[data-nextjs-call-stack-skeleton-bar] {
animation: none;
background: var(--color-gray-200);
}
}
`
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
type ReadyRuntimeError, type ReadyRuntimeError,
} from '../../utils/get-error-by-type' } from '../../utils/get-error-by-type'
export type RuntimeErrorProps = { type RuntimeErrorProps = {
error: ReadyRuntimeError error: ReadyRuntimeError
dialogResizerRef: React.RefObject<HTMLDivElement | null> dialogResizerRef: React.RefObject<HTMLDivElement | null>
} }
......
...@@ -38,9 +38,7 @@ export function useShortcuts( ...@@ -38,9 +38,7 @@ export function useShortcuts(
}, [rootRef, shortcuts]) }, [rootRef, shortcuts])
} }
export function isFocusedOnElement( function isFocusedOnElement(rootRef: React.RefObject<HTMLElement | null>) {
rootRef: React.RefObject<HTMLElement | null>
) {
const el = getActiveElement(rootRef.current) const el = getActiveElement(rootRef.current)
if (!el) return false if (!el) return false
......
export function ChevronDownIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden {...props}>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M14.0607 5.49999L13.5303 6.03032L8.7071 10.8535C8.31658 11.2441 7.68341 11.2441 7.29289 10.8535L2.46966 6.03032L1.93933 5.49999L2.99999 4.43933L3.53032 4.96966L7.99999 9.43933L12.4697 4.96966L13 4.43933L14.0607 5.49999Z"
fill="currentColor"
/>
</svg>
)
}
export function FullScreenIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<path
d="M15 14C15 14.5523 14.5523 15 14 15H10V13.5H13.5V10H15V14ZM2.5 13.499H6V14.999H2C1.44772 14.999 1 14.5513 1 13.999V9.99902H2.5V13.499ZM6 2.5H2.5V6H1V2C1 1.44772 1.44772 1 2 1H6V2.5ZM14 1C14.5523 1 15 1.44772 15 2V6H13.5V2.5H10V1H14Z"
fill="currentColor"
/>
</svg>
)
}
export function MinimizeIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M1 6V4.5H4.5V1H6V5C6 5.55228 5.55228 6 5 6H1ZM11.5 1H10V5C10 5.55228 10.4477 6 11 6H15V4.5H11.5V1ZM15.04 11.5V10H11C10.4477 10 10 10.4477 10 11V15H11.5V11.5H15.04ZM4.5 15H6V11C6 10.4477 5.55228 10 5 10H1V11.5H4.5V15Z"
fill="currentColor"
/>
</svg>
)
}
export function StopIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 16 16"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M14.5 8C14.5 11.5899 11.5899 14.5 8 14.5C4.41015 14.5 1.5 11.5899 1.5 8C1.5 4.41015 4.41015 1.5 8 1.5C11.5899 1.5 14.5 4.41015 14.5 8ZM16 8C16 12.4183 12.4183 16 8 16C3.58172 16 0 12.4183 0 8C0 3.58172 3.58172 0 8 0C12.4183 0 16 3.58172 16 8ZM5 7.25H4.25V8.75H5H11H11.75V7.25H11H5Z"
fill="#666"
/>
</svg>
)
}
...@@ -20,9 +20,9 @@ interface C { ...@@ -20,9 +20,9 @@ interface C {
setSelectedIndex: Dispatch<SetStateAction<number>> setSelectedIndex: Dispatch<SetStateAction<number>>
} }
export const MenuContext = createContext({} as C) const MenuContext = createContext({} as C)
export function MenuItem({ function MenuItem({
index, index,
label, label,
value, value,
...@@ -288,7 +288,7 @@ export const DevtoolMenu = ({ ...@@ -288,7 +288,7 @@ export const DevtoolMenu = ({
) )
} }
export function getAdjustedIndex( function getAdjustedIndex(
items: Array<{ onClick?: () => void }>, items: Array<{ onClick?: () => void }>,
targetIndex: number targetIndex: number
): number { ): number {
...@@ -306,7 +306,7 @@ export function getAdjustedIndex( ...@@ -306,7 +306,7 @@ export function getAdjustedIndex(
return adjustedIndex return adjustedIndex
} }
export function getClickableItemsCount( function getClickableItemsCount(
items: Array<{ onClick?: () => void }> items: Array<{ onClick?: () => void }>
): number { ): number {
return items.filter((item) => item.onClick).length return items.filter((item) => item.onClick).length
...@@ -343,7 +343,7 @@ export function ChevronRight() { ...@@ -343,7 +343,7 @@ export function ChevronRight() {
) )
} }
export function selectMenuItem({ function selectMenuItem({
index, index,
menuRef, menuRef,
setSelectedIndex, setSelectedIndex,
......
...@@ -306,7 +306,7 @@ const UserPreferencesWrapper = () => { ...@@ -306,7 +306,7 @@ const UserPreferencesWrapper = () => {
} }
export const usePanelContext = () => useContext(PanelContext) export const usePanelContext = () => useContext(PanelContext)
export const PanelContext = createContext<{ const PanelContext = createContext<{
name: PanelStateKind name: PanelStateKind
mounted: boolean mounted: boolean
}>(null!) }>(null!)
......
...@@ -132,7 +132,7 @@ function createTrie<Value = string>({ ...@@ -132,7 +132,7 @@ function createTrie<Value = string>({
return { insert, remove, getRoot } return { insert, remove, getRoot }
} }
export type SegmentTrie = Trie<SegmentNodeState> type SegmentTrie = Trie<SegmentNodeState>
export type SegmentTrieNode = TrieNode<SegmentNodeState> export type SegmentTrieNode = TrieNode<SegmentNodeState>
const trie: SegmentTrie = createTrie({ const trie: SegmentTrie = createTrie({
......
...@@ -93,19 +93,12 @@ export const ACTION_BUILDING_INDICATOR_HIDE = 'building-indicator-hide' ...@@ -93,19 +93,12 @@ export const ACTION_BUILDING_INDICATOR_HIDE = 'building-indicator-hide'
export const ACTION_RENDERING_INDICATOR_SHOW = 'rendering-indicator-show' export const ACTION_RENDERING_INDICATOR_SHOW = 'rendering-indicator-show'
export const ACTION_RENDERING_INDICATOR_HIDE = 'rendering-indicator-hide' export const ACTION_RENDERING_INDICATOR_HIDE = 'rendering-indicator-hide'
export const ACTION_DEVTOOLS_PANEL_OPEN = 'devtools-panel-open'
export const ACTION_DEVTOOLS_PANEL_CLOSE = 'devtools-panel-close'
export const ACTION_DEVTOOLS_PANEL_TOGGLE = 'devtools-panel-toggle'
export const ACTION_DEVTOOLS_POSITION = 'devtools-position' export const ACTION_DEVTOOLS_POSITION = 'devtools-position'
export const ACTION_DEVTOOLS_PANEL_POSITION = 'devtools-panel-position' export const ACTION_DEVTOOLS_PANEL_POSITION = 'devtools-panel-position'
export const ACTION_DEVTOOLS_PANEL_SIZE = 'devtools-panel-size'
export const ACTION_DEVTOOLS_SCALE = 'devtools-scale' export const ACTION_DEVTOOLS_SCALE = 'devtools-scale'
export const ACTION_DEVTOOLS_CONFIG = 'devtools-config' export const ACTION_DEVTOOLS_CONFIG = 'devtools-config'
export const STORAGE_KEY_THEME = '__nextjs-dev-tools-theme'
export const STORAGE_KEY_POSITION = '__nextjs-dev-tools-position'
export const STORAGE_KEY_PANEL_POSITION_PREFIX = export const STORAGE_KEY_PANEL_POSITION_PREFIX =
'__nextjs-dev-tools-panel-position' '__nextjs-dev-tools-panel-position'
export const STORE_KEY_PANEL_SIZE_PREFIX = '__nextjs-dev-tools-panel-size' export const STORE_KEY_PANEL_SIZE_PREFIX = '__nextjs-dev-tools-panel-size'
...@@ -113,7 +106,6 @@ export const STORE_KEY_SHARED_PANEL_SIZE = ...@@ -113,7 +106,6 @@ export const STORE_KEY_SHARED_PANEL_SIZE =
'__nextjs-dev-tools-shared-panel-size' '__nextjs-dev-tools-shared-panel-size'
export const STORE_KEY_SHARED_PANEL_LOCATION = export const STORE_KEY_SHARED_PANEL_LOCATION =
'__nextjs-dev-tools-shared-panel-location' '__nextjs-dev-tools-shared-panel-location'
export const STORAGE_KEY_SCALE = '__nextjs-dev-tools-scale'
export const ACTION_DEVTOOL_UPDATE_ROUTE_STATE = export const ACTION_DEVTOOL_UPDATE_ROUTE_STATE =
'segment-explorer-update-route-state' 'segment-explorer-update-route-state'
...@@ -137,16 +129,16 @@ interface FastRefreshAction { ...@@ -137,16 +129,16 @@ interface FastRefreshAction {
type: typeof ACTION_REFRESH type: typeof ACTION_REFRESH
} }
export interface UnhandledErrorAction { interface UnhandledErrorAction {
type: typeof ACTION_UNHANDLED_ERROR type: typeof ACTION_UNHANDLED_ERROR
reason: Error reason: Error
} }
export interface UnhandledRejectionAction { interface UnhandledRejectionAction {
type: typeof ACTION_UNHANDLED_REJECTION type: typeof ACTION_UNHANDLED_REJECTION
reason: Error reason: Error
} }
export interface DebugInfoAction { interface DebugInfoAction {
type: typeof ACTION_DEBUG_INFO type: typeof ACTION_DEBUG_INFO
debugInfo: any debugInfo: any
} }
...@@ -166,52 +158,52 @@ interface DevIndicatorSetAction { ...@@ -166,52 +158,52 @@ interface DevIndicatorSetAction {
disabled: boolean disabled: boolean
} }
export interface ErrorOverlayOpenAction { interface ErrorOverlayOpenAction {
type: typeof ACTION_ERROR_OVERLAY_OPEN type: typeof ACTION_ERROR_OVERLAY_OPEN
} }
export interface ErrorOverlayCloseAction { interface ErrorOverlayCloseAction {
type: typeof ACTION_ERROR_OVERLAY_CLOSE type: typeof ACTION_ERROR_OVERLAY_CLOSE
} }
export interface ErrorOverlayToggleAction { interface ErrorOverlayToggleAction {
type: typeof ACTION_ERROR_OVERLAY_TOGGLE type: typeof ACTION_ERROR_OVERLAY_TOGGLE
} }
export interface BuildingIndicatorShowAction { interface BuildingIndicatorShowAction {
type: typeof ACTION_BUILDING_INDICATOR_SHOW type: typeof ACTION_BUILDING_INDICATOR_SHOW
} }
export interface BuildingIndicatorHideAction { interface BuildingIndicatorHideAction {
type: typeof ACTION_BUILDING_INDICATOR_HIDE type: typeof ACTION_BUILDING_INDICATOR_HIDE
} }
export interface RenderingIndicatorShowAction { interface RenderingIndicatorShowAction {
type: typeof ACTION_RENDERING_INDICATOR_SHOW type: typeof ACTION_RENDERING_INDICATOR_SHOW
} }
export interface RenderingIndicatorHideAction { interface RenderingIndicatorHideAction {
type: typeof ACTION_RENDERING_INDICATOR_HIDE type: typeof ACTION_RENDERING_INDICATOR_HIDE
} }
export interface DevToolsIndicatorPositionAction { interface DevToolsIndicatorPositionAction {
type: typeof ACTION_DEVTOOLS_POSITION type: typeof ACTION_DEVTOOLS_POSITION
devToolsPosition: Corners devToolsPosition: Corners
} }
export interface DevToolsPanelPositionAction { interface DevToolsPanelPositionAction {
type: typeof ACTION_DEVTOOLS_PANEL_POSITION type: typeof ACTION_DEVTOOLS_PANEL_POSITION
key: string key: string
devToolsPanelPosition: Corners devToolsPanelPosition: Corners
} }
export interface DevToolsScaleAction { interface DevToolsScaleAction {
type: typeof ACTION_DEVTOOLS_SCALE type: typeof ACTION_DEVTOOLS_SCALE
scale: number scale: number
} }
export interface DevToolUpdateRouteStateAction { interface DevToolUpdateRouteStateAction {
type: typeof ACTION_DEVTOOL_UPDATE_ROUTE_STATE type: typeof ACTION_DEVTOOL_UPDATE_ROUTE_STATE
page: string page: string
} }
export interface DevToolsConfigAction { interface DevToolsConfigAction {
type: typeof ACTION_DEVTOOLS_CONFIG type: typeof ACTION_DEVTOOLS_CONFIG
devToolsConfig: DevToolsConfig devToolsConfig: DevToolsConfig
} }
......
...@@ -15,14 +15,12 @@ import { CALL_STACK_FRAME_STYLES } from '../components/call-stack-frame/call-sta ...@@ -15,14 +15,12 @@ import { CALL_STACK_FRAME_STYLES } from '../components/call-stack-frame/call-sta
import { css } from '../utils/css' import { css } from '../utils/css'
import { EDITOR_LINK_STYLES } from '../components/terminal/editor-link' import { EDITOR_LINK_STYLES } from '../components/terminal/editor-link'
import { ENVIRONMENT_NAME_LABEL_STYLES } from '../components/errors/environment-name-label/environment-name-label' import { ENVIRONMENT_NAME_LABEL_STYLES } from '../components/errors/environment-name-label/environment-name-label'
import { DEV_TOOLS_INFO_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/dev-tools-info'
import { DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/turbopack-info' import { DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/turbopack-info'
import { DEV_TOOLS_INFO_ROUTE_INFO_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/route-info' import { DEV_TOOLS_INFO_ROUTE_INFO_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/route-info'
import { DEV_TOOLS_INFO_USER_PREFERENCES_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/user-preferences' import { DEV_TOOLS_INFO_USER_PREFERENCES_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/user-preferences'
import { FADER_STYLES } from '../components/fader' import { FADER_STYLES } from '../components/fader'
import { CALL_STACK_STYLES } from '../components/call-stack/call-stack' import { CALL_STACK_STYLES } from '../components/call-stack/call-stack'
import { ISSUE_FEEDBACK_BUTTON_STYLES } from '../components/errors/error-overlay-toolbar/issue-feedback-button' import { ISSUE_FEEDBACK_BUTTON_STYLES } from '../components/errors/error-overlay-toolbar/issue-feedback-button'
import { ERROR_CONTENT_SKELETON_STYLES } from '../container/runtime-error/error-content-skeleton'
import { SHORTCUT_RECORDER_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/shortcut-recorder' import { SHORTCUT_RECORDER_STYLES } from '../components/errors/dev-tools-indicator/dev-tools-info/shortcut-recorder'
export function ComponentStyles() { export function ComponentStyles() {
...@@ -46,13 +44,11 @@ export function ComponentStyles() { ...@@ -46,13 +44,11 @@ export function ComponentStyles() {
${containerErrorStyles} ${containerErrorStyles}
${containerRuntimeErrorStyles} ${containerRuntimeErrorStyles}
${versionStaleness} ${versionStaleness}
${DEV_TOOLS_INFO_STYLES}
${DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES} ${DEV_TOOLS_INFO_TURBOPACK_INFO_STYLES}
${DEV_TOOLS_INFO_ROUTE_INFO_STYLES} ${DEV_TOOLS_INFO_ROUTE_INFO_STYLES}
${DEV_TOOLS_INFO_USER_PREFERENCES_STYLES} ${DEV_TOOLS_INFO_USER_PREFERENCES_STYLES}
${FADER_STYLES} ${FADER_STYLES}
${ISSUE_FEEDBACK_BUTTON_STYLES} ${ISSUE_FEEDBACK_BUTTON_STYLES}
${ERROR_CONTENT_SKELETON_STYLES}
${SHORTCUT_RECORDER_STYLES} ${SHORTCUT_RECORDER_STYLES}
`} `}
</style> </style>
......
...@@ -4,7 +4,7 @@ import type { OverlayState } from '../shared' ...@@ -4,7 +4,7 @@ import type { OverlayState } from '../shared'
export const BASE_LOGO_SIZE = 36 export const BASE_LOGO_SIZE = 36
const INDICATOR_GAP = 9 const INDICATOR_GAP = 9
export function getIndicatorSquare(state: OverlayState): number { function getIndicatorSquare(state: OverlayState): number {
return BASE_LOGO_SIZE / state.scale return BASE_LOGO_SIZE / state.scale
} }
......
import type * as React from 'react'
/**
* A function that merges React refs into one.
* Supports both functions and ref objects created using createRef() and useRef().
*
* Usage:
* ```tsx
* <div ref={mergeRefs(ref1, ref2, ref3)} />
* ```
*
* @param inputRefs Array of refs
* @returns Merged refs
*/
export default function mergeRefs<T>(
...inputRefs: (React.Ref<T> | undefined)[]
): React.Ref<T> | React.RefCallback<T> {
const filteredInputRefs = inputRefs.filter(Boolean)
if (filteredInputRefs.length <= 1) {
const firstRef = filteredInputRefs[0]
return firstRef || null
}
return function mergedRefs(ref) {
for (const inputRef of filteredInputRefs) {
if (typeof inputRef === 'function') {
inputRef(ref)
} else if (inputRef) {
;(inputRef as React.MutableRefObject<T | null>).current = ref
}
}
}
}
...@@ -3,7 +3,7 @@ const digestSym = Symbol.for('next.console.error.digest') ...@@ -3,7 +3,7 @@ const digestSym = Symbol.for('next.console.error.digest')
// Represent non Error shape unhandled promise rejections or console.error errors. // Represent non Error shape unhandled promise rejections or console.error errors.
// Those errors will be captured and displayed in Error Overlay. // Those errors will be captured and displayed in Error Overlay.
export type ConsoleError = Error & { type ConsoleError = Error & {
[digestSym]: 'NEXT_CONSOLE_ERROR' [digestSym]: 'NEXT_CONSOLE_ERROR'
environmentName: string environmentName: string
} }
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
export type { StackFrame } export type { StackFrame }
export interface ResolvedOriginalStackFrame extends OriginalStackFrameResponse { interface ResolvedOriginalStackFrame extends OriginalStackFrameResponse {
error: false error: false
reason: null reason: null
external: boolean external: boolean
...@@ -19,7 +19,7 @@ export interface ResolvedOriginalStackFrame extends OriginalStackFrameResponse { ...@@ -19,7 +19,7 @@ export interface ResolvedOriginalStackFrame extends OriginalStackFrameResponse {
sourceStackFrame: StackFrame sourceStackFrame: StackFrame
} }
export interface RejectedOriginalStackFrame extends OriginalStackFrameResponse { interface RejectedOriginalStackFrame extends OriginalStackFrameResponse {
error: true error: true
reason: string reason: string
external: boolean external: boolean
......
...@@ -16,7 +16,7 @@ import { ...@@ -16,7 +16,7 @@ import {
const queueMicroTask = const queueMicroTask =
globalThis.queueMicrotask || ((cb: () => void) => Promise.resolve().then(cb)) globalThis.queueMicrotask || ((cb: () => void) => Promise.resolve().then(cb))
export type ErrorHandler = (error: Error) => void type ErrorHandler = (error: Error) => void
const errorQueue: Array<Error> = [] const errorQueue: Array<Error> = []
const errorHandlers: Array<ErrorHandler> = [] const errorHandlers: Array<ErrorHandler> = []
......
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