diff --git a/packages/next/package.json b/packages/next/package.json index 36904bd2cee7d..4729af410c70a 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -148,7 +148,6 @@ "@napi-rs/triples": "1.1.0", "@next/polyfill-module": "14.1.1-canary.1", "@next/polyfill-nomodule": "14.1.1-canary.1", - "@next/react-dev-overlay": "14.1.1-canary.1", "@next/react-refresh-utils": "14.1.1-canary.1", "@next/swc": "14.1.1-canary.1", "@opentelemetry/api": "1.6.0", @@ -287,7 +286,7 @@ "server-only": "0.0.1", "setimmediate": "1.0.5", "shell-quote": "1.7.3", - "source-map": "0.6.1", + "source-map": "0.8.0-beta.0", "stacktrace-parser": "0.1.10", "stream-browserify": "3.0.0", "stream-http": "3.1.1", diff --git a/packages/next/src/build/collect-build-traces.ts b/packages/next/src/build/collect-build-traces.ts index 2ecf75cde9f6c..40767037ed05a 100644 --- a/packages/next/src/build/collect-build-traces.ts +++ b/packages/next/src/build/collect-build-traces.ts @@ -297,7 +297,6 @@ export async function collectBuildTraces({ '**/next/dist/compiled/webpack/(bundle4|bundle5).js', '**/node_modules/webpack5/**/*', '**/next/dist/server/lib/route-resolver*', - 'next/dist/compiled/@next/react-dev-overlay/dist/**/*', 'next/dist/compiled/semver/semver/**/*.js', ...(ciEnvironment.hasNextSupport diff --git a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts index 0096c7c83d7eb..5d50db00c18cc 100644 --- a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts +++ b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts @@ -1,6 +1,6 @@ import { bold, cyan, green, red, yellow } from '../../../../lib/picocolors' import { SimpleWebpackError } from './simpleWebpackError' -import { createOriginalStackFrame } from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' +import { createOriginalStackFrame } from '../../../../client/components/react-dev-overlay/server/middleware' import type { webpack } from 'next/dist/compiled/webpack/webpack' // Based on https://github.com/webpack/webpack/blob/fcdd04a833943394bbb0a9eeb54a962a24cc7e41/lib/stats/DefaultStatsFactoryPlugin.js#L422-L431 diff --git a/packages/next/src/client/app-index.tsx b/packages/next/src/client/app-index.tsx index 10514c7e7ba90..eecfda8682961 100644 --- a/packages/next/src/client/app-index.tsx +++ b/packages/next/src/client/app-index.tsx @@ -185,9 +185,9 @@ export function hydrate() { if (process.env.NODE_ENV !== 'production') { const rootLayoutMissingTagsError = (self as any) .__next_root_layout_missing_tags_error - const HotReload: typeof import('./components/react-dev-overlay/hot-reloader-client').default = - require('./components/react-dev-overlay/hot-reloader-client') - .default as typeof import('./components/react-dev-overlay/hot-reloader-client').default + const HotReload: typeof import('./components/react-dev-overlay/app/hot-reloader-client').default = + require('./components/react-dev-overlay/app/hot-reloader-client') + .default as typeof import('./components/react-dev-overlay/app/hot-reloader-client').default // Don't try to hydrate if root layout is missing required tags, render error instead if (rootLayoutMissingTagsError) { @@ -264,12 +264,12 @@ export function hydrate() { if (process.env.NODE_ENV !== 'production') { // if an error is thrown while rendering an RSC stream, this will catch it in dev // and show the error overlay - const ReactDevOverlay: typeof import('./components/react-dev-overlay/internal/ReactDevOverlay').default = - require('./components/react-dev-overlay/internal/ReactDevOverlay') - .default as typeof import('./components/react-dev-overlay/internal/ReactDevOverlay').default + const ReactDevOverlay: typeof import('./components/react-dev-overlay/app/ReactDevOverlay').default = + require('./components/react-dev-overlay/app/ReactDevOverlay') + .default as typeof import('./components/react-dev-overlay/app/ReactDevOverlay').default - const INITIAL_OVERLAY_STATE: typeof import('./components/react-dev-overlay/internal/error-overlay-reducer').INITIAL_OVERLAY_STATE = - require('./components/react-dev-overlay/internal/error-overlay-reducer').INITIAL_OVERLAY_STATE + const INITIAL_OVERLAY_STATE: typeof import('./components/react-dev-overlay/app/error-overlay-reducer').INITIAL_OVERLAY_STATE = + require('./components/react-dev-overlay/app/error-overlay-reducer').INITIAL_OVERLAY_STATE const getSocketUrl: typeof import('./components/react-dev-overlay/internal/helpers/get-socket-url').getSocketUrl = require('./components/react-dev-overlay/internal/helpers/get-socket-url') diff --git a/packages/next/src/client/components/app-router.tsx b/packages/next/src/client/components/app-router.tsx index e096a38f1836b..a2f10aa9dfec1 100644 --- a/packages/next/src/client/components/app-router.tsx +++ b/packages/next/src/client/components/app-router.tsx @@ -603,8 +603,8 @@ function Router({ ) } - const HotReloader: typeof import('./react-dev-overlay/hot-reloader-client').default = - require('./react-dev-overlay/hot-reloader-client').default + const HotReloader: typeof import('./react-dev-overlay/app/hot-reloader-client').default = + require('./react-dev-overlay/app/hot-reloader-client').default content = {content} } diff --git a/packages/next/src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx b/packages/next/src/client/components/react-dev-overlay/app/ReactDevOverlay.tsx similarity index 80% rename from packages/next/src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx rename to packages/next/src/client/components/react-dev-overlay/app/ReactDevOverlay.tsx index 7d3c49cd0b670..89dc0fd7509a0 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx +++ b/packages/next/src/client/components/react-dev-overlay/app/ReactDevOverlay.tsx @@ -5,15 +5,15 @@ import type { UnhandledErrorAction, } from './error-overlay-reducer' -import { ShadowPortal } from './components/ShadowPortal' -import { BuildError } from './container/BuildError' -import { Errors } from './container/Errors' -import type { SupportedErrorEvent } from './container/Errors' -import { RootLayoutError } from './container/RootLayoutError' -import { parseStack } from './helpers/parseStack' -import { Base } from './styles/Base' -import { ComponentStyles } from './styles/ComponentStyles' -import { CssReset } from './styles/CssReset' +import { ShadowPortal } from '../internal/components/ShadowPortal' +import { BuildError } from '../internal/container/BuildError' +import { Errors } from '../internal/container/Errors' +import type { SupportedErrorEvent } from '../internal/container/Errors' +import { RootLayoutError } from '../internal/container/RootLayoutError' +import { parseStack } from '../internal/helpers/parseStack' +import { Base } from '../internal/styles/Base' +import { ComponentStyles } from '../internal/styles/ComponentStyles' +import { CssReset } from '../internal/styles/CssReset' interface ReactDevOverlayState { reactError: SupportedErrorEvent | null @@ -86,12 +86,14 @@ class ReactDevOverlay extends React.PureComponent< /> ) : reactError ? ( ) : hasRuntimeErrors ? ( button:last-of-type:hover { opacity: 0.7; diff --git a/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/maintain--tab-focus.ts b/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/maintain--tab-focus.ts index 5908ef7e5d8b5..7556f4fd25049 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/maintain--tab-focus.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/maintain--tab-focus.ts @@ -918,7 +918,7 @@ var focusSvgForeignobjectTabindex = { element.innerHTML = generate( '' ) - // Safari 8's quersSelector() can't identify foreignObject, but getElementyByTagName() can + // Safari 8's querySelector() can't identify foreignObject, but getElementsByTagName() can return ( element.querySelector('foreignObject') || element.getElementsByTagName('foreignObject')[0] diff --git a/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/styles.tsx b/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/styles.tsx index c1547b3e062af..143e7ef08fd8b 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/styles.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/components/Overlay/styles.tsx @@ -29,7 +29,7 @@ const styles = css` right: 0; bottom: 0; left: 0; - background-color: rgba(17, 17, 17, 0.2); + background-color: var(--color-backdrop); pointer-events: all; z-index: -1; } diff --git a/packages/next/src/client/components/react-dev-overlay/internal/components/hot-linked-text/index.tsx b/packages/next/src/client/components/react-dev-overlay/internal/components/hot-linked-text/index.tsx index 2dde5aba96952..b842c02ac4d06 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/components/hot-linked-text/index.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/components/hot-linked-text/index.tsx @@ -1,7 +1,7 @@ import React from 'react' import { getWordsAndWhitespaces } from './get-words-and-whitespaces' -const linkRegex = /https?:\/\/[^\s/$.?#].[^\s"]*/i +const linkRegex = /https?:\/\/[^\s/$.?#].[^\s)'"]*/i export const HotlinkedText: React.FC<{ text: string @@ -15,9 +15,12 @@ export const HotlinkedText: React.FC<{ {linkRegex.test(text) ? wordsAndWhitespaces.map((word, index) => { if (linkRegex.test(word)) { + const link = linkRegex.exec(word)! return ( - {word} + + {word} + ) } diff --git a/packages/next/src/client/components/react-dev-overlay/internal/container/BuildError.tsx b/packages/next/src/client/components/react-dev-overlay/internal/container/BuildError.tsx index e2a46578d1c79..843486676e491 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/container/BuildError.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/container/BuildError.tsx @@ -67,6 +67,6 @@ export const styles = css` } .nextjs-container-build-error-body small { - color: #757575; + color: var(--color-font); } ` diff --git a/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx b/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx index 3a799356d28e1..65f27cdad1864 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/container/Errors.tsx @@ -2,11 +2,11 @@ import * as React from 'react' import { ACTION_UNHANDLED_ERROR, ACTION_UNHANDLED_REJECTION, -} from '../error-overlay-reducer' +} from '../../app/error-overlay-reducer' import type { UnhandledErrorAction, UnhandledRejectionAction, -} from '../error-overlay-reducer' +} from '../../app/error-overlay-reducer' import { Dialog, DialogBody, @@ -31,6 +31,7 @@ export type SupportedErrorEvent = { event: UnhandledErrorAction | UnhandledRejectionAction } export type ErrorsProps = { + isAppDir: boolean errors: SupportedErrorEvent[] initialDisplayState: DisplayState versionInfo?: VersionInfo @@ -57,6 +58,7 @@ function getErrorSignature(ev: SupportedErrorEvent): string { } export const Errors: React.FC = function Errors({ + isAppDir, errors, initialDisplayState, versionInfo, @@ -105,7 +107,7 @@ export const Errors: React.FC = function Errors({ } let mounted = true - getErrorByType(nextError).then( + getErrorByType(nextError, isAppDir).then( (resolved) => { // We don't care if the desired error changed while we were resolving, // thus we're not tracking it using a ref. Once the work has been done, @@ -122,7 +124,7 @@ export const Errors: React.FC = function Errors({ return () => { mounted = false } - }, [nextError]) + }, [nextError, isAppDir]) const [displayState, setDisplayState] = React.useState(initialDisplayState) diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts index cd0b866e31127..cfee460b76a5a 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts @@ -1,7 +1,7 @@ import { ACTION_UNHANDLED_ERROR, ACTION_UNHANDLED_REJECTION, -} from '../error-overlay-reducer' +} from '../../app/error-overlay-reducer' import type { SupportedErrorEvent } from '../container/Errors' import { getErrorSource } from './nodeStackFrames' import { getOriginalStackFrames } from './stack-frame' @@ -17,7 +17,8 @@ export type ReadyRuntimeError = { } export async function getErrorByType( - ev: SupportedErrorEvent + ev: SupportedErrorEvent, + isAppDir: boolean ): Promise { const { id, event } = ev switch (event.type) { @@ -30,6 +31,7 @@ export async function getErrorByType( frames: await getOriginalStackFrames( event.frames, getErrorSource(event.reason), + isAppDir, event.reason.toString() ), } diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts index ded4de3f0bde3..7d25528cc4a3d 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts @@ -1,5 +1,11 @@ import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' +type OriginalStackFrameResponse = { + originalStackFrame: StackFrame + originalCodeFrame: string | null + sourcePackage?: string +} + export type OriginalStackFrame = | { error: true @@ -35,13 +41,14 @@ export type OriginalStackFrame = export function getOriginalStackFrame( source: StackFrame, type: 'server' | 'edge-server' | null, + isAppDir: boolean, errorMessage: string ): Promise { async function _getOriginalStackFrame(): Promise { const params = new URLSearchParams() params.append('isServer', String(type === 'server')) params.append('isEdgeServer', String(type === 'edge-server')) - params.append('isAppDirectory', 'true') + params.append('isAppDirectory', String(isAppDir)) params.append('errorMessage', errorMessage) for (const key in source) { params.append(key, ((source as any)[key] ?? '').toString()) @@ -113,10 +120,13 @@ export function getOriginalStackFrame( export function getOriginalStackFrames( frames: StackFrame[], type: 'server' | 'edge-server' | null, + isAppDir: boolean, errorMessage: string ) { return Promise.all( - frames.map((frame) => getOriginalStackFrame(frame, type, errorMessage)) + frames.map((frame) => + getOriginalStackFrame(frame, type, isAppDir, errorMessage) + ) ) } diff --git a/packages/next/src/client/components/react-dev-overlay/internal/styles/Base.tsx b/packages/next/src/client/components/react-dev-overlay/internal/styles/Base.tsx index 9b00dd7f50f48..9847e352a3020 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/styles/Base.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/styles/Base.tsx @@ -17,6 +17,14 @@ export function Base() { --size-font-big: 20px; --size-font-bigger: 24px; + --color-background: white; + --color-font: #757575; + --color-backdrop: rgba(17, 17, 17, 0.2); + + --color-stack-h6: #222; + --color-stack-headline: #666; + --color-stack-subline: #999; + --color-accents-1: #808080; --color-accents-2: #222222; --color-accents-3: #404040; @@ -46,6 +54,20 @@ export function Base() { --color-ansi-bright-yellow: #ffd966; } + @media (prefers-color-scheme: dark) { + :host { + --color-background: rgb(28, 28, 30); + --color-font: white; + --color-backdrop: rgb(44, 44, 46); + + --color-stack-h6: rgb(200, 200, 204); + --color-stack-headline: rgb(99, 99, 102); + --color-stack-subline: rgba(142, 142, 147); + + --color-accents-3: rgb(118, 118, 118); + } + } + .mono { font-family: var(--font-stack-monospace); } diff --git a/packages/next/src/client/components/react-dev-overlay/internal/styles/CssReset.tsx b/packages/next/src/client/components/react-dev-overlay/internal/styles/CssReset.tsx index b2065abd9d964..eb3e2ca7a6453 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/styles/CssReset.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/styles/CssReset.tsx @@ -54,7 +54,7 @@ export function CssReset() { font-size: 16px; font-weight: 400; line-height: 1.5; - color: #212529; + color: var(--color-font); text-align: left; background-color: #fff; } diff --git a/packages/react-dev-overlay/src/internal/ErrorBoundary.tsx b/packages/next/src/client/components/react-dev-overlay/pages/ErrorBoundary.tsx similarity index 100% rename from packages/react-dev-overlay/src/internal/ErrorBoundary.tsx rename to packages/next/src/client/components/react-dev-overlay/pages/ErrorBoundary.tsx diff --git a/packages/react-dev-overlay/src/internal/ReactDevOverlay.tsx b/packages/next/src/client/components/react-dev-overlay/pages/ReactDevOverlay.tsx similarity index 88% rename from packages/react-dev-overlay/src/internal/ReactDevOverlay.tsx rename to packages/next/src/client/components/react-dev-overlay/pages/ReactDevOverlay.tsx index b6ff1d234fcf7..c6cff01c35113 100644 --- a/packages/react-dev-overlay/src/internal/ReactDevOverlay.tsx +++ b/packages/next/src/client/components/react-dev-overlay/pages/ReactDevOverlay.tsx @@ -1,14 +1,14 @@ import * as React from 'react' import * as Bus from './bus' -import { ShadowPortal } from './components/ShadowPortal' -import { BuildError } from './container/BuildError' -import type { SupportedErrorEvent } from './container/Errors' -import { Errors } from './container/Errors' +import { ShadowPortal } from '../internal/components/ShadowPortal' +import { BuildError } from '../internal/container/BuildError' +import type { SupportedErrorEvent } from '../internal/container/Errors' +import { Errors } from '../internal/container/Errors' import { ErrorBoundary } from './ErrorBoundary' -import { Base } from './styles/Base' -import { ComponentStyles } from './styles/ComponentStyles' -import { CssReset } from './styles/CssReset' +import { Base } from '../internal/styles/Base' +import { ComponentStyles } from '../internal/styles/ComponentStyles' +import { CssReset } from '../internal/styles/CssReset' type RefreshState = | { @@ -174,7 +174,7 @@ const ReactDevOverlay: React.FunctionComponent = {children ?? null} {isMounted ? ( - + @@ -185,7 +185,11 @@ const ReactDevOverlay: React.FunctionComponent = ) ? null : hasBuildError ? ( ) : hasRuntimeErrors ? ( - + ) : undefined} ) : undefined} diff --git a/packages/react-dev-overlay/src/internal/bus.ts b/packages/next/src/client/components/react-dev-overlay/pages/bus.ts similarity index 96% rename from packages/react-dev-overlay/src/internal/bus.ts rename to packages/next/src/client/components/react-dev-overlay/pages/bus.ts index 75bbfa0ca01aa..7ede905a18918 100644 --- a/packages/react-dev-overlay/src/internal/bus.ts +++ b/packages/next/src/client/components/react-dev-overlay/pages/bus.ts @@ -1,4 +1,4 @@ -import type { StackFrame } from 'stacktrace-parser' +import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' export const TYPE_BUILD_OK = 'build-ok' export const TYPE_BUILD_ERROR = 'build-error' diff --git a/packages/react-dev-overlay/src/client.ts b/packages/next/src/client/components/react-dev-overlay/pages/client.ts similarity index 84% rename from packages/react-dev-overlay/src/client.ts rename to packages/next/src/client/components/react-dev-overlay/pages/client.ts index 1e2ba0f275f06..fcbe52568702c 100644 --- a/packages/react-dev-overlay/src/client.ts +++ b/packages/next/src/client/components/react-dev-overlay/pages/client.ts @@ -1,11 +1,11 @@ -import * as Bus from './internal/bus' -import { parseStack } from './internal/helpers/parseStack' -import { parseComponentStack } from 'next/dist/client/components/react-dev-overlay/internal/helpers/parse-component-stack' +import * as Bus from './bus' +import { parseStack } from '../internal/helpers/parseStack' +import { parseComponentStack } from '../internal/helpers/parse-component-stack' import { hydrationErrorComponentStack, hydrationErrorWarning, patchConsoleError, -} from 'next/dist/client/components/react-dev-overlay/internal/helpers/hydration-error-info' +} from '../internal/helpers/hydration-error-info' // Patch console.error to collect information about hydration errors patchConsoleError() @@ -114,9 +114,9 @@ function onBeforeRefresh() { Bus.emit({ type: Bus.TYPE_BEFORE_REFRESH }) } -export { getErrorByType } from './internal/helpers/getErrorByType' -export { getServerError } from './internal/helpers/nodeStackFrames' -export { default as ReactDevOverlay } from './internal/ReactDevOverlay' +export { getErrorByType } from '../internal/helpers/getErrorByType' +export { getServerError } from '../internal/helpers/nodeStackFrames' +export { default as ReactDevOverlay } from './ReactDevOverlay' export { onBuildOk, onBuildError, diff --git a/packages/react-dev-overlay/src/middleware-turbopack.ts b/packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts similarity index 97% rename from packages/react-dev-overlay/src/middleware-turbopack.ts rename to packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts index 729ccdd8a1a4d..761169cdc9c0d 100644 --- a/packages/react-dev-overlay/src/middleware-turbopack.ts +++ b/packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts @@ -4,8 +4,8 @@ import type { OriginalStackFrameResponse } from './middleware' import fs, { constants as FS } from 'fs/promises' import url from 'url' -import { codeFrameColumns } from '@babel/code-frame' -import { launchEditor } from './internal/helpers/launchEditor' +import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame' +import { launchEditor } from '../internal/helpers/launchEditor' interface Project { getSourceForAsset(filePath: string): Promise diff --git a/packages/react-dev-overlay/src/middleware.ts b/packages/next/src/client/components/react-dev-overlay/server/middleware.ts similarity index 95% rename from packages/react-dev-overlay/src/middleware.ts rename to packages/next/src/client/components/react-dev-overlay/server/middleware.ts index 81eae3b6c0dea..bd71ef4dc13be 100644 --- a/packages/react-dev-overlay/src/middleware.ts +++ b/packages/next/src/client/components/react-dev-overlay/server/middleware.ts @@ -1,23 +1,23 @@ -import { codeFrameColumns } from '@babel/code-frame' +import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame' import { constants as FS, promises as fs } from 'fs' import type { IncomingMessage, ServerResponse } from 'http' import path from 'path' -import type { NullableMappedPosition, RawSourceMap } from 'source-map' -import { SourceMapConsumer } from 'source-map' +import type { RawSourceMap } from 'source-map' +import { SourceMapConsumer } from 'next/dist/compiled/source-map' import type { StackFrame } from 'stacktrace-parser' import url from 'url' // @ts-ignore // eslint-disable-next-line import/no-extraneous-dependencies import type webpack from 'webpack' -import { getRawSourceMap } from './internal/helpers/getRawSourceMap' -import { launchEditor } from './internal/helpers/launchEditor' +import { getRawSourceMap } from '../internal/helpers/getRawSourceMap' +import { launchEditor } from '../internal/helpers/launchEditor' -export { getErrorSource } from './internal/helpers/nodeStackFrames' +export { getErrorSource } from '../internal/helpers/nodeStackFrames' export { decorateServerError, getServerError, -} from './internal/helpers/nodeStackFrames' -export { parseStack } from './internal/helpers/parseStack' +} from '../internal/helpers/nodeStackFrames' +export { parseStack } from '../internal/helpers/parseStack' export type OverlayMiddlewareOptions = { rootDirectory: string @@ -87,12 +87,10 @@ async function findOriginalSourcePositionAndContent( ) { const consumer = await new SourceMapConsumer(webpackSource.map()) try { - const sourcePosition: NullableMappedPosition = consumer.originalPositionFor( - { - line: position.line, - column: position.column ?? 0, - } - ) + const sourcePosition = consumer.originalPositionFor({ + line: position.line, + column: position.column ?? 0, + }) if (!sourcePosition.source) { return null diff --git a/packages/next/src/client/dev/error-overlay/hot-dev-client.ts b/packages/next/src/client/dev/error-overlay/hot-dev-client.ts index 66f28fc634b76..80d016c49c7a5 100644 --- a/packages/next/src/client/dev/error-overlay/hot-dev-client.ts +++ b/packages/next/src/client/dev/error-overlay/hot-dev-client.ts @@ -34,7 +34,7 @@ import { onBuildOk, onBeforeRefresh, onRefresh, -} from 'next/dist/compiled/@next/react-dev-overlay/dist/client' +} from '../../components/react-dev-overlay/pages/client' import stripAnsi from 'next/dist/compiled/strip-ansi' import { addMessageListener, sendMessage } from './websocket' import formatWebpackMessages from './format-webpack-messages' diff --git a/packages/next/src/client/index.tsx b/packages/next/src/client/index.tsx index b163c29491247..c1138ddfeba0a 100644 --- a/packages/next/src/client/index.tsx +++ b/packages/next/src/client/index.tsx @@ -180,7 +180,7 @@ class Container extends React.Component<{ } else { const { ReactDevOverlay, - } = require('next/dist/compiled/@next/react-dev-overlay/dist/client') + } = require('./components/react-dev-overlay/pages/client') return {this.props.children} } } @@ -906,7 +906,7 @@ export async function hydrate(opts?: { beforeRender?: () => Promise }) { if (process.env.NODE_ENV === 'development') { const { getServerError, - } = require('next/dist/compiled/@next/react-dev-overlay/dist/client') + } = require('./components/react-dev-overlay/pages/client') // Server-side runtime errors need to be re-thrown on the client-side so // that the overlay is rendered. if (initialErr) { diff --git a/packages/next/src/compiled/source-map/mappings.wasm b/packages/next/src/compiled/source-map/mappings.wasm new file mode 100644 index 0000000000000..3515370723369 Binary files /dev/null and b/packages/next/src/compiled/source-map/mappings.wasm differ diff --git a/packages/next/src/compiled/source-map/source-map.js b/packages/next/src/compiled/source-map/source-map.js index 61febd7a46376..f632dbf1a089b 100644 --- a/packages/next/src/compiled/source-map/source-map.js +++ b/packages/next/src/compiled/source-map/source-map.js @@ -1 +1 @@ -(()=>{var e={542:(e,r,n)=>{var t=n(749);var o=Object.prototype.hasOwnProperty;var i=typeof Map!=="undefined";function ArraySet(){this._array=[];this._set=i?new Map:Object.create(null)}ArraySet.fromArray=function ArraySet_fromArray(e,r){var n=new ArraySet;for(var t=0,o=e.length;t=0){return r}}else{var n=t.toSetString(e);if(o.call(this._set,n)){return this._set[n]}}throw new Error('"'+e+'" is not in the set.')};ArraySet.prototype.at=function ArraySet_at(e){if(e>=0&&e{var t=n(192);var o=5;var i=1<>1;return r?-n:n}r.encode=function base64VLQ_encode(e){var r="";var n;var i=toVLQSigned(e);do{n=i&a;i>>>=o;if(i>0){n|=u}r+=t.encode(n)}while(i>0);return r};r.decode=function base64VLQ_decode(e,r,n){var i=e.length;var s=0;var l=0;var c,p;do{if(r>=i){throw new Error("Expected more digits in base 64 VLQ value.")}p=t.decode(e.charCodeAt(r++));if(p===-1){throw new Error("Invalid base64 digit: "+e.charAt(r-1))}c=!!(p&u);p&=a;s=s+(p<{var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");r.encode=function(e){if(0<=e&&e{r.GREATEST_LOWER_BOUND=1;r.LEAST_UPPER_BOUND=2;function recursiveSearch(e,n,t,o,i,a){var u=Math.floor((n-e)/2)+e;var s=i(t,o[u],true);if(s===0){return u}else if(s>0){if(n-u>1){return recursiveSearch(u,n,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return n1){return recursiveSearch(e,u,t,o,i,a)}if(a==r.LEAST_UPPER_BOUND){return u}else{return e<0?-1:e}}}r.search=function search(e,n,t,o){if(n.length===0){return-1}var i=recursiveSearch(-1,n.length,e,n,t,o||r.GREATEST_LOWER_BOUND);if(i<0){return-1}while(i-1>=0){if(t(n[i],n[i-1],true)!==0){break}--i}return i}},460:(e,r,n)=>{var t=n(749);function generatedPositionAfter(e,r){var n=e.generatedLine;var o=r.generatedLine;var i=e.generatedColumn;var a=r.generatedColumn;return o>n||o==n&&a>=i||t.compareByGeneratedPositionsInflated(e,r)<=0}function MappingList(){this._array=[];this._sorted=true;this._last={generatedLine:-1,generatedColumn:0}}MappingList.prototype.unsortedForEach=function MappingList_forEach(e,r){this._array.forEach(e,r)};MappingList.prototype.add=function MappingList_add(e){if(generatedPositionAfter(this._last,e)){this._last=e;this._array.push(e)}else{this._sorted=false;this._array.push(e)}};MappingList.prototype.toArray=function MappingList_toArray(){if(!this._sorted){this._array.sort(t.compareByGeneratedPositionsInflated);this._sorted=true}return this._array};r.H=MappingList},136:(e,r)=>{function swap(e,r,n){var t=e[r];e[r]=e[n];e[n]=t}function randomIntInRange(e,r){return Math.round(e+Math.random()*(r-e))}function doQuickSort(e,r,n,t){if(n{var t;var o=n(749);var i=n(968);var a=n(542).I;var u=n(447);var s=n(136).U;function SourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}return n.sections!=null?new IndexedSourceMapConsumer(n,r):new BasicSourceMapConsumer(n,r)}SourceMapConsumer.fromSourceMap=function(e,r){return BasicSourceMapConsumer.fromSourceMap(e,r)};SourceMapConsumer.prototype._version=3;SourceMapConsumer.prototype.__generatedMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_generatedMappings",{configurable:true,enumerable:true,get:function(){if(!this.__generatedMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__generatedMappings}});SourceMapConsumer.prototype.__originalMappings=null;Object.defineProperty(SourceMapConsumer.prototype,"_originalMappings",{configurable:true,enumerable:true,get:function(){if(!this.__originalMappings){this._parseMappings(this._mappings,this.sourceRoot)}return this.__originalMappings}});SourceMapConsumer.prototype._charIsMappingSeparator=function SourceMapConsumer_charIsMappingSeparator(e,r){var n=e.charAt(r);return n===";"||n===","};SourceMapConsumer.prototype._parseMappings=function SourceMapConsumer_parseMappings(e,r){throw new Error("Subclasses must implement _parseMappings")};SourceMapConsumer.GENERATED_ORDER=1;SourceMapConsumer.ORIGINAL_ORDER=2;SourceMapConsumer.GREATEST_LOWER_BOUND=1;SourceMapConsumer.LEAST_UPPER_BOUND=2;SourceMapConsumer.prototype.eachMapping=function SourceMapConsumer_eachMapping(e,r,n){var t=r||null;var i=n||SourceMapConsumer.GENERATED_ORDER;var a;switch(i){case SourceMapConsumer.GENERATED_ORDER:a=this._generatedMappings;break;case SourceMapConsumer.ORIGINAL_ORDER:a=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var u=this.sourceRoot;a.map((function(e){var r=e.source===null?null:this._sources.at(e.source);r=o.computeSourceURL(u,r,this._sourceMapURL);return{source:r,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:e.name===null?null:this._names.at(e.name)}}),this).forEach(e,t)};SourceMapConsumer.prototype.allGeneratedPositionsFor=function SourceMapConsumer_allGeneratedPositionsFor(e){var r=o.getArg(e,"line");var n={source:o.getArg(e,"source"),originalLine:r,originalColumn:o.getArg(e,"column",0)};n.source=this._findSourceIndex(n.source);if(n.source<0){return[]}var t=[];var a=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,i.LEAST_UPPER_BOUND);if(a>=0){var u=this._originalMappings[a];if(e.column===undefined){var s=u.originalLine;while(u&&u.originalLine===s){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}else{var l=u.originalColumn;while(u&&u.originalLine===r&&u.originalColumn==l){t.push({line:o.getArg(u,"generatedLine",null),column:o.getArg(u,"generatedColumn",null),lastColumn:o.getArg(u,"lastGeneratedColumn",null)});u=this._originalMappings[++a]}}}return t};r.SourceMapConsumer=SourceMapConsumer;function BasicSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sources");var u=o.getArg(n,"names",[]);var s=o.getArg(n,"sourceRoot",null);var l=o.getArg(n,"sourcesContent",null);var c=o.getArg(n,"mappings");var p=o.getArg(n,"file",null);if(t!=this._version){throw new Error("Unsupported version: "+t)}if(s){s=o.normalize(s)}i=i.map(String).map(o.normalize).map((function(e){return s&&o.isAbsolute(s)&&o.isAbsolute(e)?o.relative(s,e):e}));this._names=a.fromArray(u.map(String),true);this._sources=a.fromArray(i,true);this._absoluteSources=this._sources.toArray().map((function(e){return o.computeSourceURL(s,e,r)}));this.sourceRoot=s;this.sourcesContent=l;this._mappings=c;this._sourceMapURL=r;this.file=p}BasicSourceMapConsumer.prototype=Object.create(SourceMapConsumer.prototype);BasicSourceMapConsumer.prototype.consumer=SourceMapConsumer;BasicSourceMapConsumer.prototype._findSourceIndex=function(e){var r=e;if(this.sourceRoot!=null){r=o.relative(this.sourceRoot,r)}if(this._sources.has(r)){return this._sources.indexOf(r)}var n;for(n=0;n1){_.source=l+S[1];l+=S[1];_.originalLine=i+S[2];i=_.originalLine;_.originalLine+=1;_.originalColumn=a+S[3];a=_.originalColumn;if(S.length>4){_.name=c+S[4];c+=S[4]}}m.push(_);if(typeof _.originalLine==="number"){d.push(_)}}}s(m,o.compareByGeneratedPositionsDeflated);this.__generatedMappings=m;s(d,o.compareByOriginalPositions);this.__originalMappings=d};BasicSourceMapConsumer.prototype._findMapping=function SourceMapConsumer_findMapping(e,r,n,t,o,a){if(e[n]<=0){throw new TypeError("Line must be greater than or equal to 1, got "+e[n])}if(e[t]<0){throw new TypeError("Column must be greater than or equal to 0, got "+e[t])}return i.search(e,r,o,a)};BasicSourceMapConsumer.prototype.computeColumnSpans=function SourceMapConsumer_computeColumnSpans(){for(var e=0;e=0){var t=this._generatedMappings[n];if(t.generatedLine===r.generatedLine){var i=o.getArg(t,"source",null);if(i!==null){i=this._sources.at(i);i=o.computeSourceURL(this.sourceRoot,i,this._sourceMapURL)}var a=o.getArg(t,"name",null);if(a!==null){a=this._names.at(a)}return{source:i,line:o.getArg(t,"originalLine",null),column:o.getArg(t,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}};BasicSourceMapConsumer.prototype.hasContentsOfAllSources=function BasicSourceMapConsumer_hasContentsOfAllSources(){if(!this.sourcesContent){return false}return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return e==null}))};BasicSourceMapConsumer.prototype.sourceContentFor=function SourceMapConsumer_sourceContentFor(e,r){if(!this.sourcesContent){return null}var n=this._findSourceIndex(e);if(n>=0){return this.sourcesContent[n]}var t=e;if(this.sourceRoot!=null){t=o.relative(this.sourceRoot,t)}var i;if(this.sourceRoot!=null&&(i=o.urlParse(this.sourceRoot))){var a=t.replace(/^file:\/\//,"");if(i.scheme=="file"&&this._sources.has(a)){return this.sourcesContent[this._sources.indexOf(a)]}if((!i.path||i.path=="/")&&this._sources.has("/"+t)){return this.sourcesContent[this._sources.indexOf("/"+t)]}}if(r){return null}else{throw new Error('"'+t+'" is not in the SourceMap.')}};BasicSourceMapConsumer.prototype.generatedPositionFor=function SourceMapConsumer_generatedPositionFor(e){var r=o.getArg(e,"source");r=this._findSourceIndex(r);if(r<0){return{line:null,column:null,lastColumn:null}}var n={source:r,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};var t=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",o.compareByOriginalPositions,o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND));if(t>=0){var i=this._originalMappings[t];if(i.source===n.source){return{line:o.getArg(i,"generatedLine",null),column:o.getArg(i,"generatedColumn",null),lastColumn:o.getArg(i,"lastGeneratedColumn",null)}}}return{line:null,column:null,lastColumn:null}};t=BasicSourceMapConsumer;function IndexedSourceMapConsumer(e,r){var n=e;if(typeof e==="string"){n=o.parseSourceMapInput(e)}var t=o.getArg(n,"version");var i=o.getArg(n,"sections");if(t!=this._version){throw new Error("Unsupported version: "+t)}this._sources=new a;this._names=new a;var u={line:-1,column:0};this._sections=i.map((function(e){if(e.url){throw new Error("Support for url field in sections not implemented.")}var n=o.getArg(e,"offset");var t=o.getArg(n,"line");var i=o.getArg(n,"column");if(t{var t=n(447);var o=n(749);var i=n(542).I;var a=n(460).H;function SourceMapGenerator(e){if(!e){e={}}this._file=o.getArg(e,"file",null);this._sourceRoot=o.getArg(e,"sourceRoot",null);this._skipValidation=o.getArg(e,"skipValidation",false);this._sources=new i;this._names=new i;this._mappings=new a;this._sourcesContents=null}SourceMapGenerator.prototype._version=3;SourceMapGenerator.fromSourceMap=function SourceMapGenerator_fromSourceMap(e){var r=e.sourceRoot;var n=new SourceMapGenerator({file:e.file,sourceRoot:r});e.eachMapping((function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};if(e.source!=null){t.source=e.source;if(r!=null){t.source=o.relative(r,t.source)}t.original={line:e.originalLine,column:e.originalColumn};if(e.name!=null){t.name=e.name}}n.addMapping(t)}));e.sources.forEach((function(t){var i=t;if(r!==null){i=o.relative(r,t)}if(!n._sources.has(i)){n._sources.add(i)}var a=e.sourceContentFor(t);if(a!=null){n.setSourceContent(t,a)}}));return n};SourceMapGenerator.prototype.addMapping=function SourceMapGenerator_addMapping(e){var r=o.getArg(e,"generated");var n=o.getArg(e,"original",null);var t=o.getArg(e,"source",null);var i=o.getArg(e,"name",null);if(!this._skipValidation){this._validateMapping(r,n,t,i)}if(t!=null){t=String(t);if(!this._sources.has(t)){this._sources.add(t)}}if(i!=null){i=String(i);if(!this._names.has(i)){this._names.add(i)}}this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:t,name:i})};SourceMapGenerator.prototype.setSourceContent=function SourceMapGenerator_setSourceContent(e,r){var n=e;if(this._sourceRoot!=null){n=o.relative(this._sourceRoot,n)}if(r!=null){if(!this._sourcesContents){this._sourcesContents=Object.create(null)}this._sourcesContents[o.toSetString(n)]=r}else if(this._sourcesContents){delete this._sourcesContents[o.toSetString(n)];if(Object.keys(this._sourcesContents).length===0){this._sourcesContents=null}}};SourceMapGenerator.prototype.applySourceMap=function SourceMapGenerator_applySourceMap(e,r,n){var t=r;if(r==null){if(e.file==null){throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, "+'or the source map\'s "file" property. Both were omitted.')}t=e.file}var a=this._sourceRoot;if(a!=null){t=o.relative(a,t)}var u=new i;var s=new i;this._mappings.unsortedForEach((function(r){if(r.source===t&&r.originalLine!=null){var i=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});if(i.source!=null){r.source=i.source;if(n!=null){r.source=o.join(n,r.source)}if(a!=null){r.source=o.relative(a,r.source)}r.originalLine=i.line;r.originalColumn=i.column;if(i.name!=null){r.name=i.name}}}var l=r.source;if(l!=null&&!u.has(l)){u.add(l)}var c=r.name;if(c!=null&&!s.has(c)){s.add(c)}}),this);this._sources=u;this._names=s;e.sources.forEach((function(r){var t=e.sourceContentFor(r);if(t!=null){if(n!=null){r=o.join(n,r)}if(a!=null){r=o.relative(a,r)}this.setSourceContent(r,t)}}),this)};SourceMapGenerator.prototype._validateMapping=function SourceMapGenerator_validateMapping(e,r,n,t){if(r&&typeof r.line!=="number"&&typeof r.column!=="number"){throw new Error("original.line and original.column are not numbers -- you probably meant to omit "+"the original mapping entirely and only map the generated position. If so, pass "+"null for the original mapping instead of an object with empty or null values.")}if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!r&&!n&&!t){return}else if(e&&"line"in e&&"column"in e&&r&&"line"in r&&"column"in r&&e.line>0&&e.column>=0&&r.line>0&&r.column>=0&&n){return}else{throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:r,name:t}))}};SourceMapGenerator.prototype._serializeMappings=function SourceMapGenerator_serializeMappings(){var e=0;var r=1;var n=0;var i=0;var a=0;var u=0;var s="";var l;var c;var p;var g;var f=this._mappings.toArray();for(var h=0,d=f.length;h0){if(!o.compareByGeneratedPositionsInflated(c,f[h-1])){continue}l+=","}}l+=t.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){g=this._sources.indexOf(c.source);l+=t.encode(g-u);u=g;l+=t.encode(c.originalLine-1-i);i=c.originalLine-1;l+=t.encode(c.originalColumn-n);n=c.originalColumn;if(c.name!=null){p=this._names.indexOf(c.name);l+=t.encode(p-a);a=p}}s+=l}return s};SourceMapGenerator.prototype._generateSourcesContent=function SourceMapGenerator_generateSourcesContent(e,r){return e.map((function(e){if(!this._sourcesContents){return null}if(r!=null){e=o.relative(r,e)}var n=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)};SourceMapGenerator.prototype.toJSON=function SourceMapGenerator_toJSON(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null){e.file=this._file}if(this._sourceRoot!=null){e.sourceRoot=this._sourceRoot}if(this._sourcesContents){e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)}return e};SourceMapGenerator.prototype.toString=function SourceMapGenerator_toString(){return JSON.stringify(this.toJSON())};r.SourceMapGenerator=SourceMapGenerator},13:(e,r,n)=>{var t=n(231).SourceMapGenerator;var o=n(749);var i=/(\r?\n)/;var a=10;var u="$$$isSourceNode$$$";function SourceNode(e,r,n,t,o){this.children=[];this.sourceContents={};this.line=e==null?null:e;this.column=r==null?null:r;this.source=n==null?null:n;this.name=o==null?null:o;this[u]=true;if(t!=null)this.add(t)}SourceNode.fromStringWithSourceMap=function SourceNode_fromStringWithSourceMap(e,r,n){var t=new SourceNode;var a=e.split(i);var u=0;var shiftNextLine=function(){var e=getNextLine();var r=getNextLine()||"";return e+r;function getNextLine(){return u=0;r--){this.prepend(e[r])}}else if(e[u]||typeof e==="string"){this.children.unshift(e)}else{throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e)}return this};SourceNode.prototype.walk=function SourceNode_walk(e){var r;for(var n=0,t=this.children.length;n0){r=[];for(n=0;n{function getArg(e,r,n){if(r in e){return e[r]}else if(arguments.length===3){return n}else{throw new Error('"'+r+'" is a required argument.')}}r.getArg=getArg;var n=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;var t=/^data:.+\,.+$/;function urlParse(e){var r=e.match(n);if(!r){return null}return{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}}r.urlParse=urlParse;function urlGenerate(e){var r="";if(e.scheme){r+=e.scheme+":"}r+="//";if(e.auth){r+=e.auth+"@"}if(e.host){r+=e.host}if(e.port){r+=":"+e.port}if(e.path){r+=e.path}return r}r.urlGenerate=urlGenerate;function normalize(e){var n=e;var t=urlParse(e);if(t){if(!t.path){return e}n=t.path}var o=r.isAbsolute(n);var i=n.split(/\/+/);for(var a,u=0,s=i.length-1;s>=0;s--){a=i[s];if(a==="."){i.splice(s,1)}else if(a===".."){u++}else if(u>0){if(a===""){i.splice(s+1,u);u=0}else{i.splice(s,2);u--}}}n=i.join("/");if(n===""){n=o?"/":"."}if(t){t.path=n;return urlGenerate(t)}return n}r.normalize=normalize;function join(e,r){if(e===""){e="."}if(r===""){r="."}var n=urlParse(r);var o=urlParse(e);if(o){e=o.path||"/"}if(n&&!n.scheme){if(o){n.scheme=o.scheme}return urlGenerate(n)}if(n||r.match(t)){return r}if(o&&!o.host&&!o.path){o.host=r;return urlGenerate(o)}var i=r.charAt(0)==="/"?r:normalize(e.replace(/\/+$/,"")+"/"+r);if(o){o.path=i;return urlGenerate(o)}return i}r.join=join;r.isAbsolute=function(e){return e.charAt(0)==="/"||n.test(e)};function relative(e,r){if(e===""){e="."}e=e.replace(/\/$/,"");var n=0;while(r.indexOf(e+"/")!==0){var t=e.lastIndexOf("/");if(t<0){return r}e=e.slice(0,t);if(e.match(/^([^\/]+:\/)?\/*$/)){return r}++n}return Array(n+1).join("../")+r.substr(e.length+1)}r.relative=relative;var o=function(){var e=Object.create(null);return!("__proto__"in e)}();function identity(e){return e}function toSetString(e){if(isProtoString(e)){return"$"+e}return e}r.toSetString=o?identity:toSetString;function fromSetString(e){if(isProtoString(e)){return e.slice(1)}return e}r.fromSetString=o?identity:fromSetString;function isProtoString(e){if(!e){return false}var r=e.length;if(r<9){return false}if(e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95){return false}for(var n=r-10;n>=0;n--){if(e.charCodeAt(n)!==36){return false}}return true}function compareByOriginalPositions(e,r,n){var t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0||n){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0){return t}t=e.generatedLine-r.generatedLine;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByOriginalPositions=compareByOriginalPositions;function compareByGeneratedPositionsDeflated(e,r,n){var t=e.generatedLine-r.generatedLine;if(t!==0){return t}t=e.generatedColumn-r.generatedColumn;if(t!==0||n){return t}t=strcmp(e.source,r.source);if(t!==0){return t}t=e.originalLine-r.originalLine;if(t!==0){return t}t=e.originalColumn-r.originalColumn;if(t!==0){return t}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsDeflated=compareByGeneratedPositionsDeflated;function strcmp(e,r){if(e===r){return 0}if(e===null){return 1}if(r===null){return-1}if(e>r){return 1}return-1}function compareByGeneratedPositionsInflated(e,r){var n=e.generatedLine-r.generatedLine;if(n!==0){return n}n=e.generatedColumn-r.generatedColumn;if(n!==0){return n}n=strcmp(e.source,r.source);if(n!==0){return n}n=e.originalLine-r.originalLine;if(n!==0){return n}n=e.originalColumn-r.originalColumn;if(n!==0){return n}return strcmp(e.name,r.name)}r.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;function parseSourceMapInput(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}r.parseSourceMapInput=parseSourceMapInput;function computeSourceURL(e,r,n){r=r||"";if(e){if(e[e.length-1]!=="/"&&r[0]!=="/"){e+="/"}r=e+r}if(n){var t=urlParse(n);if(!t){throw new Error("sourceMapURL could not be parsed")}if(t.path){var o=t.path.lastIndexOf("/");if(o>=0){t.path=t.path.substring(0,o+1)}}r=join(urlGenerate(t),r)}return normalize(r)}r.computeSourceURL=computeSourceURL}};var r={};function __nccwpck_require__(n){var t=r[n];if(t!==undefined){return t.exports}var o=r[n]={exports:{}};var i=true;try{e[n](o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete r[n]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n={};(()=>{var e=n;e.SourceMapGenerator=__nccwpck_require__(231).SourceMapGenerator;e.SourceMapConsumer=__nccwpck_require__(69).SourceMapConsumer;e.SourceNode=__nccwpck_require__(13).SourceNode})();module.exports=n})(); \ No newline at end of file +(()=>{var e={963:(e,n)=>{class ArraySet{constructor(){this._array=[];this._set=new Map}static fromArray(e,n){const t=new ArraySet;for(let r=0,o=e.length;r=0){return n}throw new Error('"'+e+'" is not in the set.')}at(e){if(e>=0&&e{const r=t(209);const o=5;const s=1<>1;return n?-t:t}n.encode=function base64VLQ_encode(e){let n="";let t;let s=toVLQSigned(e);do{t=s&i;s>>>=o;if(s>0){t|=l}n+=r.encode(t)}while(s>0);return n}},209:(e,n)=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");n.encode=function(e){if(0<=e&&e{n.GREATEST_LOWER_BOUND=1;n.LEAST_UPPER_BOUND=2;function recursiveSearch(e,t,r,o,s,i){const l=Math.floor((t-e)/2)+e;const a=s(r,o[l],true);if(a===0){return l}else if(a>0){if(t-l>1){return recursiveSearch(l,t,r,o,s,i)}if(i==n.LEAST_UPPER_BOUND){return t1){return recursiveSearch(e,l,r,o,s,i)}if(i==n.LEAST_UPPER_BOUND){return l}return e<0?-1:e}n.search=function search(e,t,r,o){if(t.length===0){return-1}let s=recursiveSearch(-1,t.length,e,t,r,o||n.GREATEST_LOWER_BOUND);if(s<0){return-1}while(s-1>=0){if(r(t[s],t[s-1],true)!==0){break}--s}return s}},371:(e,n,t)=>{const r=t(354);function generatedPositionAfter(e,n){const t=e.generatedLine;const o=n.generatedLine;const s=e.generatedColumn;const i=n.generatedColumn;return o>t||o==t&&i>=s||r.compareByGeneratedPositionsInflated(e,n)<=0}class MappingList{constructor(){this._array=[];this._sorted=true;this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(e,n){this._array.forEach(e,n)}add(e){if(generatedPositionAfter(this._last,e)){this._last=e;this._array.push(e)}else{this._sorted=false;this._array.push(e)}}toArray(){if(!this._sorted){this._array.sort(r.compareByGeneratedPositionsInflated);this._sorted=true}return this._array}}n.H=MappingList},799:(e,n,t)=>{"use strict";const r=t(147);const o=t(17);e.exports=function readWasm(){return new Promise(((e,n)=>{const o=t.ab+"mappings.wasm";r.readFile(t.ab+"mappings.wasm",null,((t,r)=>{if(t){n(t);return}e(r.buffer)}))}))};e.exports.initialize=e=>{console.debug("SourceMapConsumer.initialize is a no-op when running in node.js")}},886:(e,n,t)=>{var r;const o=t(354);const s=t(700);const i=t(963).I;const l=t(344);const a=t(799);const u=t(776);const c=Symbol("smcInternal");class SourceMapConsumer{constructor(e,n){if(e==c){return Promise.resolve(this)}return _factory(e,n)}static initialize(e){a.initialize(e["lib/mappings.wasm"])}static fromSourceMap(e,n){return _factoryBSM(e,n)}static async with(e,n,t){const r=await new SourceMapConsumer(e,n);try{return await t(r)}finally{r.destroy()}}eachMapping(e,n,t){throw new Error("Subclasses must implement eachMapping")}allGeneratedPositionsFor(e){throw new Error("Subclasses must implement allGeneratedPositionsFor")}destroy(){throw new Error("Subclasses must implement destroy")}}SourceMapConsumer.prototype._version=3;SourceMapConsumer.GENERATED_ORDER=1;SourceMapConsumer.ORIGINAL_ORDER=2;SourceMapConsumer.GREATEST_LOWER_BOUND=1;SourceMapConsumer.LEAST_UPPER_BOUND=2;n.SourceMapConsumer=SourceMapConsumer;class BasicSourceMapConsumer extends SourceMapConsumer{constructor(e,n){return super(c).then((t=>{let r=e;if(typeof e==="string"){r=o.parseSourceMapInput(e)}const s=o.getArg(r,"version");const l=o.getArg(r,"sources").map(String);const a=o.getArg(r,"names",[]);const c=o.getArg(r,"sourceRoot",null);const g=o.getArg(r,"sourcesContent",null);const f=o.getArg(r,"mappings");const h=o.getArg(r,"file",null);if(s!=t._version){throw new Error("Unsupported version: "+s)}t._sourceLookupCache=new Map;t._names=i.fromArray(a.map(String),true);t._sources=i.fromArray(l,true);t._absoluteSources=i.fromArray(t._sources.toArray().map((function(e){return o.computeSourceURL(c,e,n)})),true);t.sourceRoot=c;t.sourcesContent=g;t._mappings=f;t._sourceMapURL=n;t.file=h;t._computedColumnSpans=false;t._mappingsPtr=0;t._wasm=null;return u().then((e=>{t._wasm=e;return t}))}))}_findSourceIndex(e){const n=this._sourceLookupCache.get(e);if(typeof n==="number"){return n}const t=o.computeSourceURL(null,e,this._sourceMapURL);if(this._absoluteSources.has(t)){const n=this._absoluteSources.indexOf(t);this._sourceLookupCache.set(e,n);return n}const r=o.computeSourceURL(this.sourceRoot,e,this._sourceMapURL);if(this._absoluteSources.has(r)){const n=this._absoluteSources.indexOf(r);this._sourceLookupCache.set(e,n);return n}return-1}static fromSourceMap(e,n){return new BasicSourceMapConsumer(e.toString())}get sources(){return this._absoluteSources.toArray()}_getMappingsPtr(){if(this._mappingsPtr===0){this._parseMappings()}return this._mappingsPtr}_parseMappings(){const e=this._mappings;const n=e.length;const t=this._wasm.exports.allocate_mappings(n);const r=new Uint8Array(this._wasm.exports.memory.buffer,t,n);for(let t=0;t{if(n.source!==null){n.source=this._absoluteSources.at(n.source);if(n.name!==null){n.name=this._names.at(n.name)}}if(this._computedColumnSpans&&n.lastGeneratedColumn===null){n.lastGeneratedColumn=Infinity}e.call(r,n)}),(()=>{switch(o){case SourceMapConsumer.GENERATED_ORDER:this._wasm.exports.by_generated_location(this._getMappingsPtr());break;case SourceMapConsumer.ORIGINAL_ORDER:this._wasm.exports.by_original_location(this._getMappingsPtr());break;default:throw new Error("Unknown order of iteration.")}}))}allGeneratedPositionsFor(e){let n=o.getArg(e,"source");const t=o.getArg(e,"line");const r=e.column||0;n=this._findSourceIndex(n);if(n<0){return[]}if(t<1){throw new Error("Line numbers must be >= 1")}if(r<0){throw new Error("Column numbers must be >= 0")}const s=[];this._wasm.withMappingCallback((e=>{let n=e.lastGeneratedColumn;if(this._computedColumnSpans&&n===null){n=Infinity}s.push({line:e.generatedLine,column:e.generatedColumn,lastColumn:n})}),(()=>{this._wasm.exports.all_generated_locations_for(this._getMappingsPtr(),n,t-1,"column"in e,r)}));return s}destroy(){if(this._mappingsPtr!==0){this._wasm.exports.free_mappings(this._mappingsPtr);this._mappingsPtr=0}}computeColumnSpans(){if(this._computedColumnSpans){return}this._wasm.exports.compute_column_spans(this._getMappingsPtr());this._computedColumnSpans=true}originalPositionFor(e){const n={generatedLine:o.getArg(e,"line"),generatedColumn:o.getArg(e,"column")};if(n.generatedLine<1){throw new Error("Line numbers must be >= 1")}if(n.generatedColumn<0){throw new Error("Column numbers must be >= 0")}let t=o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND);if(t==null){t=SourceMapConsumer.GREATEST_LOWER_BOUND}let r;this._wasm.withMappingCallback((e=>r=e),(()=>{this._wasm.exports.original_location_for(this._getMappingsPtr(),n.generatedLine-1,n.generatedColumn,t)}));if(r){if(r.generatedLine===n.generatedLine){let e=o.getArg(r,"source",null);if(e!==null){e=this._absoluteSources.at(e)}let n=o.getArg(r,"name",null);if(n!==null){n=this._names.at(n)}return{source:e,line:o.getArg(r,"originalLine",null),column:o.getArg(r,"originalColumn",null),name:n}}}return{source:null,line:null,column:null,name:null}}hasContentsOfAllSources(){if(!this.sourcesContent){return false}return this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return e==null}))}sourceContentFor(e,n){if(!this.sourcesContent){return null}const t=this._findSourceIndex(e);if(t>=0){return this.sourcesContent[t]}if(n){return null}throw new Error('"'+e+'" is not in the SourceMap.')}generatedPositionFor(e){let n=o.getArg(e,"source");n=this._findSourceIndex(n);if(n<0){return{line:null,column:null,lastColumn:null}}const t={source:n,originalLine:o.getArg(e,"line"),originalColumn:o.getArg(e,"column")};if(t.originalLine<1){throw new Error("Line numbers must be >= 1")}if(t.originalColumn<0){throw new Error("Column numbers must be >= 0")}let r=o.getArg(e,"bias",SourceMapConsumer.GREATEST_LOWER_BOUND);if(r==null){r=SourceMapConsumer.GREATEST_LOWER_BOUND}let s;this._wasm.withMappingCallback((e=>s=e),(()=>{this._wasm.exports.generated_location_for(this._getMappingsPtr(),t.source,t.originalLine-1,t.originalColumn,r)}));if(s){if(s.source===t.source){let e=s.lastGeneratedColumn;if(this._computedColumnSpans&&e===null){e=Infinity}return{line:o.getArg(s,"generatedLine",null),column:o.getArg(s,"generatedColumn",null),lastColumn:e}}}return{line:null,column:null,lastColumn:null}}}BasicSourceMapConsumer.prototype.consumer=SourceMapConsumer;r=BasicSourceMapConsumer;class IndexedSourceMapConsumer extends SourceMapConsumer{constructor(e,n){return super(c).then((t=>{let r=e;if(typeof e==="string"){r=o.parseSourceMapInput(e)}const s=o.getArg(r,"version");const i=o.getArg(r,"sections");if(s!=t._version){throw new Error("Unsupported version: "+s)}let l={line:-1,column:0};return Promise.all(i.map((e=>{if(e.url){throw new Error("Support for url field in sections not implemented.")}const t=o.getArg(e,"offset");const r=o.getArg(t,"line");const s=o.getArg(t,"column");if(r({generatedOffset:{generatedLine:r+1,generatedColumn:s+1},consumer:e})))}))).then((e=>{t._sections=e;return t}))}))}get sources(){const e=[];for(let n=0;n=0?this._sections[n]:null;const r=n>=0&&n+1=0?this._sections[n]:null;const r=n>=0&&n+1{const n=t.generatedOffset.generatedLine-1;const o=t.generatedOffset.generatedColumn-1;if(e.line===1){e.column+=o;if(typeof e.lastColumn==="number"){e.lastColumn+=o}}if(e.lastColumn===Infinity&&r&&e.line===r.generatedOffset.generatedLine){e.lastColumn=r.generatedOffset.generatedColumn-2}e.line+=n;return e}))}eachMapping(e,n,t){this._sections.forEach(((r,o)=>{const s=o+1{const r=t(344);const o=t(354);const s=t(963).I;const i=t(371).H;class SourceMapGenerator{constructor(e){if(!e){e={}}this._file=o.getArg(e,"file",null);this._sourceRoot=o.getArg(e,"sourceRoot",null);this._skipValidation=o.getArg(e,"skipValidation",false);this._sources=new s;this._names=new s;this._mappings=new i;this._sourcesContents=null}static fromSourceMap(e){const n=e.sourceRoot;const t=new SourceMapGenerator({file:e.file,sourceRoot:n});e.eachMapping((function(e){const r={generated:{line:e.generatedLine,column:e.generatedColumn}};if(e.source!=null){r.source=e.source;if(n!=null){r.source=o.relative(n,r.source)}r.original={line:e.originalLine,column:e.originalColumn};if(e.name!=null){r.name=e.name}}t.addMapping(r)}));e.sources.forEach((function(r){let s=r;if(n!==null){s=o.relative(n,r)}if(!t._sources.has(s)){t._sources.add(s)}const i=e.sourceContentFor(r);if(i!=null){t.setSourceContent(r,i)}}));return t}addMapping(e){const n=o.getArg(e,"generated");const t=o.getArg(e,"original",null);let r=o.getArg(e,"source",null);let s=o.getArg(e,"name",null);if(!this._skipValidation){this._validateMapping(n,t,r,s)}if(r!=null){r=String(r);if(!this._sources.has(r)){this._sources.add(r)}}if(s!=null){s=String(s);if(!this._names.has(s)){this._names.add(s)}}this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:t!=null&&t.line,originalColumn:t!=null&&t.column,source:r,name:s})}setSourceContent(e,n){let t=e;if(this._sourceRoot!=null){t=o.relative(this._sourceRoot,t)}if(n!=null){if(!this._sourcesContents){this._sourcesContents=Object.create(null)}this._sourcesContents[o.toSetString(t)]=n}else if(this._sourcesContents){delete this._sourcesContents[o.toSetString(t)];if(Object.keys(this._sourcesContents).length===0){this._sourcesContents=null}}}applySourceMap(e,n,t){let r=n;if(n==null){if(e.file==null){throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, "+'or the source map\'s "file" property. Both were omitted.')}r=e.file}const i=this._sourceRoot;if(i!=null){r=o.relative(i,r)}const l=this._mappings.toArray().length>0?new s:this._sources;const a=new s;this._mappings.unsortedForEach((function(n){if(n.source===r&&n.originalLine!=null){const r=e.originalPositionFor({line:n.originalLine,column:n.originalColumn});if(r.source!=null){n.source=r.source;if(t!=null){n.source=o.join(t,n.source)}if(i!=null){n.source=o.relative(i,n.source)}n.originalLine=r.line;n.originalColumn=r.column;if(r.name!=null){n.name=r.name}}}const s=n.source;if(s!=null&&!l.has(s)){l.add(s)}const u=n.name;if(u!=null&&!a.has(u)){a.add(u)}}),this);this._sources=l;this._names=a;e.sources.forEach((function(n){const r=e.sourceContentFor(n);if(r!=null){if(t!=null){n=o.join(t,n)}if(i!=null){n=o.relative(i,n)}this.setSourceContent(n,r)}}),this)}_validateMapping(e,n,t,r){if(n&&typeof n.line!=="number"&&typeof n.column!=="number"){throw new Error("original.line and original.column are not numbers -- you probably meant to omit "+"the original mapping entirely and only map the generated position. If so, pass "+"null for the original mapping instead of an object with empty or null values.")}if(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0&&!n&&!t&&!r){}else if(e&&"line"in e&&"column"in e&&n&&"line"in n&&"column"in n&&e.line>0&&e.column>=0&&n.line>0&&n.column>=0&&t){}else{throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:t,original:n,name:r}))}}_serializeMappings(){let e=0;let n=1;let t=0;let s=0;let i=0;let l=0;let a="";let u;let c;let g;let f;const h=this._mappings.toArray();for(let p=0,m=h.length;p0){if(!o.compareByGeneratedPositionsInflated(c,h[p-1])){continue}u+=","}u+=r.encode(c.generatedColumn-e);e=c.generatedColumn;if(c.source!=null){f=this._sources.indexOf(c.source);u+=r.encode(f-l);l=f;u+=r.encode(c.originalLine-1-s);s=c.originalLine-1;u+=r.encode(c.originalColumn-t);t=c.originalColumn;if(c.name!=null){g=this._names.indexOf(c.name);u+=r.encode(g-i);i=g}}a+=u}return a}_generateSourcesContent(e,n){return e.map((function(e){if(!this._sourcesContents){return null}if(n!=null){e=o.relative(n,e)}const t=o.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,t)?this._sourcesContents[t]:null}),this)}toJSON(){const e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};if(this._file!=null){e.file=this._file}if(this._sourceRoot!=null){e.sourceRoot=this._sourceRoot}if(this._sourcesContents){e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)}return e}toString(){return JSON.stringify(this.toJSON())}}SourceMapGenerator.prototype._version=3;n.SourceMapGenerator=SourceMapGenerator},589:(e,n,t)=>{const r=t(87).SourceMapGenerator;const o=t(354);const s=/(\r?\n)/;const i=10;const l="$$$isSourceNode$$$";class SourceNode{constructor(e,n,t,r,o){this.children=[];this.sourceContents={};this.line=e==null?null:e;this.column=n==null?null:n;this.source=t==null?null:t;this.name=o==null?null:o;this[l]=true;if(r!=null)this.add(r)}static fromStringWithSourceMap(e,n,t){const r=new SourceNode;const i=e.split(s);let l=0;const shiftNextLine=function(){const e=getNextLine();const n=getNextLine()||"";return e+n;function getNextLine(){return l=0;n--){this.prepend(e[n])}}else if(e[l]||typeof e==="string"){this.children.unshift(e)}else{throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e)}return this}walk(e){let n;for(let t=0,r=this.children.length;t0){n=[];for(t=0;t{"use strict";e.exports=typeof URL==="function"?URL:t(310).URL},354:(e,n,t)=>{const r=t(869);function getArg(e,n,t){if(n in e){return e[n]}else if(arguments.length===3){return t}throw new Error('"'+n+'" is a required argument.')}n.getArg=getArg;const o=function(){const e=Object.create(null);return!("__proto__"in e)}();function identity(e){return e}function toSetString(e){if(isProtoString(e)){return"$"+e}return e}n.toSetString=o?identity:toSetString;function fromSetString(e){if(isProtoString(e)){return e.slice(1)}return e}n.fromSetString=o?identity:fromSetString;function isProtoString(e){if(!e){return false}const n=e.length;if(n<9){return false}if(e.charCodeAt(n-1)!==95||e.charCodeAt(n-2)!==95||e.charCodeAt(n-3)!==111||e.charCodeAt(n-4)!==116||e.charCodeAt(n-5)!==111||e.charCodeAt(n-6)!==114||e.charCodeAt(n-7)!==112||e.charCodeAt(n-8)!==95||e.charCodeAt(n-9)!==95){return false}for(let t=n-10;t>=0;t--){if(e.charCodeAt(t)!==36){return false}}return true}function strcmp(e,n){if(e===n){return 0}if(e===null){return 1}if(n===null){return-1}if(e>n){return 1}return-1}function compareByGeneratedPositionsInflated(e,n){let t=e.generatedLine-n.generatedLine;if(t!==0){return t}t=e.generatedColumn-n.generatedColumn;if(t!==0){return t}t=strcmp(e.source,n.source);if(t!==0){return t}t=e.originalLine-n.originalLine;if(t!==0){return t}t=e.originalColumn-n.originalColumn;if(t!==0){return t}return strcmp(e.name,n.name)}n.compareByGeneratedPositionsInflated=compareByGeneratedPositionsInflated;function parseSourceMapInput(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}n.parseSourceMapInput=parseSourceMapInput;const s="http:";const i=`${s}//host`;function createSafeHandler(e){return n=>{const t=getURLType(n);const o=buildSafeBase(n);const l=new r(n,o);e(l);const a=l.toString();if(t==="absolute"){return a}else if(t==="scheme-relative"){return a.slice(s.length)}else if(t==="path-absolute"){return a.slice(i.length)}return computeRelativeURL(o,a)}}function withBase(e,n){return new r(e,n).toString()}function buildUniqueSegment(e,n){let t=0;do{const r=e+t++;if(n.indexOf(r)===-1)return r}while(true)}function buildSafeBase(e){const n=e.split("..").length-1;const t=buildUniqueSegment("p",e);let r=`${i}/`;for(let e=0;e0&&!o[o.length-1]){o.pop()}while(t.length>0&&o.length>0&&t[0]===o[0]){t.shift();o.shift()}const s=o.map((()=>"..")).concat(t).join("/");return s+n.search+n.hash}const a=createSafeHandler((e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}));const u=createSafeHandler((e=>{e.href=new r(".",e.toString()).toString()}));const c=createSafeHandler((e=>{}));n.normalize=c;function join(e,n){const t=getURLType(n);const r=getURLType(e);e=a(e);if(t==="absolute"){return withBase(n,undefined)}if(r==="absolute"){return withBase(n,e)}if(t==="scheme-relative"){return c(n)}if(r==="scheme-relative"){return withBase(n,withBase(e,i)).slice(s.length)}if(t==="path-absolute"){return c(n)}if(r==="path-absolute"){return withBase(n,withBase(e,i)).slice(i.length)}const o=buildSafeBase(n+e);const l=withBase(n,withBase(e,o));return computeRelativeURL(o,l)}n.join=join;function relative(e,n){const t=relativeIfPossible(e,n);return typeof t==="string"?t:c(n)}n.relative=relative;function relativeIfPossible(e,n){const t=getURLType(e);if(t!==getURLType(n)){return null}const o=buildSafeBase(e+n);const s=new r(e,o);const i=new r(n,o);try{new r("",i.toString())}catch(e){return null}if(i.protocol!==s.protocol||i.user!==s.user||i.password!==s.password||i.hostname!==s.hostname||i.port!==s.port){return null}return computeRelativeURL(s,i)}function computeSourceURL(e,n,t){if(e&&getURLType(n)==="path-absolute"){n=n.replace(/^\//,"")}let r=c(n||"");if(e)r=join(e,r);if(t)r=join(u(t),r);return r}n.computeSourceURL=computeSourceURL},776:(e,n,t)=>{const r=t(799);function Mapping(){this.generatedLine=0;this.generatedColumn=0;this.lastGeneratedColumn=null;this.source=null;this.originalLine=null;this.originalColumn=null;this.name=null}let o=null;e.exports=function wasm(){if(o){return o}const e=[];o=r().then((n=>WebAssembly.instantiate(n,{env:{mapping_callback(n,t,r,o,s,i,l,a,u,c){const g=new Mapping;g.generatedLine=n+1;g.generatedColumn=t;if(r){g.lastGeneratedColumn=o-1}if(s){g.source=i;g.originalLine=l+1;g.originalColumn=a;if(u){g.name=c}}e[e.length-1](g)},start_all_generated_locations_for(){console.time("all_generated_locations_for")},end_all_generated_locations_for(){console.timeEnd("all_generated_locations_for")},start_compute_column_spans(){console.time("compute_column_spans")},end_compute_column_spans(){console.timeEnd("compute_column_spans")},start_generated_location_for(){console.time("generated_location_for")},end_generated_location_for(){console.timeEnd("generated_location_for")},start_original_location_for(){console.time("original_location_for")},end_original_location_for(){console.timeEnd("original_location_for")},start_parse_mappings(){console.time("parse_mappings")},end_parse_mappings(){console.timeEnd("parse_mappings")},start_sort_by_generated_location(){console.time("sort_by_generated_location")},end_sort_by_generated_location(){console.timeEnd("sort_by_generated_location")},start_sort_by_original_location(){console.time("sort_by_original_location")},end_sort_by_original_location(){console.timeEnd("sort_by_original_location")}}}))).then((n=>({exports:n.instance.exports,withMappingCallback:(n,t)=>{e.push(n);try{t()}finally{e.pop()}}}))).then(null,(e=>{o=null;throw e}));return o}},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},310:e=>{"use strict";e.exports=require("url")}};var n={};function __nccwpck_require__(t){var r=n[t];if(r!==undefined){return r.exports}var o=n[t]={exports:{}};var s=true;try{e[t](o,o.exports,__nccwpck_require__);s=false}finally{if(s)delete n[t]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t={};(()=>{var e=t;e.SourceMapGenerator=__nccwpck_require__(87).SourceMapGenerator;e.SourceMapConsumer=__nccwpck_require__(886).SourceMapConsumer;e.SourceNode=__nccwpck_require__(589).SourceNode})();module.exports=t})(); \ No newline at end of file diff --git a/packages/next/src/export/index.ts b/packages/next/src/export/index.ts index b07ca09bdc863..4b9a478dcb4dd 100644 --- a/packages/next/src/export/index.ts +++ b/packages/next/src/export/index.ts @@ -516,7 +516,7 @@ export async function exportAppImpl( const { serverRuntimeConfig, publicRuntimeConfig } = nextConfig if (Object.keys(publicRuntimeConfig).length > 0) { - ;(renderOpts as any).runtimeConfig = publicRuntimeConfig + renderOpts.runtimeConfig = publicRuntimeConfig } // We need this for server rendering the Link component. diff --git a/packages/next/src/server/base-server.ts b/packages/next/src/server/base-server.ts index 16072e62ec073..4d2657fb730d3 100644 --- a/packages/next/src/server/base-server.ts +++ b/packages/next/src/server/base-server.ts @@ -214,51 +214,10 @@ export type RenderOpts = PagesRenderOptsPartial & AppRenderOptsPartial export type LoadedRenderOpts = RenderOpts & LoadComponentsReturnType -type BaseRenderOpts = { - deploymentId?: string +type BaseRenderOpts = RenderOpts & { poweredByHeader: boolean - buildId: string generateEtags: boolean - runtimeConfig?: { [key: string]: any } - assetPrefix?: string - canonicalBase: string - dev?: boolean previewProps: __ApiPreviewProps - customServer?: boolean - ampOptimizerConfig?: { [key: string]: any } - basePath: string - optimizeFonts: FontConfig - images: ImageConfigComplete - fontManifest?: FontManifest - disableOptimizedLoading?: boolean - optimizeCss: any - nextConfigOutput: 'standalone' | 'export' - nextScriptWorkers: any - locale?: string - locales?: string[] - defaultLocale?: string - domainLocales?: DomainLocale[] - distDir: string - runtime?: ServerRuntime - serverComponents?: boolean - enableTainting?: boolean - crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined - supportsDynamicHTML?: boolean - isBot?: boolean - clientReferenceManifest?: ClientReferenceManifest - serverActions?: { - bodySizeLimit?: SizeLimit - allowedOrigins?: string[] - } - serverActionsManifest?: any - nextFontManifest?: NextFontManifest - renderServerComponentData?: boolean - serverComponentProps?: any - largePageDataBytes?: number - appDirDevErrorLogger?: (err: any) => Promise - strictNextHead: boolean - isExperimentalCompile?: boolean - experimental: { ppr: boolean; missingSuspenseWithCSRBailout: boolean } } export interface BaseRequestHandler { @@ -506,6 +465,7 @@ export default abstract class Server { } this.renderOpts = { + supportsDynamicHTML: false, deploymentId: this.nextConfig.experimental.deploymentId, strictNextHead: !!this.nextConfig.experimental.strictNextHead, poweredByHeader: this.nextConfig.poweredByHeader, diff --git a/packages/next/src/server/dev/hot-reloader-webpack.ts b/packages/next/src/server/dev/hot-reloader-webpack.ts index 6507d56f453cc..8a58dbbf58550 100644 --- a/packages/next/src/server/dev/hot-reloader-webpack.ts +++ b/packages/next/src/server/dev/hot-reloader-webpack.ts @@ -7,7 +7,7 @@ import type { UrlObject } from 'url' import type { RouteDefinition } from '../future/route-definitions/route-definition' import { webpack, StringXor } from 'next/dist/compiled/webpack/webpack' -import { getOverlayMiddleware } from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' +import { getOverlayMiddleware } from '../../client/components/react-dev-overlay/server/middleware' import { WebpackHotMiddleware } from './hot-middleware' import { join, relative, isAbsolute, posix } from 'path' import { diff --git a/packages/next/src/server/dev/next-dev-server.ts b/packages/next/src/server/dev/next-dev-server.ts index cd57fb0ca61df..b8aa4a3833912 100644 --- a/packages/next/src/server/dev/next-dev-server.ts +++ b/packages/next/src/server/dev/next-dev-server.ts @@ -68,7 +68,7 @@ let ReactDevOverlayImpl: FunctionComponent const ReactDevOverlay = (props: any) => { if (ReactDevOverlayImpl === undefined) { ReactDevOverlayImpl = - require('next/dist/compiled/@next/react-dev-overlay/dist/client').ReactDevOverlay + require('../../client/components/react-dev-overlay/pages/client').ReactDevOverlay } return ReactDevOverlayImpl(props) } @@ -156,7 +156,7 @@ export default class DevServer extends Server { this.renderOpts.dev = true this.renderOpts.appDirDevErrorLogger = (err: any) => this.logErrorWithOriginalStack(err, 'app-dir') - ;(this.renderOpts as any).ErrorDebug = ReactDevOverlay + this.renderOpts.ErrorDebug = ReactDevOverlay this.staticPathsCache = new LRUCache({ // 5MB max: 5 * 1024 * 1024, @@ -164,12 +164,9 @@ export default class DevServer extends Server { return JSON.stringify(value.staticPaths).length }, }) - ;(this.renderOpts as any).ampSkipValidation = + this.renderOpts.ampSkipValidation = this.nextConfig.experimental?.amp?.skipValidation ?? false - ;(this.renderOpts as any).ampValidator = ( - html: string, - pathname: string - ) => { + this.renderOpts.ampValidator = (html: string, pathname: string) => { const validatorPath = this.nextConfig.experimental && this.nextConfig.experimental.amp && diff --git a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts index 2ed261fec0659..b0db697c39b26 100644 --- a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts +++ b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts @@ -102,11 +102,11 @@ import { getErrorSource, getSourceById, parseStack, -} from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' +} from '../../../client/components/react-dev-overlay/server/middleware' import { getOverlayMiddleware, createOriginalStackFrame as createOriginalTurboStackFrame, -} from 'next/dist/compiled/@next/react-dev-overlay/dist/middleware-turbopack' +} from '../../../client/components/react-dev-overlay/server/middleware-turbopack' import { mkdir, readFile, writeFile } from 'fs/promises' import { PageNotFoundError } from '../../../shared/lib/utils' import { diff --git a/packages/next/src/server/lib/server-ipc/request-utils.ts b/packages/next/src/server/lib/server-ipc/request-utils.ts index be4739e96263d..085786ad7a42b 100644 --- a/packages/next/src/server/lib/server-ipc/request-utils.ts +++ b/packages/next/src/server/lib/server-ipc/request-utils.ts @@ -25,7 +25,7 @@ export const deserializeErr = (serializedErr: any) => { process.env.NEXT_RUNTIME !== 'edge' ) { const { decorateServerError } = - require('next/dist/compiled/@next/react-dev-overlay/dist/middleware') as typeof import('next/dist/compiled/@next/react-dev-overlay/dist/middleware') + require('../../../client/components/react-dev-overlay/server/middleware') as typeof import('../../../client/components/react-dev-overlay/server/middleware') decorateServerError(err, serializedErr.source || 'server') } return err diff --git a/packages/next/src/server/render.tsx b/packages/next/src/server/render.tsx index 8a09f5df896dd..c784abce8b2f4 100644 --- a/packages/next/src/server/render.tsx +++ b/packages/next/src/server/render.tsx @@ -371,7 +371,7 @@ export function errorToJSON(err: Error) { if (process.env.NEXT_RUNTIME !== 'edge') { source = - require('next/dist/compiled/@next/react-dev-overlay/dist/middleware').getErrorSource( + require('../client/components/react-dev-overlay/server/middleware').getErrorSource( err ) || 'server' } diff --git a/packages/next/src/server/web-server.ts b/packages/next/src/server/web-server.ts index 6a563bbc88577..a8a6d77bbea95 100644 --- a/packages/next/src/server/web-server.ts +++ b/packages/next/src/server/web-server.ts @@ -38,7 +38,9 @@ interface WebServerOptions extends Options { pagesType: PAGE_TYPES loadComponent: (page: string) => Promise extendRenderOpts: Partial & - Pick + Pick & { + serverActionsManifest?: any + } renderToHTML: | typeof import('./app-render/app-render').renderToHTMLOrFlight | undefined diff --git a/packages/next/src/server/web/sandbox/context.ts b/packages/next/src/server/web/sandbox/context.ts index 5d0050dccb1dc..9e95423f162b2 100644 --- a/packages/next/src/server/web/sandbox/context.ts +++ b/packages/next/src/server/web/sandbox/context.ts @@ -28,11 +28,11 @@ interface ModuleContext { warnedEvals: Set } -let getServerError: typeof import('next/dist/compiled/@next/react-dev-overlay/dist/middleware').getServerError -let decorateServerError: typeof import('next/dist/compiled/@next/react-dev-overlay/dist/middleware').decorateServerError +let getServerError: typeof import('../../../client/components/react-dev-overlay/server/middleware').getServerError +let decorateServerError: typeof import('../../../client/components/react-dev-overlay/server/middleware').decorateServerError if (process.env.NODE_ENV === 'development') { - const middleware = require('next/dist/compiled/@next/react-dev-overlay/dist/middleware') + const middleware = require('../../../client/components/react-dev-overlay/server/middleware') getServerError = middleware.getServerError decorateServerError = middleware.decorateServerError } else { diff --git a/packages/next/src/server/web/sandbox/sandbox.ts b/packages/next/src/server/web/sandbox/sandbox.ts index 1c6b85b696cbd..26fb87d5c8943 100644 --- a/packages/next/src/server/web/sandbox/sandbox.ts +++ b/packages/next/src/server/web/sandbox/sandbox.ts @@ -31,7 +31,7 @@ type RunnerFn = (params: { function withTaggedErrors(fn: RunnerFn): RunnerFn { if (process.env.NODE_ENV === 'development') { const { getServerError } = - require('next/dist/compiled/@next/react-dev-overlay/dist/middleware') as typeof import('next/dist/compiled/@next/react-dev-overlay/dist/middleware') + require('../../../client/components/react-dev-overlay/server/middleware') as typeof import('../../../client/components/react-dev-overlay/server/middleware') return (params) => fn(params) diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index d372c1fcfe098..084845a6faeeb 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -464,83 +464,6 @@ export async function ncc_edge_runtime(task, opts) { ) } -// eslint-disable-next-line camelcase -export async function ncc_next__react_dev_overlay(task, opts) { - const overlayExternals = { - ...externals, - react: 'react', - 'react-dom': 'react-dom', - } - // dev-overlay needs a newer source-map version - delete overlayExternals['source-map'] - - await task - .source( - relative( - __dirname, - require.resolve('@next/react-dev-overlay/dist/middleware') - ) - ) - .ncc({ - precompiled: false, - packageName: '@next/react-dev-overlay', - externals: overlayExternals, - target: 'es5', - }) - .target('dist/compiled/@next/react-dev-overlay/dist') - - await task - .source( - relative( - __dirname, - require.resolve('@next/react-dev-overlay/dist/middleware-turbopack') - ) - ) - .ncc({ - precompiled: false, - packageName: '@next/react-dev-overlay', - externals: overlayExternals, - target: 'es5', - }) - .target('dist/compiled/@next/react-dev-overlay/dist') - - await task - .source( - relative( - __dirname, - require.resolve('@next/react-dev-overlay/dist/client') - ) - ) - .ncc({ - precompiled: false, - packageName: '@next/react-dev-overlay', - externals: overlayExternals, - target: 'es5', - }) - .target('dist/compiled/@next/react-dev-overlay/dist') - - const clientFile = join( - __dirname, - 'dist/compiled/@next/react-dev-overlay/dist/client.js' - ) - const content = await fs.readFile(clientFile, 'utf8') - // remove AMD define branch as this forces the module to not - // be treated as commonjs - await fs.writeFile( - clientFile, - content.replace( - new RegExp( - 'if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){r.platform=b;define((function(){return b}))}else '.replace( - /[|\\{}()[\]^$+*?.-]/g, - '\\$&' - ), - 'g' - ), - '' - ) - ) -} - // eslint-disable-next-line camelcase export async function ncc_next_font(task, opts) { // `@next/font` can be copied as is, its only dependency is already NCCed @@ -2398,7 +2321,6 @@ export async function compile(task, opts) { await task.serial([ 'ncc_react_refresh_utils', - 'ncc_next__react_dev_overlay', 'ncc_next_font', 'capsize_metrics', ]) @@ -2668,11 +2590,6 @@ export default async function (task) { ['shared_re_exported', 'shared_re_exported_esm', 'shared', 'shared_esm'], opts ) - await task.watch( - '../react-dev-overlay/dist', - 'ncc_next__react_dev_overlay', - opts - ) } export async function shared(task, opts) { diff --git a/packages/next/types/misc.d.ts b/packages/next/types/misc.d.ts index 68d969508348f..ef49768901e29 100644 --- a/packages/next/types/misc.d.ts +++ b/packages/next/types/misc.d.ts @@ -36,18 +36,6 @@ declare module 'VAR_USERLAND' declare module 'VAR_MODULE_DOCUMENT' declare module 'VAR_MODULE_APP' -declare module 'next/dist/compiled/@next/react-dev-overlay/dist/client' { - export * from '@next/react-dev-overlay/dist/client' -} - -declare module 'next/dist/compiled/@next/react-dev-overlay/dist/middleware' { - export * from '@next/react-dev-overlay/dist/middleware' -} - -declare module 'next/dist/compiled/@next/react-dev-overlay/dist/middleware-turbopack' { - export * from '@next/react-dev-overlay/dist/middleware-turbopack' -} - declare module 'next/dist/compiled/@next/react-refresh-utils/dist/ReactRefreshWebpackPlugin' { import m from '@next/react-refresh-utils/ReactRefreshWebpackPlugin' export = m diff --git a/packages/next/webpack.config.js b/packages/next/webpack.config.js index e995e7f9d634b..780a8bfc36cb9 100644 --- a/packages/next/webpack.config.js +++ b/packages/next/webpack.config.js @@ -65,7 +65,6 @@ const sharedExternals = [ 'styled-jsx', 'styled-jsx/style', '@opentelemetry/api', - 'next/dist/compiled/@next/react-dev-overlay/dist/middleware', 'next/dist/compiled/@ampproject/toolbox-optimizer', 'next/dist/compiled/edge-runtime', 'next/dist/compiled/@edge-runtime/ponyfill', diff --git a/packages/react-dev-overlay/README.md b/packages/react-dev-overlay/README.md deleted file mode 100644 index d79f30491832f..0000000000000 --- a/packages/react-dev-overlay/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@next/react-dev-overlay` - -A development-only overlay for developing React applications. diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json deleted file mode 100644 index 179c05ccfcc02..0000000000000 --- a/packages/react-dev-overlay/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "@next/react-dev-overlay", - "version": "14.1.1-canary.1", - "description": "A development-only overlay for developing React applications.", - "repository": { - "url": "vercel/next.js", - "directory": "packages/react-dev-overlay" - }, - "files": [ - "dist" - ], - "author": "Joe Haddad ", - "license": "MIT", - "scripts": { - "build": "node ../../scripts/rm.mjs dist && tsc -d -p tsconfig.json", - "prepublishOnly": "cd ../../ && turbo run build", - "dev": "tsc -d -w -p tsconfig.json", - "typescript": "tsec --noEmit -p tsconfig.json" - }, - "dependencies": { - "@babel/code-frame": "7.22.5", - "@types/babel__code-frame": "7.0.3", - "anser": "1.4.9", - "css.escape": "1.5.1", - "data-uri-to-buffer": "3.0.1", - "picocolors": "1.0.0", - "platform": "1.3.6", - "shell-quote": "1.7.3", - "source-map": "0.8.0-beta.0", - "stacktrace-parser": "0.1.10", - "strip-ansi": "6.0.1" - }, - "peerDependencies": { - "react": "^17.0.2", - "react-dom": "^17.0.2", - "webpack": "^4 || ^5" - }, - "peerDependenciesMeta": { - "webpack": { - "optional": true - } - } -} diff --git a/packages/react-dev-overlay/src/internal/components/CodeFrame/CodeFrame.tsx b/packages/react-dev-overlay/src/internal/components/CodeFrame/CodeFrame.tsx deleted file mode 100644 index 292b698e641b5..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/CodeFrame/CodeFrame.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import Anser from 'anser' -import * as React from 'react' -import type { StackFrame } from 'stacktrace-parser' -import stripAnsi from 'strip-ansi' -import { getFrameSource } from '../../helpers/stack-frame' - -export type CodeFrameProps = { stackFrame: StackFrame; codeFrame: string } - -export const CodeFrame: React.FC = function CodeFrame({ - stackFrame, - codeFrame, -}) { - // Strip leading spaces out of the code frame: - const formattedFrame = React.useMemo(() => { - const lines = codeFrame.split(/\r?\n/g) - const prefixLength = lines - .map((line) => - /^>? +\d+ +\| [ ]+/.exec(stripAnsi(line)) === null - ? null - : /^>? +\d+ +\| ( *)/.exec(stripAnsi(line)) - ) - .filter(Boolean) - .map((v) => v!.pop()!) - .reduce((c, n) => (isNaN(c) ? n.length : Math.min(c, n.length)), NaN) - - if (prefixLength > 1) { - const p = ' '.repeat(prefixLength) - return lines - .map((line, a) => - ~(a = line.indexOf('|')) - ? line.substring(0, a) + line.substring(a).replace(p, '') - : line - ) - .join('\n') - } - return lines.join('\n') - }, [codeFrame]) - - const decoded = React.useMemo(() => { - return Anser.ansiToJson(formattedFrame, { - json: true, - use_classes: true, - remove_empty: true, - }) - }, [formattedFrame]) - - const open = React.useCallback(() => { - const params = new URLSearchParams() - for (const key in stackFrame) { - params.append(key, ((stackFrame as any)[key] ?? '').toString()) - } - - self - .fetch( - `${ - process.env.__NEXT_ROUTER_BASEPATH || '' - }/__nextjs_launch-editor?${params.toString()}` - ) - .then( - () => {}, - () => { - console.error('There was an issue opening this code in your editor.') - } - ) - }, [stackFrame]) - - // TODO: make the caret absolute - return ( -
-
-

- - {getFrameSource(stackFrame)} @ {stackFrame.methodName} - - - - - - -

-
-
-        {decoded.map((entry, index) => (
-          
-            {entry.content}
-          
-        ))}
-      
-
- ) -} diff --git a/packages/react-dev-overlay/src/internal/components/CodeFrame/index.tsx b/packages/react-dev-overlay/src/internal/components/CodeFrame/index.tsx deleted file mode 100644 index 59818df56eddb..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/CodeFrame/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { CodeFrame } from './CodeFrame' diff --git a/packages/react-dev-overlay/src/internal/components/CodeFrame/styles.tsx b/packages/react-dev-overlay/src/internal/components/CodeFrame/styles.tsx deleted file mode 100644 index 324cc5fedc9c8..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/CodeFrame/styles.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { noop as css } from '../../helpers/noop-template' - -const styles = css` - [data-nextjs-codeframe] { - overflow: auto; - border-radius: var(--size-gap-half); - background-color: var(--color-ansi-bg); - color: var(--color-ansi-fg); - } - [data-nextjs-codeframe]::selection, - [data-nextjs-codeframe] *::selection { - background-color: var(--color-ansi-selection); - } - [data-nextjs-codeframe] * { - color: inherit; - background-color: transparent; - font-family: var(--font-stack-monospace); - } - - [data-nextjs-codeframe] > * { - margin: 0; - padding: calc(var(--size-gap) + var(--size-gap-half)) - calc(var(--size-gap-double) + var(--size-gap-half)); - } - [data-nextjs-codeframe] > div { - display: inline-block; - width: auto; - min-width: 100%; - border-bottom: 1px solid var(--color-ansi-bright-black); - } - [data-nextjs-codeframe] > div > p { - display: flex; - align-items: center; - justify-content: space-between; - cursor: pointer; - margin: 0; - } - [data-nextjs-codeframe] > div > p:hover { - text-decoration: underline dotted; - } - [data-nextjs-codeframe] div > p > svg { - width: auto; - height: 1em; - margin-left: 8px; - } - [data-nextjs-codeframe] div > pre { - overflow: hidden; - display: inline-block; - } -` - -export { styles } diff --git a/packages/react-dev-overlay/src/internal/components/Dialog/Dialog.tsx b/packages/react-dev-overlay/src/internal/components/Dialog/Dialog.tsx deleted file mode 100644 index 65d2bc7460e9f..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Dialog/Dialog.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import * as React from 'react' -import { useOnClickOutside } from '../../hooks/use-on-click-outside' - -export type DialogProps = { - children?: React.ReactNode - type: 'error' | 'warning' - 'aria-labelledby': string - 'aria-describedby': string - onClose?: (e: MouseEvent | TouchEvent) => void -} - -const Dialog: React.FC = function Dialog({ - children, - type, - onClose, - ...props -}) { - const [dialog, setDialog] = React.useState(null) - const [role, setRole] = React.useState( - typeof document !== 'undefined' && document.hasFocus() - ? 'dialog' - : undefined - ) - const onDialog = React.useCallback((node: HTMLDivElement | null) => { - setDialog(node) - }, []) - useOnClickOutside(dialog, onClose) - - // Make HTMLElements with `role=link` accessible to be triggered by the - // keyboard, i.e. [Enter]. - React.useEffect(() => { - if (dialog == null) { - return - } - - const root = dialog.getRootNode() - // Always true, but we do this for TypeScript: - if (!(root instanceof ShadowRoot)) { - return - } - const shadowRoot = root - function handler(e: KeyboardEvent) { - const el = shadowRoot.activeElement - if ( - e.key === 'Enter' && - el instanceof HTMLElement && - el.getAttribute('role') === 'link' - ) { - e.preventDefault() - e.stopPropagation() - - el.click() - } - } - - function handleFocus() { - // safari will force itself as the active application when a background page triggers any sort of autofocus - // this is a workaround to only set the dialog role if the document has focus - setRole(document.hasFocus() ? 'dialog' : undefined) - } - - shadowRoot.addEventListener('keydown', handler as EventListener) - window.addEventListener('focus', handleFocus) - window.addEventListener('blur', handleFocus) - return () => { - shadowRoot.removeEventListener('keydown', handler as EventListener) - window.removeEventListener('focus', handleFocus) - window.removeEventListener('blur', handleFocus) - } - }, [dialog]) - - return ( -
-
- {children} -
- ) -} - -export { Dialog } diff --git a/packages/react-dev-overlay/src/internal/components/Dialog/DialogBody.tsx b/packages/react-dev-overlay/src/internal/components/Dialog/DialogBody.tsx deleted file mode 100644 index f46fb9957f4e5..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Dialog/DialogBody.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import * as React from 'react' - -export type DialogBodyProps = { - children?: React.ReactNode - className?: string -} - -const DialogBody: React.FC = function DialogBody({ - children, - className, -}) { - return ( -
- {children} -
- ) -} - -export { DialogBody } diff --git a/packages/react-dev-overlay/src/internal/components/Dialog/DialogContent.tsx b/packages/react-dev-overlay/src/internal/components/Dialog/DialogContent.tsx deleted file mode 100644 index 85fcc83b2983e..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Dialog/DialogContent.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import * as React from 'react' - -export type DialogContentProps = { - children?: React.ReactNode - className?: string -} - -const DialogContent: React.FC = function DialogContent({ - children, - className, -}) { - return ( -
- {children} -
- ) -} - -export { DialogContent } diff --git a/packages/react-dev-overlay/src/internal/components/Dialog/DialogHeader.tsx b/packages/react-dev-overlay/src/internal/components/Dialog/DialogHeader.tsx deleted file mode 100644 index c53a613cf9ebd..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Dialog/DialogHeader.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import * as React from 'react' - -export type DialogHeaderProps = { - children?: React.ReactNode - className?: string -} - -const DialogHeader: React.FC = function DialogHeader({ - children, - className, -}) { - return ( -
- {children} -
- ) -} - -export { DialogHeader } diff --git a/packages/react-dev-overlay/src/internal/components/Dialog/index.ts b/packages/react-dev-overlay/src/internal/components/Dialog/index.ts deleted file mode 100644 index 15a3c57a88686..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Dialog/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { Dialog } from './Dialog' -export { DialogBody } from './DialogBody' -export { DialogContent } from './DialogContent' -export { DialogHeader } from './DialogHeader' -export { styles } from './styles' diff --git a/packages/react-dev-overlay/src/internal/components/Dialog/styles.ts b/packages/react-dev-overlay/src/internal/components/Dialog/styles.ts deleted file mode 100644 index ac3544e63c799..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Dialog/styles.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { noop as css } from '../../helpers/noop-template' - -const styles = css` - [data-nextjs-dialog] { - display: flex; - flex-direction: column; - width: 100%; - margin-right: auto; - margin-left: auto; - outline: none; - background: var(--color-background); - border-radius: var(--size-gap); - box-shadow: 0 var(--size-gap-half) var(--size-gap-double) - rgba(0, 0, 0, 0.25); - max-height: calc(100% - 56px); - overflow-y: hidden; - } - - @media (max-height: 812px) { - [data-nextjs-dialog-overlay] { - max-height: calc(100% - 15px); - } - } - - @media (min-width: 576px) { - [data-nextjs-dialog] { - max-width: 540px; - box-shadow: 0 var(--size-gap) var(--size-gap-quad) rgba(0, 0, 0, 0.25); - } - } - - @media (min-width: 768px) { - [data-nextjs-dialog] { - max-width: 720px; - } - } - - @media (min-width: 992px) { - [data-nextjs-dialog] { - max-width: 960px; - } - } - - [data-nextjs-dialog-banner] { - position: relative; - } - [data-nextjs-dialog-banner].banner-warning { - border-color: var(--color-ansi-yellow); - } - [data-nextjs-dialog-banner].banner-error { - border-color: var(--color-ansi-red); - } - - [data-nextjs-dialog-banner]::after { - z-index: 2; - content: ''; - position: absolute; - top: 0; - right: 0; - width: 100%; - /* banner width: */ - border-top-width: var(--size-gap-half); - border-bottom-width: 0; - border-top-style: solid; - border-bottom-style: solid; - border-top-color: inherit; - border-bottom-color: transparent; - } - - [data-nextjs-dialog-content] { - overflow-y: auto; - border: none; - margin: 0; - /* calc(padding + banner width offset) */ - padding: calc(var(--size-gap-double) + var(--size-gap-half)) - var(--size-gap-double); - height: 100%; - display: flex; - flex-direction: column; - } - [data-nextjs-dialog-content] > [data-nextjs-dialog-header] { - flex-shrink: 0; - margin-bottom: var(--size-gap-double); - } - [data-nextjs-dialog-content] > [data-nextjs-dialog-body] { - position: relative; - flex: 1 1 auto; - } -` - -export { styles } diff --git a/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/LeftRightDialogHeader.tsx b/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/LeftRightDialogHeader.tsx deleted file mode 100644 index 337028dc5cfc7..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/LeftRightDialogHeader.tsx +++ /dev/null @@ -1,169 +0,0 @@ -import * as React from 'react' -import { CloseIcon } from '../../icons/CloseIcon' - -export type LeftRightDialogHeaderProps = { - children?: React.ReactNode - className?: string - previous: (() => void) | null - next: (() => void) | null - close?: () => void -} - -const LeftRightDialogHeader: React.FC = - function LeftRightDialogHeader({ - children, - className, - previous, - next, - close, - }) { - const buttonLeft = React.useRef(null) - const buttonRight = React.useRef(null) - const buttonClose = React.useRef(null) - - const [nav, setNav] = React.useState(null) - const onNav = React.useCallback((el: HTMLElement) => { - setNav(el) - }, []) - - React.useEffect(() => { - if (nav == null) { - return - } - - const root = nav.getRootNode() - const d = self.document - - function handler(e: KeyboardEvent) { - if (e.key === 'ArrowLeft') { - e.stopPropagation() - if (buttonLeft.current) { - buttonLeft.current.focus() - } - previous && previous() - } else if (e.key === 'ArrowRight') { - e.stopPropagation() - if (buttonRight.current) { - buttonRight.current.focus() - } - next && next() - } else if (e.key === 'Escape') { - e.stopPropagation() - if (root instanceof ShadowRoot) { - const a = root.activeElement - if (a && a !== buttonClose.current && a instanceof HTMLElement) { - a.blur() - return - } - } - - if (close) { - close() - } - } - } - - root.addEventListener('keydown', handler as EventListener) - if (root !== d) { - d.addEventListener('keydown', handler) - } - return function () { - root.removeEventListener('keydown', handler as EventListener) - if (root !== d) { - d.removeEventListener('keydown', handler) - } - } - }, [close, nav, next, previous]) - - // Unlock focus for browsers like Firefox, that break all user focus if the - // currently focused item becomes disabled. - React.useEffect(() => { - if (nav == null) { - return - } - - const root = nav.getRootNode() - // Always true, but we do this for TypeScript: - if (root instanceof ShadowRoot) { - const a = root.activeElement - - if (previous == null) { - if (buttonLeft.current && a === buttonLeft.current) { - buttonLeft.current.blur() - } - } else if (next == null) { - if (buttonRight.current && a === buttonRight.current) { - buttonRight.current.blur() - } - } - } - }, [nav, next, previous]) - - return ( -
- - {close ? ( - - ) : null} -
- ) - } - -export { LeftRightDialogHeader } diff --git a/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/index.ts b/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/index.ts deleted file mode 100644 index b63edb12ba22a..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { LeftRightDialogHeader } from './LeftRightDialogHeader' -export { styles } from './styles' diff --git a/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/styles.ts b/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/styles.ts deleted file mode 100644 index 9523fe31754f9..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/LeftRightDialogHeader/styles.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { noop as css } from '../../helpers/noop-template' - -const styles = css` - [data-nextjs-dialog-left-right] { - display: flex; - flex-direction: row; - align-content: center; - align-items: center; - justify-content: space-between; - } - [data-nextjs-dialog-left-right] > nav > button { - display: inline-flex; - align-items: center; - justify-content: center; - - width: calc(var(--size-gap-double) + var(--size-gap)); - height: calc(var(--size-gap-double) + var(--size-gap)); - font-size: 0; - border: none; - background-color: rgba(255, 85, 85, 0.1); - color: var(--color-ansi-red); - cursor: pointer; - transition: background-color 0.25s ease; - } - [data-nextjs-dialog-left-right] > nav > button > svg { - width: auto; - height: calc(var(--size-gap) + var(--size-gap-half)); - } - [data-nextjs-dialog-left-right] > nav > button:hover { - background-color: rgba(255, 85, 85, 0.2); - } - [data-nextjs-dialog-left-right] > nav > button:disabled { - background-color: rgba(255, 85, 85, 0.1); - color: rgba(255, 85, 85, 0.4); - cursor: not-allowed; - } - - [data-nextjs-dialog-left-right] > nav > button:first-of-type { - border-radius: var(--size-gap-half) 0 0 var(--size-gap-half); - margin-right: 1px; - } - [data-nextjs-dialog-left-right] > nav > button:last-of-type { - border-radius: 0 var(--size-gap-half) var(--size-gap-half) 0; - } - - [data-nextjs-dialog-left-right] > button:last-of-type { - border: 0; - padding: 0; - - background-color: transparent; - appearance: none; - - opacity: 0.4; - transition: opacity 0.25s ease; - - color: var(--color-font); - } - [data-nextjs-dialog-left-right] > button:last-of-type:hover { - opacity: 0.7; - } -` - -export { styles } diff --git a/packages/react-dev-overlay/src/internal/components/Overlay/Overlay.tsx b/packages/react-dev-overlay/src/internal/components/Overlay/Overlay.tsx deleted file mode 100644 index 958552f17039e..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Overlay/Overlay.tsx +++ /dev/null @@ -1,51 +0,0 @@ -// @ts-ignore -import allyTrap from './maintain--tab-focus' -import * as React from 'react' -import { lock, unlock } from './body-locker' - -export type OverlayProps = { - children?: React.ReactNode - className?: string - fixed?: boolean -} - -const Overlay: React.FC = function Overlay({ - className, - children, - fixed, -}) { - React.useEffect(() => { - lock() - return () => { - unlock() - } - }, []) - - const [overlay, setOverlay] = React.useState(null) - const onOverlay = React.useCallback((el: HTMLDivElement) => { - setOverlay(el) - }, []) - - React.useEffect(() => { - if (overlay == null) { - return - } - - const handle2 = allyTrap({ context: overlay }) - return () => { - handle2.disengage() - } - }, [overlay]) - - return ( -
-
- {children} -
- ) -} - -export { Overlay } diff --git a/packages/react-dev-overlay/src/internal/components/Overlay/body-locker.ts b/packages/react-dev-overlay/src/internal/components/Overlay/body-locker.ts deleted file mode 100644 index 8e33e1c8d9924..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Overlay/body-locker.ts +++ /dev/null @@ -1,41 +0,0 @@ -let 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 (scrollBarGap > 0) { - previousBodyPaddingRight = document.body.style.paddingRight - document.body.style.paddingRight = `${scrollBarGap}px` - } - - previousBodyOverflowSetting = document.body.style.overflow - document.body.style.overflow = 'hidden' - }) -} - -export function unlock() { - setTimeout(() => { - if (activeLocks === 0 || --activeLocks !== 0) { - return - } - - if (previousBodyPaddingRight !== undefined) { - document.body.style.paddingRight = previousBodyPaddingRight - previousBodyPaddingRight = undefined - } - - if (previousBodyOverflowSetting !== undefined) { - document.body.style.overflow = previousBodyOverflowSetting - previousBodyOverflowSetting = undefined - } - }) -} diff --git a/packages/react-dev-overlay/src/internal/components/Overlay/index.tsx b/packages/react-dev-overlay/src/internal/components/Overlay/index.tsx deleted file mode 100644 index 9f8311327322f..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Overlay/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { Overlay } from './Overlay' diff --git a/packages/react-dev-overlay/src/internal/components/Overlay/maintain--tab-focus.ts b/packages/react-dev-overlay/src/internal/components/Overlay/maintain--tab-focus.ts deleted file mode 100644 index a013b16301508..0000000000000 --- a/packages/react-dev-overlay/src/internal/components/Overlay/maintain--tab-focus.ts +++ /dev/null @@ -1,3569 +0,0 @@ -/* eslint-disable */ -// @ts-nocheck -// Copied from https://github.com/medialize/ally.js -// License: MIT -// Copyright (c) 2015 Rodney Rehm -// -// Entrypoint: ally.js/maintain/tab-focus - -import _platform from 'platform' -import cssEscape from 'css.escape' - -// input may be undefined, selector-tring, Node, NodeList, HTMLCollection, array of Nodes -// yes, to some extent this is a bad replica of jQuery's constructor function -function nodeArray(input) { - if (!input) { - return [] - } - - if (Array.isArray(input)) { - return input - } - - // instanceof Node - does not work with iframes - if (input.nodeType !== undefined) { - return [input] - } - - if (typeof input === 'string') { - input = document.querySelectorAll(input) - } - - if (input.length !== undefined) { - return [].slice.call(input, 0) - } - - throw new TypeError('unexpected input ' + String(input)) -} - -function contextToElement(_ref) { - var context = _ref.context, - _ref$label = _ref.label, - label = _ref$label === undefined ? 'context-to-element' : _ref$label, - resolveDocument = _ref.resolveDocument, - defaultToDocument = _ref.defaultToDocument - - var element = nodeArray(context)[0] - - if (resolveDocument && element && element.nodeType === Node.DOCUMENT_NODE) { - element = element.documentElement - } - - if (!element && defaultToDocument) { - return document.documentElement - } - - if (!element) { - throw new TypeError(label + ' requires valid options.context') - } - - if ( - element.nodeType !== Node.ELEMENT_NODE && - element.nodeType !== Node.DOCUMENT_FRAGMENT_NODE - ) { - throw new TypeError(label + ' requires options.context to be an Element') - } - - return element -} - -function getShadowHost() { - var _ref = - arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - context = _ref.context - - var element = contextToElement({ - label: 'get/shadow-host', - context: context, - }) - - // walk up to the root - var container = null - - while (element) { - container = element - element = element.parentNode - } - - // https://developer.mozilla.org/docs/Web/API/Node.nodeType - // NOTE: Firefox 34 does not expose ShadowRoot.host (but 37 does) - if ( - container.nodeType === container.DOCUMENT_FRAGMENT_NODE && - container.host - ) { - // the root is attached to a fragment node that has a host - return container.host - } - - return null -} - -function getDocument(node) { - if (!node) { - return document - } - - if (node.nodeType === Node.DOCUMENT_NODE) { - return node - } - - return node.ownerDocument || document -} - -function isActiveElement(context) { - var element = contextToElement({ - label: 'is/active-element', - resolveDocument: true, - context: context, - }) - - var _document = getDocument(element) - if (_document.activeElement === element) { - return true - } - - var shadowHost = getShadowHost({ context: element }) - if (shadowHost && shadowHost.shadowRoot.activeElement === element) { - return true - } - - return false -} - -// [elem, elem.parent, elem.parent.parent, …, html] -// will not contain the shadowRoot (DOCUMENT_FRAGMENT_NODE) and shadowHost -function getParents() { - var _ref = - arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - context = _ref.context - - var list = [] - var element = contextToElement({ - label: 'get/parents', - context: context, - }) - - while (element) { - list.push(element) - // IE does know support parentElement on SVGElement - element = element.parentNode - if (element && element.nodeType !== Node.ELEMENT_NODE) { - element = null - } - } - - return list -} - -// Element.prototype.matches may be available at a different name -// https://developer.mozilla.org/en/docs/Web/API/Element/matches - -var names = [ - 'matches', - 'webkitMatchesSelector', - 'mozMatchesSelector', - 'msMatchesSelector', -] -var name = null - -function findMethodName(element) { - names.some(function (_name) { - if (!element[_name]) { - return false - } - - name = _name - return true - }) -} - -function elementMatches(element, selector) { - if (!name) { - findMethodName(element) - } - - return element[name](selector) -} - -// deep clone of original platform -var platform = JSON.parse(JSON.stringify(_platform)) - -// operating system -var os = platform.os.family || '' -var ANDROID = os === 'Android' -var WINDOWS = os.slice(0, 7) === 'Windows' -var OSX = os === 'OS X' -var IOS = os === 'iOS' - -// layout -var BLINK = platform.layout === 'Blink' -var GECKO = platform.layout === 'Gecko' -var TRIDENT = platform.layout === 'Trident' -var EDGE = platform.layout === 'EdgeHTML' -var WEBKIT = platform.layout === 'WebKit' - -// browser version (not layout engine version!) -var version = parseFloat(platform.version) -var majorVersion = Math.floor(version) -platform.majorVersion = majorVersion - -platform.is = { - // operating system - ANDROID: ANDROID, - WINDOWS: WINDOWS, - OSX: OSX, - IOS: IOS, - // layout - BLINK: BLINK, // "Chrome", "Chrome Mobile", "Opera" - GECKO: GECKO, // "Firefox" - TRIDENT: TRIDENT, // "Internet Explorer" - EDGE: EDGE, // "Microsoft Edge" - WEBKIT: WEBKIT, // "Safari" - // INTERNET EXPLORERS - IE9: TRIDENT && majorVersion === 9, - IE10: TRIDENT && majorVersion === 10, - IE11: TRIDENT && majorVersion === 11, -} - -function before() { - var data = { - // remember what had focus to restore after test - activeElement: document.activeElement, - // remember scroll positions to restore after test - windowScrollTop: window.scrollTop, - windowScrollLeft: window.scrollLeft, - bodyScrollTop: document.body.scrollTop, - bodyScrollLeft: document.body.scrollLeft, - } - - // wrap tests in an element hidden from screen readers to prevent them - // from announcing focus, which can be quite irritating to the user - var iframe = document.createElement('iframe') - iframe.setAttribute( - 'style', - 'position:absolute; position:fixed; top:0; left:-2px; width:1px; height:1px; overflow:hidden;' - ) - iframe.setAttribute('aria-live', 'off') - iframe.setAttribute('aria-busy', 'true') - iframe.setAttribute('aria-hidden', 'true') - document.body.appendChild(iframe) - - var _window = iframe.contentWindow - var _document = _window.document - - _document.open() - _document.close() - var wrapper = _document.createElement('div') - _document.body.appendChild(wrapper) - - data.iframe = iframe - data.wrapper = wrapper - data.window = _window - data.document = _document - - return data -} - -// options.element: -// {string} element name -// {function} callback(wrapper, document) to generate an element -// options.mutate: (optional) -// {function} callback(element, wrapper, document) to manipulate element prior to focus-test. -// Can return DOMElement to define focus target (default: element) -// options.validate: (optional) -// {function} callback(element, focusTarget, document) to manipulate test-result -function test(data, options) { - // make sure we operate on a clean slate - data.wrapper.innerHTML = '' - // create dummy element to test focusability of - var element = - typeof options.element === 'string' - ? data.document.createElement(options.element) - : options.element(data.wrapper, data.document) - // allow callback to further specify dummy element - // and optionally define element to focus - var focus = - options.mutate && options.mutate(element, data.wrapper, data.document) - if (!focus && focus !== false) { - focus = element - } - // element needs to be part of the DOM to be focusable - !element.parentNode && data.wrapper.appendChild(element) - // test if the element with invalid tabindex can be focused - focus && focus.focus && focus.focus() - // validate test's result - return options.validate - ? options.validate(element, focus, data.document) - : data.document.activeElement === focus -} - -function after(data) { - // restore focus to what it was before test and cleanup - if (data.activeElement === document.body) { - document.activeElement && - document.activeElement.blur && - document.activeElement.blur() - if (platform.is.IE10) { - // IE10 does not redirect focus to when the activeElement is removed - document.body.focus() - } - } else { - data.activeElement && data.activeElement.focus && data.activeElement.focus() - } - - document.body.removeChild(data.iframe) - - // restore scroll position - window.scrollTop = data.windowScrollTop - window.scrollLeft = data.windowScrollLeft - document.body.scrollTop = data.bodyScrollTop - document.body.scrollLeft = data.bodyScrollLeft -} - -function detectFocus(tests) { - var data = before() - - var results = {} - Object.keys(tests).map(function (key) { - results[key] = test(data, tests[key]) - }) - - after(data) - return results -} - -// this file is overwritten by `npm run build:pre` -var version$1 = '1.4.1' - -/* - Facility to cache test results in localStorage. - - USAGE: - cache.get('key'); - cache.set('key', 'value'); - */ - -function readLocalStorage(key) { - // allow reading from storage to retrieve previous support results - // even while the document does not have focus - var data = void 0 - - try { - data = window.localStorage && window.localStorage.getItem(key) - data = data ? JSON.parse(data) : {} - } catch (e) { - data = {} - } - - return data -} - -function writeLocalStorage(key, value) { - if (!document.hasFocus()) { - // if the document does not have focus when tests are executed, focus() may - // not be handled properly and events may not be dispatched immediately. - // This can happen when a document is reloaded while Developer Tools have focus. - try { - window.localStorage && window.localStorage.removeItem(key) - } catch (e) { - // ignore - } - - return - } - - try { - window.localStorage && - window.localStorage.setItem(key, JSON.stringify(value)) - } catch (e) { - // ignore - } -} - -var userAgent = - (typeof window !== 'undefined' && window.navigator.userAgent) || '' -var cacheKey = 'ally-supports-cache' -var cache = readLocalStorage(cacheKey) - -// update the cache if ally or the user agent changed (newer version, etc) -if (cache.userAgent !== userAgent || cache.version !== version$1) { - cache = {} -} - -cache.userAgent = userAgent -cache.version = version$1 - -var cache$1 = { - get: function get() { - return cache - }, - set: function set(values) { - Object.keys(values).forEach(function (key) { - cache[key] = values[key] - }) - - cache.time = new Date().toISOString() - writeLocalStorage(cacheKey, cache) - }, -} - -function cssShadowPiercingDeepCombinator() { - var combinator = void 0 - - // see https://dev.w3.org/csswg/css-scoping-1/#deep-combinator - // https://bugzilla.mozilla.org/show_bug.cgi?id=1117572 - // https://code.google.com/p/chromium/issues/detail?id=446051 - try { - document.querySelector('html >>> :first-child') - combinator = '>>>' - } catch (noArrowArrowArrow) { - try { - // old syntax supported at least up to Chrome 41 - // https://code.google.com/p/chromium/issues/detail?id=446051 - document.querySelector('html /deep/ :first-child') - combinator = '/deep/' - } catch (noDeep) { - combinator = '' - } - } - - return combinator -} - -var gif = - 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' - -// https://developer.mozilla.org/docs/Web/HTML/Element/img#attr-usemap -var focusAreaImgTabindex = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = - '' + - '' + - '' - - return element.querySelector('area') - }, -} - -// https://developer.mozilla.org/docs/Web/HTML/Element/img#attr-usemap -var focusAreaTabindex = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = - '' + - '' + - '' - - return false - }, - validate: function validate(element, focusTarget, _document) { - if (platform.is.GECKO) { - // fixes https://github.com/medialize/ally.js/issues/35 - // Firefox loads the DataURI asynchronously, causing a false-negative - return true - } - - var focus = element.querySelector('area') - focus.focus() - return _document.activeElement === focus - }, -} - -// https://developer.mozilla.org/docs/Web/HTML/Element/img#attr-usemap -var focusAreaWithoutHref = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = - '' + - '' + - '' - - return element.querySelector('area') - }, - validate: function validate(element, focusTarget, _document) { - if (platform.is.GECKO) { - // fixes https://github.com/medialize/ally.js/issues/35 - // Firefox loads the DataURI asynchronously, causing a false-negative - return true - } - - return _document.activeElement === focusTarget - }, -} - -var focusAudioWithoutControls = { - name: 'can-focus-audio-without-controls', - element: 'audio', - mutate: function mutate(element) { - try { - // invalid media file can trigger warning in console, data-uri to prevent HTTP request - element.setAttribute('src', gif) - } catch (e) { - // IE9 may throw "Error: Not implemented" - } - }, -} - -var invalidGif = - 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' - -// NOTE: https://github.com/medialize/ally.js/issues/35 -// https://developer.mozilla.org/docs/Web/HTML/Element/img#attr-usemap -var focusBrokenImageMap = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = - '' + - '' - - return element.querySelector('area') - }, -} - -// Children of focusable elements with display:flex are focusable in IE10-11 -var focusChildrenOfFocusableFlexbox = { - element: 'div', - mutate: function mutate(element) { - element.setAttribute('tabindex', '-1') - element.setAttribute( - 'style', - 'display: -webkit-flex; display: -ms-flexbox; display: flex;' - ) - element.innerHTML = 'hello' - return element.querySelector('span') - }, -} - -// fieldset[tabindex=0][disabled] should not be focusable, but Blink and WebKit disagree -// @specification https://www.w3.org/TR/html5/disabled-elements.html#concept-element-disabled -// @browser-issue Chromium https://crbug.com/453847 -// @browser-issue WebKit https://bugs.webkit.org/show_bug.cgi?id=141086 -var focusFieldsetDisabled = { - element: 'fieldset', - mutate: function mutate(element) { - element.setAttribute('tabindex', 0) - element.setAttribute('disabled', 'disabled') - }, -} - -var focusFieldset = { - element: 'fieldset', - mutate: function mutate(element) { - element.innerHTML = 'legend

content

' - }, -} - -// elements with display:flex are focusable in IE10-11 -var focusFlexboxContainer = { - element: 'span', - mutate: function mutate(element) { - element.setAttribute( - 'style', - 'display: -webkit-flex; display: -ms-flexbox; display: flex;' - ) - element.innerHTML = 'hello' - }, -} - -// form[tabindex=0][disabled] should be focusable as the -// specification doesn't know the disabled attribute on the form element -// @specification https://www.w3.org/TR/html5/forms.html#the-form-element -var focusFormDisabled = { - element: 'form', - mutate: function mutate(element) { - element.setAttribute('tabindex', 0) - element.setAttribute('disabled', 'disabled') - }, -} - -// NOTE: https://github.com/medialize/ally.js/issues/35 -// fixes https://github.com/medialize/ally.js/issues/20 -// https://developer.mozilla.org/docs/Web/HTML/Element/img#attr-ismap -var focusImgIsmap = { - element: 'a', - mutate: function mutate(element) { - element.href = '#void' - element.innerHTML = '' - return element.querySelector('img') - }, -} - -// NOTE: https://github.com/medialize/ally.js/issues/35 -// https://developer.mozilla.org/docs/Web/HTML/Element/img#attr-usemap -var focusImgUsemapTabindex = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = - '' + - '' - - return element.querySelector('img') - }, -} - -var focusInHiddenIframe = { - element: function element(wrapper, _document) { - var iframe = _document.createElement('iframe') - - // iframe must be part of the DOM before accessing the contentWindow is possible - wrapper.appendChild(iframe) - - // create the iframe's default document () - var iframeDocument = iframe.contentWindow.document - iframeDocument.open() - iframeDocument.close() - return iframe - }, - mutate: function mutate(iframe) { - iframe.style.visibility = 'hidden' - - var iframeDocument = iframe.contentWindow.document - var input = iframeDocument.createElement('input') - iframeDocument.body.appendChild(input) - return input - }, - validate: function validate(iframe) { - var iframeDocument = iframe.contentWindow.document - var focus = iframeDocument.querySelector('input') - return iframeDocument.activeElement === focus - }, -} - -var result = !platform.is.WEBKIT - -function focusInZeroDimensionObject() { - return result -} - -// Firefox allows *any* value and treats invalid values like tabindex="-1" -// @browser-issue Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054 -var focusInvalidTabindex = { - element: 'div', - mutate: function mutate(element) { - element.setAttribute('tabindex', 'invalid-value') - }, -} - -var focusLabelTabindex = { - element: 'label', - mutate: function mutate(element) { - element.setAttribute('tabindex', '-1') - }, - validate: function validate(element, focusTarget, _document) { - // force layout in Chrome 49, otherwise the element won't be focusable - /* eslint-disable no-unused-vars */ - var variableToPreventDeadCodeElimination = element.offsetHeight - /* eslint-enable no-unused-vars */ - element.focus() - return _document.activeElement === element - }, -} - -var svg = - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtb' + - 'G5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBpZD0ic3ZnIj48dGV4dCB4PSIxMCIgeT0iMjAiIGlkPSJ' + - 'zdmctbGluay10ZXh0Ij50ZXh0PC90ZXh0Pjwvc3ZnPg==' - -// Note: IE10 on BrowserStack does not like this test - -var focusObjectSvgHidden = { - element: 'object', - mutate: function mutate(element) { - element.setAttribute('type', 'image/svg+xml') - element.setAttribute('data', svg) - element.setAttribute('width', '200') - element.setAttribute('height', '50') - element.style.visibility = 'hidden' - }, -} - -// Note: IE10 on BrowserStack does not like this test - -var focusObjectSvg = { - name: 'can-focus-object-svg', - element: 'object', - mutate: function mutate(element) { - element.setAttribute('type', 'image/svg+xml') - element.setAttribute('data', svg) - element.setAttribute('width', '200') - element.setAttribute('height', '50') - }, - validate: function validate(element, focusTarget, _document) { - if (platform.is.GECKO) { - // Firefox seems to be handling the object creation asynchronously and thereby produces a false negative test result. - // Because we know Firefox is able to focus object elements referencing SVGs, we simply cheat by sniffing the user agent string - return true - } - - return _document.activeElement === element - }, -} - -// Every Environment except IE9 considers SWF objects focusable -var result$1 = !platform.is.IE9 - -function focusObjectSwf() { - return result$1 -} - -var focusRedirectImgUsemap = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = - '' + - '' - - // focus the , not the
- return element.querySelector('img') - }, - validate: function validate(element, focusTarget, _document) { - var target = element.querySelector('area') - return _document.activeElement === target - }, -} - -// see https://jsbin.com/nenirisage/edit?html,js,console,output - -var focusRedirectLegend = { - element: 'fieldset', - mutate: function mutate(element) { - element.innerHTML = - 'legend' - // take care of focus in validate(); - return false - }, - validate: function validate(element, focusTarget, _document) { - var focusable = element.querySelector('input[tabindex="-1"]') - var tabbable = element.querySelector('input[tabindex="0"]') - - // Firefox requires this test to focus the
first, while this is not necessary in - // https://jsbin.com/nenirisage/edit?html,js,console,output - element.focus() - - element.querySelector('legend').focus() - return ( - (_document.activeElement === focusable && 'focusable') || - (_document.activeElement === tabbable && 'tabbable') || - '' - ) - }, -} - -// https://github.com/medialize/ally.js/issues/21 -var focusScrollBody = { - element: 'div', - mutate: function mutate(element) { - element.setAttribute('style', 'width: 100px; height: 50px; overflow: auto;') - element.innerHTML = - '
scrollable content
' - return element.querySelector('div') - }, -} - -// https://github.com/medialize/ally.js/issues/21 -var focusScrollContainerWithoutOverflow = { - element: 'div', - mutate: function mutate(element) { - element.setAttribute('style', 'width: 100px; height: 50px;') - element.innerHTML = - '
scrollable content
' - }, -} - -// https://github.com/medialize/ally.js/issues/21 -var focusScrollContainer = { - element: 'div', - mutate: function mutate(element) { - element.setAttribute('style', 'width: 100px; height: 50px; overflow: auto;') - element.innerHTML = - '
scrollable content
' - }, -} - -var focusSummary = { - element: 'details', - mutate: function mutate(element) { - element.innerHTML = 'foo

content

' - return element.firstElementChild - }, -} - -function makeFocusableForeignObject() { - // Constructs - // without raising a Trusted Types violation - var foreignObject = document.createElementNS( - 'http://www.w3.org/2000/svg', - 'foreignObject' - ) - foreignObject.width.baseVal.value = 30 - foreignObject.height.baseVal.value = 30 - foreignObject.appendChild(document.createElement('input')) - foreignObject.lastChild.type = 'text' - - return foreignObject -} - -function focusSvgForeignObjectHack(element) { - // Edge13, Edge14: foreignObject focus hack - // https://jsbin.com/kunehinugi/edit?html,js,output - // https://jsbin.com/fajagi/3/edit?html,js,output - var isSvgElement = - element.ownerSVGElement || element.nodeName.toLowerCase() === 'svg' - if (!isSvgElement) { - return false - } - - // inject and focus an element into the SVG element to receive focus - var foreignObject = makeFocusableForeignObject() - element.appendChild(foreignObject) - var input = foreignObject.querySelector('input') - input.focus() - - // upon disabling the activeElement, IE and Edge - // will not shift focus to like all the other - // browsers, but instead find the first focusable - // ancestor and shift focus to that - input.disabled = true - - // clean up - element.removeChild(foreignObject) - return true -} - -function generate(element) { - return ( - '' + - element + - '' - ) -} - -function focus(element) { - if (element.focus) { - return - } - - try { - HTMLElement.prototype.focus.call(element) - } catch (e) { - focusSvgForeignObjectHack(element) - } -} - -function validate(element, focusTarget, _document) { - focus(focusTarget) - return _document.activeElement === focusTarget -} - -var focusSvgFocusableAttribute = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = generate('a') - return element.querySelector('text') - }, - validate: validate, -} - -var focusSvgTabindexAttribute = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = generate('a') - return element.querySelector('text') - }, - validate: validate, -} - -var focusSvgNegativeTabindexAttribute = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = generate('a') - return element.querySelector('text') - }, - validate: validate, -} - -var focusSvgUseTabindex = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = generate( - [ - 'link', - '', - ].join('') - ) - - return element.querySelector('use') - }, - validate: validate, -} - -var focusSvgForeignobjectTabindex = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = generate( - '' - ) - // Safari 8's querySelector() can't identify foreignObject, but getElementsByTagName() can - return ( - element.querySelector('foreignObject') || - element.getElementsByTagName('foreignObject')[0] - ) - }, - validate: validate, -} - -// Firefox seems to be handling the SVG-document-in-iframe creation asynchronously -// and thereby produces a false negative test result. Thus the test is pointless -// and we resort to UA sniffing once again. -// see http://jsbin.com/vunadohoko/1/edit?js,console,output - -var result$2 = Boolean( - platform.is.GECKO && - typeof SVGElement !== 'undefined' && - SVGElement.prototype.focus -) - -function focusSvgInIframe() { - return result$2 -} - -var focusSvg = { - element: 'div', - mutate: function mutate(element) { - element.innerHTML = generate('') - return element.firstChild - }, - validate: validate, -} - -// Firefox allows *any* value and treats invalid values like tabindex="-1" -// @browser-issue Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054 -var focusTabindexTrailingCharacters = { - element: 'div', - mutate: function mutate(element) { - element.setAttribute('tabindex', '3x') - }, -} - -var focusTable = { - element: 'table', - mutate: function mutate(element, wrapper, _document) { - // IE9 has a problem replacing TBODY contents with innerHTML. - // https://stackoverflow.com/a/8097055/515124 - // element.innerHTML = 'cell'; - var fragment = _document.createDocumentFragment() - fragment.innerHTML = 'cell' - element.appendChild(fragment) - }, -} - -var focusVideoWithoutControls = { - element: 'video', - mutate: function mutate(element) { - try { - // invalid media file can trigger warning in console, data-uri to prevent HTTP request - element.setAttribute('src', gif) - } catch (e) { - // IE9 may throw "Error: Not implemented" - } - }, -} - -// https://jsbin.com/vafaba/3/edit?html,js,console,output -var result$3 = platform.is.GECKO || platform.is.TRIDENT || platform.is.EDGE - -function tabsequenceAreaAtImgPosition() { - return result$3 -} - -var testCallbacks = { - cssShadowPiercingDeepCombinator: cssShadowPiercingDeepCombinator, - focusInZeroDimensionObject: focusInZeroDimensionObject, - focusObjectSwf: focusObjectSwf, - focusSvgInIframe: focusSvgInIframe, - tabsequenceAreaAtImgPosition: tabsequenceAreaAtImgPosition, -} - -var testDescriptions = { - focusAreaImgTabindex: focusAreaImgTabindex, - focusAreaTabindex: focusAreaTabindex, - focusAreaWithoutHref: focusAreaWithoutHref, - focusAudioWithoutControls: focusAudioWithoutControls, - focusBrokenImageMap: focusBrokenImageMap, - focusChildrenOfFocusableFlexbox: focusChildrenOfFocusableFlexbox, - focusFieldsetDisabled: focusFieldsetDisabled, - focusFieldset: focusFieldset, - focusFlexboxContainer: focusFlexboxContainer, - focusFormDisabled: focusFormDisabled, - focusImgIsmap: focusImgIsmap, - focusImgUsemapTabindex: focusImgUsemapTabindex, - focusInHiddenIframe: focusInHiddenIframe, - focusInvalidTabindex: focusInvalidTabindex, - focusLabelTabindex: focusLabelTabindex, - focusObjectSvg: focusObjectSvg, - focusObjectSvgHidden: focusObjectSvgHidden, - focusRedirectImgUsemap: focusRedirectImgUsemap, - focusRedirectLegend: focusRedirectLegend, - focusScrollBody: focusScrollBody, - focusScrollContainerWithoutOverflow: focusScrollContainerWithoutOverflow, - focusScrollContainer: focusScrollContainer, - focusSummary: focusSummary, - focusSvgFocusableAttribute: focusSvgFocusableAttribute, - focusSvgTabindexAttribute: focusSvgTabindexAttribute, - focusSvgNegativeTabindexAttribute: focusSvgNegativeTabindexAttribute, - focusSvgUseTabindex: focusSvgUseTabindex, - focusSvgForeignobjectTabindex: focusSvgForeignobjectTabindex, - focusSvg: focusSvg, - focusTabindexTrailingCharacters: focusTabindexTrailingCharacters, - focusTable: focusTable, - focusVideoWithoutControls: focusVideoWithoutControls, -} - -function executeTests() { - var results = detectFocus(testDescriptions) - Object.keys(testCallbacks).forEach(function (key) { - results[key] = testCallbacks[key]() - }) - - return results -} - -var supportsCache = null - -function _supports() { - if (supportsCache) { - return supportsCache - } - - supportsCache = cache$1.get() - if (!supportsCache.time) { - cache$1.set(executeTests()) - supportsCache = cache$1.get() - } - - return supportsCache -} - -var supports = void 0 - -// https://www.w3.org/TR/html5/infrastructure.html#rules-for-parsing-integers -// NOTE: all browsers agree to allow trailing spaces as well -var validIntegerPatternNoTrailing = /^\s*(-|\+)?[0-9]+\s*$/ -var validIntegerPatternWithTrailing = /^\s*(-|\+)?[0-9]+.*$/ - -function isValidTabindex(context) { - if (!supports) { - supports = _supports() - } - - var validIntegerPattern = supports.focusTabindexTrailingCharacters - ? validIntegerPatternWithTrailing - : validIntegerPatternNoTrailing - - var element = contextToElement({ - label: 'is/valid-tabindex', - resolveDocument: true, - context: context, - }) - - // Edge 14 has a capitalization problem on SVG elements, - // see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9282058/ - var hasTabindex = element.hasAttribute('tabindex') - var hasTabIndex = element.hasAttribute('tabIndex') - - if (!hasTabindex && !hasTabIndex) { - return false - } - - // older Firefox and Internet Explorer don't support tabindex on SVG elements - var isSvgElement = - element.ownerSVGElement || element.nodeName.toLowerCase() === 'svg' - if (isSvgElement && !supports.focusSvgTabindexAttribute) { - return false - } - - // @browser-issue Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054 - if (supports.focusInvalidTabindex) { - return true - } - - // an element matches the tabindex selector even if its value is invalid - var tabindex = element.getAttribute(hasTabindex ? 'tabindex' : 'tabIndex') - // IE11 parses tabindex="" as the value "-32768" - // @browser-issue Trident https://connect.microsoft.com/IE/feedback/details/1072965 - if (tabindex === '-32768') { - return false - } - - return Boolean(tabindex && validIntegerPattern.test(tabindex)) -} - -function tabindexValue(element) { - if (!isValidTabindex(element)) { - return null - } - - // Edge 14 has a capitalization problem on SVG elements, - // see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9282058/ - var hasTabindex = element.hasAttribute('tabindex') - var attributeName = hasTabindex ? 'tabindex' : 'tabIndex' - - // @browser-issue Gecko https://bugzilla.mozilla.org/show_bug.cgi?id=1128054 - var tabindex = parseInt(element.getAttribute(attributeName), 10) - return isNaN(tabindex) ? -1 : tabindex -} - -// this is a shared utility file for focus-relevant.js and tabbable.js -// separate testing of this file's functions is not necessary, -// as they're implicitly tested by way of the consumers - -function isUserModifyWritable(style) { - // https://www.w3.org/TR/1999/WD-css3-userint-19990916#user-modify - // https://github.com/medialize/ally.js/issues/17 - var userModify = style.webkitUserModify || '' - return Boolean(userModify && userModify.indexOf('write') !== -1) -} - -function hasCssOverflowScroll(style) { - return [ - style.getPropertyValue('overflow'), - style.getPropertyValue('overflow-x'), - style.getPropertyValue('overflow-y'), - ].some(function (overflow) { - return overflow === 'auto' || overflow === 'scroll' - }) -} - -function hasCssDisplayFlex(style) { - return style.display.indexOf('flex') > -1 -} - -function isScrollableContainer(element, nodeName, parentNodeName, parentStyle) { - if (nodeName !== 'div' && nodeName !== 'span') { - // Internet Explorer advances scrollable containers and bodies to focusable - // only if the scrollable container is
or - this does *not* - // happen for
,
, … - return false - } - - if ( - parentNodeName && - parentNodeName !== 'div' && - parentNodeName !== 'span' && - !hasCssOverflowScroll(parentStyle) - ) { - return false - } - - return ( - element.offsetHeight < element.scrollHeight || - element.offsetWidth < element.scrollWidth - ) -} - -var supports$1 = void 0 - -function isFocusRelevantRules() { - var _ref = - arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - context = _ref.context, - _ref$except = _ref.except, - except = - _ref$except === undefined - ? { - flexbox: false, - scrollable: false, - shadow: false, - } - : _ref$except - - if (!supports$1) { - supports$1 = _supports() - } - - var element = contextToElement({ - label: 'is/focus-relevant', - resolveDocument: true, - context: context, - }) - - if (!except.shadow && element.shadowRoot) { - // a ShadowDOM host receives focus when the focus moves to its content - return true - } - - var nodeName = element.nodeName.toLowerCase() - - if (nodeName === 'input' && element.type === 'hidden') { - // input[type="hidden"] supports.cannot be focused - return false - } - - if ( - nodeName === 'input' || - nodeName === 'select' || - nodeName === 'button' || - nodeName === 'textarea' - ) { - return true - } - - if (nodeName === 'legend' && supports$1.focusRedirectLegend) { - // specifics filtered in is/focusable - return true - } - - if (nodeName === 'label') { - // specifics filtered in is/focusable - return true - } - - if (nodeName === 'area') { - // specifics filtered in is/focusable - return true - } - - if (nodeName === 'a' && element.hasAttribute('href')) { - return true - } - - if (nodeName === 'object' && element.hasAttribute('usemap')) { - // object[usemap] is not focusable in any browser - return false - } - - if (nodeName === 'object') { - var svgType = element.getAttribute('type') - if (!supports$1.focusObjectSvg && svgType === 'image/svg+xml') { - // object[type="image/svg+xml"] is not focusable in Internet Explorer - return false - } else if ( - !supports$1.focusObjectSwf && - svgType === 'application/x-shockwave-flash' - ) { - // object[type="application/x-shockwave-flash"] is not focusable in Internet Explorer 9 - return false - } - } - - if (nodeName === 'iframe' || nodeName === 'object') { - // browsing context containers - return true - } - - if (nodeName === 'embed' || nodeName === 'keygen') { - // embed is considered focus-relevant but not focusable - // see https://github.com/medialize/ally.js/issues/82 - return true - } - - if (element.hasAttribute('contenteditable')) { - // also see CSS property user-modify below - return true - } - - if ( - nodeName === 'audio' && - (supports$1.focusAudioWithoutControls || element.hasAttribute('controls')) - ) { - return true - } - - if ( - nodeName === 'video' && - (supports$1.focusVideoWithoutControls || element.hasAttribute('controls')) - ) { - return true - } - - if (supports$1.focusSummary && nodeName === 'summary') { - return true - } - - var validTabindex = isValidTabindex(element) - - if (nodeName === 'img' && element.hasAttribute('usemap')) { - // Gecko, Trident and Edge do not allow an image with an image map and tabindex to be focused, - // it appears the tabindex is overruled so focus is still forwarded to the - return ( - (validTabindex && supports$1.focusImgUsemapTabindex) || - supports$1.focusRedirectImgUsemap - ) - } - - if (supports$1.focusTable && (nodeName === 'table' || nodeName === 'td')) { - // IE10-11 supports.can focus and
- return true - } - - if (supports$1.focusFieldset && nodeName === 'fieldset') { - // IE10-11 supports.can focus
- return true - } - - var isSvgElement = nodeName === 'svg' - var isSvgContent = element.ownerSVGElement - var focusableAttribute = element.getAttribute('focusable') - var tabindex = tabindexValue(element) - - if ( - nodeName === 'use' && - tabindex !== null && - !supports$1.focusSvgUseTabindex - ) { - // cannot be made focusable by adding a tabindex attribute anywhere but Blink and WebKit - return false - } - - if (nodeName === 'foreignobject') { - // can only be made focusable in Blink and WebKit - return tabindex !== null && supports$1.focusSvgForeignobjectTabindex - } - - if (elementMatches(element, 'svg a') && element.hasAttribute('xlink:href')) { - return true - } - - if ( - (isSvgElement || isSvgContent) && - element.focus && - !supports$1.focusSvgNegativeTabindexAttribute && - tabindex < 0 - ) { - // Firefox 51 and 52 treat any natively tabbable SVG element with - // tabindex="-1" as tabbable and everything else as inert - // see https://bugzilla.mozilla.org/show_bug.cgi?id=1302340 - return false - } - - if (isSvgElement) { - return ( - validTabindex || - supports$1.focusSvg || - supports$1.focusSvgInIframe || - // Internet Explorer understands the focusable attribute introduced in SVG Tiny 1.2 - Boolean( - supports$1.focusSvgFocusableAttribute && - focusableAttribute && - focusableAttribute === 'true' - ) - ) - } - - if (isSvgContent) { - if (supports$1.focusSvgTabindexAttribute && validTabindex) { - return true - } - - if (supports$1.focusSvgFocusableAttribute) { - // Internet Explorer understands the focusable attribute introduced in SVG Tiny 1.2 - return focusableAttribute === 'true' - } - } - - // https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute - if (validTabindex) { - return true - } - - var style = window.getComputedStyle(element, null) - if (isUserModifyWritable(style)) { - return true - } - - if ( - supports$1.focusImgIsmap && - nodeName === 'img' && - element.hasAttribute('ismap') - ) { - // IE10-11 considers the in focusable - // https://github.com/medialize/ally.js/issues/20 - var hasLinkParent = getParents({ context: element }).some(function ( - parent - ) { - return ( - parent.nodeName.toLowerCase() === 'a' && parent.hasAttribute('href') - ) - }) - - if (hasLinkParent) { - return true - } - } - - // https://github.com/medialize/ally.js/issues/21 - if (!except.scrollable && supports$1.focusScrollContainer) { - if (supports$1.focusScrollContainerWithoutOverflow) { - // Internet Explorer does will consider the scrollable area focusable - // if the element is a
or a and it is in fact scrollable, - // regardless of the CSS overflow property - if (isScrollableContainer(element, nodeName)) { - return true - } - } else if (hasCssOverflowScroll(style)) { - // Firefox requires proper overflow setting, IE does not necessarily - // https://developer.mozilla.org/docs/Web/CSS/overflow - return true - } - } - - if ( - !except.flexbox && - supports$1.focusFlexboxContainer && - hasCssDisplayFlex(style) - ) { - // elements with display:flex are focusable in IE10-11 - return true - } - - var parent = element.parentElement - if (!except.scrollable && parent) { - var parentNodeName = parent.nodeName.toLowerCase() - var parentStyle = window.getComputedStyle(parent, null) - if ( - supports$1.focusScrollBody && - isScrollableContainer(parent, nodeName, parentNodeName, parentStyle) - ) { - // scrollable bodies are focusable Internet Explorer - // https://github.com/medialize/ally.js/issues/21 - return true - } - - // Children of focusable elements with display:flex are focusable in IE10-11 - if (supports$1.focusChildrenOfFocusableFlexbox) { - if (hasCssDisplayFlex(parentStyle)) { - return true - } - } - } - - // NOTE: elements marked as inert are not focusable, - // but that property is not exposed to the DOM - // https://www.w3.org/TR/html5/editing.html#inert - - return false -} - -// bind exceptions to an iterator callback -isFocusRelevantRules.except = function () { - var except = - arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {} - - var isFocusRelevant = function isFocusRelevant(context) { - return isFocusRelevantRules({ - context: context, - except: except, - }) - } - - isFocusRelevant.rules = isFocusRelevantRules - return isFocusRelevant -} - -// provide isFocusRelevant(context) as default iterator callback -var isFocusRelevant = isFocusRelevantRules.except({}) - -function findIndex(array, callback) { - // attempt to use native or polyfilled Array#findIndex first - if (array.findIndex) { - return array.findIndex(callback) - } - - var length = array.length - - // shortcut if the array is empty - if (length === 0) { - return -1 - } - - // otherwise loop over array - for (var i = 0; i < length; i++) { - if (callback(array[i], i, array)) { - return i - } - } - - return -1 -} - -function getContentDocument(node) { - try { - // works on and