prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
Obj } from '@storybook/react' import { CallStackFrame } from './call-stack-frame' import { withShadowPortal } from '../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof CallStackFrame> = { component: CallStackFrame, parameters: { layout: 'fullscreen', backgrounds: { defaul...
allStackFrame> const frame = { originalCodeFrame: null, originalStackFrame: { file: './app/page.tsx', methodName: 'MyComponent', arguments: [], line1: 10, column1: 5, ignored: false, }, sourceStackFrame: { file: './app/
O: We might have setup more explicit backgrounds depending on theme. enabled: false, }, ], }, }, }, decorators: [withShadowPortal], } export default meta type Story = StoryObj<typeof C
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/call-stack-frame/call-stack-frame.stories.tsx", "language": "tsx", "file_size": 1614, "cut_index": 537, "middle_length": 229 }
../hot-linked-text' import { ExternalIcon, SourceMappingErrorIcon } from '../../icons/external' import { getStackFrameFile } from '../../../shared/stack-frame' import { useOpenInEditor } from '../../utils/use-open-in-editor' export const CallStackFrame: React.FC<{ frame: OriginalStackFrame }> = function CallStackFra...
e.g. <anonymous> will be formatted to empty string, // we'll skip rendering the frame in this case. const stackFrameFile = getStackFrameFile(f) if (!stackFrameFile) { return null } return ( <div data-nextjs-call-stack-frame
onst open = useOpenInEditor( hasOriginalCodeFrame ? { file: f.file, line1: f.line1 ?? 1, column1: f.column1 ?? 1, } : undefined ) // Formatted file source could be empty.
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/call-stack-frame/call-stack-frame.tsx", "language": "tsx", "file_size": 3676, "cut_index": 614, "middle_length": 229 }
arts } from '../../../../shared/lib/magic-identifier' const linkRegex = /https?:\/\/[^\s/$.?#].[^\s)'"]*/i export const HotlinkedText: React.FC<{ text: string matcher?: (text: string) => string | null }> = function HotlinkedText(props) { const { text, matcher } = props // Deobfuscate the entire text first ...
ink = linkRegex.exec(rawPart)! const href = link[0] // If link matcher is present, check if it returns a className let linkClassName: string | null = null if (typeof matcher === 'funct
part // Split on whitespace and links .split(/(\s+|https?:\/\/[^\s/$.?#].[^\s)'"]*)/) .map((rawPart, index) => { if (linkRegex.test(rawPart)) { const l
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/hot-linked-text/index.tsx", "language": "tsx", "file_size": 2463, "cut_index": 563, "middle_length": 229 }
OpenInEditor } from '../../utils/use-open-in-editor' type EditorLinkProps = { file: string isSourceFile: boolean location?: { line: number column: number } } export function EditorLink({ file, location }: EditorLinkProps) { const open = useOpenInEditor({ file, line1: location?.line ?? 1, ...
stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path> <polyline points="15 3 21 3 21 9"></polyline>
tle={'Click to open in your editor'} > {file} {location ? `:${location.line}:${location.column}` : null} <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/terminal/editor-link.tsx", "language": "tsx", "file_size": 1462, "cut_index": 524, "middle_length": 229 }
l insert(urlPath: string): void { this._insert(urlPath.split('/').filter(Boolean), [], false) } smoosh(): string[] { return this._smoosh() } private _smoosh(prefix: string = '/'): string[] { const childrenPaths = [...this.children.keys()].sort() if (this.slugName !== null) { childrenP...
, []) if (this.slugName !== null) { routes.push( ...this.children.get('[]')!._smoosh(`${prefix}[${this.slugName}]/`) ) } if (!this.placeholder) { const r = prefix === '/' ? '/' : prefix.slice(0, -1) if (this.op
= null) { childrenPaths.splice(childrenPaths.indexOf('[[...]]'), 1) } const routes = childrenPaths .map((c) => this.children.get(c)!._smoosh(`${prefix}${c}/`)) .reduce((prev, curr) => [...prev, ...curr]
{ "filepath": "packages/next/src/shared/lib/router/utils/sorted-routes.ts", "language": "typescript", "file_size": 8617, "cut_index": 716, "middle_length": 229 }
erver/config-shared' import { acceptLanguage } from '../../../server/accept-header' import { denormalizePagePath } from '../page-path/denormalize-page-path' import { detectDomainLocale } from './detect-domain-locale' import { formatUrl } from '../router/utils/format-url' import { getCookieParser } from '../../../server...
ring]: string | string[] | undefined } = {} ) { const nextLocale = getCookieParser( headers || {} )()?.NEXT_LOCALE?.toLowerCase() return nextLocale ? i18n.locales.find((locale) => nextLocale === locale.toLowerCase()) : undefined } functi
th?: string i18n?: I18NConfig | null trailingSlash?: boolean } pathLocale?: string urlParsed: { hostname?: string | null; pathname: string } } function getLocaleFromCookie( i18n: I18NConfig, headers: { [key: st
{ "filepath": "packages/next/src/shared/lib/i18n/get-locale-redirect.ts", "language": "typescript", "file_size": 3162, "cut_index": 614, "middle_length": 229 }
port { BailoutToCSR } from './dynamic-bailout-to-csr' import type { ComponentModule } from './types' import { PreloadChunks } from './preload-chunks' // Normalize loader to return the module as form { default: Component } for `React.lazy`. // Also for backward compatible since next/dynamic allows to resolve a componen...
fault: proxy(Component) } // mod: proxy(Component) const hasDefault = mod && 'default' in mod return { default: hasDefault ? (mod as ComponentModule<P>).default : (mod as React.ComponentType<P>), } } const defaultOptions = { load
fault: React.ComponentType<P> } { // Check "default" prop before accessing it, as it could be client reference proxy that could break it reference. // Cases: // mod: { default: Component } // mod: Component // mod: { de
{ "filepath": "packages/next/src/shared/lib/lazy-dynamic/loadable.tsx", "language": "tsx", "file_size": 2542, "cut_index": 563, "middle_length": 229 }
import { workAsyncStorage } from '../../../server/app-render/work-async-storage.external' import { encodeURIPath } from '../encode-uri-path' import { getAssetTokenQuery } from '../deployment-id' export function PreloadChunks({ moduleIds, }: { moduleIds: string[] | undefined }) { // Early return in client compila...
const manifest = workStore.reactLoadableManifest for (const key of moduleIds) { if (!manifest[key]) continue const chunks = manifest[key].files allFiles.push(...chunks) } } if (allFiles.length === 0) { return null }
return null } const allFiles = [] // Search the current dynamic call unique key id in react loadable manifest, // and find the corresponding CSS files to preload if (workStore.reactLoadableManifest && moduleIds) {
{ "filepath": "packages/next/src/shared/lib/lazy-dynamic/preload-chunks.tsx", "language": "tsx", "file_size": 2131, "cut_index": 563, "middle_length": 229 }
NG_INDICATOR_SHOW, ACTION_RENDERING_INDICATOR_HIDE, ACTION_RENDERING_INDICATOR_SHOW, ACTION_DEVTOOL_UPDATE_ROUTE_STATE, ACTION_DEVTOOLS_CONFIG, type OverlayState, type DispatcherEvent, ACTION_CACHE_INDICATOR, ACTION_INSTANT_NAVS_TOGGLE, } from './dev-overlay/shared' import type { FlightRouterState } fr...
ation-error' import type { DebugInfo } from './shared/types' import { DevOverlay } from './dev-overlay/dev-overlay' import type { DevIndicatorServerState } from '../server/dev/dev-indicator-server-state' import type { VersionInfo } from '../server/dev/pars
t { createRoot } from 'react-dom/client' import type { CacheIndicatorState } from './dev-overlay/cache-indicator' import { FontStyles } from './dev-overlay/font/font-styles' import type { HydrationErrorState } from './shared/hydr
{ "filepath": "packages/next/src/next-devtools/dev-overlay.browser.tsx", "language": "tsx", "file_size": 15231, "cut_index": 921, "middle_length": 229 }
from './components/shadow-portal' import { ComponentStyles } from './styles/component-styles' import { ErrorOverlay } from './components/errors/error-overlay/error-overlay' import { RenderError } from './container/runtime-error/render-error' import { ScaleUpdater } from './styles/scale-updater' import type { ReadyRunt...
text = createContext<{ runtimeErrors: ReadyRuntimeError[] totalErrorCount: number }>(null!) export const useRenderErrorContext = () => useContext(RenderErrorContext) // Dispatches `ACTION_INSTANT_ERRORS_CLEAR` whenever the page changes to a // new no
nelRouterContext, type PanelStateKind } from './menu/context' import { useDevOverlayContext } from '../dev-overlay.browser' import { ACTION_INSTANT_ERRORS_CLEAR, type DispatcherEvent } from './shared' export const RenderErrorCon
{ "filepath": "packages/next/src/next-devtools/dev-overlay/dev-overlay.tsx", "language": "tsx", "file_size": 3499, "cut_index": 614, "middle_length": 229 }
ntNodeState } from '../userspace/app/segment-explorer-node' import type * as SegmentExplorer from './segment-explorer-trie' const createSegmentNode = ({ pagePath, type, }: { pagePath: string type: string }): SegmentNodeState => { function placeholder() {} return { type, pagePath, boundaryType: ...
(() => { jest.resetModules() jest.clearAllMocks() const segmentExplorer = require('./segment-explorer-trie') as typeof SegmentExplorer useSegmentTree = segmentExplorer.useSegmentTree insertSegmentNode = segmentExplorer.insertSegm
rary/react').renderHook let useSegmentTree: typeof SegmentExplorer.useSegmentTree let insertSegmentNode: typeof SegmentExplorer.insertSegmentNode let removeSegmentNode: typeof SegmentExplorer.removeSegmentNode beforeEach
{ "filepath": "packages/next/src/next-devtools/dev-overlay/segment-explorer-trie.test.tsx", "language": "tsx", "file_size": 7790, "cut_index": 716, "middle_length": 229 }
outeRegex } from '../../shared/lib/router/utils/route-regex' export type DevToolsConfig = { theme?: 'light' | 'dark' | 'system' disableDevIndicator?: boolean devToolsPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' devToolsPanelPosition?: Record< string, 'top-left' | 'top-right' | '...
} export type DevToolsScale = (typeof NEXT_DEV_TOOLS_SCALE)[keyof typeof NEXT_DEV_TOOLS_SCALE] type FastRefreshState = /** No refresh in progress. */ | { type: 'idle' } /** The refresh process has been triggered, but the new code has not been ex
'top-right' | 'bottom-left' | 'bottom-right' export type DevToolsIndicatorPosition = Corners const BASE_SIZE = 16 export const NEXT_DEV_TOOLS_SCALE = { Small: BASE_SIZE / 14, Medium: BASE_SIZE / 16, Large: BASE_SIZE / 18,
{ "filepath": "packages/next/src/next-devtools/dev-overlay/shared.ts", "language": "typescript", "file_size": 20360, "cut_index": 1331, "middle_length": 229 }
rtionEffect } from 'react' export const FontStyles = () => { useInsertionEffect(() => { const style = document.createElement('style') style.textContent = css` /* latin-ext */ @font-face { font-family: '__nextjs-Geist'; font-style: normal; font-weight: 400 600; font...
t Mono'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(/__nextjs_font/geist-mono-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* latin-ext */ @font-face { font-family: '__nextjs-Geis
{ "filepath": "packages/next/src/next-devtools/dev-overlay/font/font-styles.tsx", "language": "tsx", "file_size": 2291, "cut_index": 563, "middle_length": 229 }
hShadowPortal } from '../../../../.storybook/decorators/with-shadow-portal' import { lorem } from '../utils/lorem' import { instantCurrentTimeErrors, instantClientMathRandomErrors, instantCryptoRandomUUIDErrors, instantMetadataErrors, instantMetadataUncachedErrors, instantMathRandomErrors, instantRuntimeD...
ders necessary, instead of passing props directly, before they expected props export const Default: Story = { args: { getSquashedHydrationErrorDetails: () => null, runtimeErrors, versionInfo: { installed: '15.0.0', staleness: 'fre
rs> = { component: Errors, parameters: { layout: 'fullscreen', }, decorators: [withShadowPortal], } export default meta type Story = StoryObj<typeof Errors> // todo: update the stories to be wrapped in context provi
{ "filepath": "packages/next/src/next-devtools/dev-overlay/container/errors.stories.tsx", "language": "tsx", "file_size": 4307, "cut_index": 614, "middle_length": 229 }
components/errors/error-overlay/error-overlay' import type { HydrationErrorState } from '../../shared/hydration-error' import { useActiveRuntimeError } from '../hooks/use-active-runtime-error' import { formatCodeFrame } from '../components/code-frame/parse-code-frame' import stripAnsi from 'next/dist/compiled/strip-ans...
overlay-call-stack/error-overlay-call-stack' import { ErrorCause } from './runtime-error/error-cause' import { useFrames } from '../utils/get-error-by-type' interface ErrorsProps extends ErrorBaseProps { getSquashedHydrationErrorDetails: (error: Error)
mport { BLOCKING_ROUTE_NAVIGATION_EXPLANATION } from '../components/instant/instant-guidance-data' import { CodeFrame } from '../components/code-frame/code-frame' import { ErrorOverlayCallStack } from '../components/errors/error-
{ "filepath": "packages/next/src/next-devtools/dev-overlay/container/errors.tsx", "language": "tsx", "file_size": 25333, "cut_index": 1331, "middle_length": 229 }
sh } from './ensure-leading-slash' import { normalizePathSep } from './normalize-path-sep' import path from '../isomorphic/path' import { removePagePathTail } from './remove-page-path-tail' import { normalizeMetadataRoute } from '../../../lib/metadata/get-metadata-route' import type { PAGE_TYPES } from '../../../lib/pa...
/sitemap/route` * * @param filepath Absolute path to the page. * @param opts.dir Absolute path to the pages/app folder. * @param opts.extensions Extensions allowed for the page. * @param opts.keepIndex When true the trailing `index` kept in the path.
der. It doesn't consider index tail. Example: * - `/Users/rick/my-project/pages/foo/bar/baz.js` -> `/foo/bar/baz` * * It also handles special metadata routes mapping. Example: * - `/Users/rick/my-project/app/sitemap.js` -> `
{ "filepath": "packages/next/src/shared/lib/page-path/absolute-path-to-page.ts", "language": "typescript", "file_size": 1599, "cut_index": 537, "middle_length": 229 }
a page and the trailing `index` if it exists * making sure to not return an empty string. The page head is not touched * and returned as it is passed. Examples: * - `/foo/bar/baz/index.js` -> `/foo/bar/baz` * - `/foo/bar/baz.js` -> `/foo/bar/baz` * * @param pagePath A page to a page file (absolute or relativ...
<string> keepIndex?: boolean } ) { pagePath = normalizePathSep(pagePath).replace( new RegExp(`\\.+(?:${options.extensions.join('|')})$`), '' ) if (options.keepIndex !== true) { pagePath = pagePath.replace(/\/index$/, '') || '/' }
: string, options: { extensions: ReadonlyArray
{ "filepath": "packages/next/src/shared/lib/page-path/remove-page-path-tail.ts", "language": "typescript", "file_size": 936, "cut_index": 606, "middle_length": 52 }
g]/[projectSlug]/monitoring', }, ] const sorted = sortSortableRoutes(routes) expect(sorted).toEqual([ { sourcePage: '/[lang]/[teamSlug]/~/monitoring', page: '/[lang]/[teamSlug]/~/monitoring', }, { sourcePage: '/[lang]/[teamSlug]/[projectSlug]/monitoring', ...
ameter types', () => { const routes: SortableRoute[] = [ { sourcePage: '/docs/[[...slug]]', page: '/docs/[[...slug]]', }, { sourcePage: '/docs/[...slug]', page: '/docs/[...slug]', }, {
g', }, { sourcePage: '/[lang]/[teamSlug]/[projectSlug]/monitoring', page: '/[lang]/[teamSlug]/[projectSlug]/monitoring', }, ]) }) it('should sort routes by specificity with different par
{ "filepath": "packages/next/src/shared/lib/router/utils/sortable-routes.test.ts", "language": "typescript", "file_size": 28878, "cut_index": 1331, "middle_length": 229 }
ple, the `app/[lang]/[...rest]/page.tsx` that was rendered with a lang * value of `en` would have a page of '/en/[...rest]'. */ readonly page: string } /** * Determines the specificity of a route segment for sorting purposes. * * In Next.js routing, more specific routes should match before less specific one...
ment (e.g., "api", "[id]", "[...slug]") * @returns A numeric specificity value (0-3, where 0 is most specific) */ export function getSegmentSpecificity(segment: string): number { // Static segments are most specific - they match exactly one path if (
turn 0 * 2. Dynamic segments (e.g., "[id]", "[slug]") - return 1 * 3. Catch-all segments (e.g., "[...slug]") - return 2 * 4. Optional catch-all segments (e.g., "[[...slug]]") - return 3 * * @param segment - A single path seg
{ "filepath": "packages/next/src/shared/lib/router/utils/sortable-routes.ts", "language": "typescript", "file_size": 9448, "cut_index": 921, "middle_length": 229 }
/ This has to be a shared module which is shared between client component error boundary and dynamic component const BAILOUT_TO_CSR = 'BAILOUT_TO_CLIENT_SIDE_RENDERING' /** An error that should be thrown when we want to bail out to client-side rendering. */ export class BailoutToCSRError extends Error { public reado...
want to bail out to client-side rendering. */ export function isBailoutToCSRError(err: unknown): err is BailoutToCSRError { if (typeof err !== 'object' || err === null || !('digest' in err)) { return false } return err.digest === BAILOUT_TO_CSR
s thrown if we
{ "filepath": "packages/next/src/shared/lib/lazy-dynamic/bailout-to-csr.ts", "language": "typescript", "file_size": 786, "cut_index": 513, "middle_length": 14 }
x will have fast negatives meaning valid identifiers may not pass // this test. However this is only used during static generation to provide hints // about why a page bailed out of some or all prerendering and we can use bracket notation // for example while `ΰ² _ΰ² ` is a valid identifier it's ok to print `searchParams['...
prop: string ) { const stringifiedProp = JSON.stringify(prop) return `\`Reflect.has(${target}, ${stringifiedProp})\`, \`${stringifiedProp} in ${target}\`, or similar` } export const wellKnownProperties = new Set([ 'hasOwnProperty', 'isPrototypeO
g, prop: string) { if (isDefinitelyAValidIdentifier.test(prop)) { return `\`${target}.${prop}\`` } return `\`${target}[${JSON.stringify(prop)}]\`` } export function describeHasCheckingStringProperty( target: string,
{ "filepath": "packages/next/src/shared/lib/utils/reflect-utils.ts", "language": "typescript", "file_size": 1428, "cut_index": 524, "middle_length": 229 }
egment-explorer-node' /** * Trie data structure for storing and searching paths * * This can be used to store app router paths and search for them efficiently. * e.g. * * [trie root] * β”œβ”€β”€ layout.js * β”œβ”€β”€ page.js * β”œβ”€β”€ blog * β”œβ”€β”€ layout.js * β”œβ”€β”€ page.js * β”œβ”€β”€ [slug] * β”œβ”€β”€ ...
> void getSnapshot: () => SegmentTrieNode getServerSnapshot: () => SegmentTrieNode } => { // return a store that can be used by useSyncExternalStore return { subscribe: (callback) => { listeners.add(callback) return () => listeners.
g> = { insert: (value: Value) => void remove: (value: Value) => void getRoot: () => TrieNode<Value> } const listeners = new Set<() => void>() const createSegmentTreeStore = (): { subscribe: (callback: () => void) => () =
{ "filepath": "packages/next/src/next-devtools/dev-overlay/segment-explorer-trie.ts", "language": "typescript", "file_size": 3978, "cut_index": 614, "middle_length": 229 }
{ Meta, StoryObj } from '@storybook/react' import { BuildError } from './build-error' import { withShadowPortal } from '../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof BuildError> = { component: BuildError, parameters: { layout: 'fullscreen', }, decorators: [withShadowPortal],...
const > 3 | return <div>Hello World</div> | ^^^^^^ 4 | } 5 | Expected identError: Failed to resolve import "./missing-module" https://nextjs.org/docs/messages/module-not-found`, versionInfo: { installed: '15.0.0', staleness
ing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 1 | export default function Home() { 2 |
{ "filepath": "packages/next/src/next-devtools/dev-overlay/container/build-error.stories.tsx", "language": "tsx", "file_size": 1453, "cut_index": 524, "middle_length": 229 }
wportError, createDynamicViewportError, createRuntimeBodyError, createRuntimeBodyErrorInNavigation, createRuntimeMetadataError, createRuntimeViewportError, } from '../../../server/app-render/blocking-route-messages' import { createSyncIOClientError, createSyncIOError, createSyncIORuntimeError, type Sy...
namic body factory output', () => { expect(isRuntimeVariant(createDynamicBodyError(ROUTE).message)).toBe(false) }) it('returns true for runtime metadata factory output', () => { expect(isRuntimeVariant(createRuntimeMetadataError(ROUTE).message
ROUTE = '/example' describe('isRuntimeVariant', () => { it('returns true for runtime body factory output', () => { expect(isRuntimeVariant(createRuntimeBodyError(ROUTE).message)).toBe(true) }) it('returns false for dy
{ "filepath": "packages/next/src/next-devtools/dev-overlay/container/errors.test.ts", "language": "typescript", "file_size": 8683, "cut_index": 716, "middle_length": 229 }
import type { Meta, StoryObj } from '@storybook/react' import { PseudoHtmlDiff } from './component-stack-pseudo-html' import { withShadowPortal } from '../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof PseudoHtmlDiff> = { component: PseudoHtmlDiff, parameters: { layout: 'fullscre...
t> <div> - Server content + Client content`, }, } export const ReactUnifiedMismatch: Story = { args: { reactOutputComponentDiff: '<Page>\n <Layout>\n <div>asd\n- <p>Server content</p>\n+ <p>Client content</p>', }, }
Page> <Layou
{ "filepath": "packages/next/src/next-devtools/dev-overlay/container/runtime-error/component-stack-pseudo-html.stories.tsx", "language": "tsx", "file_size": 783, "cut_index": 512, "middle_length": 14 }
import { addPathPrefix } from './add-path-prefix' import { pathHasPrefix } from './path-has-prefix' /** * For a given path and a locale, if the locale is given, it will prefix the * locale. The path shouldn't be an API path. If a default locale is given the * prefix will be omitted if the locale is already the defa...
on't need to prefix the path. if (!ignorePrefix) { if (pathHasPrefix(lower, '/api')) return path if (pathHasPrefix(lower, `/${locale.toLowerCase()}`)) return path } // Add the locale prefix to the path. return addPathPrefix(path, `/${local
fault locale, we don't need // to prefix the path. if (!locale || locale === defaultLocale) return path const lower = path.toLowerCase() // If the path is an API path or the path already has the locale prefix, we // d
{ "filepath": "packages/next/src/shared/lib/router/utils/add-locale.ts", "language": "typescript", "file_size": 1004, "cut_index": 512, "middle_length": 229 }
le { detectedLocale?: string pathname: string } /** * A cache of lowercased locales for each list of locales. This is stored as a * WeakMap so if the locales are garbage collected, the cache entry will be * removed as well. */ const cache = new WeakMap<readonly string[], readonly string[]>() /** * For a path...
locales is undefined, return the pathname as is. if (!locales) return { pathname } // Get the cached lowercased locales or create a new cache entry. let lowercasedLocales = cache.get(locales) if (!lowercasedLocales) { lowercasedLocales = loca
include a locale. * @param locales A list of locales. * @returns The detected locale and pathname without locale */ export function normalizeLocalePath( pathname: string, locales?: readonly string[] ): PathLocale { // If
{ "filepath": "packages/next/src/shared/lib/i18n/normalize-locale-path.ts", "language": "typescript", "file_size": 2011, "cut_index": 537, "middle_length": 229 }
ng * * This module is shared between server and client. */ export type VaryParams = Set<string> type FulfilledVaryParamsThenable = { status: 'fulfilled' value: VaryParams } & PromiseLike<VaryParams> type PendingVaryParamsThenable = { // 'resolved_model' is an internal React Flight state: the underlying mode...
(client-side or in collectSegmentData), the * thenable should already be fulfilled because the Flight stream has been * fully received. We check the status synchronously to avoid unnecessary * microtasks. * * Returns null if the thenable is still pend
value: unknown } & PromiseLike<VaryParams> export type VaryParamsThenable = | FulfilledVaryParamsThenable | PendingVaryParamsThenable /** * Synchronously reads vary params from a thenable. * * By the time this is called
{ "filepath": "packages/next/src/shared/lib/segment-cache/vary-params-decoding.ts", "language": "typescript", "file_size": 1929, "cut_index": 537, "middle_length": 229 }
import stripAnsi from 'next/dist/compiled/strip-ansi' import { Terminal } from '../components/terminal' import { ErrorOverlayLayout } from '../components/errors/error-overlay-layout/error-overlay-layout' import type { ErrorBaseProps } from '../components/errors/error-overlay/error-overlay' interface BuildErrorProps e...
. return ( stripAnsi(lines[1] || '') // label will already say that it's an error .replace(/^Error: /, '') ) } export const BuildError: React.FC<BuildErrorProps> = function BuildError({ message, ...props }) { const noop = useCall
ror message looks like: // <file path>:<line number>:<column number> // <error message> // <error code frame of compiler or bundler> // e.g. // ./path/to/file.js:1:1 // SyntaxError: ... // > 1 | con st foo = // ..
{ "filepath": "packages/next/src/next-devtools/dev-overlay/container/build-error.tsx", "language": "tsx", "file_size": 2209, "cut_index": 563, "middle_length": 229 }
{ denormalizePagePath } from './denormalize-page-path' import path from '../isomorphic/path' /** * Calculate all possible pagePaths for a given normalized pagePath along with * allowed extensions. This can be used to check which one of the files exists * and to debug inspected locations. * * For pages, map `/rou...
malizedPagePath) let prefixes: string[] if (isAppDir) { prefixes = [page] } else if (normalizedPagePath.endsWith('/index')) { prefixes = [path.join(page, 'index')] } else { prefixes = [page, path.join(page, 'index')] } const paths
ized page path (it will denormalize). * @param extensions Allowed extensions. */ export function getPagePaths( normalizedPagePath: string, extensions: string[], isAppDir: boolean ) { const page = denormalizePagePath(nor
{ "filepath": "packages/next/src/shared/lib/page-path/get-page-paths.ts", "language": "typescript", "file_size": 1167, "cut_index": 518, "middle_length": 229 }
ct' import type { OverlayState } from './shared' // @ts-expect-error import imgApp from './app.png' import { DevOverlay } from './dev-overlay' import { errors } from '../../../.storybook/fixtures/errors' import { storybookDefaultOverlayState, useStorybookOverlayReducer, } from '../../../.storybook/decorators/use-...
ng on theme. enabled: false, }, ], }, }, }, } export default meta type Story = StoryObj<typeof DevOverlay> function getNoSquashedHydrationErrorDetails() { return null } const initialState: OverlayState = { .
'fullscreen', a11y: { config: { rules: [ { id: 'color-contrast', // Manual testing shows no violation. // TODO: We might have setup more explicit backgrounds dependi
{ "filepath": "packages/next/src/next-devtools/dev-overlay/dev-overlay.stories.tsx", "language": "tsx", "file_size": 2675, "cut_index": 563, "middle_length": 229 }
{ ensureLeadingSlash } from './ensure-leading-slash' import { isDynamicRoute } from '../router/utils' import { NormalizeError } from '../utils' /** * Takes a page and transforms it into its file counterpart ensuring that the * output is normalized. Note this function is not idempotent because a page * `/index` can...
ensureLeadingSlash(page) if (process.env.NEXT_RUNTIME !== 'edge') { const { posix } = require('path') as typeof import('path') const resolvedPage = posix.normalize(normalized) if (resolvedPage !== normalized) { throw new NormalizeErro
`/index/index` */ export function normalizePagePath(page: string): string { const normalized = /^\/index(\/|$)/.test(page) && !isDynamicRoute(page) ? `/index${page}` : page === '/' ? '/index' :
{ "filepath": "packages/next/src/shared/lib/page-path/normalize-page-path.ts", "language": "typescript", "file_size": 1125, "cut_index": 518, "middle_length": 229 }
reateRuntimeBodyErrorInNavigation, } from '../../server/app-render/blocking-route-messages' import { getInstantErrorRoute, routeTemplateMatchesPath } from './shared' const STATIC_ROUTE = '/example' const DYNAMIC_ROUTE_TEMPLATE = '/posts/[slug]' const CATCH_ALL_ROUTE_TEMPLATE = '/docs/[...slug]' describe('getInstantEr...
ROUTE_TEMPLATE) }) it('returns the route for the unrendered-segment wrapper', () => { const error = new Error( `Route "${STATIC_ROUTE}": Could not validate instant UI because an expected segment was not rendered.\n\nUnrendered segment:\n ap
(STATIC_ROUTE) }) it('returns the route for an in-navigation dynamic body error', () => { expect( getInstantErrorRoute( createDynamicBodyErrorInNavigation(DYNAMIC_ROUTE_TEMPLATE) ) ).toBe(DYNAMIC_
{ "filepath": "packages/next/src/next-devtools/dev-overlay/shared.test.ts", "language": "typescript", "file_size": 3113, "cut_index": 614, "middle_length": 229 }
Obj } from '@storybook/react' import { ErrorMessage } from './error-message' import { withShadowPortal } from '../../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof ErrorMessage> = { component: ErrorMessage, parameters: { layout: 'fullscreen', backgrounds: { default: 'ba...
essage> export const ShortString: Story = { args: { errorMessage: 'A simple error message', }, } export const LongString: Story = { args: { errorMessage: ` Lorem ipsum dolor sit amet consectetur. Aliquet nulla ut fames eu posuere le
might have setup more explicit backgrounds depending on theme. enabled: false, }, ], }, }, }, decorators: [withShadowPortal], } export default meta type Story = StoryObj<typeof ErrorM
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-message/error-message.stories.tsx", "language": "tsx", "file_size": 1854, "cut_index": 537, "middle_length": 229 }
./shared/stack-frame' import { useMemo, useState, useRef } from 'react' import { CallStack } from '../../call-stack/call-stack' interface CallStackProps { frames: readonly OriginalStackFrame[] dialogResizerRef: React.RefObject<HTMLDivElement | null> } export function ErrorOverlayCallStack({ frames, dialogResi...
ialog for animation if (!dialog) { // No dialog ref available, just close without animation setIsIgnoreListOpen(false) return } const { height: currentHeight } = dialog.getBoundingClientRect() if (!initialD
return frames.reduce((tally, frame) => tally + (frame.ignored ? 1 : 0), 0) }, [frames]) function onToggleIgnoreList() { const dialog = dialogResizerRef?.current if (isIgnoreListOpen) { // Closing requires d
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-call-stack/error-overlay-call-stack.tsx", "language": "tsx", "file_size": 2231, "cut_index": 563, "middle_length": 229 }
mport { Dialog } from '../../dialog/dialog' type ErrorOverlayDialogProps = { children?: React.ReactNode onClose?: () => void } & React.HTMLAttributes<HTMLDivElement> export function ErrorOverlayDialog({ children, onClose, ...props }: ErrorOverlayDialogProps) { return ( <div className="error-overlay-di...
ground: var(--color-background-100); background-clip: padding-box; border-radius: var(--next-dialog-radius); box-shadow: var(--shadow-menu); position: relative; overflow: hidden; } .error-overlay-dialog-scroll { overflow-y: aut
onClose={onClose} {...props} > {children} </Dialog> </div> ) } export const DIALOG_STYLES = ` .error-overlay-dialog-container { display: flex; flex-direction: column; back
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dialog/dialog.tsx", "language": "tsx", "file_size": 1055, "cut_index": 513, "middle_length": 229 }
bject<HTMLElement | null>, triggerRef: React.RefObject<HTMLButtonElement | null> | null, active: boolean, onOpenFocus?: () => void ) { const fireOpenFocus = useEffectEvent((rootNode: HTMLElement | null) => { if (onOpenFocus) { onOpenFocus() } else { rootNode?.focus() } }) useEffect((...
() e.preventDefault() } } else { if (activeElement === lastFocusableNode) { firstFocusableNode?.focus() e.preventDefault() } } } const id = setTimeout(() => { // Grab this on
Node, lastFocusableNode] = getFocusableNodes(rootNode) const activeElement = getActiveElement(rootNode) if (e.shiftKey) { if (activeElement === firstFocusableNode) { lastFocusableNode?.focus
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/utils.ts", "language": "typescript", "file_size": 4850, "cut_index": 614, "middle_length": 229 }
'react' export function CacheDisabledBody(props: ComponentProps<'div'>) { return ( <article className="dev-tools-info-article" {...props}> <p className="dev-tools-info-paragraph"> While loading this page, all caches were bypassed. </p> <p className="dev-tools-info-paragraph"> T...
be the same as in production. React's DevTools will also not accurately show information about what would normally suspend in the page, and Next.js cannot validate whether a navigation to this page would be instant or blocking.
As a result, the loading experience might not
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/dev-tools-info/cache-disabled.tsx", "language": "tsx", "file_size": 884, "cut_index": 547, "middle_length": 52 }
{ routerType: 'pages' | 'app' } & ComponentProps<'div'>) { return ( <article className="dev-tools-info-article" {...props}> <p className="dev-tools-info-paragraph"> The path{' '} <code className="dev-tools-info-code">{window.location.pathname}</code>{' '} is marked as "static" since...
l-static-regeneration' : `https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration` } target="_blank" rel="noopener noreferrer" > data revalidation
background after{' '} <a className="dev-tools-info-link" href={ routerType === 'pages' ? 'https://nextjs.org/docs/pages/building-your-application/data-fetching/incrementa
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/dev-tools-info/route-info.tsx", "language": "tsx", "file_size": 4477, "cut_index": 614, "middle_length": 229 }
Obj } from '@storybook/react' import { ErrorOverlayCallStack } from './error-overlay-call-stack' import { withShadowPortal } from '../../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof ErrorOverlayCallStack> = { component: ErrorOverlayCallStack, parameters: { layout: 'fullscreen',...
a type Story = StoryObj<typeof ErrorOverlayCallStack> const frame = { originalStackFrame: { file: './app/page.tsx', methodName: 'MyComponent', arguments: [], line1: 10, column1: 5, ignored: false, }, sourceStackFrame: { f
no violation. // TODO: We might have setup more explicit backgrounds depending on theme. enabled: false, }, ], }, }, }, decorators: [withShadowPortal], } export default met
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-call-stack/error-overlay-call-stack.stories.tsx", "language": "tsx", "file_size": 1939, "cut_index": 537, "middle_length": 229 }
rom '../hot-linked-text' import { EditorLink } from './editor-link' import { ExternalIcon } from '../../icons/external' import { getStackFrameFile, type StackFrame } from '../../../shared/stack-frame' import { useOpenInEditor } from '../../utils/use-open-in-editor' import { FileIcon } from '../../icons/file' type Term...
ileName, location: hasLocation ? { line1: parsedLine, column1: parsedColumn, } : undefined, } } function getImportTraceFiles(lines: string[]) { if ( lines.some((line) => /ReactServerComponentsError:/.tes
ame.split(':', 3) const parsedLine = Number(line) const parsedColumn = Number(column) const hasLocation = !Number.isNaN(parsedLine) && !Number.isNaN(parsedColumn) return { fileName: hasLocation ? fileName : contentF
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/terminal/terminal.tsx", "language": "tsx", "file_size": 5025, "cut_index": 614, "middle_length": 229 }
'error' error: unknown } | { state: 'success' } const [copyState, dispatch, isPending] = React.useActionState( ( state: CopyState, action: 'reset' | 'copy' ): CopyState | Promise<CopyState> => { if (action === 'reset') { return { state: 'initial' } } i...
return { state: 'error', error } } ) }) } return state }, { state: 'initial', } ) function copy() { React.startTransition(() => { dispatch('copy') }) } const reset =
} return getContent().then((content) => { return navigator.clipboard.writeText(content).then( () => { return { state: 'success' } }, (error) => {
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/copy-button/index.tsx", "language": "tsx", "file_size": 5682, "cut_index": 716, "middle_length": 229 }
Obj } from '@storybook/react' import { CallStack } from './call-stack' import { withShadowPortal } from '../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof CallStack> = { component: CallStack, parameters: { layout: 'fullscreen', backgrounds: { default: 'background-100-da...
e = { originalStackFrame: { file: './app/page.tsx', methodName: 'MyComponent', arguments: [], line1: 10, column1: 5, ignored: false, }, sourceStackFrame: { file: './app/page.tsx', methodName: 'MyComponent', argumen
p more explicit backgrounds depending on theme. enabled: false, }, ], }, }, }, decorators: [withShadowPortal], } export default meta type Story = StoryObj<typeof CallStack> const fram
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/call-stack/call-stack.stories.tsx", "language": "tsx", "file_size": 1874, "cut_index": 537, "middle_length": 229 }
tjs-dialog-overlay] { position: fixed; top: 0; right: 0; bottom: 0; left: 0; /* secondary z-index, -1 than toast z-index */ z-index: 2147483646; display: flex; align-content: center; align-items: center; flex-direction: column; padding: 10vh 15px 0; /* color schemes ...
sition: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: var(--color-backdrop); backdrop-filter: blur(10px); pointer-events: all; z-index: -1; } [data-nextjs-dialog-backdrop-fixed] { cursor: not-allowe
} } [data-nextjs-dialog-backdrop] { po
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/overlay/styles.tsx", "language": "tsx", "file_size": 990, "cut_index": 582, "middle_length": 52 }
' }, dynamic: { label: 'Dynamic', color: 'blue', icon: 'server-stack' }, client: { label: 'Client', color: 'amber', icon: 'layout' }, defer: { label: 'Defer', color: 'amber', icon: 'pointer-click' }, measure: { label: 'Measure', color: 'gray', icon: 'timer' }, } export type FixCard = { /** Stable docs-anchor...
ghlight` flag. `text` is still kept for any // tooling that reads the full line content. parts?: SnippetPart[] } // ── Blocking-route cards ────────────────────────── const runtimeCards: FixCard[] = [ { id: 'wrap-in-or-move-into-suspense',
ype SnippetPart = { text: string highlight?: boolean } export type Snippet = { text: string highlight?: boolean // When present, render the line with inline highlighted parts instead of // applying the line-level `hi
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/instant/instant-guidance-data.ts", "language": "typescript", "file_size": 20385, "cut_index": 1331, "middle_length": 229 }
segment-explorer-path' import { useClickOutsideAndEscape } from '../errors/dev-tools-indicator/utils' const composeRefs = (...refs: (React.Ref<HTMLButtonElement> | undefined)[]) => { return (node: HTMLButtonElement | null) => { refs.forEach((ref) => { if (typeof ref === 'function') { ref(node) ...
vOverlayContext() const triggerRef = useRef<HTMLButtonElement>(null) const popupRef = useRef<HTMLDivElement>(null) // Click outside of popup should close the menu useClickOutsideAndEscape( popupRef, triggerRef, isOpen, () => {
<SegmentBoundaryType, string | null> }) { const currNode = nodeState const { pagePath, boundaryType, setBoundaryType: onSelectBoundary } = currNode const [isOpen, setIsOpen] = useState(false) const { shadowRoot } = useDe
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/overview/segment-boundary-trigger.tsx", "language": "tsx", "file_size": 11041, "cut_index": 921, "middle_length": 229 }
{ Meta, StoryObj } from '@storybook/react' import { CodeFrame } from './code-frame' import { withShadowPortal } from '../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof CodeFrame> = { component: CodeFrame, parameters: { layout: 'fullscreen', }, decorators: [withShadowPortal], ...
39m() {\u001b[0m \u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 2 \u001b[39m \u001b[36mthrow\u001b[39m \u001b[36mnew\u001b[39m \u001b[33mError\u001b[39m(\u001b[32m'boom'\u001b[39m)\u001b[0m \u001b[0m \u001b[90m \u001b[39m \u001b[31
onst SimpleCodeFrame: Story = { args: { stackFrame: baseStackFrame, codeFrame: `\u001b[0m \u001b[90m 1 \u001b[39m \u001b[36mexport\u001b[39m \u001b[36mdefault\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mHome\u001b[
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/code-frame/code-frame.stories.tsx", "language": "tsx", "file_size": 1422, "cut_index": 524, "middle_length": 229 }
tils/use-open-in-editor' import { ExternalIcon } from '../../icons/external' import { FileIcon } from '../../icons/file' import { formatCodeFrame, groupCodeFrameLines, parseLineNumberFromCodeFrameLine, } from './parse-code-frame' type CodeFrameProps = { stackFrame: StackFrame codeFrame: string } export func...
e, line1: stackFrame.line1 ?? 1, column1: stackFrame.column1 ?? 1, }) const fileExtension = stackFrame?.file?.split('.').pop() return ( <div data-nextjs-codeframe> <div className="code-frame-header"> {/* TODO: This is <div>
dedLines.map((line) => { return { line, parsedLine: parseLineNumberFromCodeFrameLine(line, stackFrame), } }) }, [codeFrame, stackFrame]) const open = useOpenInEditor({ file: stackFrame.fil
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/code-frame/code-frame.tsx", "language": "tsx", "file_size": 6969, "cut_index": 716, "middle_length": 229 }
ort type { Meta, StoryObj } from '@storybook/react' import { ErrorOverlayLayout } from './error-overlay-layout' import { withShadowPortal } from '../../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof ErrorOverlayLayout> = { component: ErrorOverlayLayout, parameters: { layout: 'ful...
aleness: 'fresh', }, children: ( <div style={{ margin: '1rem' }}> Module not found: Cannot find module './missing-module' </div> ), }, } export const Turbopack: Story = { args: { ...Default.args, isTurbopack: tr
duleNotFoundError', message: "Cannot find module './missing-module'", }, errorType: 'Build Error', errorMessage: 'Failed to compile', errorCode: 'E001', versionInfo: { installed: '15.0.0', st
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-layout/error-overlay-layout.stories.tsx", "language": "tsx", "file_size": 1112, "cut_index": 515, "middle_length": 229 }
} from './error-feedback/error-feedback' import { styles as feedbackStyles } from './error-feedback/error-feedback' type ErrorOverlayFooterProps = { errorCode: string | undefined } export function ErrorOverlayFooter({ errorCode }: ErrorOverlayFooterProps) { return ( <footer data-nextjs-error-overlay-footer cl...
irection: row; justify-content: space-between; gap: 8px; padding: 12px 12px 8px 12px; } .error-feedback { margin-left: auto; p { font-size: var(--size-14); font-weight: 500; margin: 0; } } ${feedbackSty
error-overlay-footer { display: flex; flex-d
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-footer/error-overlay-footer.tsx", "language": "tsx", "file_size": 850, "cut_index": 535, "middle_length": 52 }
e-label/error-type-label' export type ErrorMessageType = React.ReactNode type ErrorMessageProps = { errorMessage: ErrorMessageType errorType: ErrorType } export function ErrorMessage({ errorMessage, errorType }: ErrorMessageProps) { const [isExpanded, setIsExpanded] = useState(false) const [isTooTall, setIsT...
scroll overflow instead. const shouldTruncate = isTooTall && errorType !== 'Instant' return ( <> <div className="nextjs__container_errors_wrapper"> <div ref={messageRef} id="nextjs__container_errors_desc"
} }, [errorMessage]) if (!errorMessage) { return null } // Instant errors are formatted specifically for the overlay rather than // passed through from the console, so we don't truncate them β€” they rely // on
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-message/error-message.tsx", "language": "tsx", "file_size": 3631, "cut_index": 614, "middle_length": 229 }
le, normalizeBoundaryFilename, } from '../../../../server/app-render/segment-explorer-path' import { SegmentSuggestion } from './segment-suggestion' import type { SegmentBoundaryType } from '../../../userspace/app/segment-explorer-node' const isFileNode = (node: SegmentTrieNode) => { return !!node.value?.type && !...
ndaries(child) } }) } function countActiveBoundaries(node: SegmentTrieNode): number { let count = 0 // Count this node's boundary override if it's active // Only count when there's a non ":boundary" type and it has an active override (boundar
aryType function if (node.value?.setBoundaryType) { node.value.setBoundaryType(null) } // Recursively traverse children Object.values(node.children).forEach((child) => { if (child) { traverseTreeAndResetBou
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.tsx", "language": "tsx", "file_size": 16586, "cut_index": 921, "middle_length": 229 }
urn ( <svg clipRule="evenodd" fillRule="evenodd" height="16" viewBox="0 0 1321.45 1333.33" width="16" > <path d="M221.37 618.44h757.94V405.15H755.14c-23.5 0-56.32-12.74-71.82-28.24-15.5-15.5-25-43.47-25-66.97V82.89H88.39c-1.99 0-3.49 1-4.49 2-1.5 1-2 2.5-2 4.5v1155.04...
2.81 26.33 1.76 5.78 4.75 10.37 9 13.95 2.87 2.33 6.94 3.46 12.25 3.46 8.4 0 14.58-3.46 18.53-10.37 3.9-6.92 5.87-18.6 5.87-35V735.92zm112.77 180.67l71.17-4.97c1.54 12.81 4.69 22.62 9.44 29.28 7.74 10.88 18.74 16.34 33.09 16.34 10.68 0 18.93-2.76 24.68-8.3
30.79-2.44 54.23-7.33 70.31-4.92 16.03-14.8 29.67-29.65 40.85-14.86 11.12-33.91 16.72-57.05 16.72-24.53 0-43.51-3.71-56.94-11.06-13.5-7.36-23.89-18.1-31.23-32.3-7.35-14.14-11.69-31.67-12.99-52.53l71.5-10.81c.11 11.81 1.07 20.61
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/file.tsx", "language": "tsx", "file_size": 13487, "cut_index": 921, "middle_length": 229 }
rentColor', strokeWidth: 2, strokeLinecap: 'round' as const, strokeLinejoin: 'round' as const, } export function FixCardAlignLeftIcon() { return ( <svg {...ICON_PROPS}> <path d="M3 6h18M3 12h12M3 18h18" /> </svg> ) } export function FixCardServerStackIcon() { return ( <svg width="1...
3.5V9m3.75 4.25a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M8 12.5a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m2.5-9a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0m-1.75.75a.75.75 0 1 1 0-1.5.75.75 0 0 1 0 1.5" /> </svg> ) } export function FixCardHistoryIcon() {
ule="evenodd" d="M13.5 1.5h-11v3a1 1 0 0 0 1 1h9a1 1 0 0 0 1-1zM15 0H1v4.5A2.5 2.5 0 0 0 3.5 7h9A2.5 2.5 0 0 0 15 4.5V0M2.5 13.5v-3h11v3a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1M1 9h14v4.5a2.5 2.5 0 0 1-2.5 2.5h-9A2.5 2.5 0 0 1 1 1
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/fix-card-icons.tsx", "language": "tsx", "file_size": 5072, "cut_index": 614, "middle_length": 229 }
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 20 20" fill="none" > <path fill="currentColor" fillRule="evenodd" d="m9.7 3.736.045-.236h.51l.044.236a2.024 2.024 0 0 0 1.334 1.536c.19.066.375.143.554.23.618.301 1.398.29 2.03-.1...
0 0 0-2.03.143l-.199.136-.36-.361.135-.199a2.024 2.024 0 0 0 .143-2.03 4.958 4.958 0 0 1-.23-.554 2.024 2.024 0 0 0-1.536-1.334l-.236-.044v-.51l.236-.044a2.024 2.024 0 0 0 1.536-1.334 4.96 4.96 0 0 1 .23-.554 2.024 2.024 0 0 0-.143-2.03l-.136-.199.361-.36
2.024 0 0 0 .143 2.03l.136.199-.361.36-.199-.135a2.024 2.024 0 0 0-2.03-.143c-.179.087-.364.164-.554.23a2.024 2.024 0 0 0-1.334 1.536l-.044.236h-.51l-.044-.236a2.024 2.024 0 0 0-1.334-1.536 4.952 4.952 0 0 1-.554-.23 2.024 2.024
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/gear-icon.tsx", "language": "tsx", "file_size": 2066, "cut_index": 563, "middle_length": 229 }
xport default function LightIcon() { return ( <svg xmlns="http://www.w3.org/2000/svg" width="20" height="16" viewBox="0 0 16 16" fill="none" > <g clipPath="url(#light_icon_clip_path)"> <path fill="currentColor" fillRule="evenodd" d="M8....
53.53 1.06-1.06-.53-.53-.354-.354-.53-.53-1.06 1.06.53.53.353.354ZM8.75 14v2h-1.5v-2h1.5Z" clipRule="evenodd" /> </g> <defs> <clipPath id="light_icon_clip_path"> <path fill="currentColor" d="M0 0h16v16H0z" />
5 3.25 0 1 0 0-6.5 3.25 3.25 0 0 0 0 6.5Zm0 1.5a4.75 4.75 0 1 0 0-9.5 4.75 4.75 0 0 0 0 9.5Zm6-5.5h2v1.5h-2v-1.5Zm-13.25 0H0v1.5h2v-1.5H.75Zm1.62 5.32-.53.53 1.06 1.06.53-.53.354-.353.53-.53-1.06-1.061-.53.53-.354.354Zm10.2 1.06.
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/light-icon.tsx", "language": "tsx", "file_size": 1050, "cut_index": 513, "middle_length": 229 }
ort function Warning(props: React.SVGProps<SVGSVGElement>) { return ( <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" {...props} > <path fillRule="evenodd" clipRule="evenodd" d="M3.98071 1.125L1.12...
11.921 3.4357 11.7803 3.29505L8.70495 0.21967C8.5643 0.0790177 8.37353 0 8.17462 0H3.82538ZM6.5625 2.8125V3.375V6V6.5625H5.4375V6V3.375V2.8125H6.5625ZM6 9C6.41421 9 6.75 8.66421 6.75 8.25C6.75 7.83579 6.41421 7.5 6 7.5C5.58579 7.5 5.25 7.83579 5.25 8.25C5
.82538V8.17462C0 8.37353 0.0790178 8.5643 0.21967 8.70495L3.29505 11.7803C3.4357 11.921 3.62647 12 3.82538 12H8.17462C8.37353 12 8.5643 11.921 8.70495 11.7803L11.7803 8.70495C11.921 8.5643 12 8.37353 12 8.17462V3.82538C12 3.62647
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/warning.tsx", "language": "tsx", "file_size": 1082, "cut_index": 515, "middle_length": 229 }
n(props: ComponentProps<'svg'>) { return ( <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className="thumbs-down-icon" {...props} > <path fillRule="evenodd" clipRule="evenodd" d="M5.89531 12...
1 11.6889L5.89531 12.7603ZM4 12.5569C4 13.9803 5.6089 14.8082 6.76717 13.9809L8.26717 12.9095C8.72706 12.581 9 12.0506 9 11.4854V9.5H12.1884C13.9775 9.5 15.2903 7.81868 14.8563 6.08303L13.8563 2.08303C13.5503 0.858816 12.4503 0 11.1884 0H0.75H0V0.75V8.75V9
H7.5V8.75V11.4854C7.5 11.5662 7.46101 11.6419 7.3953
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/thumbs/thumbs-down.tsx", "language": "tsx", "file_size": 996, "cut_index": 582, "middle_length": 52 }
type { ComponentProps } from 'react' export function ThumbsUp(props: ComponentProps<'svg'>) { return ( <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" className="thumbs-up-icon" {...props} > <g id="thumb-up-16"> ...
59ZM5 2.44303C5 1.01963 6.6089 0.191656 7.76717 1.01899L9.26717 2.09042C9.72706 2.41892 10 2.94929 10 3.51446V5.49989H13.1884C14.9775 5.49989 16.2903 7.18121 15.8563 8.91686L14.8563 12.9169C14.5503 14.1411 13.4503 14.9999 12.1884 14.9999H1.75H1V14.2499V6.2
989 4.75 6.99989H2.5V13.4999H12.1884C12.762 13.4999 13.262 13.1095 13.4011 12.5531L14.4011 8.55306C14.5984 7.76412 14.0017 6.99989 13.1884 6.99989H9.25H8.5V6.24989V3.51446C8.5 3.43372 8.46101 3.35795 8.39531 3.31102L6.89531 2.239
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/thumbs/thumbs-up.tsx", "language": "tsx", "file_size": 1141, "cut_index": 518, "middle_length": 229 }
s' describe('css template literal tag', () => { it('should combines strings and interpolations correctly', () => { const color = 'red' const result = css` color: ${color}; background: blue; ` expect(result).toBe('color:red;background:blue;') }) it('should remove all whitespace', () =...
() => { const result = css` color: blue; /* * This is multi-line comment. * Is should be removed. */ margin: 10px; ` expect(result).toBe('color:blue;margin:10px;') }) it('should handle multiple interp
s` color: blue; /* this is a comment */ /* multi-line comment */ /** jsdoc */ margin: 10px; ` expect(result).toBe('color:blue;margin:10px;') }) it('should remove multiline comments',
{ "filepath": "packages/next/src/next-devtools/dev-overlay/utils/css.test.ts", "language": "typescript", "file_size": 1643, "cut_index": 537, "middle_length": 229 }
tack-frame' import { getErrorSource } from '../../../shared/lib/error-source' import { parseStack } from '../../../server/lib/parse-stack' import React from 'react' export type ReadyErrorCause = | { error: Error frames: () => Promise<readonly OriginalStackFrame[]> cause?: ReadyErrorCause } | ...
ReadyErrorCause } | { id: number runtime: true error: AggregateError & { environmentName?: string } frames: () => Promise<readonly OriginalStackFrame[]> type: 'runtime' | 'console' | 'recoverable' cause?: ReadyErr
untimeError = | { id: number runtime: true error: Error & { environmentName?: string } frames: () => Promise<readonly OriginalStackFrame[]> type: 'runtime' | 'console' | 'recoverable' cause?:
{ "filepath": "packages/next/src/next-devtools/dev-overlay/utils/get-error-by-type.ts", "language": "typescript", "file_size": 5253, "cut_index": 716, "middle_length": 229 }
nte non malesuada. Nunc congue urna id laoreet tempor. Nunc rhoncus nec ante eu dapibus. Sed egestas neque vel vehicula ullamcorper. Phasellus quis accumsan turpis, et condimentum nibh. Sed dignissim diam ex, consectetur aliquet lectus feugiat a. Etiam tempor varius massa, sed suscipit nulla. Pellentesque orci est, ...
pibus et. Donec sodales dui in semper consequat. Suspendisse potenti. Aliquam augue dolor, tincidunt quis sem a, rhoncus porttitor eros. Sed molestie leo eget elementum vehicula. Praesent velit turpis, blandit non ex et, lacinia elementum dolor. Aliquam
rnare. Nunc quis augue id velit venenatis posuere. Aenean et velit fermentum, facilisis nunc vel, cursus purus. Integer tempus velit et diam vulputate, in convallis nisi feugiat. Sed euismod aliquet neque, ac fermentum risus da
{ "filepath": "packages/next/src/next-devtools/dev-overlay/utils/lorem.ts", "language": "typescript", "file_size": 3362, "cut_index": 614, "middle_length": 229 }
seUrlFromText } from './parse-url-from-text' describe('parseUrlFromText', () => { it('should extract a URL from text', () => { const text = 'Check out https://nextjs.org for more info' expect(parseUrlFromText(text)).toEqual(['https://nextjs.org']) }) it('should extract multiple URLs from text', () => { ...
tarted?query=123#fragment', ]) }) it('should return empty array when no URLs are found', () => { const text = 'This text contains no URLs' expect(parseUrlFromText(text)).toEqual([]) }) it('should handle empty string input', () => {
handle URLs with paths and query parameters', () => { const text = 'Link: https://nextjs.org/docs/getting-started?query=123#fragment' expect(parseUrlFromText(text)).toEqual([ 'https://nextjs.org/docs/getting-s
{ "filepath": "packages/next/src/next-devtools/dev-overlay/utils/parse-url-from-text.test.ts", "language": "typescript", "file_size": 1329, "cut_index": 524, "middle_length": 229 }
type { DevToolsConfig } from '../shared' import { devToolsConfigSchema } from '../../shared/devtools-config-schema' import { deepMerge } from '../../shared/deepmerge' let queuedConfigPatch: DevToolsConfig = {} let timer: ReturnType<typeof setTimeout> | null = null function flushPatch() { if (Object.keys(queuedConf...
data: body, error, }) }) } export function saveDevToolsConfig(patch: DevToolsConfig) { const validation = devToolsConfigSchema.safeParse(patch) if (!validation.success) { console.warn( '[Next.js DevTools] Invalid config patc
ontent-Type': 'application/json' }, body, // keepalive in case of fetch interrupted, e.g. navigation or reload keepalive: true, }).catch((error) => { console.warn('[Next.js DevTools] Failed to save config:', {
{ "filepath": "packages/next/src/next-devtools/dev-overlay/utils/save-devtools-config.ts", "language": "typescript", "file_size": 1204, "cut_index": 518, "middle_length": 229 }
ction useOpenInEditor({ file, line1, column1, }: { file?: string | null line1?: number | null column1?: number | null } = {}) { const openInEditor = useCallback(() => { if (file == null || line1 == null || column1 == null) return const params = new URLSearchParams() params.append('file', file...
.then( () => {}, (cause) => { console.error( `Failed to open file "${file} (${line1}:${column1})" in your editor. Cause:`, cause ) } ) }, [file, line1, column1]) return openIn
tjs_launch-editor?${params.toString()}` )
{ "filepath": "packages/next/src/next-devtools/dev-overlay/utils/use-open-in-editor.ts", "language": "typescript", "file_size": 876, "cut_index": 559, "middle_length": 52 }
de-frame/code-frame' import { styles as dialog } from '../components/dialog' import { styles as errorLayout } from '../components/errors/error-overlay-layout/error-overlay-layout' import { styles as pagination } from '../components/errors/error-overlay-pagination/error-overlay-pagination' import { styles as overlay } f...
'../container/errors' import { styles as containerRuntimeErrorStyles } from '../container/runtime-error' import { COPY_BUTTON_STYLES } from '../components/copy-button' import { CALL_STACK_FRAME_STYLES } from '../components/call-stack-frame/call-stack-frame
minal' import { styles as versionStaleness } from '../components/version-staleness-info/version-staleness-info' import { styles as buildErrorStyles } from '../container/build-error' import { styles as containerErrorStyles } from
{ "filepath": "packages/next/src/next-devtools/dev-overlay/styles/component-styles.tsx", "language": "tsx", "file_size": 2341, "cut_index": 563, "middle_length": 229 }
wardRef, useEffect, useState } from 'react' export const Resizer = forwardRef(function Resizer( { children, measure, ...props }: { children: React.ReactNode measure: boolean } & React.HTMLProps<HTMLDivElement>, resizerRef: React.Ref<HTMLDivElement | null> ) { const [element, setElement] =...
div ref={setElement}>{children}</div> </div> ) }) function useMeasureHeight( element: HTMLDivElement | null, measure: boolean ): [number, boolean] { const [height, setHeight] = useState<number>(0) const [measuring, setMeasuring] = useState<b
on initial load // [x] No duplicate elements // [x] Responds to content growth style={{ height: measuring ? 'auto' : height, transition: 'height 250ms var(--timing-swift)', }} > <
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/resizer/index.tsx", "language": "tsx", "file_size": 1498, "cut_index": 524, "middle_length": 229 }
ayDispatch, type OverlayState, } from '../../../shared' import { Activity } from 'react' import { BuildError } from '../../../container/build-error' import { Errors } from '../../../container/errors' import { useDelayedRender } from '../../../hooks/use-delayed-render' import type { ReadyRuntimeError } from '../../.....
errorCount, }: { state: OverlayState dispatch: OverlayDispatch getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null runtimeErrors: ReadyRuntimeError[] errorCount: number }) { const isTurbopack = !!process.env.TURBOPACK
transitionDurationMs: number isTurbopack: boolean versionInfo: OverlayState['versionInfo'] errorCount: number } export function ErrorOverlay({ state, dispatch, getSquashedHydrationErrorDetails, runtimeErrors,
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay/error-overlay.tsx", "language": "tsx", "file_size": 2071, "cut_index": 563, "middle_length": 229 }
t type { Meta, StoryObj } from '@storybook/react' import { ErrorOverlayToolbar } from './error-overlay-toolbar' import { withShadowPortal } from '../../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof ErrorOverlayToolbar> = { component: ErrorOverlayToolbar, parameters: { layout: 'c...
error with stack trace'), debugInfo: { devtoolsFrontendUrl: 'chrome-devtools://devtools/bundled/inspector.html', }, }, } export const WithErrorOnly: Story = { args: { error: new Error('Test error without debug info'), debugInfo:
w Error('Test
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-toolbar/error-overlay-toolbar.stories.tsx", "language": "tsx", "file_size": 805, "cut_index": 517, "middle_length": 14 }
kUnits="userSpaceOnUse" x="0" y="0" width="14" height="14" > <path d="M6.67.089 1.205 3.256a.663.663 0 0 0-.33.573v6.339c0 .237.126.455.33.574l5.466 3.17a.66.66 0 0 0 .66 0l5.465-3.17a.664.664 0 0 0 .329-.574V3.829a.663.663 0 0 0-.33-.573L7.33.089a.663.663 0 0 0-....
h="12" height="14" > <path d="M1.01 10.57a.663.663 0 0 0 .195.17l4.688 2.72.781.45a.66.66 0 0 0 .51.063l5.764-10.597a.653.653 0 0 0-.153-.122L9.216 1.18 7.325.087a.688.688 0 0 0-.171-.07L1.01 10.57z" fill="#fff"
fill="url(#nodejs_icon_linear_gradient_b)" /> </g> <mask id="nodejs_icon_mask_c" style={{ maskType: 'luminance' }} maskUnits="userSpaceOnUse" x="1" y="0" widt
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-toolbar/nodejs-inspector-button.tsx", "language": "tsx", "file_size": 9699, "cut_index": 921, "middle_length": 229 }
seRestartServer() { const [isPending, setIsPending] = useState(false) const restartServer = async ({ invalidateFileSystemCache, }: { invalidateFileSystemCache: boolean }): Promise<void> => { setIsPending(true) const url = invalidateFileSystemCache ? '/__nextjs_restart_dev?invalidateFileS...
eturn null }) if (!curId) { console.log( '[Next.js DevTools] Failed to get the current server execution ID while restarting dev server.' ) return } const restartRes = await fetch(url, {
.then((data) => data.executionId as number) .catch((error) => { console.log( '[Next.js DevTools] Failed to fetch server status while restarting dev server.', error ) r
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-toolbar/use-restart-server.ts", "language": "typescript", "file_size": 2563, "cut_index": 563, "middle_length": 229 }
{ Meta, StoryObj } from '@storybook/react' import { ErrorOverlayNav } from './error-overlay-nav' import { withShadowPortal } from '../../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof ErrorOverlayNav> = { component: ErrorOverlayNav, parameters: { layout: 'fullscreen', }, deco...
sage'), frames: () => Promise.resolve([]), type: 'runtime', }, { id: 2, runtime: true, error: new Error('Third error message'), frames: () => Promise.resolve([]), type: 'runtime', },
runtime: true, error: new Error('First error message'), frames: () => Promise.resolve([]), type: 'runtime', }, { id: 1, runtime: true, error: new Error('Second error mes
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-nav/error-overlay-nav.stories.tsx", "language": "tsx", "file_size": 1503, "cut_index": 524, "middle_length": 229 }
} from '../components/devtools-indicator/devtools-indicator' import { usePanelRouterContext } from './context' import { usePanelContext } from './panel-router' interface C { closeMenu?: () => void selectedIndex: number setSelectedIndex: Dispatch<SetStateAction<number>> } const MenuContext = createContext({} as...
nction click() { if (isInteractive) { onClick?.() closeMenu?.() if (href) { window.open(href, '_blank', 'noopener, noreferrer') } } } return ( <div className="dev-tools-indicator-item" data-index
=> void }) { const isInteractive = typeof onClick === 'function' || typeof href === 'string' const { closeMenu, selectedIndex, setSelectedIndex } = useContext(MenuContext) const selected = selectedIndex === index fu
{ "filepath": "packages/next/src/next-devtools/dev-overlay/menu/dev-overlay-menu.tsx", "language": "tsx", "file_size": 10251, "cut_index": 921, "middle_length": 229 }
sHeader } from '../components/errors/dev-tools-indicator/dev-tools-info/dev-tools-header' import { useDelayedRender } from '../hooks/use-delayed-render' import { MENU_CURVE, MENU_DURATION_MS, } from '../components/errors/dev-tools-indicator/utils' import { useDevOverlayContext } from '../../dev-overlay.browser' imp...
/dev-tools-indicator/dev-tools-info/user-preferences' import { useShortcuts } from '../hooks/use-shortcuts' import { useUpdateAllPanelPositions } from '../components/devtools-indicator/devtools-indicator' import { saveDevToolsConfig } from '../utils/save-d
ACTION_ERROR_OVERLAY_CLOSE, ACTION_ERROR_OVERLAY_OPEN, } from '../shared' import GearIcon from '../icons/gear-icon' import { LoadingIcon } from '../icons/loading-icon' import { UserPreferencesBody } from '../components/errors
{ "filepath": "packages/next/src/next-devtools/dev-overlay/menu/panel-router.tsx", "language": "tsx", "file_size": 12767, "cut_index": 921, "middle_length": 229 }
-code-frame' describe('parse line numbers', () => { it('parse line numbers from code frame', () => { const input = { stackFrame: { file: 'app/page.tsx', line1: 2, column1: 9, methodName: 'Page', arguments: [], ignored: false, }, // 1 | export de...
b[36mthrow\u001b[39m \u001b[36mnew\u001b[39m \u001b[33mError\u001b[39m(\u001b[32m'test error'\u001b[39m)\u001b[0m\n\u001b[0m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m\n\u001b[0m \u001b[90m 3 |\u001b[39m \u001b[36m
\u001b[90m 1 |\u001b[39m \u001b[36mexport\u001b[39m \u001b[36mdefault\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mPage\u001b[39m() {\u001b[0m\n\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 2 |\u001b[39m \u001
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/code-frame/parse-code-frame.test.ts", "language": "typescript", "file_size": 3754, "cut_index": 614, "middle_length": 229 }
e-label/error-type-label' import { DialogContent } from '../../dialog' import { styles as toolbarStyles } from '../error-overlay-toolbar/error-overlay-toolbar' import { ErrorOverlayFooter } from '../error-overlay-footer/error-overlay-footer' import { ErrorMessage, styles as errorMessageStyles, } from '../error-mes...
Body, DIALOG_BODY_STYLES } from '../dialog/body' import { OVERLAY_STYLES, ErrorOverlayOverlay } from '../overlay/overlay' import type { ErrorBaseProps } from '../error-overlay/error-overlay' import type { ReadyRuntimeError } from '../../../utils/get-error-
rom '../error-overlay-nav/error-overlay-nav' import { ErrorOverlayDialog, DIALOG_STYLES } from '../dialog/dialog' import { ErrorOverlayDialogHeader, DIALOG_HEADER_STYLES, } from '../dialog/header' import { ErrorOverlayDialog
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-layout/error-overlay-layout.tsx", "language": "tsx", "file_size": 5686, "cut_index": 716, "middle_length": 229 }
seContext, useEffect, useMemo, useRef, type Ref, type RefObject, } from 'react' interface DragContextValue { register: (el: HTMLElement) => void unregister: (el: HTMLElement) => void handles: Set<HTMLElement> disabled: boolean } const DragContext = createContext<DragContextValue | null>(null) expor...
> ({ register, unregister, handles: // eslint-disable-next-line react-hooks/refs -- TODO handlesRef.current, disabled, }), [register, unregister, disabled] ) return <DragContext.Provider value={value}>{c
= useCallback((el: HTMLElement) => { handlesRef.current.add(el) }, []) const unregister = useCallback((el: HTMLElement) => { handlesRef.current.delete(el) }, []) const value = useMemo<DragContextValue>( () =
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/drag-context.tsx", "language": "tsx", "file_size": 2075, "cut_index": 563, "middle_length": 229 }
ntext } from '../../../../menu/context' import { css } from '../../../../utils/css' interface DevToolsHeaderProps { title: React.ReactNode children?: React.ReactNode } export function DevToolsHeader({ title, children, ref, }: DevToolsHeaderProps & { ref?: React.Ref<HTMLDivElement> }) { const { setPanel } =...
fontSize: '14px', color: 'var(--color-text-primary)', fontWeight: 'normal', }} > {title} </h3> {children} <button id="_next-devtools-panel-close" className="dev-tools-info-close-b
ng: '8px 20px', userSelect: 'none', WebkitUserSelect: 'none', borderBottom: '1px solid var(--color-gray-alpha-400)', }} ref={ref} > <h3 style={{ margin: 0,
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/dev-tools-info/dev-tools-header.tsx", "language": "tsx", "file_size": 2059, "cut_index": 563, "middle_length": 229 }
rk-icon' import SystemIcon from '../../../../icons/system-icon' import { ShortcutRecorder } from './shortcut-recorder' import { useRestartServer } from '../../error-overlay-toolbar/use-restart-server' import { saveDevToolsConfig } from '../../../../utils/save-devtools-config' export function UserPreferencesBody({ th...
artServer, isPending } = useRestartServer() const { shadowRoot } = useDevOverlayContext() const handleThemeChange = (e: React.ChangeEvent<HTMLSelectElement>) => { const portal = shadowRoot.host if (e.target.value === 'system') { portal.c
HideShortcut: (value: string | null) => void setPosition: (position: DevToolsIndicatorPosition) => void position: DevToolsIndicatorPosition scale: DevToolsScale setScale: (value: DevToolsScale) => void }) { const { rest
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/dev-tools-info/user-preferences.tsx", "language": "tsx", "file_size": 10619, "cut_index": 921, "middle_length": 229 }
* * Format component stack into pseudo HTML * component stack is an array of strings, e.g.: ['p', 'p', 'Page', ...] * * For html tags mismatch, it will render it for the code block * * ``` * <pre> * <code>{` * <Page> * <p red> * <p red> * `}</code> * </pre> * ``` * * For text mismat...
* </div> * </Page> * `}</code> * ``` * */ export function PseudoHtmlDiff({ reactOutputComponentDiff, }: { reactOutputComponentDiff: string }) { const [isDiffCollapsed, toggleCollapseHtml] = useState(true) const htmlComponents = useMem
* ``` * * For bad text under a tag it will render it for the code block, * e.g. "Mismatched Text" under <p> * * ``` * <pre> * <code>{` * <Page> * <div> * <p> * "Mismatched Text" (red) * </p>
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/hydration-diff/diff-view.tsx", "language": "tsx", "file_size": 3915, "cut_index": 614, "middle_length": 229 }
et previousBodyPaddingRight: string | undefined let previousBodyOverflowSetting: string | undefined let activeLocks = 0 export function lock() { setTimeout(() => { if (activeLocks++ > 0) { return } const scrollBarGap = window.innerWidth - document.documentElement.clientWidth if (scroll...
ndefined) { document.body.style.paddingRight = previousBodyPaddingRight previousBodyPaddingRight = undefined } if (previousBodyOverflowSetting !== undefined) { document.body.style.overflow = previousBodyOverflowSetting prev
ody.style.overflow document.body.style.overflow = 'hidden' }) } export function unlock() { setTimeout(() => { if (activeLocks === 0 || --activeLocks !== 0) { return } if (previousBodyPaddingRight !== u
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/overlay/body-locker.ts", "language": "typescript", "file_size": 1047, "cut_index": 513, "middle_length": 229 }
NT_DOCS, SYNC_IO_DOCS, getCards, type FixCard, type FixCardIcon, type GuidanceKind, type GuidanceVariant, } from './instant-guidance-data' export { SYNC_IO_CLIENT_DOCS, SYNC_IO_DOCS } from './instant-guidance-data' export type { GuidanceKind, GuidanceVariant } from './instant-guidance-data' function getCa...
g': return <FixCardLoadingIcon /> case 'zap': return <FixCardZapIcon /> case 'layout': return <FixCardLayoutIcon /> default: icon satisfies never return null } } function CardGrid({ cards }: { cards: FixCard[] }
ick': return <FixCardPointerClickIcon /> case 'history': return <FixCardHistoryIcon /> case 'database': return <FixCardDatabaseIcon /> case 'timer': return <FixCardTimerIcon /> case 'loadin
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/instant/instant-guidance.tsx", "language": "tsx", "file_size": 10303, "cut_index": 921, "middle_length": 229 }
RATION_ERROR_LINK, } from '../../../../shared/react-19-hydration-error' import { parseUrlFromText } from '../../../utils/parse-url-from-text' const docsURLAllowlist = ['https://nextjs.org', 'https://react.dev'] function docsLinkMatcher(text: string): boolean { return docsURLAllowlist.some((url) => text.startsWith(u...
essage }: { errorMessage: string }) { const docsURL = getDocsURLFromErrorMessage(errorMessage) if (!docsURL) { return ( <button title="No related documentation found" aria-label="No related documentation found" classN
= urls[0] // Replace react hydration error link with nextjs hydration error link if (href === REACT_HYDRATION_ERROR_LINK) { return NEXTJS_HYDRATION_ERROR_LINK } return href } export function DocsLinkButton({ errorM
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-toolbar/docs-link-button.tsx", "language": "tsx", "file_size": 2322, "cut_index": 563, "middle_length": 229 }
ct' import { ErrorOverlayPagination } from './error-overlay-pagination' import { withShadowPortal } from '../../../../../../.storybook/decorators/with-shadow-portal' import { useState } from 'react' import type { ReadyRuntimeError } from '../../../utils/get-error-by-type' const meta: Meta<typeof ErrorOverlayPagination...
id: 2, runtime: true as const, error: new Error('Second error'), frames: () => Promise.resolve([]), type: 'runtime', }, { id: 3, runtime: true as const, error: new Error('Third error'), frames: () => Promise.resolve([]),
tion> // Mock errors for stories const mockErrors: ReadyRuntimeError[] = [ { id: 1, runtime: true as const, error: new Error('First error'), frames: () => Promise.resolve([]), type: 'runtime', }, {
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-pagination/error-overlay-pagination.stories.tsx", "language": "tsx", "file_size": 2357, "cut_index": 563, "middle_length": 229 }
mport type { ReadyRuntimeError } from '../../../utils/get-error-by-type' type ErrorPaginationProps = { runtimeErrors: ReadyRuntimeError[] activeIdx: number onActiveIndexChange: (index: number) => void } export function ErrorOverlayPagination({ runtimeErrors, activeIdx, onActiveIndexChange, }: ErrorPaginat...
ath.min(runtimeErrors.length - 1, activeIdx + 1)) ) } }), [activeIdx, runtimeErrors.length, onActiveIndexChange] ) const buttonLeft = useRef<HTMLButtonElement | null>(null) const buttonRight = useRef<HTMLButtonElement | n
}), [activeIdx, onActiveIndexChange] ) const handleNext = useCallback( () => startTransition(() => { if (activeIdx < runtimeErrors.length - 1) { onActiveIndexChange( Math.max(0, M
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-pagination/error-overlay-pagination.tsx", "language": "tsx", "file_size": 5540, "cut_index": 716, "middle_length": 229 }
con(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" fill="currentColor" d="M11.5 9....
25H8.5V3Z" /> </svg> ) } export function SourceMappingErrorIcon(props: React.SVGProps<SVGSVGElement>) { return ( <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"
35 13 4.75 13H11.25C12.2165 13 13 12.2165 13 11.25V9.75V9H11.5V9.75ZM8.5 3H9.25H12.2495C12.6637 3 12.9995 3.33579 12.9995 3.75V6.75V7.5H11.4995V6.75V5.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L10.4388 4.5H9.
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/external.tsx", "language": "tsx", "file_size": 1656, "cut_index": 537, "middle_length": 229 }
st/compiled/anser' import stripAnsi from 'next/dist/compiled/strip-ansi' import type { StackFrame } from '../../../shared/stack-frame' // Strip leading spaces out of the code frame export function formatCodeFrame(codeFrame: string) { const lines = codeFrame.split(/\r?\n/g) // Find the minimum length of leading sp...
m // from the code frame to help the indentation looks better when there's a lot leading spaces. if (miniLeadingSpacesLength > 1) { return lines .map((line, a) => ~(a = line.indexOf('|')) ? line.substring(0, a) +
/.exec(stripAnsi(line)) ) .filter(Boolean) .map((v) => v!.pop()!) .reduce((c, n) => (isNaN(c) ? n.length : Math.min(c, n.length)), NaN) // When the minimum length of leading spaces is greater than 1, remove the
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/code-frame/parse-code-frame.ts", "language": "typescript", "file_size": 2996, "cut_index": 563, "middle_length": 229 }
s-up' import { ThumbsDown } from '../../../../icons/thumbs/thumbs-down' import { cx } from '../../../../utils/cx' interface ErrorFeedbackProps { errorCode: string className?: string } export function ErrorFeedback({ errorCode, className }: ErrorFeedbackProps) { const [votedMap, setVotedMap] = useState<Record<str...
try { const response = await fetch( `${process.env.__NEXT_ROUTER_BASEPATH || ''}/__nextjs_error_feedback?${new URLSearchParams( { errorCode, wasHelpful: wasHelpful.toString(), }
async (wasHelpful: boolean) => { // Optimistically set feedback state without loading/error states to keep implementation simple setVotedMap((prev) => ({ ...prev, [errorCode]: wasHelpful, }))
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-footer/error-feedback/error-feedback.tsx", "language": "tsx", "file_size": 4300, "cut_index": 614, "middle_length": 229 }
ct' import { Terminal } from './terminal' import { withShadowPortal } from '../../../../../.storybook/decorators/with-shadow-portal' const meta: Meta<typeof Terminal> = { component: Terminal, parameters: { layout: 'fullscreen', a11y: { config: { rules: [ { id: 'color-con...
\x1B[22m\x1B[39m: Can't resolve '\x1B[32mnot-existing-module\x1B[39m' \x1B[0m\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 1 |\x1B[39m \x1B[36mimport\x1B[39m \x1B[32m'not-existing-module'\x1B[39m\x1B[0m \x1B[0m \x1B[90m |\x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[
], }, }, }, decorators: [withShadowPortal], } export default meta type Story = StoryObj<typeof Terminal> export const Default: Story = { args: { content: `./app/page.tsx:1:1 \x1B[31m\x1B[1mModule not found
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/terminal/terminal.stories.tsx", "language": "tsx", "file_size": 2079, "cut_index": 563, "middle_length": 229 }
logHeader } from '../../dialog/dialog-header' type ErrorOverlayDialogHeaderProps = { children?: React.ReactNode } export function ErrorOverlayDialogHeader({ children, }: ErrorOverlayDialogHeaderProps) { return ( <DialogHeader className="nextjs-container-errors-header"> {children} </DialogHeader> ...
rors-header small { font-size: var(--size-14); color: var(--color-accents-1); margin-left: 16px; } .nextjs-container-errors-header small > span { font-family: var(--font-stack-monospace); } .nextjs-container-errors-header > div > sm
: 0; } .nextjs-container-errors-header > h1 { font-size: var(--size-20); line-height: var(--size-24); font-weight: bold; margin: calc(16px * 1.5) 0; color: var(--color-title-h1); } .nextjs-container-er
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dialog/header.tsx", "language": "tsx", "file_size": 1274, "cut_index": 524, "middle_length": 229 }
rver/dev/parse-version-info' import type { DebugInfo } from '../../../../shared/types' import { NodejsInspectorButton } from './nodejs-inspector-button' import { CopyErrorButton } from './copy-error-button' import { DocsLinkButton } from './docs-link-button' import { VersionStalenessInfo } from '../../version-staleness...
olbarProps) { return ( <span className="error-overlay-toolbar"> {/* TODO: Move the button inside and remove the feedback on the footer of the error overlay. */} {feedbackButton} <CopyErrorButton error={error} generateErrorInfo={gen
versionInfo?: VersionInfo bundlerName?: 'Turbopack' | 'Webpack' | 'Rspack' } export function ErrorOverlayToolbar({ error, debugInfo, feedbackButton, generateErrorInfo, versionInfo, bundlerName, }: ErrorOverlayTo
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-toolbar/error-overlay-toolbar.tsx", "language": "tsx", "file_size": 2434, "cut_index": 563, "middle_length": 229 }
export default function DarkIcon() { return ( <svg data-testid="geist-icon" height="16" strokeLinejoin="round" viewBox="0 0 16 16" width="16" > <path fillRule="evenodd" clipRule="evenodd" d="M1.5 8.00005C1.5 5.53089 2.99198 3.40932 5.12349 2.48889C4....
0.2501 6.25 7.78767 6.25 4.7501C6.25 3.63431 6.58146 2.59823 7.15111 1.73217L6.41706 0.577759ZM13.25 1V1.75V2.75L14.25 2.75H15V4.25H14.25H13.25V5.25V6H11.75V5.25V4.25H10.75L10 4.25V2.75H10.75L11.75 2.75V1.75V1H13.25Z" fill="currentColor" ></p
11.3138 1.5 8.00005ZM6.41706 0.577759C2.78784 1.1031 0 4.22536 0 8.00005C0 12.1422 3.35786 15.5001 7.5 15.5001C10.5798 15.5001 13.2244 13.6438 14.3792 10.9921L13.4588 9.9797C12.9218 10.155 12.3478 10.2501 11.75 10.2501C8.71243 1
{ "filepath": "packages/next/src/next-devtools/dev-overlay/icons/dark-icon.tsx", "language": "tsx", "file_size": 1019, "cut_index": 512, "middle_length": 229 }
, disableDrag = false, avoidZone, ...props }: { children: React.ReactElement position: Corners padding: number setPosition: (position: Corners) => void onDragStart?: () => void dragHandleSelector?: string disableDrag?: boolean style?: React.CSSProperties avoidZone?: { square: number corn...
if (distance === 0) { ref.current?.style.removeProperty('translate') return } const projectedPosition = { x: translation.x + project(velocity.x), y: translation.y + project(velocity.y), } const nearestCorner = ge
onDragEnd, onAnimationEnd, dragHandleSelector, }) function onDragEnd(translation: Point, velocity: Point) { const distance = Math.sqrt( translation.x * translation.x + translation.y * translation.y )
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/draggable.tsx", "language": "tsx", "file_size": 10854, "cut_index": 921, "middle_length": 229 }
ristine, setPristine] = useState(true) const [show, setShow] = useState(false) const [keys, setKeys] = useState<string[]>(value ?? []) const [success, setSuccess] = useState<boolean>(false) const timeoutRef = useRef<number | null>(null) const buttonRef = useRef<HTMLButtonElement>(null) const hasShortcut = B...
g session if (pristine) { setKeys([]) setPristine(false) } function handleValidation(next: string[]) { timeoutRef.current = window.setTimeout(() => { setSuccess(true) onChange(next.join('+')) timeoutRe
return if (e.key === 'Tab') return if (timeoutRef.current) clearTimeout(timeoutRef.current) if (!show) { setShow(true) } // Reset current shortcut on first key press // if this is a fresh recordin
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/dev-tools-info/shortcut-recorder.tsx", "language": "tsx", "file_size": 13296, "cut_index": 921, "middle_length": 229 }
types' import type { VersionInfo } from '../../../../../server/dev/parse-version-info' import { ErrorOverlayPagination } from '../error-overlay-pagination/error-overlay-pagination' import { ErrorOverlayToolbar } from '../error-overlay-toolbar/error-overlay-toolbar' import type { ReadyRuntimeError } from '../../../util...
rInfo, }: ErrorOverlayNavProps) { const bundlerName = (process.env.__NEXT_BUNDLER || 'Turbopack') as | 'Turbopack' | 'Webpack' | 'Rspack' return ( <div data-nextjs-error-overlay-nav> <NavItem side="left"> {/* TODO: better
eadyRuntimeError['error'] debugInfo?: DebugInfo generateErrorInfo: () => Promise<string> } export function ErrorOverlayNav({ runtimeErrors, activeIdx, setActiveIndex, versionInfo, error, debugInfo, generateErro
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-nav/error-overlay-nav.tsx", "language": "tsx", "file_size": 2555, "cut_index": 563, "middle_length": 229 }
hared/stack-frame' import { CallStackFrame } from '../call-stack-frame/call-stack-frame' import { ChevronUpDownIcon } from '../../icons/chevron-up-down' import { css } from '../../utils/css' export function CallStack({ frames, isIgnoreListOpen, ignoredFramesTally, onToggleIgnoreList, }: { frames: readonly O...
gnoreListOpen value is used by tests to confirm whether it is open or not. data-nextjs-call-stack-ignored-list-toggle-button={isIgnoreListOpen} onClick={onToggleIgnoreList} > {`${isIgnoreListOpen ? 'Hide' : 'Sh
call-stack-header> <p data-nextjs-call-stack-title> Call Stack <span data-nextjs-call-stack-count>{frames.length}</span> </p> {ignoredFramesTally > 0 && ( <button // The isI
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/call-stack/call-stack.tsx", "language": "tsx", "file_size": 2956, "cut_index": 563, "middle_length": 229 }
ErrorType = | 'Build Error' | `Runtime ${string}` | `Console ${string}` | `Recoverable ${string}` | 'Blocking Route' | 'Ambiguous Metadata' | 'Instant' type ErrorTypeLabelProps = { errorType: ErrorType } export function ErrorTypeLabel({ errorType }: ErrorTypeLabelProps) { return ( <span id...
: 0; border-radius: var(--rounded-md-2); background: var(--color-red-100); font-weight: 600; font-size: var(--size-12); color: var(--color-red-900); font-family: var(--font-stack-monospace); line-height: var(--size-20); } .
king_page' : ''} ${errorType === 'Instant' ? 'nextjs__container_errors_label_instant' : ''}`} > {errorType} </span> ) } export const styles = ` .nextjs__container_errors_label { padding: 2px 6px; margin
{ "filepath": "packages/next/src/next-devtools/dev-overlay/components/errors/error-type-label/error-type-label.tsx", "language": "tsx", "file_size": 1322, "cut_index": 524, "middle_length": 229 }
et-next-error-feedback-middleware' import type { IncomingMessage, ServerResponse } from 'http' describe('getNextErrorFeedbackMiddleware', () => { const mockTelemetry = { record: jest.fn().mockResolvedValue({}), } as any let mockReq: Partial<IncomingMessage> let mockRes: Partial<ServerResponse> let mockN...
mockReq as IncomingMessage, mockRes as ServerResponse, mockNext ) expect(mockNext).toHaveBeenCalled() expect(mockTelemetry.record).not.toHaveBeenCalled() }) it('records telemetry when feedback is submitted', async () => {
st.fn(), } mockNext = jest.fn() jest.clearAllMocks() }) it('calls next() if path does not match', async () => { mockReq.url = '/some-other-path' await getNextErrorFeedbackMiddleware(mockTelemetry)(
{ "filepath": "packages/next/src/next-devtools/server/get-next-error-feedback-middleware.test.ts", "language": "typescript", "file_size": 2114, "cut_index": 563, "middle_length": 229 }
ates the detection helper added in // https://github.com/vercel/next.js/pull/91854 (branch: imm/agent-telemetry). // When that PR lands, whichever branch merges second should collapse the // duplicate β€” the contents are intentionally identical so the merge is a // no-op. The env variable checks mirror the same function...
lot-cli' ? 'github-copilot' : name return normalized as AgentName } } if (process.env.CURSOR_TRACE_ID) { return 'cursor' } if (process.env.CURSOR_AGENT) { return 'cursor-cli' } if (process.env.GEMINI_CLI) { return 'gemi
cli' | 'opencode' | 'github-copilot' export function detectAgent(): AgentName | null { if (process.env.AI_AGENT) { const name = process.env.AI_AGENT.trim() if (name) { const normalized = name === 'github-copi
{ "filepath": "packages/next/src/telemetry/detect-agent.ts", "language": "typescript", "file_size": 1741, "cut_index": 537, "middle_length": 229 }
lemetry-payload' describe('postNextTelemetryPayload', () => { let originalFetch: typeof fetch beforeEach(() => { originalFetch = global.fetch }) afterEach(() => { global.fetch = originalFetch }) it('sends telemetry payload successfully', async () => { const mockFetch = jest.fn().mockResolved...
mockFetch).toHaveBeenCalledWith( 'https://telemetry.nextjs.org/api/v1/record', { method: 'POST', body: JSON.stringify(payload), headers: { 'content-type': 'application/json' }, signal: expect.any(AbortSignal),
ject', sessionId: 'test-session', }, events: [ { eventName: 'test-event', fields: { foo: 'bar' }, }, ], } await postNextTelemetryPayload(payload) expect(
{ "filepath": "packages/next/src/telemetry/post-telemetry-payload.test.ts", "language": "typescript", "file_size": 2075, "cut_index": 563, "middle_length": 229 }