Unverified Commit e3df5909 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Handle error overlay for new router (#41325)

parent 2060d0e3
......@@ -15,7 +15,7 @@ import {
onBuildOk,
onRefresh,
ReactDevOverlay,
} from 'next/dist/compiled/@next/react-dev-overlay/dist/client'
} from './react-dev-overlay/src/client'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import formatWebpackMessages from '../dev/error-overlay/format-webpack-messages'
import { useRouter } from './hooks-client'
......
import * as Bus from './internal/bus'
import { parseStack } from './internal/helpers/parseStack'
let isRegistered = false
let stackTraceLimit: number | undefined = undefined
function onUnhandledError(ev: ErrorEvent) {
const error = ev?.error
if (!error || !(error instanceof Error) || typeof error.stack !== 'string') {
// A non-error was thrown, we don't have anything to show. :-(
return
}
if (
error.message.match(/(hydration|content does not match|did not match)/i)
) {
error.message += `\n\nSee more info here: https://nextjs.org/docs/messages/react-hydration-error`
}
const e = error
Bus.emit({
type: Bus.TYPE_UNHANDLED_ERROR,
reason: error,
frames: parseStack(e.stack!),
})
}
function onUnhandledRejection(ev: PromiseRejectionEvent) {
const reason = ev?.reason
if (
!reason ||
!(reason instanceof Error) ||
typeof reason.stack !== 'string'
) {
// A non-error was thrown, we don't have anything to show. :-(
return
}
const e = reason
Bus.emit({
type: Bus.TYPE_UNHANDLED_REJECTION,
reason: reason,
frames: parseStack(e.stack!),
})
}
function register() {
if (isRegistered) {
return
}
isRegistered = true
try {
const limit = Error.stackTraceLimit
Error.stackTraceLimit = 50
stackTraceLimit = limit
} catch {}
window.addEventListener('error', onUnhandledError)
window.addEventListener('unhandledrejection', onUnhandledRejection)
}
function unregister() {
if (!isRegistered) {
return
}
isRegistered = false
if (stackTraceLimit !== undefined) {
try {
Error.stackTraceLimit = stackTraceLimit
} catch {}
stackTraceLimit = undefined
}
window.removeEventListener('error', onUnhandledError)
window.removeEventListener('unhandledrejection', onUnhandledRejection)
}
function onBuildOk() {
Bus.emit({ type: Bus.TYPE_BUILD_OK })
}
function onBuildError(message: string) {
Bus.emit({ type: Bus.TYPE_BUILD_ERROR, message })
}
function onRefresh() {
Bus.emit({ type: Bus.TYPE_REFRESH })
}
export { getErrorByType } from './internal/helpers/getErrorByType'
export { getServerError } from './internal/helpers/nodeStackFrames'
export { default as ReactDevOverlay } from './internal/ReactDevOverlay'
export { onBuildOk, onBuildError, register, unregister, onRefresh }
import React from 'react'
type ErrorBoundaryProps = {
onError: (error: Error, componentStack: string | null) => void
globalOverlay?: boolean
isMounted?: boolean
}
type ErrorBoundaryState = { error: Error | null }
class ErrorBoundary extends React.PureComponent<
ErrorBoundaryProps,
ErrorBoundaryState
> {
state = { error: null }
static getDerivedStateFromError(error: Error) {
return { error }
}
componentDidCatch(
error: Error,
// Loosely typed because it depends on the React version and was
// accidentally excluded in some versions.
errorInfo?: { componentStack?: string | null }
) {
this.props.onError(error, errorInfo?.componentStack || null)
if (!this.props.globalOverlay) {
this.setState({ error })
}
}
render() {
// The component has to be unmounted or else it would continue to error
return this.state.error ||
(this.props.globalOverlay && this.props.isMounted) ? (
// When the overlay is global for the application and it wraps a component rendering `<html>`
// we have to render the html shell otherwise the shadow root will not be able to attach
this.props.globalOverlay ? (
<html>
<head></head>
<body></body>
</html>
) : null
) : (
this.props.children
)
}
}
export { ErrorBoundary }
import * as React from 'react'
import * as Bus from './bus'
import { ShadowPortal } from './components/ShadowPortal'
import { BuildError } from './container/BuildError'
import { Errors, SupportedErrorEvent } from './container/Errors'
import { ErrorBoundary } from './ErrorBoundary'
import { Base } from './styles/Base'
import { ComponentStyles } from './styles/ComponentStyles'
import { CssReset } from './styles/CssReset'
type OverlayState = {
nextId: number
buildError: string | null
errors: SupportedErrorEvent[]
}
function reducer(state: OverlayState, ev: Bus.BusEvent): OverlayState {
switch (ev.type) {
case Bus.TYPE_BUILD_OK: {
return { ...state, buildError: null }
}
case Bus.TYPE_BUILD_ERROR: {
return { ...state, buildError: ev.message }
}
case Bus.TYPE_REFRESH: {
return { ...state, buildError: null, errors: [] }
}
case Bus.TYPE_UNHANDLED_ERROR:
case Bus.TYPE_UNHANDLED_REJECTION: {
return {
...state,
nextId: state.nextId + 1,
errors: [
...state.errors.filter((err) => {
// Filter out duplicate errors
return err.event.reason !== ev.reason
}),
{ id: state.nextId, event: ev },
],
}
}
default: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _: never = ev
return state
}
}
}
type ErrorType = 'runtime' | 'build'
const shouldPreventDisplay = (
errorType?: ErrorType | null,
preventType?: ErrorType[] | null
) => {
if (!preventType || !errorType) {
return false
}
return preventType.includes(errorType)
}
type ReactDevOverlayProps = {
children?: React.ReactNode
preventDisplay?: ErrorType[]
globalOverlay?: boolean
}
const ReactDevOverlay: React.FunctionComponent<ReactDevOverlayProps> =
function ReactDevOverlay({ children, preventDisplay, globalOverlay }) {
const [state, dispatch] = React.useReducer<
React.Reducer<OverlayState, Bus.BusEvent>
>(reducer, {
nextId: 1,
buildError: null,
errors: [],
})
React.useEffect(() => {
Bus.on(dispatch)
return function () {
Bus.off(dispatch)
}
}, [dispatch])
const onComponentError = React.useCallback(
(_error: Error, _componentStack: string | null) => {
// TODO: special handling
},
[]
)
const hasBuildError = state.buildError != null
const hasRuntimeErrors = Boolean(state.errors.length)
const isMounted = hasBuildError || hasRuntimeErrors
return (
<React.Fragment>
<ErrorBoundary
globalOverlay={globalOverlay}
isMounted={isMounted}
onError={onComponentError}
>
{children ?? null}
</ErrorBoundary>
{isMounted ? (
<ShadowPortal globalOverlay={globalOverlay}>
<CssReset />
<Base />
<ComponentStyles />
{shouldPreventDisplay(
hasBuildError ? 'build' : hasRuntimeErrors ? 'runtime' : null,
preventDisplay
) ? null : hasBuildError ? (
<BuildError message={state.buildError!} />
) : hasRuntimeErrors ? (
<Errors errors={state.errors} />
) : undefined}
</ShadowPortal>
) : undefined}
</React.Fragment>
)
}
export default ReactDevOverlay
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'
export const TYPE_BUILD_OK = 'build-ok'
export const TYPE_BUILD_ERROR = 'build-error'
export const TYPE_REFRESH = 'fast-refresh'
export const TYPE_UNHANDLED_ERROR = 'unhandled-error'
export const TYPE_UNHANDLED_REJECTION = 'unhandled-rejection'
export type BuildOk = { type: typeof TYPE_BUILD_OK }
export type BuildError = {
type: typeof TYPE_BUILD_ERROR
message: string
}
export type FastRefresh = { type: typeof TYPE_REFRESH }
export type UnhandledError = {
type: typeof TYPE_UNHANDLED_ERROR
reason: Error
frames: StackFrame[]
}
export type UnhandledRejection = {
type: typeof TYPE_UNHANDLED_REJECTION
reason: Error
frames: StackFrame[]
}
export type BusEvent =
| BuildOk
| BuildError
| FastRefresh
| UnhandledError
| UnhandledRejection
export type BusEventHandler = (ev: BusEvent) => void
let handlers: Set<BusEventHandler> = new Set()
let queue: BusEvent[] = []
function drain() {
// Draining should never happen synchronously in case multiple handlers are
// registered.
setTimeout(function () {
while (
// Until we are out of events:
Boolean(queue.length) &&
// Or, if all handlers removed themselves as a result of handling the
// event(s)
Boolean(handlers.size)
) {
const ev = queue.shift()!
handlers.forEach((handler) => handler(ev))
}
}, 1)
}
export function emit(ev: BusEvent): void {
queue.push(Object.freeze({ ...ev }))
drain()
}
export function on(fn: BusEventHandler): boolean {
if (handlers.has(fn)) {
return false
}
handlers.add(fn)
drain()
return true
}
export function off(fn: BusEventHandler): boolean {
if (handlers.has(fn)) {
handlers.delete(fn)
return true
}
return false
}
import Anser from 'next/dist/compiled/anser'
import * as React from 'react'
import { StackFrame } from 'next/dist/compiled/stacktrace-parser'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import { getFrameSource } from '../../helpers/stack-frame'
export type CodeFrameProps = { stackFrame: StackFrame; codeFrame: string }
export const CodeFrame: React.FC<CodeFrameProps> = function CodeFrame({
stackFrame,
codeFrame,
}) {
// Strip leading spaces out of the code frame:
const formattedFrame = React.useMemo<string>(() => {
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 (
<div data-nextjs-codeframe>
<div>
<p
role="link"
onClick={open}
tabIndex={1}
title="Click to open in your editor"
>
<span>
{getFrameSource(stackFrame)} @ {stackFrame.methodName}
</span>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
<polyline points="15 3 21 3 21 9"></polyline>
<line x1="10" y1="14" x2="21" y2="3"></line>
</svg>
</p>
</div>
<pre>
{decoded.map((entry, index) => (
<span
key={`frame-${index}`}
style={{
color: entry.fg ? `var(--color-${entry.fg})` : undefined,
...(entry.decoration === 'bold'
? { fontWeight: 800 }
: entry.decoration === 'italic'
? { fontStyle: 'italic' }
: undefined),
}}
>
{entry.content}
</span>
))}
</pre>
</div>
)
}
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 }
import * as React from 'react'
import { useOnClickOutside } from '../../hooks/use-on-click-outside'
export type DialogProps = {
type: 'error' | 'warning'
'aria-labelledby': string
'aria-describedby': string
onClose?: (e: MouseEvent | TouchEvent) => void
}
const Dialog: React.FC<DialogProps> = function Dialog({
children,
type,
onClose,
...props
}) {
const [dialog, setDialog] = React.useState<HTMLDivElement | null>(null)
const onDialog = React.useCallback((node) => {
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()
}
}
shadowRoot.addEventListener('keydown', handler as EventListener)
return () =>
shadowRoot.removeEventListener('keydown', handler as EventListener)
}, [dialog])
return (
<div
ref={onDialog}
data-nextjs-dialog
tabIndex={-1}
role="dialog"
aria-labelledby={props['aria-labelledby']}
aria-describedby={props['aria-describedby']}
aria-modal="true"
>
<div data-nextjs-dialog-banner className={`banner-${type}`} />
{children}
</div>
)
}
export { Dialog }
import * as React from 'react'
export type DialogBodyProps = {
className?: string
}
const DialogBody: React.FC<DialogBodyProps> = function DialogBody({
children,
className,
}) {
return (
<div data-nextjs-dialog-body className={className}>
{children}
</div>
)
}
export { DialogBody }
import * as React from 'react'
export type DialogContentProps = {
className?: string
}
const DialogContent: React.FC<DialogContentProps> = function DialogContent({
children,
className,
}) {
return (
<div data-nextjs-dialog-content className={className}>
{children}
</div>
)
}
export { DialogContent }
import * as React from 'react'
export type DialogHeaderProps = {
className?: string
}
const DialogHeader: React.FC<DialogHeaderProps> = function DialogHeader({
children,
className,
}) {
return (
<div data-nextjs-dialog-header className={className}>
{children}
</div>
)
}
export { DialogHeader }
export { Dialog } from './Dialog'
export { DialogBody } from './DialogBody'
export { DialogContent } from './DialogContent'
export { DialogHeader } from './DialogHeader'
export { styles } from './styles'
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: white;
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 }
import * as React from 'react'
import { CloseIcon } from '../../icons/CloseIcon'
export type LeftRightDialogHeaderProps = {
className?: string
previous: (() => void) | null
next: (() => void) | null
close?: () => void
}
const LeftRightDialogHeader: React.FC<LeftRightDialogHeaderProps> =
function LeftRightDialogHeader({
children,
className,
previous,
next,
close,
}) {
const buttonLeft = React.useRef<HTMLButtonElement | null>(null)
const buttonRight = React.useRef<HTMLButtonElement | null>(null)
const buttonClose = React.useRef<HTMLButtonElement | null>(null)
const [nav, setNav] = React.useState<HTMLElement | null>(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 (
<div data-nextjs-dialog-left-right className={className}>
<nav ref={onNav}>
<button
ref={buttonLeft}
type="button"
disabled={previous == null ? true : undefined}
aria-disabled={previous == null ? true : undefined}
onClick={previous ?? undefined}
>
<svg
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M6.99996 1.16666L1.16663 6.99999L6.99996 12.8333M12.8333 6.99999H1.99996H12.8333Z"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</button>
<button
ref={buttonRight}
type="button"
disabled={next == null ? true : undefined}
aria-disabled={next == null ? true : undefined}
onClick={next ?? undefined}
>
<svg
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M6.99996 1.16666L12.8333 6.99999L6.99996 12.8333M1.16663 6.99999H12H1.16663Z"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</button>
&nbsp;
{children}
</nav>
{close ? (
<button
data-nextjs-errors-dialog-left-right-close-button
ref={buttonClose}
type="button"
onClick={close}
aria-label="Close"
>
<span aria-hidden="true">
<CloseIcon />
</span>
</button>
) : null}
</div>
)
}
export { LeftRightDialogHeader }
export { LeftRightDialogHeader } from './LeftRightDialogHeader'
export { styles } from './styles'
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;
}
[data-nextjs-dialog-left-right] > button:last-of-type:hover {
opacity: 0.7;
}
`
export { styles }
// @ts-ignore
import allyTrap from './maintain--tab-focus'
import * as React from 'react'
import { lock, unlock } from './body-locker'
export type OverlayProps = { className?: string; fixed?: boolean }
const Overlay: React.FC<OverlayProps> = function Overlay({
className,
children,
fixed,
}) {
React.useEffect(() => {
lock()
return () => {
unlock()
}
}, [])
const [overlay, setOverlay] = React.useState<HTMLDivElement | null>(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 (
<div data-nextjs-dialog-overlay className={className} ref={onOverlay}>
<div
data-nextjs-dialog-backdrop
data-nextjs-dialog-backdrop-fixed={fixed ? true : undefined}
/>
{children}
</div>
)
}
export { Overlay }
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
}
})
}
This source diff could not be displayed because it is too large. You can view the blob instead.
import { noop as css } from '../../helpers/noop-template'
const styles = css`
[data-nextjs-dialog-overlay] {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: auto;
z-index: 9000;
display: flex;
align-content: center;
align-items: center;
flex-direction: column;
padding: 10vh 15px 0;
}
@media (max-height: 812px) {
[data-nextjs-dialog-overlay] {
padding: 15px 15px 0;
}
}
[data-nextjs-dialog-backdrop] {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(17, 17, 17, 0.2);
pointer-events: all;
z-index: -1;
}
[data-nextjs-dialog-backdrop-fixed] {
cursor: not-allowed;
-webkit-backdrop-filter: blur(8px);
backdrop-filter: blur(8px);
}
`
export { styles }
import * as React from 'react'
import { createPortal } from 'react-dom'
export type ShadowPortalProps = {
children: React.ReactNode
globalOverlay?: boolean
}
export const ShadowPortal: React.FC<ShadowPortalProps> = function Portal({
children,
globalOverlay,
}) {
let mountNode = React.useRef<HTMLDivElement | null>(null)
let portalNode = React.useRef<HTMLElement | null>(null)
let shadowNode = React.useRef<ShadowRoot | null>(null)
let [, forceUpdate] = React.useState<{} | undefined>()
React.useLayoutEffect(() => {
const ownerDocument = globalOverlay
? document
: mountNode.current!.ownerDocument!
portalNode.current = ownerDocument.createElement('nextjs-portal')
shadowNode.current = portalNode.current.attachShadow({ mode: 'open' })
ownerDocument.body.appendChild(portalNode.current)
forceUpdate({})
return () => {
if (portalNode.current && portalNode.current.ownerDocument) {
portalNode.current.ownerDocument.body.removeChild(portalNode.current)
}
}
}, [globalOverlay])
return shadowNode.current ? (
createPortal(children, shadowNode.current as any)
) : globalOverlay ? null : (
<span ref={mountNode} />
)
}
import Anser from 'next/dist/compiled/anser'
import * as React from 'react'
export type TerminalProps = { content: string }
export const Terminal: React.FC<TerminalProps> = function Terminal({
content,
}) {
const decoded = React.useMemo(() => {
return Anser.ansiToJson(content, {
json: true,
use_classes: true,
remove_empty: true,
})
}, [content])
return (
<div data-nextjs-terminal>
<pre>
{decoded.map((entry, index) => (
<span
key={`terminal-entry-${index}`}
style={{
color: entry.fg ? `var(--color-${entry.fg})` : undefined,
...(entry.decoration === 'bold'
? { fontWeight: 800 }
: entry.decoration === 'italic'
? { fontStyle: 'italic' }
: undefined),
}}
>
{entry.content}
</span>
))}
</pre>
</div>
)
}
import { noop as css } from '../../helpers/noop-template'
const styles = css`
[data-nextjs-terminal] {
border-radius: var(--size-gap-half);
background-color: var(--color-ansi-bg);
color: var(--color-ansi-fg);
}
[data-nextjs-terminal]::selection,
[data-nextjs-terminal] *::selection {
background-color: var(--color-ansi-selection);
}
[data-nextjs-terminal] * {
color: inherit;
background-color: transparent;
font-family: var(--font-stack-monospace);
}
[data-nextjs-terminal] > * {
margin: 0;
padding: calc(var(--size-gap) + var(--size-gap-half))
calc(var(--size-gap-double) + var(--size-gap-half));
}
[data-nextjs-terminal] pre {
white-space: pre-wrap;
word-break: break-word;
}
`
export { styles }
import * as React from 'react'
export type ToastProps = {
onClick?: (ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
className?: string
}
export const Toast: React.FC<ToastProps> = function Toast({
onClick,
children,
className,
}) {
return (
<div data-nextjs-toast onClick={onClick} className={className}>
<div data-nextjs-toast-wrapper>{children}</div>
</div>
)
}
export { styles } from './styles'
export { Toast } from './Toast'
import { noop as css } from '../../helpers/noop-template'
const styles = css`
[data-nextjs-toast] {
position: fixed;
bottom: var(--size-gap-double);
left: var(--size-gap-double);
max-width: 420px;
z-index: 9000;
}
@media (max-width: 440px) {
[data-nextjs-toast] {
max-width: 90vw;
left: 5vw;
}
}
[data-nextjs-toast-wrapper] {
padding: 16px;
border-radius: var(--size-gap-half);
font-weight: 500;
color: var(--color-ansi-bright-white);
background-color: var(--color-ansi-red);
box-shadow: 0px var(--size-gap-double) var(--size-gap-quad)
rgba(0, 0, 0, 0.25);
}
`
export { styles }
import * as React from 'react'
import {
Dialog,
DialogBody,
DialogContent,
DialogHeader,
} from '../components/Dialog'
import { Overlay } from '../components/Overlay'
import { Terminal } from '../components/Terminal'
import { noop as css } from '../helpers/noop-template'
export type BuildErrorProps = { message: string }
export const BuildError: React.FC<BuildErrorProps> = function BuildError({
message,
}) {
const noop = React.useCallback(() => {}, [])
return (
<Overlay fixed>
<Dialog
type="error"
aria-labelledby="nextjs__container_build_error_label"
aria-describedby="nextjs__container_build_error_desc"
onClose={noop}
>
<DialogContent>
<DialogHeader className="nextjs-container-build-error-header">
<h4 id="nextjs__container_build_error_label">Failed to compile</h4>
</DialogHeader>
<DialogBody className="nextjs-container-build-error-body">
<Terminal content={message} />
<footer>
<p id="nextjs__container_build_error_desc">
<small>
This error occurred during the build process and can only be
dismissed by fixing the error.
</small>
</p>
</footer>
</DialogBody>
</DialogContent>
</Dialog>
</Overlay>
)
}
export const styles = css`
.nextjs-container-build-error-header > h4 {
line-height: 1.5;
margin: 0;
padding: 0;
}
.nextjs-container-build-error-body footer {
margin-top: var(--size-gap);
}
.nextjs-container-build-error-body footer p {
margin: 0;
}
.nextjs-container-build-error-body small {
color: #757575;
}
`
import * as React from 'react'
import {
TYPE_UNHANDLED_ERROR,
TYPE_UNHANDLED_REJECTION,
UnhandledError,
UnhandledRejection,
} from '../bus'
import {
Dialog,
DialogBody,
DialogContent,
DialogHeader,
} from '../components/Dialog'
import { LeftRightDialogHeader } from '../components/LeftRightDialogHeader'
import { Overlay } from '../components/Overlay'
import { Toast } from '../components/Toast'
import { getErrorByType, ReadyRuntimeError } from '../helpers/getErrorByType'
import { getErrorSource } from '../helpers/nodeStackFrames'
import { noop as css } from '../helpers/noop-template'
import { CloseIcon } from '../icons/CloseIcon'
import { RuntimeError } from './RuntimeError'
export type SupportedErrorEvent = {
id: number
event: UnhandledError | UnhandledRejection
}
export type ErrorsProps = { errors: SupportedErrorEvent[] }
type ReadyErrorEvent = ReadyRuntimeError
function getErrorSignature(ev: SupportedErrorEvent): string {
const { event } = ev
switch (event.type) {
case TYPE_UNHANDLED_ERROR:
case TYPE_UNHANDLED_REJECTION: {
return `${event.reason.name}::${event.reason.message}::${event.reason.stack}`
}
default: {
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _: never = event
return ''
}
const HotlinkedText: React.FC<{
text: string
}> = function HotlinkedText(props) {
const { text } = props
const linkRegex = /https?:\/\/[^\s/$.?#].[^\s"]*/i
return (
<>
{linkRegex.test(text)
? text.split(' ').map((word, index, array) => {
if (linkRegex.test(word)) {
return (
<React.Fragment key={`link-${index}`}>
<a href={word}>{word}</a>
{index === array.length - 1 ? '' : ' '}
</React.Fragment>
)
}
return index === array.length - 1 ? (
<React.Fragment key={`text-${index}`}>{word}</React.Fragment>
) : (
<React.Fragment key={`text-${index}`}>{word} </React.Fragment>
)
})
: text}
</>
)
}
export const Errors: React.FC<ErrorsProps> = function Errors({ errors }) {
const [lookups, setLookups] = React.useState(
{} as { [eventId: string]: ReadyErrorEvent }
)
const [readyErrors, nextError] = React.useMemo<
[ReadyErrorEvent[], SupportedErrorEvent | null]
>(() => {
let ready: ReadyErrorEvent[] = []
let next: SupportedErrorEvent | null = null
// Ensure errors are displayed in the order they occurred in:
for (let idx = 0; idx < errors.length; ++idx) {
const e = errors[idx]
const { id } = e
if (id in lookups) {
ready.push(lookups[id])
continue
}
// Check for duplicate errors
if (idx > 0) {
const prev = errors[idx - 1]
if (getErrorSignature(prev) === getErrorSignature(e)) {
continue
}
}
next = e
break
}
return [ready, next]
}, [errors, lookups])
const isLoading = React.useMemo<boolean>(() => {
return readyErrors.length < 1 && Boolean(errors.length)
}, [errors.length, readyErrors.length])
React.useEffect(() => {
if (nextError == null) {
return
}
let mounted = true
getErrorByType(nextError).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,
// we'll store it.
if (mounted) {
setLookups((m) => ({ ...m, [resolved.id]: resolved }))
}
},
() => {
// TODO: handle this, though an edge case
}
)
return () => {
mounted = false
}
}, [nextError])
const [displayState, setDisplayState] = React.useState<
'minimized' | 'fullscreen' | 'hidden'
>('fullscreen')
const [activeIdx, setActiveIndex] = React.useState<number>(0)
const previous = React.useCallback((e?: MouseEvent | TouchEvent) => {
e?.preventDefault()
setActiveIndex((v) => Math.max(0, v - 1))
}, [])
const next = React.useCallback(
(e?: MouseEvent | TouchEvent) => {
e?.preventDefault()
setActiveIndex((v) =>
Math.max(0, Math.min(readyErrors.length - 1, v + 1))
)
},
[readyErrors.length]
)
const activeError = React.useMemo<ReadyErrorEvent | null>(
() => readyErrors[activeIdx] ?? null,
[activeIdx, readyErrors]
)
// Reset component state when there are no errors to be displayed.
// This should never happen, but lets handle it.
React.useEffect(() => {
if (errors.length < 1) {
setLookups({})
setDisplayState('hidden')
setActiveIndex(0)
}
}, [errors.length])
const minimize = React.useCallback((e?: MouseEvent | TouchEvent) => {
e?.preventDefault()
setDisplayState('minimized')
}, [])
const hide = React.useCallback((e?: MouseEvent | TouchEvent) => {
e?.preventDefault()
setDisplayState('hidden')
}, [])
const fullscreen = React.useCallback(
(e?: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
e?.preventDefault()
setDisplayState('fullscreen')
},
[]
)
// This component shouldn't be rendered with no errors, but if it is, let's
// handle it gracefully by rendering nothing.
if (errors.length < 1 || activeError == null) {
return null
}
if (isLoading) {
// TODO: better loading state
return <Overlay />
}
if (displayState === 'hidden') {
return null
}
if (displayState === 'minimized') {
return (
<Toast className="nextjs-toast-errors-parent" onClick={fullscreen}>
<div className="nextjs-toast-errors">
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<circle cx="12" cy="12" r="10"></circle>
<line x1="12" y1="8" x2="12" y2="12"></line>
<line x1="12" y1="16" x2="12.01" y2="16"></line>
</svg>
<span>
{readyErrors.length} error{readyErrors.length > 1 ? 's' : ''}
</span>
<button
data-nextjs-toast-errors-hide-button
className="nextjs-toast-errors-hide-button"
type="button"
onClick={(e) => {
e.stopPropagation()
hide()
}}
aria-label="Hide Errors"
>
<CloseIcon />
</button>
</div>
</Toast>
)
}
const isServerError = ['server', 'edge-server'].includes(
getErrorSource(activeError.error) || ''
)
return (
<Overlay>
<Dialog
type="error"
aria-labelledby="nextjs__container_errors_label"
aria-describedby="nextjs__container_errors_desc"
onClose={isServerError ? undefined : minimize}
>
<DialogContent>
<DialogHeader className="nextjs-container-errors-header">
<LeftRightDialogHeader
previous={activeIdx > 0 ? previous : null}
next={activeIdx < readyErrors.length - 1 ? next : null}
close={isServerError ? undefined : minimize}
>
<small>
<span>{activeIdx + 1}</span> of{' '}
<span>{readyErrors.length}</span> unhandled error
{readyErrors.length < 2 ? '' : 's'}
</small>
</LeftRightDialogHeader>
<h1 id="nextjs__container_errors_label">
{isServerError ? 'Server Error' : 'Unhandled Runtime Error'}
</h1>
<p id="nextjs__container_errors_desc">
{activeError.error.name}:{' '}
<HotlinkedText text={activeError.error.message} />
</p>
{isServerError ? (
<div>
<small>
This error happened while generating the page. Any console
logs will be displayed in the terminal window.
</small>
</div>
) : undefined}
</DialogHeader>
<DialogBody className="nextjs-container-errors-body">
<RuntimeError key={activeError.id.toString()} error={activeError} />
</DialogBody>
</DialogContent>
</Dialog>
</Overlay>
)
}
export const styles = css`
.nextjs-container-errors-header > h1 {
font-size: var(--size-font-big);
line-height: var(--size-font-bigger);
font-weight: bold;
margin: 0;
margin-top: calc(var(--size-gap-double) + var(--size-gap-half));
}
.nextjs-container-errors-header small {
font-size: var(--size-font-small);
color: var(--color-accents-1);
margin-left: var(--size-gap-double);
}
.nextjs-container-errors-header small > span {
font-family: var(--font-stack-monospace);
}
.nextjs-container-errors-header > p {
font-family: var(--font-stack-monospace);
font-size: var(--size-font-small);
line-height: var(--size-font-big);
font-weight: bold;
margin: 0;
margin-top: var(--size-gap-half);
color: var(--color-ansi-red);
white-space: pre-wrap;
}
.nextjs-container-errors-header > div > small {
margin: 0;
margin-top: var(--size-gap-half);
}
.nextjs-container-errors-header > p > a {
color: var(--color-ansi-red);
}
.nextjs-container-errors-body > h5:not(:first-child) {
margin-top: calc(var(--size-gap-double) + var(--size-gap));
}
.nextjs-container-errors-body > h5 {
margin-bottom: var(--size-gap);
}
.nextjs-toast-errors-parent {
cursor: pointer;
transition: transform 0.2s ease;
}
.nextjs-toast-errors-parent:hover {
transform: scale(1.1);
}
.nextjs-toast-errors {
display: flex;
align-items: center;
justify-content: flex-start;
}
.nextjs-toast-errors > svg {
margin-right: var(--size-gap);
}
.nextjs-toast-errors-hide-button {
margin-left: var(--size-gap-triple);
border: none;
background: none;
color: var(--color-ansi-bright-white);
padding: 0;
transition: opacity 0.25s ease;
opacity: 0.7;
}
.nextjs-toast-errors-hide-button:hover {
opacity: 1;
}
`
import * as React from 'react'
import { StackFrame } from 'next/dist/compiled/stacktrace-parser'
import { CodeFrame } from '../components/CodeFrame'
import { ReadyRuntimeError } from '../helpers/getErrorByType'
import { noop as css } from '../helpers/noop-template'
import { getFrameSource, OriginalStackFrame } from '../helpers/stack-frame'
export type RuntimeErrorProps = { error: ReadyRuntimeError }
const CallStackFrame: React.FC<{
frame: OriginalStackFrame
}> = function CallStackFrame({ frame }) {
// TODO: ability to expand resolved frames
// TODO: render error or external indicator
const f: StackFrame = frame.originalStackFrame ?? frame.sourceStackFrame
const hasSource = Boolean(frame.originalCodeFrame)
const open = React.useCallback(() => {
if (!hasSource) return
const params = new URLSearchParams()
for (const key in f) {
params.append(key, ((f 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.')
}
)
}, [hasSource, f])
return (
<div data-nextjs-call-stack-frame>
<h6 data-nextjs-frame-expanded={Boolean(frame.expanded)}>
{f.methodName}
</h6>
<div
data-has-source={hasSource ? 'true' : undefined}
tabIndex={hasSource ? 10 : undefined}
role={hasSource ? 'link' : undefined}
onClick={open}
title={hasSource ? 'Click to open in your editor' : undefined}
>
<span>{getFrameSource(f)}</span>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
<polyline points="15 3 21 3 21 9"></polyline>
<line x1="10" y1="14" x2="21" y2="3"></line>
</svg>
</div>
</div>
)
}
const RuntimeError: React.FC<RuntimeErrorProps> = function RuntimeError({
error,
}) {
const firstFirstPartyFrameIndex = React.useMemo<number>(() => {
return error.frames.findIndex(
(entry) =>
entry.expanded &&
Boolean(entry.originalCodeFrame) &&
Boolean(entry.originalStackFrame)
)
}, [error.frames])
const firstFrame = React.useMemo<OriginalStackFrame | null>(() => {
return error.frames[firstFirstPartyFrameIndex] ?? null
}, [error.frames, firstFirstPartyFrameIndex])
const allLeadingFrames = React.useMemo<OriginalStackFrame[]>(
() =>
firstFirstPartyFrameIndex < 0
? []
: error.frames.slice(0, firstFirstPartyFrameIndex),
[error.frames, firstFirstPartyFrameIndex]
)
const [all, setAll] = React.useState(firstFrame == null)
const toggleAll = React.useCallback(() => {
setAll((v) => !v)
}, [])
const leadingFrames = React.useMemo(
() => allLeadingFrames.filter((f) => f.expanded || all),
[all, allLeadingFrames]
)
const allCallStackFrames = React.useMemo<OriginalStackFrame[]>(
() => error.frames.slice(firstFirstPartyFrameIndex + 1),
[error.frames, firstFirstPartyFrameIndex]
)
const visibleCallStackFrames = React.useMemo<OriginalStackFrame[]>(
() => allCallStackFrames.filter((f) => f.expanded || all),
[all, allCallStackFrames]
)
const canShowMore = React.useMemo<boolean>(() => {
return (
allCallStackFrames.length !== visibleCallStackFrames.length ||
(all && firstFrame != null)
)
}, [
all,
allCallStackFrames.length,
firstFrame,
visibleCallStackFrames.length,
])
return (
<React.Fragment>
{firstFrame ? (
<React.Fragment>
<h5>Source</h5>
{leadingFrames.map((frame, index) => (
<CallStackFrame
key={`leading-frame-${index}-${all}`}
frame={frame}
/>
))}
<CodeFrame
stackFrame={firstFrame.originalStackFrame!}
codeFrame={firstFrame.originalCodeFrame!}
/>
</React.Fragment>
) : undefined}
{visibleCallStackFrames.length ? (
<React.Fragment>
<h5>Call Stack</h5>
{visibleCallStackFrames.map((frame, index) => (
<CallStackFrame key={`call-stack-${index}-${all}`} frame={frame} />
))}
</React.Fragment>
) : undefined}
{canShowMore ? (
<React.Fragment>
<button
tabIndex={10}
data-nextjs-data-runtime-error-collapsed-action
type="button"
onClick={toggleAll}
>
{all ? 'Hide' : 'Show'} collapsed frames
</button>
</React.Fragment>
) : undefined}
</React.Fragment>
)
}
export const styles = css`
button[data-nextjs-data-runtime-error-collapsed-action] {
background: none;
border: none;
padding: 0;
font-size: var(--size-font-small);
line-height: var(--size-font-bigger);
color: var(--color-accents-3);
}
[data-nextjs-call-stack-frame]:not(:last-child) {
margin-bottom: var(--size-gap-double);
}
[data-nextjs-call-stack-frame] > h6 {
margin-top: 0;
margin-bottom: var(--size-gap);
font-family: var(--font-stack-monospace);
color: #222;
}
[data-nextjs-call-stack-frame] > h6[data-nextjs-frame-expanded='false'] {
color: #666;
}
[data-nextjs-call-stack-frame] > div {
display: flex;
align-items: center;
padding-left: calc(var(--size-gap) + var(--size-gap-half));
font-size: var(--size-font-small);
color: #999;
}
[data-nextjs-call-stack-frame] > div > svg {
width: auto;
height: var(--size-font-small);
margin-left: var(--size-gap);
display: none;
}
[data-nextjs-call-stack-frame] > div[data-has-source] {
cursor: pointer;
}
[data-nextjs-call-stack-frame] > div[data-has-source]:hover {
text-decoration: underline dotted;
}
[data-nextjs-call-stack-frame] > div[data-has-source] > svg {
display: unset;
}
`
export { RuntimeError }
import { TYPE_UNHANDLED_ERROR, TYPE_UNHANDLED_REJECTION } from '../bus'
import { SupportedErrorEvent } from '../container/Errors'
import { getErrorSource } from './nodeStackFrames'
import { getOriginalStackFrames, OriginalStackFrame } from './stack-frame'
export type ReadyRuntimeError = {
id: number
runtime: true
error: Error
frames: OriginalStackFrame[]
}
export async function getErrorByType(
ev: SupportedErrorEvent
): Promise<ReadyRuntimeError> {
const { id, event } = ev
switch (event.type) {
case TYPE_UNHANDLED_ERROR:
case TYPE_UNHANDLED_REJECTION: {
return {
id,
runtime: true,
error: event.reason,
frames: await getOriginalStackFrames(
event.frames,
getErrorSource(event.reason),
event.reason.toString()
),
}
}
default: {
break
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _: never = event
throw new Error('type system invariant violation')
}
import dataUriToBuffer, {
MimeBuffer,
} from 'next/dist/compiled/data-uri-to-buffer'
import type { RawSourceMap } from 'source-map'
import { getSourceMapUrl } from './getSourceMapUrl'
export function getRawSourceMap(fileContents: string): RawSourceMap | null {
const sourceUrl = getSourceMapUrl(fileContents)
if (!sourceUrl?.startsWith('data:')) {
return null
}
let buffer: MimeBuffer
try {
// @ts-expect-error TODO-APP: fix type.
buffer = dataUriToBuffer(sourceUrl)
} catch (err) {
console.error('Failed to parse source map URL:', err)
return null
}
if (buffer.type !== 'application/json') {
console.error(`Unknown source map type: ${buffer.typeFull}.`)
return null
}
try {
return JSON.parse(buffer.toString())
} catch {
console.error('Failed to parse source map.')
return null
}
}
export function getSourceMapUrl(fileContents: string): string | null {
const regex = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/gm
let match = null
for (;;) {
let next = regex.exec(fileContents)
if (next == null) {
break
}
match = next
}
if (!(match && match[1])) {
return null
}
return match[1].toString()
}
/**
* MIT License
*
* Copyright (c) 2015-present, Facebook, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import chalk from 'next/dist/compiled/chalk'
import child_process from 'child_process'
import fs from 'fs'
import os from 'os'
import path from 'path'
// @ts-ignore
import shellQuote from 'next/dist/compiled/shell-quote'
function isTerminalEditor(editor: string) {
switch (editor) {
case 'vi':
case 'vim':
case 'emacs':
case 'nano': {
return true
}
default: {
}
}
return false
}
// Map from full process name to binary that starts the process
// We can't just re-use full process name, because it will spawn a new instance
// of the app every time
const COMMON_EDITORS_MACOS = {
'/Applications/Atom.app/Contents/MacOS/Atom': 'atom',
'/Applications/Atom Beta.app/Contents/MacOS/Atom Beta':
'/Applications/Atom Beta.app/Contents/MacOS/Atom Beta',
'/Applications/Brackets.app/Contents/MacOS/Brackets': 'brackets',
'/Applications/Sublime Text.app/Contents/MacOS/Sublime Text':
'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl',
'/Applications/Sublime Text Dev.app/Contents/MacOS/Sublime Text':
'/Applications/Sublime Text Dev.app/Contents/SharedSupport/bin/subl',
'/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2':
'/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl',
'/Applications/Visual Studio Code.app/Contents/MacOS/Electron':
'/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code',
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron':
'/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code',
'/Applications/VSCodium.app/Contents/MacOS/Electron':
'/Applications/VSCodium.app/Contents/Resources/app/bin/code',
'/Applications/AppCode.app/Contents/MacOS/appcode':
'/Applications/AppCode.app/Contents/MacOS/appcode',
'/Applications/CLion.app/Contents/MacOS/clion':
'/Applications/CLion.app/Contents/MacOS/clion',
'/Applications/IntelliJ IDEA.app/Contents/MacOS/idea':
'/Applications/IntelliJ IDEA.app/Contents/MacOS/idea',
'/Applications/PhpStorm.app/Contents/MacOS/phpstorm':
'/Applications/PhpStorm.app/Contents/MacOS/phpstorm',
'/Applications/PyCharm.app/Contents/MacOS/pycharm':
'/Applications/PyCharm.app/Contents/MacOS/pycharm',
'/Applications/PyCharm CE.app/Contents/MacOS/pycharm':
'/Applications/PyCharm CE.app/Contents/MacOS/pycharm',
'/Applications/RubyMine.app/Contents/MacOS/rubymine':
'/Applications/RubyMine.app/Contents/MacOS/rubymine',
'/Applications/WebStorm.app/Contents/MacOS/webstorm':
'/Applications/WebStorm.app/Contents/MacOS/webstorm',
'/Applications/MacVim.app/Contents/MacOS/MacVim': 'mvim',
'/Applications/GoLand.app/Contents/MacOS/goland':
'/Applications/GoLand.app/Contents/MacOS/goland',
'/Applications/Rider.app/Contents/MacOS/rider':
'/Applications/Rider.app/Contents/MacOS/rider',
}
const COMMON_EDITORS_LINUX = {
atom: 'atom',
Brackets: 'brackets',
code: 'code',
'code-insiders': 'code-insiders',
vscodium: 'vscodium',
emacs: 'emacs',
gvim: 'gvim',
'idea.sh': 'idea',
'phpstorm.sh': 'phpstorm',
'pycharm.sh': 'pycharm',
'rubymine.sh': 'rubymine',
sublime_text: 'sublime_text',
vim: 'vim',
'webstorm.sh': 'webstorm',
'goland.sh': 'goland',
'rider.sh': 'rider',
}
const COMMON_EDITORS_WIN = [
'Brackets.exe',
'Code.exe',
'Code - Insiders.exe',
'VSCodium.exe',
'atom.exe',
'sublime_text.exe',
'notepad++.exe',
'clion.exe',
'clion64.exe',
'idea.exe',
'idea64.exe',
'phpstorm.exe',
'phpstorm64.exe',
'pycharm.exe',
'pycharm64.exe',
'rubymine.exe',
'rubymine64.exe',
'webstorm.exe',
'webstorm64.exe',
'goland.exe',
'goland64.exe',
'rider.exe',
'rider64.exe',
]
// Transpiled version of: /^([A-Za-z]:[/\\])?[\p{L}0-9/.\-_\\]+$/u
// Non-transpiled version requires support for Unicode property regex. Allows
// alphanumeric characters, periods, dashes, slashes, and underscores.
const WINDOWS_FILE_NAME_ACCESS_LIST =
/^([A-Za-z]:[/\\])?(?:[\x2D-9A-Z\\_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEF\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7B9\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDF00-\uDF1C\uDF27\uDF30-\uDF45]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFF1]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D])+$/
function getArgumentsForLineNumber(
editor: string,
fileName: string,
lineNumber: number,
colNumber: number
): string[] {
const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, '')
switch (editorBasename) {
case 'atom':
case 'Atom':
case 'Atom Beta':
case 'subl':
case 'sublime':
case 'sublime_text': {
return [fileName + ':' + lineNumber + ':' + colNumber]
}
case 'wstorm':
case 'charm': {
return [fileName + ':' + lineNumber]
}
case 'notepad++': {
return ['-n' + lineNumber, '-c' + colNumber, fileName]
}
case 'vim':
case 'mvim':
case 'joe':
case 'gvim': {
return ['+' + lineNumber, fileName]
}
case 'emacs':
case 'emacsclient': {
return ['+' + lineNumber + ':' + colNumber, fileName]
}
case 'rmate':
case 'mate':
case 'mine': {
return ['--line', lineNumber.toString(), fileName]
}
case 'code':
case 'Code':
case 'code-insiders':
case 'Code - Insiders':
case 'vscodium':
case 'VSCodium': {
return ['-g', fileName + ':' + lineNumber + ':' + colNumber]
}
case 'appcode':
case 'clion':
case 'clion64':
case 'idea':
case 'idea64':
case 'phpstorm':
case 'phpstorm64':
case 'pycharm':
case 'pycharm64':
case 'rubymine':
case 'rubymine64':
case 'webstorm':
case 'webstorm64':
case 'goland':
case 'goland64':
case 'rider':
case 'rider64': {
return ['--line', lineNumber.toString(), fileName]
}
default: {
// For all others, drop the lineNumber until we have
// a mapping above, since providing the lineNumber incorrectly
// can result in errors or confusing behavior.
return [fileName]
}
}
}
function guessEditor(): string[] {
// Explicit config always wins
if (process.env.REACT_EDITOR) {
// TODO-APP: fix this type
return shellQuote.parse(process.env.REACT_EDITOR) as any
}
// We can find out which editor is currently running by:
// `ps x` on macOS and Linux
// `Get-Process` on Windows
try {
if (process.platform === 'darwin') {
const output = child_process.execSync('ps x').toString()
const processNames = Object.keys(COMMON_EDITORS_MACOS)
for (let i = 0; i < processNames.length; i++) {
const processName = processNames[i]
if (output.indexOf(processName) !== -1) {
return [(COMMON_EDITORS_MACOS as any)[processName]]
}
}
} else if (process.platform === 'win32') {
// Some processes need elevated rights to get its executable path.
// Just filter them out upfront. This also saves 10-20ms on the command.
const output = child_process
.execSync(
'wmic process where "executablepath is not null" get executablepath'
)
.toString()
const runningProcesses = output.split('\r\n')
for (let i = 0; i < runningProcesses.length; i++) {
const processPath = runningProcesses[i].trim()
const processName = path.basename(processPath)
if (COMMON_EDITORS_WIN.indexOf(processName) !== -1) {
return [processPath]
}
}
} else if (process.platform === 'linux') {
// --no-heading No header line
// x List all processes owned by you
// -o comm Need only names column
const output = child_process
.execSync('ps x --no-heading -o comm --sort=comm')
.toString()
const processNames = Object.keys(COMMON_EDITORS_LINUX)
for (let i = 0; i < processNames.length; i++) {
const processName = processNames[i]
if (output.indexOf(processName) !== -1) {
return [(COMMON_EDITORS_LINUX as any)[processName] as string]
}
}
}
} catch (error) {
// Ignore...
}
// Last resort, use old skool env vars
if (process.env.VISUAL) {
return [process.env.VISUAL]
} else if (process.env.EDITOR) {
return [process.env.EDITOR]
}
return []
}
function printInstructions(fileName: string, errorMessage: string | null) {
console.log()
console.log(
chalk.red('Could not open ' + path.basename(fileName) + ' in the editor.')
)
if (errorMessage) {
if (errorMessage[errorMessage.length - 1] !== '.') {
errorMessage += '.'
}
console.log(
chalk.red('The editor process exited with an error: ' + errorMessage)
)
}
console.log()
console.log(
'To set up the editor integration, add something like ' +
chalk.cyan('REACT_EDITOR=atom') +
' to the ' +
chalk.green('.env.local') +
' file in your project folder ' +
'and restart the development server.'
)
console.log()
}
function launchEditor(fileName: string, lineNumber: number, colNumber: number) {
if (!fs.existsSync(fileName)) {
return
}
// Sanitize lineNumber to prevent malicious use on win32
// via: https://github.com/nodejs/node/blob/c3bb4b1aa5e907d489619fb43d233c3336bfc03d/lib/child_process.js#L333
// and it should be a positive integer
if (!(Number.isInteger(lineNumber) && lineNumber > 0)) {
return
}
// colNumber is optional, but should be a positive integer too
// default is 1
if (!(Number.isInteger(colNumber) && colNumber > 0)) {
colNumber = 1
}
let [editor, ...args] = guessEditor()
if (!editor) {
printInstructions(fileName, null)
return
}
if (editor.toLowerCase() === 'none') {
return
}
if (
process.platform === 'linux' &&
fileName.startsWith('/mnt/') &&
/Microsoft/i.test(os.release())
) {
// Assume WSL / "Bash on Ubuntu on Windows" is being used, and
// that the file exists on the Windows file system.
// `os.release()` is "4.4.0-43-Microsoft" in the current release
// build of WSL, see: https://github.com/Microsoft/BashOnWindows/issues/423#issuecomment-221627364
// When a Windows editor is specified, interop functionality can
// handle the path translation, but only if a relative path is used.
fileName = path.relative('', fileName)
}
// cmd.exe on Windows is vulnerable to RCE attacks given a file name of the
// form "C:\Users\myusername\Downloads\& curl 172.21.93.52". Use an access list
// to validate user-provided file names. This doesn't cover the entire range
// of valid file names but should cover almost all of them in practice.
if (
process.platform === 'win32' &&
!WINDOWS_FILE_NAME_ACCESS_LIST.test(fileName.trim())
) {
console.log()
console.log(
chalk.red('Could not open ' + path.basename(fileName) + ' in the editor.')
)
console.log()
console.log(
'When running on Windows, file names are checked against an access list ' +
'to protect against remote code execution attacks. File names may ' +
'consist only of alphanumeric characters (all languages), periods, ' +
'dashes, slashes, and underscores.'
)
console.log()
return
}
if (lineNumber) {
args = args.concat(
getArgumentsForLineNumber(editor, fileName, lineNumber, colNumber)
)
} else {
args.push(fileName)
}
let p: child_process.ChildProcess | undefined = undefined
if (process.platform === 'win32') {
// On Windows, launch the editor in a shell because spawn can only
// launch .exe files.
p = child_process.spawn('cmd.exe', ['/C', editor].concat(args), {
stdio: 'inherit',
detached: true,
})
} else if (isTerminalEditor(editor)) {
if (process.platform === 'darwin') {
p = child_process.spawn(
'osascript',
[
'-e',
`tell application "Terminal" to do script "${shellQuote.quote([
editor,
...args,
])}"`,
],
{ stdio: 'ignore' }
)
} else {
printInstructions(fileName, 'Terminal editors can only be used on macOS.')
}
} else {
p = child_process.spawn(editor, args, { stdio: 'inherit' })
}
if (p) {
p.on('exit', function (errorCode) {
if (errorCode) {
printInstructions(fileName, '(code ' + errorCode + ')')
}
})
p.on('error', function (error) {
printInstructions(fileName, error.message)
})
}
}
export { launchEditor }
import { parse, StackFrame } from 'next/dist/compiled/stacktrace-parser'
export function getFilesystemFrame(frame: StackFrame): StackFrame {
const f: StackFrame = { ...frame }
if (typeof f.file === 'string') {
if (
// Posix:
f.file.startsWith('/') ||
// Win32:
/^[a-z]:\\/i.test(f.file) ||
// Win32 UNC:
f.file.startsWith('\\\\')
) {
f.file = `file://${f.file}`
}
}
return f
}
const symbolError = Symbol('NextjsError')
export function getErrorSource(error: Error): 'server' | 'edge-server' | null {
return (error as any)[symbolError] || null
}
type ErrorType = 'edge-server' | 'server'
export function decorateServerError(error: Error, type: ErrorType) {
Object.defineProperty(error, symbolError, {
writable: false,
enumerable: false,
configurable: false,
value: type,
})
}
export function getServerError(error: Error, type: ErrorType): Error {
let n: Error
try {
throw new Error(error.message)
} catch (e) {
n = e as Error
}
n.name = error.name
try {
n.stack = `${n.toString()}\n${parse(error.stack!)
.map(getFilesystemFrame)
.map((f) => {
let str = ` at ${f.methodName}`
if (f.file) {
let loc = f.file
if (f.lineNumber) {
loc += `:${f.lineNumber}`
if (f.column) {
loc += `:${f.column}`
}
}
str += ` (${loc})`
}
return str
})
.join('\n')}`
} catch {
n.stack = error.stack
}
decorateServerError(n, type)
return n
}
export function noop(
strings: TemplateStringsArray,
...keys: readonly string[]
) {
const lastIndex = strings.length - 1
return (
strings.slice(0, lastIndex).reduce((p, s, i) => p + s + keys[i], '') +
strings[lastIndex]
)
}
import { parse, StackFrame } from 'next/dist/compiled/stacktrace-parser'
const regexNextStatic = /\/_next(\/static\/.+)/g
export function parseStack(stack: string): StackFrame[] {
const frames = parse(stack)
return frames.map((frame) => {
try {
const url = new URL(frame.file!)
const res = regexNextStatic.exec(url.pathname)
if (res) {
const distDir = process.env.__NEXT_DIST_DIR
?.replace(/\\/g, '/')
?.replace(/\/$/, '')
if (distDir) {
frame.file = 'file://' + distDir.concat(res.pop()!)
}
}
} catch {}
return frame
})
}
import { StackFrame } from 'next/dist/compiled/stacktrace-parser'
// import type { OriginalStackFrameResponse } from '../../middleware'
export type OriginalStackFrame =
| {
error: true
reason: string
external: false
expanded: false
sourceStackFrame: StackFrame
originalStackFrame: null
originalCodeFrame: null
}
| {
error: false
reason: null
external: false
expanded: boolean
sourceStackFrame: StackFrame
originalStackFrame: StackFrame
originalCodeFrame: string | null
}
| {
error: false
reason: null
external: true
expanded: false
sourceStackFrame: StackFrame
originalStackFrame: null
originalCodeFrame: null
}
export function getOriginalStackFrame(
source: StackFrame,
type: 'server' | 'edge-server' | null,
errorMessage: string
): Promise<OriginalStackFrame> {
async function _getOriginalStackFrame(): Promise<OriginalStackFrame> {
const params = new URLSearchParams()
params.append('isServer', String(type === 'server'))
params.append('isEdgeServer', String(type === 'edge-server'))
params.append('errorMessage', errorMessage)
for (const key in source) {
params.append(key, ((source as any)[key] ?? '').toString())
}
const controller = new AbortController()
const tm = setTimeout(() => controller.abort(), 3000)
const res = await self
.fetch(
`${
process.env.__NEXT_ROUTER_BASEPATH || ''
}/__nextjs_original-stack-frame?${params.toString()}`,
{
signal: controller.signal,
}
)
.finally(() => {
clearTimeout(tm)
})
if (!res.ok || res.status === 204) {
return Promise.reject(new Error(await res.text()))
}
const body: /* OriginalStackFrameResponse */ any = await res.json()
return {
error: false,
reason: null,
external: false,
expanded: !Boolean(
/* collapsed */
(source.file?.includes('node_modules') ||
body.originalStackFrame?.file?.includes('node_modules')) ??
true
),
sourceStackFrame: source,
originalStackFrame: body.originalStackFrame,
originalCodeFrame: body.originalCodeFrame || null,
}
}
if (
!(
source.file?.startsWith('webpack-internal:') ||
source.file?.startsWith('file:')
)
) {
return Promise.resolve({
error: false,
reason: null,
external: true,
expanded: false,
sourceStackFrame: source,
originalStackFrame: null,
originalCodeFrame: null,
})
}
return _getOriginalStackFrame().catch((err: Error) => ({
error: true,
reason: err?.message ?? err?.toString() ?? 'Unknown Error',
external: false,
expanded: false,
sourceStackFrame: source,
originalStackFrame: null,
originalCodeFrame: null,
}))
}
export function getOriginalStackFrames(
frames: StackFrame[],
type: 'server' | 'edge-server' | null,
errorMessage: string
) {
return Promise.all(
frames.map((frame) => getOriginalStackFrame(frame, type, errorMessage))
)
}
export function getFrameSource(frame: StackFrame): string {
let str = ''
try {
const u = new URL(frame.file!)
// Strip the origin for same-origin scripts.
if (
typeof globalThis !== 'undefined' &&
globalThis.location?.origin !== u.origin
) {
// URLs can be valid without an `origin`, so long as they have a
// `protocol`. However, `origin` is preferred.
if (u.origin === 'null') {
str += u.protocol
} else {
str += u.origin
}
}
// Strip query string information as it's typically too verbose to be
// meaningful.
str += u.pathname
str += ' '
} catch {
str += (frame.file || '(unknown)') + ' '
}
if (frame.lineNumber != null) {
if (frame.column != null) {
str += `(${frame.lineNumber}:${frame.column}) `
} else {
str += `(${frame.lineNumber}) `
}
}
return str.slice(0, -1)
}
import * as React from 'react'
export function useOnClickOutside(
el: Node | null,
handler: ((e: MouseEvent | TouchEvent) => void) | undefined
) {
React.useEffect(() => {
if (el == null || handler == null) {
return
}
const listener = (e: MouseEvent | TouchEvent) => {
// Do nothing if clicking ref's element or descendent elements
if (!el || el.contains(e.target as Element)) {
return
}
handler(e)
}
const root = el.getRootNode()
root.addEventListener('mousedown', listener as EventListener)
root.addEventListener('touchstart', listener as EventListener)
return function () {
root.removeEventListener('mousedown', listener as EventListener)
root.removeEventListener('touchstart', listener as EventListener)
}
}, [handler, el])
}
import * as React from 'react'
const CloseIcon = () => {
return (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M18 6L6 18"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M6 6L18 18"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
)
}
export { CloseIcon }
import * as React from 'react'
import { noop as css } from '../helpers/noop-template'
export function Base() {
return (
<style>
{css`
:host {
--size-gap-half: 4px;
--size-gap: 8px;
--size-gap-double: 16px;
--size-gap-triple: 24px;
--size-gap-quad: 32px;
--size-font-small: 14px;
--size-font: 16px;
--size-font-big: 20px;
--size-font-bigger: 24px;
--color-accents-1: #808080;
--color-accents-2: #222222;
--color-accents-3: #404040;
--font-stack-monospace: 'SFMono-Regular', Consolas, 'Liberation Mono',
Menlo, Courier, monospace;
--color-ansi-selection: rgba(95, 126, 151, 0.48);
--color-ansi-bg: #111111;
--color-ansi-fg: #cccccc;
--color-ansi-white: #777777;
--color-ansi-black: #141414;
--color-ansi-blue: #00aaff;
--color-ansi-cyan: #88ddff;
--color-ansi-green: #98ec65;
--color-ansi-magenta: #aa88ff;
--color-ansi-red: #ff5555;
--color-ansi-yellow: #ffcc33;
--color-ansi-bright-white: #ffffff;
--color-ansi-bright-black: #777777;
--color-ansi-bright-blue: #33bbff;
--color-ansi-bright-cyan: #bbecff;
--color-ansi-bright-green: #b6f292;
--color-ansi-bright-magenta: #cebbff;
--color-ansi-bright-red: #ff8888;
--color-ansi-bright-yellow: #ffd966;
}
.mono {
font-family: var(--font-stack-monospace);
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-bottom: var(--size-gap);
font-weight: 500;
line-height: 1.5;
}
h1 {
font-size: 40px;
}
h2 {
font-size: 32px;
}
h3 {
font-size: 28px;
}
h4 {
font-size: 24px;
}
h5 {
font-size: 20px;
}
h6 {
font-size: 16px;
}
`}
</style>
)
}
import * as React from 'react'
import { styles as codeFrame } from '../components/CodeFrame/styles'
import { styles as dialog } from '../components/Dialog'
import { styles as leftRightDialogHeader } from '../components/LeftRightDialogHeader/styles'
import { styles as overlay } from '../components/Overlay/styles'
import { styles as terminal } from '../components/Terminal/styles'
import { styles as toast } from '../components/Toast'
import { styles as buildErrorStyles } from '../container/BuildError'
import { styles as containerErrorStyles } from '../container/Errors'
import { styles as containerRuntimeErrorStyles } from '../container/RuntimeError'
import { noop as css } from '../helpers/noop-template'
export function ComponentStyles() {
return (
<style>
{css`
${overlay}
${toast}
${dialog}
${leftRightDialogHeader}
${codeFrame}
${terminal}
${buildErrorStyles}
${containerErrorStyles}
${containerRuntimeErrorStyles}
`}
</style>
)
}
import * as React from 'react'
import { noop as css } from '../helpers/noop-template'
export function CssReset() {
return (
<style>
{css`
:host {
all: initial;
/* the direction property is not reset by 'all' */
direction: ltr;
}
/*!
* Bootstrap Reboot v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
:host {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article,
aside,
figcaption,
figure,
footer,
header,
hgroup,
main,
nav,
section {
display: block;
}
:host {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
'Noto Color Emoji';
font-size: 16px;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex='-1']:focus:not(:focus-visible) {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 0;
margin-bottom: 8px;
}
p {
margin-top: 0;
margin-bottom: 16px;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 16px;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 16px;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: 8px;
margin-left: 0;
}
blockquote {
margin: 0 0 16px;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]) {
color: inherit;
text-decoration: none;
}
a:not([href]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas,
'Liberation Mono', 'Courier New', monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 16px;
overflow: auto;
}
figure {
margin: 0 0 16px;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 12px;
padding-bottom: 12px;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
}
label {
display: inline-block;
margin-bottom: 8px;
}
button {
border-radius: 0;
}
button:focus {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
select {
word-wrap: normal;
}
button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button;
}
button:not(:disabled),
[type='button']:not(:disabled),
[type='reset']:not(:disabled),
[type='submit']:not(:disabled) {
cursor: pointer;
}
button::-moz-focus-inner,
[type='button']::-moz-focus-inner,
[type='reset']::-moz-focus-inner,
[type='submit']::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type='radio'],
input[type='checkbox'] {
box-sizing: border-box;
padding: 0;
}
input[type='date'],
input[type='time'],
input[type='datetime-local'],
input[type='month'] {
-webkit-appearance: listbox;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: 8px;
font-size: 24px;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type='number']::-webkit-inner-spin-button,
[type='number']::-webkit-outer-spin-button {
height: auto;
}
[type='search'] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type='search']::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
`}
</style>
)
}
The MIT License (MIT)
Copyright (c) 2012-19 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
(()=>{"use strict";var e={211:e=>{var r=function(){function defineProperties(e,r){for(var n=0;n<r.length;n++){var s=r[n];s.enumerable=s.enumerable||false;s.configurable=true;if("value"in s)s.writable=true;Object.defineProperty(e,s.key,s)}}return function(e,r,n){if(r)defineProperties(e.prototype,r);if(n)defineProperties(e,n);return e}}();function _classCallCheck(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}var n=[[{color:"0, 0, 0",class:"ansi-black"},{color:"187, 0, 0",class:"ansi-red"},{color:"0, 187, 0",class:"ansi-green"},{color:"187, 187, 0",class:"ansi-yellow"},{color:"0, 0, 187",class:"ansi-blue"},{color:"187, 0, 187",class:"ansi-magenta"},{color:"0, 187, 187",class:"ansi-cyan"},{color:"255,255,255",class:"ansi-white"}],[{color:"85, 85, 85",class:"ansi-bright-black"},{color:"255, 85, 85",class:"ansi-bright-red"},{color:"0, 255, 0",class:"ansi-bright-green"},{color:"255, 255, 85",class:"ansi-bright-yellow"},{color:"85, 85, 255",class:"ansi-bright-blue"},{color:"255, 85, 255",class:"ansi-bright-magenta"},{color:"85, 255, 255",class:"ansi-bright-cyan"},{color:"255, 255, 255",class:"ansi-bright-white"}]];var s=function(){r(Anser,null,[{key:"escapeForHtml",value:function escapeForHtml(e){return(new Anser).escapeForHtml(e)}},{key:"linkify",value:function linkify(e){return(new Anser).linkify(e)}},{key:"ansiToHtml",value:function ansiToHtml(e,r){return(new Anser).ansiToHtml(e,r)}},{key:"ansiToJson",value:function ansiToJson(e,r){return(new Anser).ansiToJson(e,r)}},{key:"ansiToText",value:function ansiToText(e){return(new Anser).ansiToText(e)}}]);function Anser(){_classCallCheck(this,Anser);this.fg=this.bg=this.fg_truecolor=this.bg_truecolor=null;this.bright=0}r(Anser,[{key:"setupPalette",value:function setupPalette(){this.PALETTE_COLORS=[];for(var e=0;e<2;++e){for(var r=0;r<8;++r){this.PALETTE_COLORS.push(n[e][r].color)}}var s=[0,95,135,175,215,255];var i=function format(e,r,n){return s[e]+", "+s[r]+", "+s[n]};var t=void 0,o=void 0,a=void 0;for(var l=0;l<6;++l){for(var c=0;c<6;++c){for(var u=0;u<6;++u){this.PALETTE_COLORS.push(i(l,c,u))}}}var f=8;for(var h=0;h<24;++h,f+=10){this.PALETTE_COLORS.push(i(f,f,f))}}},{key:"escapeForHtml",value:function escapeForHtml(e){return e.replace(/[&<>]/gm,(function(e){return e=="&"?"&amp;":e=="<"?"&lt;":e==">"?"&gt;":""}))}},{key:"linkify",value:function linkify(e){return e.replace(/(https?:\/\/[^\s]+)/gm,(function(e){return'<a href="'+e+'">'+e+"</a>"}))}},{key:"ansiToHtml",value:function ansiToHtml(e,r){return this.process(e,r,true)}},{key:"ansiToJson",value:function ansiToJson(e,r){r=r||{};r.json=true;r.clearLine=false;return this.process(e,r,true)}},{key:"ansiToText",value:function ansiToText(e){return this.process(e,{},false)}},{key:"process",value:function process(e,r,n){var s=this;var i=this;var t=e.split(/\033\[/);var o=t.shift();if(r===undefined||r===null){r={}}r.clearLine=/\r/.test(e);var a=t.map((function(e){return s.processChunk(e,r,n)}));if(r&&r.json){var l=i.processChunkJson("");l.content=o;l.clearLine=r.clearLine;a.unshift(l);if(r.remove_empty){a=a.filter((function(e){return!e.isEmpty()}))}return a}else{a.unshift(o)}return a.join("")}},{key:"processChunkJson",value:function processChunkJson(e,r,s){r=typeof r=="undefined"?{}:r;var i=r.use_classes=typeof r.use_classes!="undefined"&&r.use_classes;var t=r.key=i?"class":"color";var o={content:e,fg:null,bg:null,fg_truecolor:null,bg_truecolor:null,clearLine:r.clearLine,decoration:null,was_processed:false,isEmpty:function isEmpty(){return!o.content}};var a=e.match(/^([!\x3c-\x3f]*)([\d;]*)([\x20-\x2c]*[\x40-\x7e])([\s\S]*)/m);if(!a)return o;var l=o.content=a[4];var c=a[2].split(";");if(a[1]!==""||a[3]!=="m"){return o}if(!s){return o}var u=this;u.decoration=null;while(c.length>0){var f=c.shift();var h=parseInt(f);if(isNaN(h)||h===0){u.fg=u.bg=u.decoration=null}else if(h===1){u.decoration="bold"}else if(h===2){u.decoration="dim"}else if(h==3){u.decoration="italic"}else if(h==4){u.decoration="underline"}else if(h==5){u.decoration="blink"}else if(h===7){u.decoration="reverse"}else if(h===8){u.decoration="hidden"}else if(h===9){u.decoration="strikethrough"}else if(h==39){u.fg=null}else if(h==49){u.bg=null}else if(h>=30&&h<38){u.fg=n[0][h%10][t]}else if(h>=90&&h<98){u.fg=n[1][h%10][t]}else if(h>=40&&h<48){u.bg=n[0][h%10][t]}else if(h>=100&&h<108){u.bg=n[1][h%10][t]}else if(h===38||h===48){var p=h===38;if(c.length>=1){var g=c.shift();if(g==="5"&&c.length>=1){var v=parseInt(c.shift());if(v>=0&&v<=255){if(!i){if(!this.PALETTE_COLORS){u.setupPalette()}if(p){u.fg=this.PALETTE_COLORS[v]}else{u.bg=this.PALETTE_COLORS[v]}}else{var d=v>=16?"ansi-palette-"+v:n[v>7?1:0][v%8]["class"];if(p){u.fg=d}else{u.bg=d}}}}else if(g==="2"&&c.length>=3){var _=parseInt(c.shift());var b=parseInt(c.shift());var y=parseInt(c.shift());if(_>=0&&_<=255&&b>=0&&b<=255&&y>=0&&y<=255){var k=_+", "+b+", "+y;if(!i){if(p){u.fg=k}else{u.bg=k}}else{if(p){u.fg="ansi-truecolor";u.fg_truecolor=k}else{u.bg="ansi-truecolor";u.bg_truecolor=k}}}}}}}if(u.fg===null&&u.bg===null&&u.decoration===null){return o}else{var T=[];var m=[];var w={};o.fg=u.fg;o.bg=u.bg;o.fg_truecolor=u.fg_truecolor;o.bg_truecolor=u.bg_truecolor;o.decoration=u.decoration;o.was_processed=true;return o}}},{key:"processChunk",value:function processChunk(e,r,n){var s=this;var i=this;r=r||{};var t=this.processChunkJson(e,r,n);if(r.json){return t}if(t.isEmpty()){return""}if(!t.was_processed){return t.content}var o=r.use_classes;var a=[];var l=[];var c={};var u=function render_data(e){var r=[];var n=void 0;for(n in e){if(e.hasOwnProperty(n)){r.push("data-"+n+'="'+s.escapeForHtml(e[n])+'"')}}return r.length>0?" "+r.join(" "):""};if(t.fg){if(o){l.push(t.fg+"-fg");if(t.fg_truecolor!==null){c["ansi-truecolor-fg"]=t.fg_truecolor;t.fg_truecolor=null}}else{a.push("color:rgb("+t.fg+")")}}if(t.bg){if(o){l.push(t.bg+"-bg");if(t.bg_truecolor!==null){c["ansi-truecolor-bg"]=t.bg_truecolor;t.bg_truecolor=null}}else{a.push("background-color:rgb("+t.bg+")")}}if(t.decoration){if(o){l.push("ansi-"+t.decoration)}else if(t.decoration==="bold"){a.push("font-weight:bold")}else if(t.decoration==="dim"){a.push("opacity:0.5")}else if(t.decoration==="italic"){a.push("font-style:italic")}else if(t.decoration==="reverse"){a.push("filter:invert(100%)")}else if(t.decoration==="hidden"){a.push("visibility:hidden")}else if(t.decoration==="strikethrough"){a.push("text-decoration:line-through")}else{a.push("text-decoration:"+t.decoration)}}if(o){return'<span class="'+l.join(" ")+'"'+u(c)+">"+t.content+"</span>"}else{return'<span style="'+a.join(";")+'"'+u(c)+">"+t.content+"</span>"}}}]);return Anser}();e.exports=s}};var r={};function __nccwpck_require__(n){var s=r[n];if(s!==undefined){return s.exports}var i=r[n]={exports:{}};var t=true;try{e[n](i,i.exports,__nccwpck_require__);t=false}finally{if(t)delete r[n]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(211);module.exports=n})();
\ No newline at end of file
{"name":"anser","main":"index.js","author":"Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)","license":"MIT"}
(()=>{var e={553:function(e){(function(r,t){if(true){e.exports=t(r)}else{}})(typeof global!="undefined"?global:this,(function(e){if(e.CSS&&e.CSS.escape){return e.CSS.escape}var cssEscape=function(e){if(arguments.length==0){throw new TypeError("`CSS.escape` requires an argument.")}var r=String(e);var t=r.length;var n=-1;var a;var i="";var u=r.charCodeAt(0);while(++n<t){a=r.charCodeAt(n);if(a==0){i+="�";continue}if(a>=1&&a<=31||a==127||n==0&&a>=48&&a<=57||n==1&&a>=48&&a<=57&&u==45){i+="\\"+a.toString(16)+" ";continue}if(n==0&&t==1&&a==45){i+="\\"+r.charAt(n);continue}if(a>=128||a==45||a==95||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122){i+=r.charAt(n);continue}i+="\\"+r.charAt(n)}return i};if(!e.CSS){e.CSS={}}e.CSS.escape=cssEscape;return cssEscape}))}};var r={};function __nccwpck_require__(t){var n=r[t];if(n!==undefined){return n.exports}var a=r[t]={exports:{}};var i=true;try{e[t].call(a.exports,a,a.exports,__nccwpck_require__);i=false}finally{if(i)delete r[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(553);module.exports=t})();
\ No newline at end of file
{"name":"css.escape","main":"css.escape.js","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"license":"MIT"}
(()=>{"use strict";var e={151:e=>{function dataUriToBuffer(e){if(!/^data:/i.test(e)){throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")')}e=e.replace(/\r?\n/g,"");const r=e.indexOf(",");if(r===-1||r<=4){throw new TypeError("malformed data: URI")}const t=e.substring(5,r).split(";");let a="";let i=false;const s=t[0]||"text/plain";let n=s;for(let e=1;e<t.length;e++){if(t[e]==="base64"){i=true}else{n+=`;${t[e]}`;if(t[e].indexOf("charset=")===0){a=t[e].substring(8)}}}if(!t[0]&&!a.length){n+=";charset=US-ASCII";a="US-ASCII"}const o=i?"base64":"ascii";const f=unescape(e.substring(r+1));const _=Buffer.from(f,o);_.type=s;_.typeFull=n;_.charset=a;return _}e.exports=dataUriToBuffer}};var r={};function __nccwpck_require__(t){var a=r[t];if(a!==undefined){return a.exports}var i=r[t]={exports:{}};var s=true;try{e[t](i,i.exports,__nccwpck_require__);s=false}finally{if(s)delete r[t]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(151);module.exports=t})();
\ No newline at end of file
{"name":"data-uri-to-buffer","main":"index.js","author":"Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)","license":"MIT"}
Copyright 2014-2020 Benjamin Tan
Copyright 2011-2013 John-David Dalton
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{"name":"platform","main":"platform.js","author":"Benjamin Tan <demoneaux@gmail.com>","license":"MIT"}
(()=>{var e={541:function(e,i,t){e=t.nmd(e);
/*!
* Platform.js v1.3.6
* Copyright 2014-2020 Benjamin Tan
* Copyright 2011-2013 John-David Dalton
* Available under MIT license
*/(function(){"use strict";var t={function:true,object:true};var r=t[typeof window]&&window||this;var a=r;var n=t[typeof i]&&i;var o=t["object"]&&e&&!e.nodeType&&e;var l=n&&o&&typeof global=="object"&&global;if(l&&(l.global===l||l.window===l||l.self===l)){r=l}var s=Math.pow(2,53)-1;var f=/\bOpera/;var b=this;var c=Object.prototype;var p=c.hasOwnProperty;var u=c.toString;function capitalize(e){e=String(e);return e.charAt(0).toUpperCase()+e.slice(1)}function cleanupOS(e,i,t){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};if(i&&t&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])){e="Windows "+r}e=String(e);if(i&&t){e=e.replace(RegExp(i,"i"),t)}e=format(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0]);return e}function each(e,i){var t=-1,r=e?e.length:0;if(typeof r=="number"&&r>-1&&r<=s){while(++t<r){i(e[t],t,e)}}else{forOwn(e,i)}}function format(e){e=trim(e);return/^(?:webOS|i(?:OS|P))/.test(e)?e:capitalize(e)}function forOwn(e,i){for(var t in e){if(p.call(e,t)){i(e[t],t,e)}}}function getClassOf(e){return e==null?capitalize(e):u.call(e).slice(8,-1)}function isHostType(e,i){var t=e!=null?typeof e[i]:"number";return!/^(?:boolean|number|string|undefined)$/.test(t)&&(t=="object"?!!e[i]:true)}function qualify(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function reduce(e,i){var t=null;each(e,(function(r,a){t=i(t,r,a,e)}));return t}function trim(e){return String(e).replace(/^ +| +$/g,"")}function parse(e){var i=r;var t=e&&typeof e=="object"&&getClassOf(e)!="String";if(t){i=e;e=null}var n=i.navigator||{};var o=n.userAgent||"";e||(e=o);var l=t||b==a;var s=t?!!n.likeChrome:/\bChrome\b/.test(e)&&!/internal|\n/i.test(u.toString());var c="Object",p=t?c:"ScriptBridgingProxyObject",d=t?c:"Environment",S=t&&i.java?"JavaPackage":getClassOf(i.java),x=t?c:"RuntimeObject";var m=/\bJava/.test(S)&&i.java;var g=m&&getClassOf(i.environment)==d;var h=m?"a":"α";var v=m?"b":"β";var O=i.document||{};var y=i.operamini||i.opera;var w=f.test(w=t&&y?y["[[Class]]"]:getClassOf(y))?w:y=null;var M;var E=e;var P=[];var C=null;var k=e==o;var B=k&&y&&typeof y.version=="function"&&y.version();var W;var _=getLayout([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]);var R=getName(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]);var A=getProduct([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]);var I=getManufacturer({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}});var T=getOS(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function getLayout(i){return reduce(i,(function(i,t){return i||RegExp("\\b"+(t.pattern||qualify(t))+"\\b","i").exec(e)&&(t.label||t)}))}function getManufacturer(i){return reduce(i,(function(i,t,r){return i||(t[A]||t[/^[a-z]+(?: +[a-z]+\b)*/i.exec(A)]||RegExp("\\b"+qualify(r)+"(?:\\b|\\w*\\d)","i").exec(e))&&r}))}function getName(i){return reduce(i,(function(i,t){return i||RegExp("\\b"+(t.pattern||qualify(t))+"\\b","i").exec(e)&&(t.label||t)}))}function getOS(i){return reduce(i,(function(i,t){var r=t.pattern||qualify(t);if(!i&&(i=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(e))){i=cleanupOS(i,r,t.label||t)}return i}))}function getProduct(i){return reduce(i,(function(i,t){var r=t.pattern||qualify(t);if(!i&&(i=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(e)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(e)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(e))){if((i=String(t.label&&!RegExp(r,"i").test(t.label)?t.label:i).split("/"))[1]&&!/[\d.]+/.test(i[0])){i[0]+=" "+i[1]}t=t.label||t;i=format(i[0].replace(RegExp(r,"i"),t).replace(RegExp("; *(?:"+t+"[_-])?","i")," ").replace(RegExp("("+t+")[-_.]?(\\w)","i"),"$1 $2"))}return i}))}function getVersion(i){return reduce(i,(function(i,t){return i||(RegExp(t+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(e)||0)[1]||null}))}function toStringPlatform(){return this.description||""}_&&(_=[_]);if(/\bAndroid\b/.test(T)&&!A&&(M=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(e))){A=trim(M[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null}if(I&&!A){A=getProduct([I])}else if(I&&A){A=A.replace(RegExp("^("+qualify(I)+")[-_.\\s]","i"),I+" ").replace(RegExp("^("+qualify(I)+")[-_.]?(\\w)","i"),I+" $2")}if(M=/\bGoogle TV\b/.exec(A)){A=M[0]}if(/\bSimulator\b/i.test(e)){A=(A?A+" ":"")+"Simulator"}if(R=="Opera Mini"&&/\bOPiOS\b/.test(e)){P.push("running in Turbo/Uncompressed mode")}if(R=="IE"&&/\blike iPhone OS\b/.test(e)){M=parse(e.replace(/like iPhone OS/,""));I=M.manufacturer;A=M.product}else if(/^iP/.test(A)){R||(R="Safari");T="iOS"+((M=/ OS ([\d_]+)/i.exec(e))?" "+M[1].replace(/_/g,"."):"")}else if(R=="Konqueror"&&/^Linux\b/i.test(T)){T="Kubuntu"}else if(I&&I!="Google"&&(/Chrome/.test(R)&&!/\bMobile Safari\b/i.test(e)||/\bVita\b/.test(A))||/\bAndroid\b/.test(T)&&/^Chrome/.test(R)&&/\bVersion\//i.test(e)){R="Android Browser";T=/\bAndroid\b/.test(T)?T:"Android"}else if(R=="Silk"){if(!/\bMobi/i.test(e)){T="Android";P.unshift("desktop mode")}if(/Accelerated *= *true/i.test(e)){P.unshift("accelerated")}}else if(R=="UC Browser"&&/\bUCWEB\b/.test(e)){P.push("speed mode")}else if(R=="PaleMoon"&&(M=/\bFirefox\/([\d.]+)\b/.exec(e))){P.push("identifying as Firefox "+M[1])}else if(R=="Firefox"&&(M=/\b(Mobile|Tablet|TV)\b/i.exec(e))){T||(T="Firefox OS");A||(A=M[1])}else if(!R||(M=!/\bMinefield\b/i.test(e)&&/\b(?:Firefox|Safari)\b/.exec(R))){if(R&&!A&&/[\/,]|^[^(]+?\)/.test(e.slice(e.indexOf(M+"/")+8))){R=null}if((M=A||I||T)&&(A||I||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(T))){R=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(T)?T:M)+" Browser"}}else if(R=="Electron"&&(M=(/\bChrome\/([\d.]+)\b/.exec(e)||0)[1])){P.push("Chromium "+M)}if(!B){B=getVersion(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",qualify(R),"(?:Firefox|Minefield|NetFront)"])}if(M=_=="iCab"&&parseFloat(B)>3&&"WebKit"||/\bOpera\b/.test(R)&&(/\bOPR\b/.test(e)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(_)&&"WebKit"||!_&&/\bMSIE\b/i.test(e)&&(T=="Mac OS"?"Tasman":"Trident")||_=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(R)&&"NetFront"){_=[M]}if(R=="IE"&&(M=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])){R+=" Mobile";T="Windows Phone "+(/\+$/.test(M)?M:M+".x");P.unshift("desktop mode")}else if(/\bWPDesktop\b/i.test(e)){R="IE Mobile";T="Windows Phone 8.x";P.unshift("desktop mode");B||(B=(/\brv:([\d.]+)/.exec(e)||0)[1])}else if(R!="IE"&&_=="Trident"&&(M=/\brv:([\d.]+)/.exec(e))){if(R){P.push("identifying as "+R+(B?" "+B:""))}R="IE";B=M[1]}if(k){if(isHostType(i,"global")){if(m){M=m.lang.System;E=M.getProperty("os.arch");T=T||M.getProperty("os.name")+" "+M.getProperty("os.version")}if(g){try{B=i.require("ringo/engine").version.join(".");R="RingoJS"}catch(e){if((M=i.system)&&M.global.system==i.system){R="Narwhal";T||(T=M[0].os||null)}}if(!R){R="Rhino"}}else if(typeof i.process=="object"&&!i.process.browser&&(M=i.process)){if(typeof M.versions=="object"){if(typeof M.versions.electron=="string"){P.push("Node "+M.versions.node);R="Electron";B=M.versions.electron}else if(typeof M.versions.nw=="string"){P.push("Chromium "+B,"Node "+M.versions.node);R="NW.js";B=M.versions.nw}}if(!R){R="Node.js";E=M.arch;T=M.platform;B=/[\d.]+/.exec(M.version);B=B?B[0]:null}}}else if(getClassOf(M=i.runtime)==p){R="Adobe AIR";T=M.flash.system.Capabilities.os}else if(getClassOf(M=i.phantom)==x){R="PhantomJS";B=(M=M.version||null)&&M.major+"."+M.minor+"."+M.patch}else if(typeof O.documentMode=="number"&&(M=/\bTrident\/(\d+)/i.exec(e))){B=[B,O.documentMode];if((M=+M[1]+4)!=B[1]){P.push("IE "+B[1]+" mode");_&&(_[1]="");B[1]=M}B=R=="IE"?String(B[1].toFixed(1)):B[0]}else if(typeof O.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(R)){P.push("masking as "+R+" "+B);R="IE";B="11.0";_=["Trident"];T="Windows"}T=T&&format(T)}if(B&&(M=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(B)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+";"+(k&&n.appMinorVersion))||/\bMinefield\b/i.test(e)&&"a")){C=/b/i.test(M)?"beta":"alpha";B=B.replace(RegExp(M+"\\+?$"),"")+(C=="beta"?v:h)+(/\d+\+?/.exec(M)||"")}if(R=="Fennec"||R=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(T)){R="Firefox Mobile"}else if(R=="Maxthon"&&B){B=B.replace(/\.[\d.]+/,".x")}else if(/\bXbox\b/i.test(A)){if(A=="Xbox 360"){T=null}if(A=="Xbox 360"&&/\bIEMobile\b/.test(e)){P.unshift("mobile mode")}}else if((/^(?:Chrome|IE|Opera)$/.test(R)||R&&!A&&!/Browser|Mobi/.test(R))&&(T=="Windows CE"||/Mobi/i.test(e))){R+=" Mobile"}else if(R=="IE"&&k){try{if(i.external===null){P.unshift("platform preview")}}catch(e){P.unshift("embedded")}}else if((/\bBlackBerry\b/.test(A)||/\bBB10\b/.test(e))&&(M=(RegExp(A.replace(/ +/g," *")+"/([.\\d]+)","i").exec(e)||0)[1]||B)){M=[M,/BB10/.test(e)];T=(M[1]?(A=null,I="BlackBerry"):"Device Software")+" "+M[0];B=null}else if(this!=forOwn&&A!="Wii"&&(k&&y||/Opera/.test(R)&&/\b(?:MSIE|Firefox)\b/i.test(e)||R=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(T)||R=="IE"&&(T&&!/^Win/.test(T)&&B>5.5||/\bWindows XP\b/.test(T)&&B>8||B==8&&!/\bTrident\b/.test(e)))&&!f.test(M=parse.call(forOwn,e.replace(f,"")+";"))&&M.name){M="ing as "+M.name+((M=M.version)?" "+M:"");if(f.test(R)){if(/\bIE\b/.test(M)&&T=="Mac OS"){T=null}M="identify"+M}else{M="mask"+M;if(w){R=format(w.replace(/([a-z])([A-Z])/g,"$1 $2"))}else{R="Opera"}if(/\bIE\b/.test(M)){T=null}if(!k){B=null}}_=["Presto"];P.push(M)}if(M=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1]){M=[parseFloat(M.replace(/\.(\d)$/,".0$1")),M];if(R=="Safari"&&M[1].slice(-1)=="+"){R="WebKit Nightly";C="alpha";B=M[1].slice(0,-1)}else if(B==M[1]||B==(M[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1])){B=null}M[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(e)||0)[1];if(M[0]==537.36&&M[2]==537.36&&parseFloat(M[1])>=28&&_=="WebKit"){_=["Blink"]}if(!k||!s&&!M[1]){_&&(_[1]="like Safari");M=(M=M[0],M<400?1:M<500?2:M<526?3:M<533?4:M<534?"4+":M<535?5:M<537?6:M<538?7:M<601?8:M<602?9:M<604?10:M<606?11:M<608?12:"12")}else{_&&(_[1]="like Chrome");M=M[1]||(M=M[0],M<530?1:M<532?2:M<532.05?3:M<533?4:M<534.03?5:M<534.07?6:M<534.1?7:M<534.13?8:M<534.16?9:M<534.24?10:M<534.3?11:M<535.01?12:M<535.02?"13+":M<535.07?15:M<535.11?16:M<535.19?17:M<536.05?18:M<536.1?19:M<537.01?20:M<537.11?"21+":M<537.13?23:M<537.18?24:M<537.24?25:M<537.36?26:_!="Blink"?"27":"28")}_&&(_[1]+=" "+(M+=typeof M=="number"?".x":/[.+]/.test(M)?"":"+"));if(R=="Safari"&&(!B||parseInt(B)>45)){B=M}else if(R=="Chrome"&&/\bHeadlessChrome/i.test(e)){P.unshift("headless")}}if(R=="Opera"&&(M=/\bzbov|zvav$/.exec(T))){R+=" ";P.unshift("desktop mode");if(M=="zvav"){R+="Mini";B=null}else{R+="Mobile"}T=T.replace(RegExp(" *"+M+"$"),"")}else if(R=="Safari"&&/\bChrome\b/.exec(_&&_[1])){P.unshift("desktop mode");R="Chrome Mobile";B=null;if(/\bOS X\b/.test(T)){I="Apple";T="iOS 4.3+"}else{T=null}}else if(/\bSRWare Iron\b/.test(R)&&!B){B=getVersion("Chrome")}if(B&&B.indexOf(M=/[\d.]+$/.exec(T))==0&&e.indexOf("/"+M+"-")>-1){T=trim(T.replace(M,""))}if(T&&T.indexOf(R)!=-1&&!RegExp(R+" OS").test(T)){T=T.replace(RegExp(" *"+qualify(R)+" *"),"")}if(_&&!/\b(?:Avant|Nook)\b/.test(R)&&(/Browser|Lunascape|Maxthon/.test(R)||R!="Safari"&&/^iOS/.test(T)&&/\bSafari\b/.test(_[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(R)&&_[1])){(M=_[_.length-1])&&P.push(M)}if(P.length){P=["("+P.join("; ")+")"]}if(I&&A&&A.indexOf(I)<0){P.push("on "+I)}if(A){P.push((/^on /.test(P[P.length-1])?"":"on ")+A)}if(T){M=/ ([\d.+]+)$/.exec(T);W=M&&T.charAt(T.length-M[0].length-1)=="/";T={architecture:32,family:M&&!W?T.replace(M[0],""):T,version:M?M[1]:null,toString:function(){var e=this.version;return this.family+(e&&!W?" "+e:"")+(this.architecture==64?" 64-bit":"")}}}if((M=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(E))&&!/\bi686\b/i.test(E)){if(T){T.architecture=64;T.family=T.family.replace(RegExp(" *"+M),"")}if(R&&(/\bWOW64\b/i.test(e)||k&&/\w(?:86|32)$/.test(n.cpuClass||n.platform)&&!/\bWin64; x64\b/i.test(e))){P.unshift("32-bit")}}else if(T&&/^OS X/.test(T.family)&&R=="Chrome"&&parseFloat(B)>=39){T.architecture=64}e||(e=null);var F={};F.description=e;F.layout=_&&_[0];F.manufacturer=I;F.name=R;F.prerelease=C;F.product=A;F.ua=e;F.version=R&&B;F.os=T||{architecture:null,family:null,version:null,toString:function(){return"null"}};F.parse=parse;F.toString=toStringPlatform;if(F.version){P.unshift(B)}if(F.name){P.unshift(R)}if(T&&R&&!(T==String(T).split(" ")[0]&&(T==R.split(" ")[0]||A))){P.push(A?"("+T+")":"on "+T)}if(P.length){F.description=P.join(" ")}return F}var d=parse();if(n&&o){forOwn(d,(function(e,i){n[i]=e}))}else{r.platform=d}}).call(this)}};var i={};function __nccwpck_require__(t){var r=i[t];if(r!==undefined){return r.exports}var a=i[t]={id:t,loaded:false,exports:{}};var n=true;try{e[t].call(a.exports,a,a.exports,__nccwpck_require__);n=false}finally{if(n)delete i[t]}a.loaded=true;return a.exports}(()=>{__nccwpck_require__.nmd=e=>{e.paths=[];if(!e.children)e.children=[];return e}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(541);module.exports=t})();
\ No newline at end of file
The MIT License
Copyright (c) 2013 James Halliday (mail@substack.net)
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
(()=>{if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var e={};(()=>{var r=e;r.quote=function(e){return e.map((function(e){if(e&&typeof e==="object"){return e.op.replace(/(.)/g,"\\$1")}else if(/["\s]/.test(e)&&!/'/.test(e)){return"'"+e.replace(/(['\\])/g,"\\$1")+"'"}else if(/["'\s]/.test(e)){return'"'+e.replace(/(["\\$`!])/g,"\\$1")+'"'}else{return String(e).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@\[\\\]^`{|}])/g,"$1\\$2")}})).join(" ")};var t="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(",">>",">\\&","[&;()|<>]"].join("|")+")";var n="|&;()<> \\t";var i="(\\\\['\""+n+"]|[^\\s'\""+n+"])+";var a='"((\\\\"|[^"])*?)"';var f="'((\\\\'|[^'])*?)'";var s="";for(var u=0;u<4;u++){s+=(Math.pow(16,8)*Math.random()).toString(16)}r.parse=function(e,r,t){var n=parse(e,r,t);if(typeof r!=="function")return n;return n.reduce((function(e,r){if(typeof r==="object")return e.concat(r);var t=r.split(RegExp("("+s+".*?"+s+")","g"));if(t.length===1)return e.concat(t[0]);return e.concat(t.filter(Boolean).map((function(e){if(RegExp("^"+s).test(e)){return JSON.parse(e.split(s)[1])}else return e})))}),[])};function parse(e,r,n){var u=new RegExp(["("+t+")","("+i+"|"+a+"|"+f+")*"].join("|"),"g");var o=e.match(u).filter(Boolean);var l=false;if(!o)return[];if(!r)r={};if(!n)n={};return o.map((function(e,r){if(l){return}if(RegExp("^"+t+"$").test(e)){return{op:e}}var i="'";var a='"';var f="$";var s=n.escape||"\\";var u=false;var c=false;var p="";var v=false;for(var g=0,d=e.length;g<d;g++){var h=e.charAt(g);v=v||!u&&(h==="*"||h==="?");if(c){p+=h;c=false}else if(u){if(h===u){u=false}else if(u==i){p+=h}else{if(h===s){g+=1;h=e.charAt(g);if(h===a||h===s||h===f){p+=h}else{p+=s+h}}else if(h===f){p+=parseEnvVar()}else{p+=h}}}else if(h===a||h===i){u=h}else if(RegExp("^"+t+"$").test(h)){return{op:e}}else if(RegExp("^#$").test(h)){l=true;if(p.length){return[p,{comment:e.slice(g+1)+o.slice(r+1).join(" ")}]}return[{comment:e.slice(g+1)+o.slice(r+1).join(" ")}]}else if(h===s){c=true}else if(h===f){p+=parseEnvVar()}else p+=h}if(v)return{op:"glob",pattern:p};return p;function parseEnvVar(){g+=1;var r,t;if(e.charAt(g)==="{"){g+=1;if(e.charAt(g)==="}"){throw new Error("Bad substitution: "+e.substr(g-2,3))}r=e.indexOf("}",g);if(r<0){throw new Error("Bad substitution: "+e.substr(g))}t=e.substr(g,r-g);g=r}else if(/[*@#?$!_\-]/.test(e.charAt(g))){t=e.charAt(g);g+=1}else{r=e.substr(g).match(/[^\w\d_]/);if(!r){t=e.substr(g);g=e.length}else{t=e.substr(g,r.index);g+=r.index-1}}return getVar(null,"",t)}})).reduce((function(e,r){if(r===undefined){return e}return e.concat(r)}),[]);function getVar(e,t,n){var i=typeof r==="function"?r(n):r[n];if(i===undefined&&n!="")i="";else if(i===undefined)i="$";if(typeof i==="object"){return t+s+JSON.stringify(i)+s}else return t+i}}})();module.exports=e})();
\ No newline at end of file
{"name":"shell-quote","main":"index.js","author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"license":"MIT"}
MIT License
Copyright (c) 2014-2019 Georg Tavonius
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{"name":"stacktrace-parser","main":"stack-trace-parser.cjs.js","author":"Georg Tavonius <g.tavonius@gmail.com> (http://jaz-lounge.com)","license":"MIT"}
(()=>{"use strict";if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var e={};(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:true});var n="<unknown>";function parse(e){var r=e.split("\n");return r.reduce((function(e,r){var n=parseChrome(r)||parseWinjs(r)||parseGecko(r)||parseNode(r)||parseJSC(r);if(n){e.push(n)}return e}),[])}var a=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;var l=/\((\S*)(?::(\d+))(?::(\d+))\)/;function parseChrome(e){var r=a.exec(e);if(!r){return null}var u=r[2]&&r[2].indexOf("native")===0;var t=r[2]&&r[2].indexOf("eval")===0;var i=l.exec(r[2]);if(t&&i!=null){r[2]=i[1];r[3]=i[2];r[4]=i[3]}return{file:!u?r[2]:null,methodName:r[1]||n,arguments:u?[r[2]]:[],lineNumber:r[3]?+r[3]:null,column:r[4]?+r[4]:null}}var u=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;function parseWinjs(e){var r=u.exec(e);if(!r){return null}return{file:r[2],methodName:r[1]||n,arguments:[],lineNumber:+r[3],column:r[4]?+r[4]:null}}var t=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;var i=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function parseGecko(e){var r=t.exec(e);if(!r){return null}var a=r[3]&&r[3].indexOf(" > eval")>-1;var l=i.exec(r[3]);if(a&&l!=null){r[3]=l[1];r[4]=l[2];r[5]=null}return{file:r[3],methodName:r[1]||n,arguments:r[2]?r[2].split(","):[],lineNumber:r[4]?+r[4]:null,column:r[5]?+r[5]:null}}var s=/^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;function parseJSC(e){var r=s.exec(e);if(!r){return null}return{file:r[3],methodName:r[1]||n,arguments:[],lineNumber:+r[4],column:r[5]?+r[5]:null}}var o=/^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;function parseNode(e){var r=o.exec(e);if(!r){return null}return{file:r[2],methodName:r[1]||n,arguments:[],lineNumber:+r[3],column:r[4]?+r[4]:null}}r.parse=parse})();module.exports=e})();
\ No newline at end of file
......@@ -152,11 +152,13 @@
"@types/micromatch": "4.0.2",
"@types/node-fetch": "2.6.1",
"@types/path-to-regexp": "1.7.0",
"@types/platform": "1.3.4",
"@types/react": "16.9.17",
"@types/react-dom": "16.9.4",
"@types/react-is": "16.7.1",
"@types/semver": "7.3.1",
"@types/send": "0.14.4",
"@types/shell-quote": "1.7.1",
"@types/tar": "4.0.3",
"@types/text-table": "0.2.1",
"@types/ua-parser-js": "0.7.36",
......@@ -168,6 +170,7 @@
"acorn": "8.5.0",
"ajv": "8.11.0",
"amphtml-validator": "1.0.35",
"anser": "1.4.9",
"arg": "4.1.0",
"assert": "2.0.0",
"async-retry": "1.2.3",
......@@ -190,7 +193,9 @@
"cookie": "0.4.1",
"cross-spawn": "6.0.5",
"crypto-browserify": "3.12.0",
"css.escape": "1.5.1",
"cssnano-simple": "3.0.1",
"data-uri-to-buffer": "3.0.1",
"debug": "4.1.1",
"devalue": "2.0.1",
"domain-browser": "4.19.0",
......@@ -228,6 +233,7 @@
"p-limit": "3.1.0",
"path-browserify": "1.0.1",
"path-to-regexp": "6.1.0",
"platform": "1.3.6",
"postcss-flexbugs-fixes": "5.0.2",
"postcss-modules-extract-imports": "3.0.0",
"postcss-modules-local-by-default": "4.0.0",
......@@ -251,7 +257,9 @@
"semver": "7.3.2",
"send": "0.17.1",
"setimmediate": "1.0.5",
"shell-quote": "1.7.3",
"source-map": "0.6.1",
"stacktrace-parser": "0.1.10",
"stream-browserify": "3.0.0",
"stream-http": "3.1.1",
"string-hash": "1.1.3",
......
......@@ -169,6 +169,76 @@ export async function ncc_node_fetch(task, opts) {
.target('compiled/node-fetch')
}
externals['anser'] = 'next/dist/compiled/anser'
export async function ncc_node_anser(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('anser')))
.ncc({ packageName: 'anser', externals })
.target('compiled/anser')
}
externals['stacktrace-parser'] = 'next/dist/compiled/stacktrace-parser'
export async function ncc_node_stacktrace_parser(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('stacktrace-parser'))
)
.ncc({ packageName: 'stacktrace-parser', externals })
.target('compiled/stacktrace-parser')
}
externals['data-uri-to-buffer'] = 'next/dist/compiled/data-uri-to-buffer'
export async function ncc_node_data_uri_to_buffer(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('data-uri-to-buffer'))
)
.ncc({ packageName: 'data-uri-to-buffer', externals })
.target('compiled/data-uri-to-buffer')
}
externals['css.escape'] = 'next/dist/compiled/css.escape'
export async function ncc_node_cssescape(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('css.escape')))
.ncc({ packageName: 'css.escape', externals })
.target('compiled/css.escape')
}
externals['shell-quote'] = 'next/dist/compiled/shell-quote'
export async function ncc_node_shell_quote(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('shell-quote')))
.ncc({ packageName: 'shell-quote', externals })
.target('compiled/shell-quote')
}
externals['platform'] = 'next/dist/compiled/platform'
export async function ncc_node_platform(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('platform')))
.ncc({ packageName: 'platform', externals })
.target('compiled/platform')
const clientFile = join(__dirname, 'compiled/platform/platform.js')
const content = fs.readFileSync(clientFile, 'utf8')
// remove AMD define branch as this forces the module to not
// be treated as commonjs in serverless/client mode
fs.writeFileSync(
clientFile,
content.replace(
new RegExp(
'if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){r.platform=d;define((function(){return d}))}else '.replace(
/[|\\{}()[\]^$+*?.-]/g,
'\\$&'
),
'g'
),
''
)
)
}
externals['undici'] = 'next/dist/compiled/undici'
export async function ncc_undici(task, opts) {
await task
......@@ -1850,6 +1920,12 @@ export async function ncc(task, opts) {
'ncc_get_orientation',
'ncc_hapi_accept',
'ncc_node_fetch',
'ncc_node_anser',
'ncc_node_stacktrace_parser',
'ncc_node_data_uri_to_buffer',
'ncc_node_cssescape',
'ncc_node_platform',
'ncc_node_shell_quote',
'ncc_undici',
'ncc_acorn',
'ncc_amphtml_validator',
......
......@@ -339,6 +339,35 @@ declare module 'next/dist/compiled/@segment/ajv-human-errors' {
export = m
}
declare module 'next/dist/compiled/stacktrace-parser' {
import * as m from 'stacktrace-parser'
export = m
}
declare module 'next/dist/compiled/anser' {
import * as m from 'anser'
export = m
}
declare module 'next/dist/compiled/platform' {
import * as m from 'platform'
export = m
}
declare module 'next/dist/compiled/css.escape' {
export = CSS.escape
}
declare module 'next/dist/compiled/data-uri-to-buffer' {
import * as m from 'data-uri-to-buffer'
export = m
}
declare module 'next/dist/compiled/shell-quote' {
import * as m from 'shell-quote'
export = m
}
declare namespace NodeJS {
interface ProcessVersions {
pnp?: string
......
......@@ -499,11 +499,13 @@ importers:
'@types/micromatch': 4.0.2
'@types/node-fetch': 2.6.1
'@types/path-to-regexp': 1.7.0
'@types/platform': 1.3.4
'@types/react': 16.9.17
'@types/react-dom': 16.9.4
'@types/react-is': 16.7.1
'@types/semver': 7.3.1
'@types/send': 0.14.4
'@types/shell-quote': 1.7.1
'@types/tar': 4.0.3
'@types/text-table': 0.2.1
'@types/ua-parser-js': 0.7.36
......@@ -515,6 +517,7 @@ importers:
acorn: 8.5.0
ajv: 8.11.0
amphtml-validator: 1.0.35
anser: 1.4.9
arg: 4.1.0
assert: 2.0.0
async-retry: 1.2.3
......@@ -538,7 +541,9 @@ importers:
cookie: 0.4.1
cross-spawn: 6.0.5
crypto-browserify: 3.12.0
css.escape: 1.5.1
cssnano-simple: 3.0.1
data-uri-to-buffer: 3.0.1
debug: 4.1.1
devalue: 2.0.1
domain-browser: 4.19.0
......@@ -576,6 +581,7 @@ importers:
p-limit: 3.1.0
path-browserify: 1.0.1
path-to-regexp: 6.1.0
platform: 1.3.6
postcss: 8.4.14
postcss-flexbugs-fixes: 5.0.2
postcss-modules-extract-imports: 3.0.0
......@@ -600,7 +606,9 @@ importers:
semver: 7.3.2
send: 0.17.1
setimmediate: 1.0.5
shell-quote: 1.7.3
source-map: 0.6.1
stacktrace-parser: 0.1.10
stream-browserify: 3.0.0
stream-http: 3.1.1
string_decoder: 1.3.0
......@@ -691,11 +699,13 @@ importers:
'@types/micromatch': 4.0.2
'@types/node-fetch': 2.6.1
'@types/path-to-regexp': 1.7.0
'@types/platform': 1.3.4
'@types/react': 16.9.17
'@types/react-dom': 16.9.4
'@types/react-is': 16.7.1
'@types/semver': 7.3.1
'@types/send': 0.14.4
'@types/shell-quote': 1.7.1
'@types/tar': 4.0.3
'@types/text-table': 0.2.1
'@types/ua-parser-js': 0.7.36
......@@ -707,6 +717,7 @@ importers:
acorn: 8.5.0
ajv: 8.11.0
amphtml-validator: 1.0.35
anser: 1.4.9
arg: 4.1.0
assert: 2.0.0
async-retry: 1.2.3
......@@ -729,7 +740,9 @@ importers:
cookie: 0.4.1
cross-spawn: 6.0.5
crypto-browserify: 3.12.0
css.escape: 1.5.1
cssnano-simple: 3.0.1_postcss@8.4.14
data-uri-to-buffer: 3.0.1
debug: 4.1.1
devalue: 2.0.1
domain-browser: 4.19.0
......@@ -767,6 +780,7 @@ importers:
p-limit: 3.1.0
path-browserify: 1.0.1
path-to-regexp: 6.1.0
platform: 1.3.6
postcss-flexbugs-fixes: 5.0.2_postcss@8.4.14
postcss-modules-extract-imports: 3.0.0_postcss@8.4.14
postcss-modules-local-by-default: 4.0.0_postcss@8.4.14
......@@ -790,7 +804,9 @@ importers:
semver: 7.3.2
send: 0.17.1
setimmediate: 1.0.5
shell-quote: 1.7.3
source-map: 0.6.1
stacktrace-parser: 0.1.10
stream-browserify: 3.0.0
stream-http: 3.1.1
string_decoder: 1.3.0
......@@ -7686,6 +7702,13 @@ packages:
path-to-regexp: 6.1.0
dev: true
/@types/platform/1.3.4:
resolution:
{
integrity: sha512-U0o4K+GNiK0PNxoDwd8xRnvLVe4kzei6opn3/FCjAriqaP+rfrDdSl1kP/hLL6Y3/Y3hhGnBwD4dCkkAqs1W/Q==,
}
dev: true
/@types/prettier/2.2.3:
resolution:
{
......@@ -7845,6 +7868,13 @@ packages:
'@types/node': 17.0.21
dev: true
/@types/shell-quote/1.7.1:
resolution:
{
integrity: sha512-SWZ2Nom1pkyXCDohRSrkSKvDh8QOG9RfAsrt5/NsPQC4UQJ55eG0qClA40I+Gkez4KTQ0uDUT8ELRXThf3J5jw==,
}
dev: true
/@types/source-list-map/0.1.2:
resolution:
{
......@@ -8786,7 +8816,6 @@ packages:
{
integrity: sha512-AI+BjTeGt2+WFk4eWcqbQ7snZpDBt8SaLlj0RT2h5xfdWaiy51OjYvqwMrNzJLGy8iOAL6nKDITWO+rd4MkYEA==,
}
dev: false
/ansi-align/3.0.0:
resolution:
......@@ -12246,7 +12275,6 @@ packages:
{
integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==,
}
dev: false
/css/3.0.0:
resolution:
......@@ -12537,7 +12565,6 @@ packages:
integrity: sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==,
}
engines: { node: '>= 6' }
dev: false
/data-urls/2.0.0:
resolution:
......@@ -23465,7 +23492,6 @@ packages:
{
integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==,
}
dev: false
/playwright-chromium/1.22.2:
resolution:
......@@ -27636,7 +27662,6 @@ packages:
engines: { node: '>=6' }
dependencies:
type-fest: 0.7.1
dev: false
/state-toggle/1.0.2:
resolution:
......@@ -29164,7 +29189,6 @@ packages:
integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==,
}
engines: { node: '>=8' }
dev: false
/type-fest/0.8.1:
resolution:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment