next 15.2.0-canary.47 → 15.2.0-canary.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of next might be problematic. Click here for more details.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/app-dir/link.d.ts +108 -28
- package/dist/client/app-dir/link.js +6 -4
- package/dist/client/app-dir/link.js.map +1 -1
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +3 -2
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +8 -6
- package/dist/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
- package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +2 -3
- package/dist/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
- package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js +39 -13
- package/dist/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
- package/dist/client/components/react-dev-overlay/server/middleware-webpack.js +13 -3
- package/dist/client/components/react-dev-overlay/server/middleware-webpack.js.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page-experimental.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/app-page.runtime.dev.js +2 -2
- package/dist/compiled/next-server/app-page.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js +6 -6
- package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
- package/dist/esm/build/index.js +2 -2
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/app-dir/link.js +6 -4
- package/dist/esm/client/app-dir/link.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js +3 -2
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js +8 -6
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js +2 -3
- package/dist/esm/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js +39 -13
- package/dist/esm/client/components/react-dev-overlay/server/middleware-turbopack.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/server/middleware-webpack.js +13 -3
- package/dist/esm/client/components/react-dev-overlay/server/middleware-webpack.js.map +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/lib/metadata/types/metadata-interface.js +13 -1
- package/dist/esm/lib/metadata/types/metadata-interface.js.map +1 -1
- package/dist/esm/server/config.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/server/patch-error-inspect.js +42 -15
- package/dist/esm/server/patch-error-inspect.js.map +1 -1
- package/dist/lib/metadata/types/metadata-interface.d.ts +252 -179
- package/dist/lib/metadata/types/metadata-interface.js +13 -1
- package/dist/lib/metadata/types/metadata-interface.js.map +1 -1
- package/dist/server/config.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/server/patch-error-inspect.js +42 -15
- package/dist/server/patch-error-inspect.js.map +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
package/dist/esm/build/index.js
CHANGED
|
@@ -296,7 +296,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
|
296
296
|
const nextBuildSpan = trace('next-build', undefined, {
|
|
297
297
|
buildMode: experimentalBuildMode,
|
|
298
298
|
isTurboBuild: String(turboNextBuild),
|
|
299
|
-
version: "15.2.0-canary.
|
|
299
|
+
version: "15.2.0-canary.48"
|
|
300
300
|
});
|
|
301
301
|
NextBuildContext.nextBuildSpan = nextBuildSpan;
|
|
302
302
|
NextBuildContext.dir = dir;
|
|
@@ -661,7 +661,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
|
661
661
|
// Files outside of the distDir can be "type": "module"
|
|
662
662
|
await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
|
663
663
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
|
664
|
-
await recordFrameworkVersion("15.2.0-canary.
|
|
664
|
+
await recordFrameworkVersion("15.2.0-canary.48");
|
|
665
665
|
await updateBuildDiagnostics({
|
|
666
666
|
buildStage: 'start'
|
|
667
667
|
});
|
|
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
|
|
|
11
11
|
import { getDefineEnv } from '../webpack/plugins/define-env-plugin';
|
|
12
12
|
import { getReactCompilerLoader } from '../get-babel-loader-config';
|
|
13
13
|
import { TurbopackInternalError } from '../../shared/lib/turbopack/utils';
|
|
14
|
-
const nextVersion = "15.2.0-canary.
|
|
14
|
+
const nextVersion = "15.2.0-canary.48";
|
|
15
15
|
const ArchName = arch();
|
|
16
16
|
const PlatformName = platform();
|
|
17
17
|
function infoLog(...args) {
|
|
@@ -1411,7 +1411,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1411
1411
|
isClient && new CopyFilePlugin({
|
|
1412
1412
|
// file path to build output of `@next/polyfill-nomodule`
|
|
1413
1413
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
|
1414
|
-
cacheKey: "15.2.0-canary.
|
|
1414
|
+
cacheKey: "15.2.0-canary.48",
|
|
1415
1415
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
|
1416
1416
|
minimize: false,
|
|
1417
1417
|
info: {
|
|
@@ -1644,7 +1644,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1644
1644
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
|
1645
1645
|
// - Next.js version
|
|
1646
1646
|
// - next.config.js keys that affect compilation
|
|
1647
|
-
version: `${__dirname}|${"15.2.0-canary.
|
|
1647
|
+
version: `${__dirname}|${"15.2.0-canary.48"}|${configVars}`,
|
|
1648
1648
|
cacheDirectory: path.join(distDir, 'cache', 'webpack'),
|
|
1649
1649
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
|
1650
1650
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
|
@@ -209,12 +209,14 @@ function formatStringOrUrl(urlObjOrString) {
|
|
|
209
209
|
return formatUrl(urlObjOrString);
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
212
|
-
* A React component that extends the HTML `<a>` element to provide
|
|
213
|
-
* and
|
|
212
|
+
* A React component that extends the HTML `<a>` element to provide
|
|
213
|
+
* [prefetching](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching)
|
|
214
|
+
* and client-side navigation. This is the primary way to navigate between routes in Next.js.
|
|
214
215
|
*
|
|
215
|
-
*
|
|
216
|
+
* @remarks
|
|
217
|
+
* - Prefetching is only enabled in production.
|
|
216
218
|
*
|
|
217
|
-
*
|
|
219
|
+
* @see https://nextjs.org/docs/app/api-reference/components/link
|
|
218
220
|
*/ const Link = /*#__PURE__*/ React.forwardRef(function LinkComponent(props, forwardedRef) {
|
|
219
221
|
let children;
|
|
220
222
|
const { href: hrefProp, as: asProp, children: childrenProp, prefetch: prefetchProp = null, passHref, replace, shallow, scroll, onClick, onMouseEnter: onMouseEnterProp, onTouchStart: onTouchStartProp, legacyBehavior = false, ...restProps } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/app-dir/link.tsx"],"sourcesContent":["'use client'\n\nimport type { NextRouter } from '../../shared/lib/router/router'\n\nimport React from 'react'\nimport type { UrlObject } from 'url'\nimport { formatUrl } from '../../shared/lib/router/utils/format-url'\nimport { AppRouterContext } from '../../shared/lib/app-router-context.shared-runtime'\nimport type { AppRouterInstance } from '../../shared/lib/app-router-context.shared-runtime'\nimport { PrefetchKind } from '../components/router-reducer/router-reducer-types'\nimport { useMergedRef } from '../use-merged-ref'\nimport { isAbsoluteUrl } from '../../shared/lib/utils'\nimport { addBasePath } from '../add-base-path'\nimport { warnOnce } from '../../shared/lib/utils/warn-once'\nimport {\n type PrefetchTask,\n schedulePrefetchTask as scheduleSegmentPrefetchTask,\n cancelPrefetchTask,\n bumpPrefetchTask,\n PrefetchPriority,\n} from '../components/segment-cache/scheduler'\nimport { getCurrentAppRouterState } from '../../shared/lib/router/action-queue'\nimport { createCacheKey } from '../components/segment-cache/cache-key'\nimport { createPrefetchURL } from '../components/app-router'\n\ntype Url = string | UrlObject\ntype RequiredKeys<T> = {\n [K in keyof T]-?: {} extends Pick<T, K> ? never : K\n}[keyof T]\ntype OptionalKeys<T> = {\n [K in keyof T]-?: {} extends Pick<T, K> ? K : never\n}[keyof T]\n\ntype InternalLinkProps = {\n /**\n * The path or URL to navigate to. It can also be an object.\n *\n * @example https://nextjs.org/docs/api-reference/next/link#with-url-object\n */\n href: Url\n /**\n * Optional decorator for the path that will be shown in the browser URL bar. Before Next.js 9.5.3 this was used for dynamic routes, check our [previous docs](https://github.com/vercel/next.js/blob/v9.5.2/docs/api-reference/next/link.md#dynamic-routes) to see how it worked. Note: when this path differs from the one provided in `href` the previous `href`/`as` behavior is used as shown in the [previous docs](https://github.com/vercel/next.js/blob/v9.5.2/docs/api-reference/next/link.md#dynamic-routes).\n */\n as?: Url\n /**\n * Replace the current `history` state instead of adding a new url into the stack.\n *\n * @defaultValue `false`\n */\n replace?: boolean\n /**\n * Whether to override the default scroll behavior\n *\n * @example https://nextjs.org/docs/api-reference/next/link#disable-scrolling-to-the-top-of-the-page\n *\n * @defaultValue `true`\n */\n scroll?: boolean\n /**\n * Update the path of the current page without rerunning [`getStaticProps`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-props), [`getServerSideProps`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props) or [`getInitialProps`](/docs/pages/api-reference/functions/get-initial-props).\n *\n * @defaultValue `false`\n */\n shallow?: boolean\n /**\n * Forces `Link` to send the `href` property to its child.\n *\n * @defaultValue `false`\n */\n passHref?: boolean\n /**\n * Prefetch the page in the background.\n * Any `<Link />` that is in the viewport (initially or through scroll) will be prefetched.\n * Prefetch can be disabled by passing `prefetch={false}`. Prefetching is only enabled in production.\n *\n * In App Router:\n * - `null` (default): For statically generated pages, this will prefetch the full React Server Component data. For dynamic pages, this will prefetch up to the nearest route segment with a [`loading.js`](https://nextjs.org/docs/app/api-reference/file-conventions/loading) file. If there is no loading file, it will not fetch the full tree to avoid fetching too much data.\n * - `true`: This will prefetch the full React Server Component data for all route segments, regardless of whether they contain a segment with `loading.js`.\n * - `false`: This will not prefetch any data, even on hover.\n *\n * In Pages Router:\n * - `true` (default): The full route & its data will be prefetched.\n * - `false`: Prefetching will not happen when entering the viewport, but will still happen on hover.\n * @defaultValue `true` (pages router) or `null` (app router)\n */\n prefetch?: boolean | null\n /**\n * The active locale is automatically prepended. `locale` allows for providing a different locale.\n * When `false` `href` has to include the locale as the default behavior is disabled.\n * Note: This is only available in the Pages Router.\n */\n locale?: string | false\n /**\n * Enable legacy link behavior.\n * @defaultValue `false`\n * @see https://github.com/vercel/next.js/commit/489e65ed98544e69b0afd7e0cfc3f9f6c2b803b7\n */\n legacyBehavior?: boolean\n /**\n * Optional event handler for when the mouse pointer is moved onto Link\n */\n onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>\n /**\n * Optional event handler for when Link is touched.\n */\n onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>\n /**\n * Optional event handler for when Link is clicked.\n */\n onClick?: React.MouseEventHandler<HTMLAnchorElement>\n}\n\n// TODO-APP: Include the full set of Anchor props\n// adding this to the publicly exported type currently breaks existing apps\n\n// `RouteInferType` is a stub here to avoid breaking `typedRoutes` when the type\n// isn't generated yet. It will be replaced when the webpack plugin runs.\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type LinkProps<RouteInferType = any> = InternalLinkProps\ntype LinkPropsRequired = RequiredKeys<LinkProps>\ntype LinkPropsOptional = OptionalKeys<Omit<InternalLinkProps, 'locale'>>\n\ntype LinkInstance = {\n router: AppRouterInstance\n kind: PrefetchKind.AUTO | PrefetchKind.FULL\n prefetchHref: string\n\n isVisible: boolean\n wasHoveredOrTouched: boolean\n\n // The most recently initiated prefetch task. It may or may not have\n // already completed. The same prefetch task object can be reused across\n // multiple prefetches of the same link.\n prefetchTask: PrefetchTask | null\n}\n\n// TODO: This is currently a WeakMap because it doesn't need to be enumerable,\n// but eventually we'll want to be able to re-prefetch all the currently\n// visible links, e.g. after a revalidation or refresh.\nconst links:\n | WeakMap<HTMLAnchorElement | SVGAElement, LinkInstance>\n | Map<Element, LinkInstance> =\n typeof WeakMap === 'function' ? new WeakMap() : new Map()\n\n// A single IntersectionObserver instance shared by all <Link> components.\nconst observer: IntersectionObserver | null =\n typeof IntersectionObserver === 'function'\n ? new IntersectionObserver(handleIntersect, {\n rootMargin: '200px',\n })\n : null\n\nfunction mountLinkInstance(\n element: HTMLAnchorElement | SVGAElement,\n href: string,\n router: AppRouterInstance,\n kind: PrefetchKind.AUTO | PrefetchKind.FULL\n) {\n let prefetchUrl: URL | null = null\n try {\n prefetchUrl = createPrefetchURL(href)\n if (prefetchUrl === null) {\n // We only track the link if it's prefetchable. For example, this excludes\n // links to external URLs.\n return\n }\n } catch {\n // createPrefetchURL sometimes throws an error if an invalid URL is\n // provided, though I'm not sure if it's actually necessary.\n // TODO: Consider removing the throw from the inner function, or change it\n // to reportError. Or maybe the error isn't even necessary for automatic\n // prefetches, just navigations.\n const reportErrorFn =\n typeof reportError === 'function' ? reportError : console.error\n reportErrorFn(\n `Cannot prefetch '${href}' because it cannot be converted to a URL.`\n )\n return\n }\n\n const instance: LinkInstance = {\n prefetchHref: prefetchUrl.href,\n router,\n kind,\n isVisible: false,\n wasHoveredOrTouched: false,\n prefetchTask: null,\n }\n const existingInstance = links.get(element)\n if (existingInstance !== undefined) {\n // This shouldn't happen because each <Link> component should have its own\n // anchor tag instance, but it's defensive coding to avoid a memory leak in\n // case there's a logical error somewhere else.\n unmountLinkInstance(element)\n }\n links.set(element, instance)\n if (observer !== null) {\n observer.observe(element)\n }\n}\n\nexport function unmountLinkInstance(element: HTMLAnchorElement | SVGAElement) {\n const instance = links.get(element)\n if (instance !== undefined) {\n links.delete(element)\n const prefetchTask = instance.prefetchTask\n if (prefetchTask !== null) {\n cancelPrefetchTask(prefetchTask)\n }\n }\n if (observer !== null) {\n observer.unobserve(element)\n }\n}\n\nfunction handleIntersect(entries: Array<IntersectionObserverEntry>) {\n for (const entry of entries) {\n // Some extremely old browsers or polyfills don't reliably support\n // isIntersecting so we check intersectionRatio instead. (Do we care? Not\n // really. But whatever this is fine.)\n const isVisible = entry.intersectionRatio > 0\n onLinkVisibilityChanged(entry.target as HTMLAnchorElement, isVisible)\n }\n}\n\nfunction onLinkVisibilityChanged(\n element: HTMLAnchorElement | SVGAElement,\n isVisible: boolean\n) {\n if (process.env.NODE_ENV !== 'production') {\n // Prefetching on viewport is disabled in development for performance\n // reasons, because it requires compiling the target page.\n // TODO: Investigate re-enabling this.\n return\n }\n\n const instance = links.get(element)\n if (instance === undefined) {\n return\n }\n\n instance.isVisible = isVisible\n rescheduleLinkPrefetch(instance)\n}\n\nfunction onNavigationIntent(element: HTMLAnchorElement | SVGAElement) {\n const instance = links.get(element)\n if (instance === undefined) {\n return\n }\n // Prefetch the link on hover/touchstart.\n if (instance !== undefined) {\n instance.wasHoveredOrTouched = true\n rescheduleLinkPrefetch(instance)\n }\n}\n\nfunction rescheduleLinkPrefetch(instance: LinkInstance) {\n const existingPrefetchTask = instance.prefetchTask\n\n if (!instance.isVisible) {\n // Cancel any in-progress prefetch task. (If it already finished then this\n // is a no-op.)\n if (existingPrefetchTask !== null) {\n cancelPrefetchTask(existingPrefetchTask)\n }\n // We don't need to reset the prefetchTask to null upon cancellation; an\n // old task object can be rescheduled with bumpPrefetchTask. This is a\n // micro-optimization but also makes the code simpler (don't need to\n // worry about whether an old task object is stale).\n return\n }\n\n if (!process.env.__NEXT_CLIENT_SEGMENT_CACHE) {\n // The old prefetch implementation does not have different priority levels.\n // Just schedule a new prefetch task.\n prefetchWithOldCacheImplementation(instance)\n return\n }\n\n // In the Segment Cache implementation, we assign a higher priority level to\n // links that were at one point hovered or touched. Since the queue is last-\n // in-first-out, the highest priority Link is whichever one was hovered last.\n //\n // We also increase the relative priority of links whenever they re-enter the\n // viewport, as if they were being scheduled for the first time.\n const priority = instance.wasHoveredOrTouched\n ? PrefetchPriority.Intent\n : PrefetchPriority.Default\n if (existingPrefetchTask === null) {\n // Initiate a prefetch task.\n const appRouterState = getCurrentAppRouterState()\n if (appRouterState !== null) {\n const nextUrl = appRouterState.nextUrl\n const treeAtTimeOfPrefetch = appRouterState.tree\n const cacheKey = createCacheKey(instance.prefetchHref, nextUrl)\n instance.prefetchTask = scheduleSegmentPrefetchTask(\n cacheKey,\n treeAtTimeOfPrefetch,\n instance.kind === PrefetchKind.FULL,\n priority\n )\n }\n } else {\n // We already have an old task object that we can reschedule. This is\n // effectively the same as canceling the old task and creating a new one.\n bumpPrefetchTask(existingPrefetchTask, priority)\n }\n}\n\nfunction prefetchWithOldCacheImplementation(instance: LinkInstance) {\n // This is the path used when the Segment Cache is not enabled.\n if (typeof window === 'undefined') {\n return\n }\n\n const doPrefetch = async () => {\n // note that `appRouter.prefetch()` is currently sync,\n // so we have to wrap this call in an async function to be able to catch() errors below.\n return instance.router.prefetch(instance.prefetchHref, {\n kind: instance.kind,\n })\n }\n\n // Prefetch the page if asked (only in the client)\n // We need to handle a prefetch error here since we may be\n // loading with priority which can reject but we don't\n // want to force navigation since this is only a prefetch\n doPrefetch().catch((err) => {\n if (process.env.NODE_ENV !== 'production') {\n // rethrow to show invalid URL errors\n throw err\n }\n })\n}\n\nfunction isModifiedEvent(event: React.MouseEvent): boolean {\n const eventTarget = event.currentTarget as HTMLAnchorElement | SVGAElement\n const target = eventTarget.getAttribute('target')\n return (\n (target && target !== '_self') ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey || // triggers resource download\n (event.nativeEvent && event.nativeEvent.which === 2)\n )\n}\n\nfunction linkClicked(\n e: React.MouseEvent,\n router: NextRouter | AppRouterInstance,\n href: string,\n as: string,\n replace?: boolean,\n shallow?: boolean,\n scroll?: boolean\n): void {\n const { nodeName } = e.currentTarget\n\n // anchors inside an svg have a lowercase nodeName\n const isAnchorNodeName = nodeName.toUpperCase() === 'A'\n\n if (isAnchorNodeName && isModifiedEvent(e)) {\n // ignore click for browser’s default behavior\n return\n }\n\n e.preventDefault()\n\n const navigate = () => {\n // If the router is an NextRouter instance it will have `beforePopState`\n const routerScroll = scroll ?? true\n if ('beforePopState' in router) {\n router[replace ? 'replace' : 'push'](href, as, {\n shallow,\n scroll: routerScroll,\n })\n } else {\n router[replace ? 'replace' : 'push'](as || href, {\n scroll: routerScroll,\n })\n }\n }\n\n React.startTransition(navigate)\n}\n\ntype LinkPropsReal = React.PropsWithChildren<\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps> &\n LinkProps\n>\n\nfunction formatStringOrUrl(urlObjOrString: UrlObject | string): string {\n if (typeof urlObjOrString === 'string') {\n return urlObjOrString\n }\n\n return formatUrl(urlObjOrString)\n}\n\n/**\n * A React component that extends the HTML `<a>` element to provide [prefetching](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching)\n * and client-side navigation between routes.\n *\n * It is the primary way to navigate between routes in Next.js.\n *\n * Read more: [Next.js docs: `<Link>`](https://nextjs.org/docs/app/api-reference/components/link)\n */\nconst Link = React.forwardRef<HTMLAnchorElement, LinkPropsReal>(\n function LinkComponent(props, forwardedRef) {\n let children: React.ReactNode\n\n const {\n href: hrefProp,\n as: asProp,\n children: childrenProp,\n prefetch: prefetchProp = null,\n passHref,\n replace,\n shallow,\n scroll,\n onClick,\n onMouseEnter: onMouseEnterProp,\n onTouchStart: onTouchStartProp,\n legacyBehavior = false,\n ...restProps\n } = props\n\n children = childrenProp\n\n if (\n legacyBehavior &&\n (typeof children === 'string' || typeof children === 'number')\n ) {\n children = <a>{children}</a>\n }\n\n const router = React.useContext(AppRouterContext)\n\n const prefetchEnabled = prefetchProp !== false\n /**\n * The possible states for prefetch are:\n * - null: this is the default \"auto\" mode, where we will prefetch partially if the link is in the viewport\n * - true: we will prefetch if the link is visible and prefetch the full page, not just partially\n * - false: we will not prefetch if in the viewport at all\n */\n const appPrefetchKind =\n prefetchProp === null ? PrefetchKind.AUTO : PrefetchKind.FULL\n\n if (process.env.NODE_ENV !== 'production') {\n function createPropError(args: {\n key: string\n expected: string\n actual: string\n }) {\n return new Error(\n `Failed prop type: The prop \\`${args.key}\\` expects a ${args.expected} in \\`<Link>\\`, but got \\`${args.actual}\\` instead.` +\n (typeof window !== 'undefined'\n ? \"\\nOpen your browser's console to view the Component stack trace.\"\n : '')\n )\n }\n\n // TypeScript trick for type-guarding:\n const requiredPropsGuard: Record<LinkPropsRequired, true> = {\n href: true,\n } as const\n const requiredProps: LinkPropsRequired[] = Object.keys(\n requiredPropsGuard\n ) as LinkPropsRequired[]\n requiredProps.forEach((key: LinkPropsRequired) => {\n if (key === 'href') {\n if (\n props[key] == null ||\n (typeof props[key] !== 'string' && typeof props[key] !== 'object')\n ) {\n throw createPropError({\n key,\n expected: '`string` or `object`',\n actual: props[key] === null ? 'null' : typeof props[key],\n })\n }\n } else {\n // TypeScript trick for type-guarding:\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = key\n }\n })\n\n // TypeScript trick for type-guarding:\n const optionalPropsGuard: Record<LinkPropsOptional, true> = {\n as: true,\n replace: true,\n scroll: true,\n shallow: true,\n passHref: true,\n prefetch: true,\n onClick: true,\n onMouseEnter: true,\n onTouchStart: true,\n legacyBehavior: true,\n } as const\n const optionalProps: LinkPropsOptional[] = Object.keys(\n optionalPropsGuard\n ) as LinkPropsOptional[]\n optionalProps.forEach((key: LinkPropsOptional) => {\n const valType = typeof props[key]\n\n if (key === 'as') {\n if (props[key] && valType !== 'string' && valType !== 'object') {\n throw createPropError({\n key,\n expected: '`string` or `object`',\n actual: valType,\n })\n }\n } else if (\n key === 'onClick' ||\n key === 'onMouseEnter' ||\n key === 'onTouchStart'\n ) {\n if (props[key] && valType !== 'function') {\n throw createPropError({\n key,\n expected: '`function`',\n actual: valType,\n })\n }\n } else if (\n key === 'replace' ||\n key === 'scroll' ||\n key === 'shallow' ||\n key === 'passHref' ||\n key === 'prefetch' ||\n key === 'legacyBehavior'\n ) {\n if (props[key] != null && valType !== 'boolean') {\n throw createPropError({\n key,\n expected: '`boolean`',\n actual: valType,\n })\n }\n } else {\n // TypeScript trick for type-guarding:\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = key\n }\n })\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (props.locale) {\n warnOnce(\n 'The `locale` prop is not supported in `next/link` while using the `app` router. Read more about app router internalization: https://nextjs.org/docs/app/building-your-application/routing/internationalization'\n )\n }\n if (!asProp) {\n let href: string | undefined\n if (typeof hrefProp === 'string') {\n href = hrefProp\n } else if (\n typeof hrefProp === 'object' &&\n typeof hrefProp.pathname === 'string'\n ) {\n href = hrefProp.pathname\n }\n\n if (href) {\n const hasDynamicSegment = href\n .split('/')\n .some((segment) => segment.startsWith('[') && segment.endsWith(']'))\n\n if (hasDynamicSegment) {\n throw new Error(\n `Dynamic href \\`${href}\\` found in <Link> while using the \\`/app\\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href`\n )\n }\n }\n }\n }\n\n const { href, as } = React.useMemo(() => {\n const resolvedHref = formatStringOrUrl(hrefProp)\n return {\n href: resolvedHref,\n as: asProp ? formatStringOrUrl(asProp) : resolvedHref,\n }\n }, [hrefProp, asProp])\n\n // This will return the first child, if multiple are provided it will throw an error\n let child: any\n if (legacyBehavior) {\n if (process.env.NODE_ENV === 'development') {\n if (onClick) {\n console.warn(\n `\"onClick\" was passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but \"legacyBehavior\" was set. The legacy behavior requires onClick be set on the child of next/link`\n )\n }\n if (onMouseEnterProp) {\n console.warn(\n `\"onMouseEnter\" was passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but \"legacyBehavior\" was set. The legacy behavior requires onMouseEnter be set on the child of next/link`\n )\n }\n try {\n child = React.Children.only(children)\n } catch (err) {\n if (!children) {\n throw new Error(\n `No children were passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but one child is required https://nextjs.org/docs/messages/link-no-children`\n )\n }\n throw new Error(\n `Multiple children were passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children` +\n (typeof window !== 'undefined'\n ? \" \\nOpen your browser's console to view the Component stack trace.\"\n : '')\n )\n }\n } else {\n child = React.Children.only(children)\n }\n } else {\n if (process.env.NODE_ENV === 'development') {\n if ((children as any)?.type === 'a') {\n throw new Error(\n 'Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>.\\nLearn more: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor'\n )\n }\n }\n }\n\n const childRef: any = legacyBehavior\n ? child && typeof child === 'object' && child.ref\n : forwardedRef\n\n // Use a callback ref to attach an IntersectionObserver to the anchor tag on\n // mount. In the future we will also use this to keep track of all the\n // currently mounted <Link> instances, e.g. so we can re-prefetch them after\n // a revalidation or refresh.\n const observeLinkVisibilityOnMount = React.useCallback(\n (element: HTMLAnchorElement | SVGAElement) => {\n if (prefetchEnabled && router !== null) {\n mountLinkInstance(element, href, router, appPrefetchKind)\n }\n return () => {\n unmountLinkInstance(element)\n }\n },\n [prefetchEnabled, href, router, appPrefetchKind]\n )\n\n const mergedRef = useMergedRef(observeLinkVisibilityOnMount, childRef)\n\n const childProps: {\n onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>\n onMouseEnter: React.MouseEventHandler<HTMLAnchorElement>\n onClick: React.MouseEventHandler<HTMLAnchorElement>\n href?: string\n ref?: any\n } = {\n ref: mergedRef,\n onClick(e) {\n if (process.env.NODE_ENV !== 'production') {\n if (!e) {\n throw new Error(\n `Component rendered inside next/link has to pass click event to \"onClick\" prop.`\n )\n }\n }\n\n if (!legacyBehavior && typeof onClick === 'function') {\n onClick(e)\n }\n\n if (\n legacyBehavior &&\n child.props &&\n typeof child.props.onClick === 'function'\n ) {\n child.props.onClick(e)\n }\n\n if (!router) {\n return\n }\n\n if (e.defaultPrevented) {\n return\n }\n\n linkClicked(e, router, href, as, replace, shallow, scroll)\n },\n onMouseEnter(e) {\n if (!legacyBehavior && typeof onMouseEnterProp === 'function') {\n onMouseEnterProp(e)\n }\n\n if (\n legacyBehavior &&\n child.props &&\n typeof child.props.onMouseEnter === 'function'\n ) {\n child.props.onMouseEnter(e)\n }\n\n if (!router) {\n return\n }\n\n if (!prefetchEnabled || process.env.NODE_ENV === 'development') {\n return\n }\n\n onNavigationIntent(e.currentTarget as HTMLAnchorElement | SVGAElement)\n },\n onTouchStart: process.env.__NEXT_LINK_NO_TOUCH_START\n ? undefined\n : function onTouchStart(e) {\n if (!legacyBehavior && typeof onTouchStartProp === 'function') {\n onTouchStartProp(e)\n }\n\n if (\n legacyBehavior &&\n child.props &&\n typeof child.props.onTouchStart === 'function'\n ) {\n child.props.onTouchStart(e)\n }\n\n if (!router) {\n return\n }\n\n if (!prefetchEnabled) {\n return\n }\n\n onNavigationIntent(\n e.currentTarget as HTMLAnchorElement | SVGAElement\n )\n },\n }\n\n // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is\n // defined, we specify the current 'href', so that repetition is not needed by the user.\n // If the url is absolute, we can bypass the logic to prepend the basePath.\n if (isAbsoluteUrl(as)) {\n childProps.href = as\n } else if (\n !legacyBehavior ||\n passHref ||\n (child.type === 'a' && !('href' in child.props))\n ) {\n childProps.href = addBasePath(as)\n }\n\n return legacyBehavior ? (\n React.cloneElement(child, childProps)\n ) : (\n <a {...restProps} {...childProps}>\n {children}\n </a>\n )\n }\n)\n\nexport default Link\n"],"names":["React","formatUrl","AppRouterContext","PrefetchKind","useMergedRef","isAbsoluteUrl","addBasePath","warnOnce","schedulePrefetchTask","scheduleSegmentPrefetchTask","cancelPrefetchTask","bumpPrefetchTask","PrefetchPriority","getCurrentAppRouterState","createCacheKey","createPrefetchURL","links","WeakMap","Map","observer","IntersectionObserver","handleIntersect","rootMargin","mountLinkInstance","element","href","router","kind","prefetchUrl","reportErrorFn","reportError","console","error","instance","prefetchHref","isVisible","wasHoveredOrTouched","prefetchTask","existingInstance","get","undefined","unmountLinkInstance","set","observe","delete","unobserve","entries","entry","intersectionRatio","onLinkVisibilityChanged","target","process","env","NODE_ENV","rescheduleLinkPrefetch","onNavigationIntent","existingPrefetchTask","__NEXT_CLIENT_SEGMENT_CACHE","prefetchWithOldCacheImplementation","priority","Intent","Default","appRouterState","nextUrl","treeAtTimeOfPrefetch","tree","cacheKey","FULL","window","doPrefetch","prefetch","catch","err","isModifiedEvent","event","eventTarget","currentTarget","getAttribute","metaKey","ctrlKey","shiftKey","altKey","nativeEvent","which","linkClicked","e","as","replace","shallow","scroll","nodeName","isAnchorNodeName","toUpperCase","preventDefault","navigate","routerScroll","startTransition","formatStringOrUrl","urlObjOrString","Link","forwardRef","LinkComponent","props","forwardedRef","children","hrefProp","asProp","childrenProp","prefetchProp","passHref","onClick","onMouseEnter","onMouseEnterProp","onTouchStart","onTouchStartProp","legacyBehavior","restProps","a","useContext","prefetchEnabled","appPrefetchKind","AUTO","createPropError","args","Error","key","expected","actual","requiredPropsGuard","requiredProps","Object","keys","forEach","_","optionalPropsGuard","optionalProps","valType","locale","pathname","hasDynamicSegment","split","some","segment","startsWith","endsWith","useMemo","resolvedHref","child","warn","Children","only","type","childRef","ref","observeLinkVisibilityOnMount","useCallback","mergedRef","childProps","defaultPrevented","__NEXT_LINK_NO_TOUCH_START","cloneElement"],"mappings":"AAAA;;AAIA,OAAOA,WAAW,QAAO;AAEzB,SAASC,SAAS,QAAQ,2CAA0C;AACpE,SAASC,gBAAgB,QAAQ,qDAAoD;AAErF,SAASC,YAAY,QAAQ,oDAAmD;AAChF,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,QAAQ,QAAQ,mCAAkC;AAC3D,SAEEC,wBAAwBC,2BAA2B,EACnDC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,QACX,wCAAuC;AAC9C,SAASC,wBAAwB,QAAQ,uCAAsC;AAC/E,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,iBAAiB,QAAQ,2BAA0B;AAiH5D,8EAA8E;AAC9E,wEAAwE;AACxE,uDAAuD;AACvD,MAAMC,QAGJ,OAAOC,YAAY,aAAa,IAAIA,YAAY,IAAIC;AAEtD,0EAA0E;AAC1E,MAAMC,WACJ,OAAOC,yBAAyB,aAC5B,IAAIA,qBAAqBC,iBAAiB;IACxCC,YAAY;AACd,KACA;AAEN,SAASC,kBACPC,OAAwC,EACxCC,IAAY,EACZC,MAAyB,EACzBC,IAA2C;IAE3C,IAAIC,cAA0B;IAC9B,IAAI;QACFA,cAA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B;YAEA,IAAI,CAAC3D,QAAQ;gBACX;YACF;YAEA,IAAI,CAAC6F,iBAAiB;gBACpB;YACF;YAEAhE,mBACE8B,EAAET,aAAa;QAEnB;IACN;IAEA,6FAA6F;IAC7F,wFAAwF;IACxF,2EAA2E;IAC3E,IAAIvE,cAAciF,KAAK;QACrBuE,WAAWpI,IAAI,GAAG6D;IACpB,OAAO,IACL,CAAC6B,kBACDN,YACCsC,MAAMI,IAAI,KAAK,OAAO,CAAE,CAAA,UAAUJ,MAAM7C,KAAK,AAAD,GAC7C;QACAuD,WAAWpI,IAAI,GAAGnB,YAAYgF;IAChC;IAEA,OAAO6B,+BACLnH,MAAMgK,YAAY,CAACb,OAAOU,4BAE1B,KAACxC;QAAG,GAAGD,SAAS;QAAG,GAAGyC,UAAU;kBAC7BrD;;AAGP;AAGF,eAAeL,KAAI"}
|
|
1
|
+
{"version":3,"sources":["../../../src/client/app-dir/link.tsx"],"sourcesContent":["'use client'\n\nimport type { NextRouter } from '../../shared/lib/router/router'\n\nimport React from 'react'\nimport type { UrlObject } from 'url'\nimport { formatUrl } from '../../shared/lib/router/utils/format-url'\nimport { AppRouterContext } from '../../shared/lib/app-router-context.shared-runtime'\nimport type { AppRouterInstance } from '../../shared/lib/app-router-context.shared-runtime'\nimport { PrefetchKind } from '../components/router-reducer/router-reducer-types'\nimport { useMergedRef } from '../use-merged-ref'\nimport { isAbsoluteUrl } from '../../shared/lib/utils'\nimport { addBasePath } from '../add-base-path'\nimport { warnOnce } from '../../shared/lib/utils/warn-once'\nimport {\n type PrefetchTask,\n schedulePrefetchTask as scheduleSegmentPrefetchTask,\n cancelPrefetchTask,\n bumpPrefetchTask,\n PrefetchPriority,\n} from '../components/segment-cache/scheduler'\nimport { getCurrentAppRouterState } from '../../shared/lib/router/action-queue'\nimport { createCacheKey } from '../components/segment-cache/cache-key'\nimport { createPrefetchURL } from '../components/app-router'\n\ntype Url = string | UrlObject\ntype RequiredKeys<T> = {\n [K in keyof T]-?: {} extends Pick<T, K> ? never : K\n}[keyof T]\ntype OptionalKeys<T> = {\n [K in keyof T]-?: {} extends Pick<T, K> ? K : never\n}[keyof T]\n\ntype InternalLinkProps = {\n /**\n * **Required**. The path or URL to navigate to. It can also be an object (similar to `URL`).\n *\n * @example\n * ```tsx\n * // Navigate to /dashboard:\n * <Link href=\"/dashboard\">Dashboard</Link>\n *\n * // Navigate to /about?name=test:\n * <Link href={{ pathname: '/about', query: { name: 'test' } }}>\n * About\n * </Link>\n * ```\n *\n * @remarks\n * - For external URLs, use a fully qualified URL such as `https://...`.\n * - In the App Router, dynamic routes must not include bracketed segments in `href`.\n */\n href: Url\n\n /**\n * @deprecated v10.0.0: `href` props pointing to a dynamic route are\n * automatically resolved and no longer require the `as` prop.\n */\n as?: Url\n\n /**\n * Replace the current `history` state instead of adding a new URL into the stack.\n *\n * @defaultValue `false`\n *\n * @example\n * ```tsx\n * <Link href=\"/about\" replace>\n * About (replaces the history state)\n * </Link>\n * ```\n */\n replace?: boolean\n\n /**\n * Whether to override the default scroll behavior. If `true`, Next.js attempts to maintain\n * the scroll position if the newly navigated page is still visible. If not, it scrolls to the top.\n *\n * If `false`, Next.js will not modify the scroll behavior at all.\n *\n * @defaultValue `true`\n *\n * @example\n * ```tsx\n * <Link href=\"/dashboard\" scroll={false}>\n * No auto scroll\n * </Link>\n * ```\n */\n scroll?: boolean\n\n /**\n * Update the path of the current page without rerunning data fetching methods\n * like `getStaticProps`, `getServerSideProps`, or `getInitialProps`.\n *\n * @remarks\n * `shallow` only applies to the Pages Router. For the App Router, see the\n * [following documentation](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api).\n *\n * @defaultValue `false`\n *\n * @example\n * ```tsx\n * <Link href=\"/blog\" shallow>\n * Shallow navigation\n * </Link>\n * ```\n */\n shallow?: boolean\n\n /**\n * Forces `Link` to pass its `href` to the child component. Useful if the child is a custom\n * component that wraps an `<a>` tag, or if you're using certain styling libraries.\n *\n * @defaultValue `false`\n *\n * @example\n * ```tsx\n * <Link href=\"/dashboard\" passHref>\n * <MyStyledAnchor>Dashboard</MyStyledAnchor>\n * </Link>\n * ```\n */\n passHref?: boolean\n\n /**\n * Prefetch the page in the background.\n * Any `<Link />` that is in the viewport (initially or through scroll) will be prefetched.\n * Prefetch can be disabled by passing `prefetch={false}`.\n *\n * @remarks\n * Prefetching is only enabled in production.\n *\n * - In the **App Router**:\n * - `null` (default): Prefetch behavior depends on static vs dynamic routes:\n * - Static routes: fully prefetched\n * - Dynamic routes: partial prefetch to the nearest segment with a `loading.js`\n * - `true`: Always prefetch the full route and data.\n * - `false`: Disable prefetching on both viewport and hover.\n * - In the **Pages Router**:\n * - `true` (default): Prefetches the route and data in the background on viewport or hover.\n * - `false`: Prefetch only on hover, not on viewport.\n *\n * @defaultValue `true` (Pages Router) or `null` (App Router)\n *\n * @example\n * ```tsx\n * <Link href=\"/dashboard\" prefetch={false}>\n * Dashboard\n * </Link>\n * ```\n */\n prefetch?: boolean | null\n\n /**\n * The active locale is automatically prepended in the Pages Router. `locale` allows for providing\n * a different locale, or can be set to `false` to opt out of automatic locale behavior.\n *\n * @remarks\n * Note: locale only applies in the Pages Router and is ignored in the App Router.\n *\n * @example\n * ```tsx\n * // Use the 'fr' locale:\n * <Link href=\"/about\" locale=\"fr\">\n * About (French)\n * </Link>\n *\n * // Disable locale prefix:\n * <Link href=\"/about\" locale={false}>\n * About (no locale prefix)\n * </Link>\n * ```\n */\n locale?: string | false\n\n /**\n * Enable legacy link behavior, requiring an `<a>` tag to wrap the child content\n * if the child is a string or number.\n *\n * @defaultValue `false`\n * @see https://github.com/vercel/next.js/commit/489e65ed98544e69b0afd7e0cfc3f9f6c2b803b7\n */\n legacyBehavior?: boolean\n\n /**\n * Optional event handler for when the mouse pointer is moved onto the `<Link>`.\n */\n onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>\n\n /**\n * Optional event handler for when the `<Link>` is touched.\n */\n onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>\n\n /**\n * Optional event handler for when the `<Link>` is clicked.\n */\n onClick?: React.MouseEventHandler<HTMLAnchorElement>\n}\n\n// TODO-APP: Include the full set of Anchor props\n// adding this to the publicly exported type currently breaks existing apps\n\n// `RouteInferType` is a stub here to avoid breaking `typedRoutes` when the type\n// isn't generated yet. It will be replaced when the webpack plugin runs.\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type LinkProps<RouteInferType = any> = InternalLinkProps\ntype LinkPropsRequired = RequiredKeys<LinkProps>\ntype LinkPropsOptional = OptionalKeys<Omit<InternalLinkProps, 'locale'>>\n\ntype LinkInstance = {\n router: AppRouterInstance\n kind: PrefetchKind.AUTO | PrefetchKind.FULL\n prefetchHref: string\n\n isVisible: boolean\n wasHoveredOrTouched: boolean\n\n // The most recently initiated prefetch task. It may or may not have\n // already completed. The same prefetch task object can be reused across\n // multiple prefetches of the same link.\n prefetchTask: PrefetchTask | null\n}\n\n// TODO: This is currently a WeakMap because it doesn't need to be enumerable,\n// but eventually we'll want to be able to re-prefetch all the currently\n// visible links, e.g. after a revalidation or refresh.\nconst links:\n | WeakMap<HTMLAnchorElement | SVGAElement, LinkInstance>\n | Map<Element, LinkInstance> =\n typeof WeakMap === 'function' ? new WeakMap() : new Map()\n\n// A single IntersectionObserver instance shared by all <Link> components.\nconst observer: IntersectionObserver | null =\n typeof IntersectionObserver === 'function'\n ? new IntersectionObserver(handleIntersect, {\n rootMargin: '200px',\n })\n : null\n\nfunction mountLinkInstance(\n element: HTMLAnchorElement | SVGAElement,\n href: string,\n router: AppRouterInstance,\n kind: PrefetchKind.AUTO | PrefetchKind.FULL\n) {\n let prefetchUrl: URL | null = null\n try {\n prefetchUrl = createPrefetchURL(href)\n if (prefetchUrl === null) {\n // We only track the link if it's prefetchable. For example, this excludes\n // links to external URLs.\n return\n }\n } catch {\n // createPrefetchURL sometimes throws an error if an invalid URL is\n // provided, though I'm not sure if it's actually necessary.\n // TODO: Consider removing the throw from the inner function, or change it\n // to reportError. Or maybe the error isn't even necessary for automatic\n // prefetches, just navigations.\n const reportErrorFn =\n typeof reportError === 'function' ? reportError : console.error\n reportErrorFn(\n `Cannot prefetch '${href}' because it cannot be converted to a URL.`\n )\n return\n }\n\n const instance: LinkInstance = {\n prefetchHref: prefetchUrl.href,\n router,\n kind,\n isVisible: false,\n wasHoveredOrTouched: false,\n prefetchTask: null,\n }\n const existingInstance = links.get(element)\n if (existingInstance !== undefined) {\n // This shouldn't happen because each <Link> component should have its own\n // anchor tag instance, but it's defensive coding to avoid a memory leak in\n // case there's a logical error somewhere else.\n unmountLinkInstance(element)\n }\n links.set(element, instance)\n if (observer !== null) {\n observer.observe(element)\n }\n}\n\nexport function unmountLinkInstance(element: HTMLAnchorElement | SVGAElement) {\n const instance = links.get(element)\n if (instance !== undefined) {\n links.delete(element)\n const prefetchTask = instance.prefetchTask\n if (prefetchTask !== null) {\n cancelPrefetchTask(prefetchTask)\n }\n }\n if (observer !== null) {\n observer.unobserve(element)\n }\n}\n\nfunction handleIntersect(entries: Array<IntersectionObserverEntry>) {\n for (const entry of entries) {\n // Some extremely old browsers or polyfills don't reliably support\n // isIntersecting so we check intersectionRatio instead. (Do we care? Not\n // really. But whatever this is fine.)\n const isVisible = entry.intersectionRatio > 0\n onLinkVisibilityChanged(entry.target as HTMLAnchorElement, isVisible)\n }\n}\n\nfunction onLinkVisibilityChanged(\n element: HTMLAnchorElement | SVGAElement,\n isVisible: boolean\n) {\n if (process.env.NODE_ENV !== 'production') {\n // Prefetching on viewport is disabled in development for performance\n // reasons, because it requires compiling the target page.\n // TODO: Investigate re-enabling this.\n return\n }\n\n const instance = links.get(element)\n if (instance === undefined) {\n return\n }\n\n instance.isVisible = isVisible\n rescheduleLinkPrefetch(instance)\n}\n\nfunction onNavigationIntent(element: HTMLAnchorElement | SVGAElement) {\n const instance = links.get(element)\n if (instance === undefined) {\n return\n }\n // Prefetch the link on hover/touchstart.\n if (instance !== undefined) {\n instance.wasHoveredOrTouched = true\n rescheduleLinkPrefetch(instance)\n }\n}\n\nfunction rescheduleLinkPrefetch(instance: LinkInstance) {\n const existingPrefetchTask = instance.prefetchTask\n\n if (!instance.isVisible) {\n // Cancel any in-progress prefetch task. (If it already finished then this\n // is a no-op.)\n if (existingPrefetchTask !== null) {\n cancelPrefetchTask(existingPrefetchTask)\n }\n // We don't need to reset the prefetchTask to null upon cancellation; an\n // old task object can be rescheduled with bumpPrefetchTask. This is a\n // micro-optimization but also makes the code simpler (don't need to\n // worry about whether an old task object is stale).\n return\n }\n\n if (!process.env.__NEXT_CLIENT_SEGMENT_CACHE) {\n // The old prefetch implementation does not have different priority levels.\n // Just schedule a new prefetch task.\n prefetchWithOldCacheImplementation(instance)\n return\n }\n\n // In the Segment Cache implementation, we assign a higher priority level to\n // links that were at one point hovered or touched. Since the queue is last-\n // in-first-out, the highest priority Link is whichever one was hovered last.\n //\n // We also increase the relative priority of links whenever they re-enter the\n // viewport, as if they were being scheduled for the first time.\n const priority = instance.wasHoveredOrTouched\n ? PrefetchPriority.Intent\n : PrefetchPriority.Default\n if (existingPrefetchTask === null) {\n // Initiate a prefetch task.\n const appRouterState = getCurrentAppRouterState()\n if (appRouterState !== null) {\n const nextUrl = appRouterState.nextUrl\n const treeAtTimeOfPrefetch = appRouterState.tree\n const cacheKey = createCacheKey(instance.prefetchHref, nextUrl)\n instance.prefetchTask = scheduleSegmentPrefetchTask(\n cacheKey,\n treeAtTimeOfPrefetch,\n instance.kind === PrefetchKind.FULL,\n priority\n )\n }\n } else {\n // We already have an old task object that we can reschedule. This is\n // effectively the same as canceling the old task and creating a new one.\n bumpPrefetchTask(existingPrefetchTask, priority)\n }\n}\n\nfunction prefetchWithOldCacheImplementation(instance: LinkInstance) {\n // This is the path used when the Segment Cache is not enabled.\n if (typeof window === 'undefined') {\n return\n }\n\n const doPrefetch = async () => {\n // note that `appRouter.prefetch()` is currently sync,\n // so we have to wrap this call in an async function to be able to catch() errors below.\n return instance.router.prefetch(instance.prefetchHref, {\n kind: instance.kind,\n })\n }\n\n // Prefetch the page if asked (only in the client)\n // We need to handle a prefetch error here since we may be\n // loading with priority which can reject but we don't\n // want to force navigation since this is only a prefetch\n doPrefetch().catch((err) => {\n if (process.env.NODE_ENV !== 'production') {\n // rethrow to show invalid URL errors\n throw err\n }\n })\n}\n\nfunction isModifiedEvent(event: React.MouseEvent): boolean {\n const eventTarget = event.currentTarget as HTMLAnchorElement | SVGAElement\n const target = eventTarget.getAttribute('target')\n return (\n (target && target !== '_self') ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey || // triggers resource download\n (event.nativeEvent && event.nativeEvent.which === 2)\n )\n}\n\nfunction linkClicked(\n e: React.MouseEvent,\n router: NextRouter | AppRouterInstance,\n href: string,\n as: string,\n replace?: boolean,\n shallow?: boolean,\n scroll?: boolean\n): void {\n const { nodeName } = e.currentTarget\n\n // anchors inside an svg have a lowercase nodeName\n const isAnchorNodeName = nodeName.toUpperCase() === 'A'\n\n if (isAnchorNodeName && isModifiedEvent(e)) {\n // ignore click for browser’s default behavior\n return\n }\n\n e.preventDefault()\n\n const navigate = () => {\n // If the router is an NextRouter instance it will have `beforePopState`\n const routerScroll = scroll ?? true\n if ('beforePopState' in router) {\n router[replace ? 'replace' : 'push'](href, as, {\n shallow,\n scroll: routerScroll,\n })\n } else {\n router[replace ? 'replace' : 'push'](as || href, {\n scroll: routerScroll,\n })\n }\n }\n\n React.startTransition(navigate)\n}\n\ntype LinkPropsReal = React.PropsWithChildren<\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps> &\n LinkProps\n>\n\nfunction formatStringOrUrl(urlObjOrString: UrlObject | string): string {\n if (typeof urlObjOrString === 'string') {\n return urlObjOrString\n }\n\n return formatUrl(urlObjOrString)\n}\n\n/**\n * A React component that extends the HTML `<a>` element to provide\n * [prefetching](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching)\n * and client-side navigation. This is the primary way to navigate between routes in Next.js.\n *\n * @remarks\n * - Prefetching is only enabled in production.\n *\n * @see https://nextjs.org/docs/app/api-reference/components/link\n */\nconst Link = React.forwardRef<HTMLAnchorElement, LinkPropsReal>(\n function LinkComponent(props, forwardedRef) {\n let children: React.ReactNode\n\n const {\n href: hrefProp,\n as: asProp,\n children: childrenProp,\n prefetch: prefetchProp = null,\n passHref,\n replace,\n shallow,\n scroll,\n onClick,\n onMouseEnter: onMouseEnterProp,\n onTouchStart: onTouchStartProp,\n legacyBehavior = false,\n ...restProps\n } = props\n\n children = childrenProp\n\n if (\n legacyBehavior &&\n (typeof children === 'string' || typeof children === 'number')\n ) {\n children = <a>{children}</a>\n }\n\n const router = React.useContext(AppRouterContext)\n\n const prefetchEnabled = prefetchProp !== false\n /**\n * The possible states for prefetch are:\n * - null: this is the default \"auto\" mode, where we will prefetch partially if the link is in the viewport\n * - true: we will prefetch if the link is visible and prefetch the full page, not just partially\n * - false: we will not prefetch if in the viewport at all\n */\n const appPrefetchKind =\n prefetchProp === null ? PrefetchKind.AUTO : PrefetchKind.FULL\n\n if (process.env.NODE_ENV !== 'production') {\n function createPropError(args: {\n key: string\n expected: string\n actual: string\n }) {\n return new Error(\n `Failed prop type: The prop \\`${args.key}\\` expects a ${args.expected} in \\`<Link>\\`, but got \\`${args.actual}\\` instead.` +\n (typeof window !== 'undefined'\n ? \"\\nOpen your browser's console to view the Component stack trace.\"\n : '')\n )\n }\n\n // TypeScript trick for type-guarding:\n const requiredPropsGuard: Record<LinkPropsRequired, true> = {\n href: true,\n } as const\n const requiredProps: LinkPropsRequired[] = Object.keys(\n requiredPropsGuard\n ) as LinkPropsRequired[]\n requiredProps.forEach((key: LinkPropsRequired) => {\n if (key === 'href') {\n if (\n props[key] == null ||\n (typeof props[key] !== 'string' && typeof props[key] !== 'object')\n ) {\n throw createPropError({\n key,\n expected: '`string` or `object`',\n actual: props[key] === null ? 'null' : typeof props[key],\n })\n }\n } else {\n // TypeScript trick for type-guarding:\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = key\n }\n })\n\n // TypeScript trick for type-guarding:\n const optionalPropsGuard: Record<LinkPropsOptional, true> = {\n as: true,\n replace: true,\n scroll: true,\n shallow: true,\n passHref: true,\n prefetch: true,\n onClick: true,\n onMouseEnter: true,\n onTouchStart: true,\n legacyBehavior: true,\n } as const\n const optionalProps: LinkPropsOptional[] = Object.keys(\n optionalPropsGuard\n ) as LinkPropsOptional[]\n optionalProps.forEach((key: LinkPropsOptional) => {\n const valType = typeof props[key]\n\n if (key === 'as') {\n if (props[key] && valType !== 'string' && valType !== 'object') {\n throw createPropError({\n key,\n expected: '`string` or `object`',\n actual: valType,\n })\n }\n } else if (\n key === 'onClick' ||\n key === 'onMouseEnter' ||\n key === 'onTouchStart'\n ) {\n if (props[key] && valType !== 'function') {\n throw createPropError({\n key,\n expected: '`function`',\n actual: valType,\n })\n }\n } else if (\n key === 'replace' ||\n key === 'scroll' ||\n key === 'shallow' ||\n key === 'passHref' ||\n key === 'prefetch' ||\n key === 'legacyBehavior'\n ) {\n if (props[key] != null && valType !== 'boolean') {\n throw createPropError({\n key,\n expected: '`boolean`',\n actual: valType,\n })\n }\n } else {\n // TypeScript trick for type-guarding:\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const _: never = key\n }\n })\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (props.locale) {\n warnOnce(\n 'The `locale` prop is not supported in `next/link` while using the `app` router. Read more about app router internalization: https://nextjs.org/docs/app/building-your-application/routing/internationalization'\n )\n }\n if (!asProp) {\n let href: string | undefined\n if (typeof hrefProp === 'string') {\n href = hrefProp\n } else if (\n typeof hrefProp === 'object' &&\n typeof hrefProp.pathname === 'string'\n ) {\n href = hrefProp.pathname\n }\n\n if (href) {\n const hasDynamicSegment = href\n .split('/')\n .some((segment) => segment.startsWith('[') && segment.endsWith(']'))\n\n if (hasDynamicSegment) {\n throw new Error(\n `Dynamic href \\`${href}\\` found in <Link> while using the \\`/app\\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href`\n )\n }\n }\n }\n }\n\n const { href, as } = React.useMemo(() => {\n const resolvedHref = formatStringOrUrl(hrefProp)\n return {\n href: resolvedHref,\n as: asProp ? formatStringOrUrl(asProp) : resolvedHref,\n }\n }, [hrefProp, asProp])\n\n // This will return the first child, if multiple are provided it will throw an error\n let child: any\n if (legacyBehavior) {\n if (process.env.NODE_ENV === 'development') {\n if (onClick) {\n console.warn(\n `\"onClick\" was passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but \"legacyBehavior\" was set. The legacy behavior requires onClick be set on the child of next/link`\n )\n }\n if (onMouseEnterProp) {\n console.warn(\n `\"onMouseEnter\" was passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but \"legacyBehavior\" was set. The legacy behavior requires onMouseEnter be set on the child of next/link`\n )\n }\n try {\n child = React.Children.only(children)\n } catch (err) {\n if (!children) {\n throw new Error(\n `No children were passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but one child is required https://nextjs.org/docs/messages/link-no-children`\n )\n }\n throw new Error(\n `Multiple children were passed to <Link> with \\`href\\` of \\`${hrefProp}\\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children` +\n (typeof window !== 'undefined'\n ? \" \\nOpen your browser's console to view the Component stack trace.\"\n : '')\n )\n }\n } else {\n child = React.Children.only(children)\n }\n } else {\n if (process.env.NODE_ENV === 'development') {\n if ((children as any)?.type === 'a') {\n throw new Error(\n 'Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>.\\nLearn more: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor'\n )\n }\n }\n }\n\n const childRef: any = legacyBehavior\n ? child && typeof child === 'object' && child.ref\n : forwardedRef\n\n // Use a callback ref to attach an IntersectionObserver to the anchor tag on\n // mount. In the future we will also use this to keep track of all the\n // currently mounted <Link> instances, e.g. so we can re-prefetch them after\n // a revalidation or refresh.\n const observeLinkVisibilityOnMount = React.useCallback(\n (element: HTMLAnchorElement | SVGAElement) => {\n if (prefetchEnabled && router !== null) {\n mountLinkInstance(element, href, router, appPrefetchKind)\n }\n return () => {\n unmountLinkInstance(element)\n }\n },\n [prefetchEnabled, href, router, appPrefetchKind]\n )\n\n const mergedRef = useMergedRef(observeLinkVisibilityOnMount, childRef)\n\n const childProps: {\n onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>\n onMouseEnter: React.MouseEventHandler<HTMLAnchorElement>\n onClick: React.MouseEventHandler<HTMLAnchorElement>\n href?: string\n ref?: any\n } = {\n ref: mergedRef,\n onClick(e) {\n if (process.env.NODE_ENV !== 'production') {\n if (!e) {\n throw new Error(\n `Component rendered inside next/link has to pass click event to \"onClick\" prop.`\n )\n }\n }\n\n if (!legacyBehavior && typeof onClick === 'function') {\n onClick(e)\n }\n\n if (\n legacyBehavior &&\n child.props &&\n typeof child.props.onClick === 'function'\n ) {\n child.props.onClick(e)\n }\n\n if (!router) {\n return\n }\n\n if (e.defaultPrevented) {\n return\n }\n\n linkClicked(e, router, href, as, replace, shallow, scroll)\n },\n onMouseEnter(e) {\n if (!legacyBehavior && typeof onMouseEnterProp === 'function') {\n onMouseEnterProp(e)\n }\n\n if (\n legacyBehavior &&\n child.props &&\n typeof child.props.onMouseEnter === 'function'\n ) {\n child.props.onMouseEnter(e)\n }\n\n if (!router) {\n return\n }\n\n if (!prefetchEnabled || process.env.NODE_ENV === 'development') {\n return\n }\n\n onNavigationIntent(e.currentTarget as HTMLAnchorElement | SVGAElement)\n },\n onTouchStart: process.env.__NEXT_LINK_NO_TOUCH_START\n ? undefined\n : function onTouchStart(e) {\n if (!legacyBehavior && typeof onTouchStartProp === 'function') {\n onTouchStartProp(e)\n }\n\n if (\n legacyBehavior &&\n child.props &&\n typeof child.props.onTouchStart === 'function'\n ) {\n child.props.onTouchStart(e)\n }\n\n if (!router) {\n return\n }\n\n if (!prefetchEnabled) {\n return\n }\n\n onNavigationIntent(\n e.currentTarget as HTMLAnchorElement | SVGAElement\n )\n },\n }\n\n // If child is an <a> tag and doesn't have a href attribute, or if the 'passHref' property is\n // defined, we specify the current 'href', so that repetition is not needed by the user.\n // If the url is absolute, we can bypass the logic to prepend the basePath.\n if (isAbsoluteUrl(as)) {\n childProps.href = as\n } else if (\n !legacyBehavior ||\n passHref ||\n (child.type === 'a' && !('href' in child.props))\n ) {\n childProps.href = addBasePath(as)\n }\n\n return legacyBehavior ? (\n React.cloneElement(child, childProps)\n ) : (\n <a {...restProps} {...childProps}>\n {children}\n </a>\n )\n }\n)\n\nexport default Link\n"],"names":["React","formatUrl","AppRouterContext","PrefetchKind","useMergedRef","isAbsoluteUrl","addBasePath","warnOnce","schedulePrefetchTask","scheduleSegmentPrefetchTask","cancelPrefetchTask","bumpPrefetchTask","PrefetchPriority","getCurrentAppRouterState","createCacheKey","createPrefetchURL","links","WeakMap","Map","observer","IntersectionObserver","handleIntersect","rootMargin","mountLinkInstance","element","href","router","kind","prefetchUrl","reportErrorFn","reportError","console","error","instance","prefetchHref","isVisible","wasHoveredOrTouched","prefetchTask","existingInstance","get","undefined","unmountLinkInstance","set","observe","delete","unobserve","entries","entry","intersectionRatio","onLinkVisibilityChanged","target","process","env","NODE_ENV","rescheduleLinkPrefetch","onNavigationIntent","existingPrefetchTask","__NEXT_CLIENT_SEGMENT_CACHE","prefetchWithOldCacheImplementation","priority","Intent","Default","appRouterState","nextUrl","treeAtTimeOfPrefetch","tree","cacheKey","FULL","window","doPrefetch","prefetch","catch","err","isModifiedEvent","event","eventTarget","currentTarget","getAttribute","metaKey","ctrlKey","shiftKey","altKey","nativeEvent","which","linkClicked","e","as","replace","shallow","scroll","nodeName","isAnchorNodeName","toUpperCase","preventDefault","navigate","routerScroll","startTransition","formatStringOrUrl","urlObjOrString","Link","forwardRef","LinkComponent","props","forwardedRef","children","hrefProp","asProp","childrenProp","prefetchProp","passHref","onClick","onMouseEnter","onMouseEnterProp","onTouchStart","onTouchStartProp","legacyBehavior","restProps","a","useContext","prefetchEnabled","appPrefetchKind","AUTO","createPropError","args","Error","key","expected","actual","requiredPropsGuard","requiredProps","Object","keys","forEach","_","optionalPropsGuard","optionalProps","valType","locale","pathname","hasDynamicSegment","split","some","segment","startsWith","endsWith","useMemo","resolvedHref","child","warn","Children","only","type","childRef","ref","observeLinkVisibilityOnMount","useCallback","mergedRef","childProps","defaultPrevented","__NEXT_LINK_NO_TOUCH_START","cloneElement"],"mappings":"AAAA;;AAIA,OAAOA,WAAW,QAAO;AAEzB,SAASC,SAAS,QAAQ,2CAA0C;AACpE,SAASC,gBAAgB,QAAQ,qDAAoD;AAErF,SAASC,YAAY,QAAQ,oDAAmD;AAChF,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,QAAQ,QAAQ,mCAAkC;AAC3D,SAEEC,wBAAwBC,2BAA2B,EACnDC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,QACX,wCAAuC;AAC9C,SAASC,wBAAwB,QAAQ,uCAAsC;AAC/E,SAASC,cAAc,QAAQ,wCAAuC;AACtE,SAASC,iBAAiB,QAAQ,2BAA0B;AA0M5D,8EAA8E;AAC9E,wEAAwE;AACxE,uDAAuD;AACvD,MAAMC,QAGJ,OAAOC,YAAY,aAAa,IAAIA,YAAY,IAAIC;AAEtD,0EAA0E;AAC1E,MAAMC,WACJ,OAAOC,yBAAyB,aAC5B,IAAIA,qBAAqBC,iBAAiB;IACxCC,YAAY;AACd,KACA;AAEN,SAASC,kBACPC,OAAwC,EACxCC,IAAY,EACZC,MAAyB,EACzBC,IAA2C;IAE3C,IAAIC,cAA0B;IAC9B,IAAI;QACFA,cAAcb,kBAAkBU;QAChC,IAAIG,gBAAgB,MAAM;YACxB,0EAA0E;YAC1E,0BAA0B;YAC1B;QACF;IACF,EAAE,UAAM;QACN,mEAAmE;QACnE,4DAA4D;QAC5D,0EAA0E;QAC1E,wEAAwE;QACxE,gCAAgC;QAChC,MAAMC,gBACJ,OAAOC,gBAAgB,aAAaA,cAA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GAAG6D;IACpB,OAAO,IACL,CAAC6B,kBACDN,YACCsC,MAAMI,IAAI,KAAK,OAAO,CAAE,CAAA,UAAUJ,MAAM7C,KAAK,AAAD,GAC7C;QACAuD,WAAWpI,IAAI,GAAGnB,YAAYgF;IAChC;IAEA,OAAO6B,+BACLnH,MAAMgK,YAAY,CAACb,OAAOU,4BAE1B,KAACxC;QAAG,GAAGD,SAAS;QAAG,GAAGyC,UAAU;kBAC7BrD;;AAGP;AAGF,eAAeL,KAAI"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { _ as _tagged_template_literal_loose } from "@swc/helpers/_/_tagged_template_literal_loose";
|
|
2
2
|
function _templateObject() {
|
|
3
3
|
const data = _tagged_template_literal_loose([
|
|
4
|
-
"\n [data-nextjs-dialog-root] {\n --next-dialog-radius: var(--rounded-xl);\n --next-dialog-footer-height: 48px;\n --next-dialog-max-width: 960px;\n\n display: flex;\n flex-direction: column;\n width: 100%;\n max-height: calc(100% - 56px);\n max-width: var(--next-dialog-max-width);\n margin-right: auto;\n margin-left: auto;\n scale: 0.98;\n opacity: 0;\n transition-property: scale, opacity;\n transition-duration: var(--transition-duration);\n transition-timing-function: var(--timing-overlay);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n [data-nextjs-dialog] {\n outline: none;\n }\n\n
|
|
4
|
+
"\n [data-nextjs-dialog-root] {\n --next-dialog-radius: var(--rounded-xl);\n --next-dialog-footer-height: 48px;\n --next-dialog-max-width: 960px;\n\n display: flex;\n flex-direction: column;\n width: 100%;\n max-height: calc(100% - 56px);\n max-width: var(--next-dialog-max-width);\n margin-right: auto;\n margin-left: auto;\n scale: 0.98;\n opacity: 0;\n transition-property: scale, opacity;\n transition-duration: var(--transition-duration);\n transition-timing-function: var(--timing-overlay);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n [data-nextjs-dialog] {\n outline: none;\n }\n\n ",
|
|
5
|
+
"\n [data-nextjs-dialog-sizer] {\n overflow: hidden;\n border-radius: inherit;\n }\n\n [data-nextjs-dialog-backdrop] {\n opacity: 0;\n transition: opacity var(--transition-duration) var(--timing-overlay);\n }\n\n [data-nextjs-dialog-overlay][data-rendered='true']\n [data-nextjs-dialog-backdrop] {\n opacity: 1;\n }\n\n [data-nextjs-dialog-content] {\n border: none;\n margin: 0;\n display: flex;\n flex-direction: column;\n position: relative;\n }\n\n /* Account for the footer height, when present */\n [data-nextjs-dialog-body]:has(~ [data-nextjs-dialog-footer]) {\n margin-bottom: calc(var(--next-dialog-footer-height) + 2px);\n }\n\n [data-nextjs-dialog-content] > [data-nextjs-dialog-header] {\n flex-shrink: 0;\n padding: var(--size-4);\n }\n\n [data-nextjs-dialog-content] > [data-nextjs-dialog-body] {\n position: relative;\n flex: 1 1 auto;\n }\n\n [data-nextjs-dialog-footer] {\n width: 100%;\n /* We make this element absolute to fix it to the bottom during the height transition */\n position: absolute;\n bottom: 0;\n min-height: var(--next-dialog-footer-height);\n border-radius: 0 0 var(--next-dialog-radius) var(--next-dialog-radius);\n overflow: hidden;\n\n > * {\n height: 100%;\n }\n }\n\n @media (max-height: 812px) {\n [data-nextjs-dialog-overlay] {\n max-height: calc(100% - 15px);\n }\n }\n\n @media (min-width: 576px) {\n [data-nextjs-dialog-root] {\n --next-dialog-max-width: 540px;\n }\n }\n\n @media (min-width: 768px) {\n [data-nextjs-dialog-root] {\n --next-dialog-max-width: 720px;\n }\n }\n\n @media (min-width: 992px) {\n [data-nextjs-dialog-root] {\n --next-dialog-max-width: 960px;\n }\n }\n"
|
|
5
6
|
]);
|
|
6
7
|
_templateObject = function() {
|
|
7
8
|
return data;
|
|
@@ -9,7 +10,7 @@ function _templateObject() {
|
|
|
9
10
|
return data;
|
|
10
11
|
}
|
|
11
12
|
import { noop as css } from '../../helpers/noop-template';
|
|
12
|
-
const styles = css(_templateObject());
|
|
13
|
+
const styles = css(_templateObject(), '' /* Place overflow: hidden on this so we can break out from [data-nextjs-dialog] */ );
|
|
13
14
|
export { styles };
|
|
14
15
|
|
|
15
16
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.ts"],"sourcesContent":["import { noop as css } from '../../helpers/noop-template'\n\nconst styles = css`\n [data-nextjs-dialog-root] {\n --next-dialog-radius: var(--rounded-xl);\n --next-dialog-footer-height: 48px;\n --next-dialog-max-width: 960px;\n\n display: flex;\n flex-direction: column;\n width: 100%;\n max-height: calc(100% - 56px);\n max-width: var(--next-dialog-max-width);\n margin-right: auto;\n margin-left: auto;\n scale: 0.98;\n opacity: 0;\n transition-property: scale, opacity;\n transition-duration: var(--transition-duration);\n transition-timing-function: var(--timing-overlay);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n [data-nextjs-dialog] {\n outline: none;\n }\n\n /* Place overflow: hidden on this so we can break out from [data-nextjs-dialog] */\n [data-nextjs-dialog-sizer] {\n overflow: hidden;\n border-radius: inherit;\n }\n\n [data-nextjs-dialog-backdrop] {\n opacity: 0;\n transition: opacity var(--transition-duration) var(--timing-overlay);\n }\n\n [data-nextjs-dialog-overlay][data-rendered='true']\n [data-nextjs-dialog-backdrop] {\n opacity: 1;\n }\n\n [data-nextjs-dialog-content] {\n border: none;\n margin: 0;\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/client/components/react-dev-overlay/_experimental/internal/components/dialog/styles.ts"],"sourcesContent":["import { noop as css } from '../../helpers/noop-template'\n\nconst styles = css`\n [data-nextjs-dialog-root] {\n --next-dialog-radius: var(--rounded-xl);\n --next-dialog-footer-height: 48px;\n --next-dialog-max-width: 960px;\n\n display: flex;\n flex-direction: column;\n width: 100%;\n max-height: calc(100% - 56px);\n max-width: var(--next-dialog-max-width);\n margin-right: auto;\n margin-left: auto;\n scale: 0.98;\n opacity: 0;\n transition-property: scale, opacity;\n transition-duration: var(--transition-duration);\n transition-timing-function: var(--timing-overlay);\n\n &[data-rendered='true'] {\n opacity: 1;\n scale: 1;\n }\n }\n\n [data-nextjs-dialog] {\n outline: none;\n }\n\n ${\n '' /* Place overflow: hidden on this so we can break out from [data-nextjs-dialog] */\n }\n [data-nextjs-dialog-sizer] {\n overflow: hidden;\n border-radius: inherit;\n }\n\n [data-nextjs-dialog-backdrop] {\n opacity: 0;\n transition: opacity var(--transition-duration) var(--timing-overlay);\n }\n\n [data-nextjs-dialog-overlay][data-rendered='true']\n [data-nextjs-dialog-backdrop] {\n opacity: 1;\n }\n\n [data-nextjs-dialog-content] {\n border: none;\n margin: 0;\n display: flex;\n flex-direction: column;\n position: relative;\n }\n\n /* Account for the footer height, when present */\n [data-nextjs-dialog-body]:has(~ [data-nextjs-dialog-footer]) {\n margin-bottom: calc(var(--next-dialog-footer-height) + 2px);\n }\n\n [data-nextjs-dialog-content] > [data-nextjs-dialog-header] {\n flex-shrink: 0;\n padding: var(--size-4);\n }\n\n [data-nextjs-dialog-content] > [data-nextjs-dialog-body] {\n position: relative;\n flex: 1 1 auto;\n }\n\n [data-nextjs-dialog-footer] {\n width: 100%;\n /* We make this element absolute to fix it to the bottom during the height transition */\n position: absolute;\n bottom: 0;\n min-height: var(--next-dialog-footer-height);\n border-radius: 0 0 var(--next-dialog-radius) var(--next-dialog-radius);\n overflow: hidden;\n\n > * {\n height: 100%;\n }\n }\n\n @media (max-height: 812px) {\n [data-nextjs-dialog-overlay] {\n max-height: calc(100% - 15px);\n }\n }\n\n @media (min-width: 576px) {\n [data-nextjs-dialog-root] {\n --next-dialog-max-width: 540px;\n }\n }\n\n @media (min-width: 768px) {\n [data-nextjs-dialog-root] {\n --next-dialog-max-width: 720px;\n }\n }\n\n @media (min-width: 992px) {\n [data-nextjs-dialog-root] {\n --next-dialog-max-width: 960px;\n }\n }\n`\n\nexport { styles }\n"],"names":["noop","css","styles"],"mappings":";;;;;;;;;;;AAAA,SAASA,QAAQC,GAAG,QAAQ,8BAA6B;AAEzD,MAAMC,SAASD,uBA8BX,GAAG,gFAAgF;AA+EvF,SAASC,MAAM,GAAE"}
|
|
@@ -20,14 +20,16 @@ export function ErrorOverlay(param) {
|
|
|
20
20
|
};
|
|
21
21
|
if (!!((_state_rootLayoutMissingTags = state.rootLayoutMissingTags) == null ? void 0 : _state_rootLayoutMissingTags.length)) {
|
|
22
22
|
return /*#__PURE__*/ _jsx(RootLayoutMissingTagsError, {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
...commonProps,
|
|
24
|
+
// This is a runtime error, forcedly display error overlay
|
|
25
|
+
rendered: true,
|
|
26
|
+
missingTags: state.rootLayoutMissingTags
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
if (state.buildError !== null) {
|
|
28
30
|
return /*#__PURE__*/ _jsx(BuildError, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
...commonProps,
|
|
32
|
+
message: state.buildError
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
// No Runtime Errors.
|
|
@@ -38,12 +40,12 @@ export function ErrorOverlay(param) {
|
|
|
38
40
|
return null;
|
|
39
41
|
}
|
|
40
42
|
return /*#__PURE__*/ _jsx(Errors, {
|
|
43
|
+
...commonProps,
|
|
41
44
|
debugInfo: state.debugInfo,
|
|
42
45
|
readyErrors: readyErrors,
|
|
43
46
|
onClose: ()=>{
|
|
44
47
|
setIsErrorOverlayOpen(false);
|
|
45
|
-
}
|
|
46
|
-
...commonProps
|
|
48
|
+
}
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.tsx"],"sourcesContent":["import type { OverlayState } from '../../../../../shared'\n\nimport { BuildError } from '../../../container/build-error'\nimport { Errors } from '../../../container/errors'\nimport { RootLayoutMissingTagsError } from '../../../container/root-layout-missing-tags-error'\nimport { useDelayedRender } from '../../../hooks/use-delayed-render'\nimport type { ReadyRuntimeError } from '../../../../../internal/helpers/get-error-by-type'\n\nconst transitionDurationMs = 200\n\nexport interface ErrorBaseProps {\n rendered: boolean\n transitionDurationMs: number\n isTurbopack: boolean\n versionInfo: OverlayState['versionInfo']\n}\n\nexport function ErrorOverlay({\n state,\n readyErrors,\n isErrorOverlayOpen,\n setIsErrorOverlayOpen,\n}: {\n state: OverlayState\n readyErrors: ReadyRuntimeError[]\n isErrorOverlayOpen: boolean\n setIsErrorOverlayOpen: (value: boolean) => void\n}) {\n const isTurbopack = !!process.env.TURBOPACK\n\n // This hook lets us do an exit animation before unmounting the component\n const { mounted, rendered } = useDelayedRender(isErrorOverlayOpen, {\n exitDelay: transitionDurationMs,\n })\n\n const commonProps = {\n rendered,\n transitionDurationMs,\n isTurbopack,\n versionInfo: state.versionInfo,\n }\n\n if (!!state.rootLayoutMissingTags?.length) {\n return (\n <RootLayoutMissingTagsError\n missingTags={state.rootLayoutMissingTags}\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/client/components/react-dev-overlay/_experimental/internal/components/errors/error-overlay/error-overlay.tsx"],"sourcesContent":["import type { OverlayState } from '../../../../../shared'\n\nimport { BuildError } from '../../../container/build-error'\nimport { Errors } from '../../../container/errors'\nimport { RootLayoutMissingTagsError } from '../../../container/root-layout-missing-tags-error'\nimport { useDelayedRender } from '../../../hooks/use-delayed-render'\nimport type { ReadyRuntimeError } from '../../../../../internal/helpers/get-error-by-type'\n\nconst transitionDurationMs = 200\n\nexport interface ErrorBaseProps {\n rendered: boolean\n transitionDurationMs: number\n isTurbopack: boolean\n versionInfo: OverlayState['versionInfo']\n}\n\nexport function ErrorOverlay({\n state,\n readyErrors,\n isErrorOverlayOpen,\n setIsErrorOverlayOpen,\n}: {\n state: OverlayState\n readyErrors: ReadyRuntimeError[]\n isErrorOverlayOpen: boolean\n setIsErrorOverlayOpen: (value: boolean) => void\n}) {\n const isTurbopack = !!process.env.TURBOPACK\n\n // This hook lets us do an exit animation before unmounting the component\n const { mounted, rendered } = useDelayedRender(isErrorOverlayOpen, {\n exitDelay: transitionDurationMs,\n })\n\n const commonProps = {\n rendered,\n transitionDurationMs,\n isTurbopack,\n versionInfo: state.versionInfo,\n }\n\n if (!!state.rootLayoutMissingTags?.length) {\n return (\n <RootLayoutMissingTagsError\n {...commonProps}\n // This is a runtime error, forcedly display error overlay\n rendered\n missingTags={state.rootLayoutMissingTags}\n />\n )\n }\n\n if (state.buildError !== null) {\n return <BuildError {...commonProps} message={state.buildError} />\n }\n\n // No Runtime Errors.\n if (!readyErrors.length) {\n return null\n }\n\n if (!mounted) {\n return null\n }\n\n return (\n <Errors\n {...commonProps}\n debugInfo={state.debugInfo}\n readyErrors={readyErrors}\n onClose={() => {\n setIsErrorOverlayOpen(false)\n }}\n />\n )\n}\n"],"names":["BuildError","Errors","RootLayoutMissingTagsError","useDelayedRender","transitionDurationMs","ErrorOverlay","state","readyErrors","isErrorOverlayOpen","setIsErrorOverlayOpen","isTurbopack","process","env","TURBOPACK","mounted","rendered","exitDelay","commonProps","versionInfo","rootLayoutMissingTags","length","missingTags","buildError","message","debugInfo","onClose"],"mappings":";AAEA,SAASA,UAAU,QAAQ,iCAAgC;AAC3D,SAASC,MAAM,QAAQ,4BAA2B;AAClD,SAASC,0BAA0B,QAAQ,oDAAmD;AAC9F,SAASC,gBAAgB,QAAQ,oCAAmC;AAGpE,MAAMC,uBAAuB;AAS7B,OAAO,SAASC,aAAa,KAU5B;IAV4B,IAAA,EAC3BC,KAAK,EACLC,WAAW,EACXC,kBAAkB,EAClBC,qBAAqB,EAMtB,GAV4B;QAyBrBH;IAdN,MAAMI,cAAc,CAAC,CAACC,QAAQC,GAAG,CAACC,SAAS;IAE3C,yEAAyE;IACzE,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGZ,iBAAiBK,oBAAoB;QACjEQ,WAAWZ;IACb;IAEA,MAAMa,cAAc;QAClBF;QACAX;QACAM;QACAQ,aAAaZ,MAAMY,WAAW;IAChC;IAEA,IAAI,CAAC,GAACZ,+BAAAA,MAAMa,qBAAqB,qBAA3Bb,6BAA6Bc,MAAM,GAAE;QACzC,qBACE,KAAClB;YACE,GAAGe,WAAW;YACf,0DAA0D;YAC1DF,QAAQ;YACRM,aAAaf,MAAMa,qBAAqB;;IAG9C;IAEA,IAAIb,MAAMgB,UAAU,KAAK,MAAM;QAC7B,qBAAO,KAACtB;YAAY,GAAGiB,WAAW;YAAEM,SAASjB,MAAMgB,UAAU;;IAC/D;IAEA,qBAAqB;IACrB,IAAI,CAACf,YAAYa,MAAM,EAAE;QACvB,OAAO;IACT;IAEA,IAAI,CAACN,SAAS;QACZ,OAAO;IACT;IAEA,qBACE,KAACb;QACE,GAAGgB,WAAW;QACfO,WAAWlB,MAAMkB,SAAS;QAC1BjB,aAAaA;QACbkB,SAAS;YACPhB,sBAAsB;QACxB;;AAGN"}
|
|
@@ -12,8 +12,7 @@ function getErrorSignature(ev) {
|
|
|
12
12
|
default:
|
|
13
13
|
break;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
const _ = event;
|
|
15
|
+
event;
|
|
17
16
|
return '';
|
|
18
17
|
}
|
|
19
18
|
export function useErrorHook(param) {
|
|
@@ -80,7 +79,7 @@ export function useErrorHook(param) {
|
|
|
80
79
|
// will be displayed. Since build error and root layout
|
|
81
80
|
// missing tags won't be dismissed until resolved, the
|
|
82
81
|
// total number of errors may be fixed to their length.
|
|
83
|
-
totalErrorCount: (rootLayoutMissingTags == null ? void 0 : rootLayoutMissingTags.length) ?
|
|
82
|
+
totalErrorCount: (rootLayoutMissingTags == null ? void 0 : rootLayoutMissingTags.length) ? 1 : !!buildError ? 1 : readyErrors.length
|
|
84
83
|
};
|
|
85
84
|
}
|
|
86
85
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../src/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.ts"],"sourcesContent":["import type {\n OverlayState,\n UnhandledErrorAction,\n UnhandledRejectionAction,\n} from '../../../../shared'\n\nimport { useMemo, useState, useEffect } from 'react'\nimport {\n ACTION_UNHANDLED_ERROR,\n ACTION_UNHANDLED_REJECTION,\n} from '../../../../shared'\nimport {\n getErrorByType,\n type ReadyRuntimeError,\n} from '../../../../internal/helpers/get-error-by-type'\n\nexport type SupportedErrorEvent = {\n id: number\n event: UnhandledErrorAction | UnhandledRejectionAction\n}\n\nfunction getErrorSignature(ev: SupportedErrorEvent): string {\n const { event } = ev\n switch (event.type) {\n case ACTION_UNHANDLED_ERROR:\n case ACTION_UNHANDLED_REJECTION: {\n return `${event.reason.name}::${event.reason.message}::${event.reason.stack}`\n }\n default:\n break\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/client/components/react-dev-overlay/_experimental/internal/container/runtime-error/use-error-hook.ts"],"sourcesContent":["import type {\n OverlayState,\n UnhandledErrorAction,\n UnhandledRejectionAction,\n} from '../../../../shared'\n\nimport { useMemo, useState, useEffect } from 'react'\nimport {\n ACTION_UNHANDLED_ERROR,\n ACTION_UNHANDLED_REJECTION,\n} from '../../../../shared'\nimport {\n getErrorByType,\n type ReadyRuntimeError,\n} from '../../../../internal/helpers/get-error-by-type'\n\nexport type SupportedErrorEvent = {\n id: number\n event: UnhandledErrorAction | UnhandledRejectionAction\n}\n\nfunction getErrorSignature(ev: SupportedErrorEvent): string {\n const { event } = ev\n switch (event.type) {\n case ACTION_UNHANDLED_ERROR:\n case ACTION_UNHANDLED_REJECTION: {\n return `${event.reason.name}::${event.reason.message}::${event.reason.stack}`\n }\n default:\n break\n }\n\n event satisfies never\n return ''\n}\n\nexport function useErrorHook({\n state,\n isAppDir,\n}: {\n state: OverlayState\n isAppDir: boolean\n}) {\n const { errors, rootLayoutMissingTags, buildError } = state\n\n const [lookups, setLookups] = useState<{\n [eventId: string]: ReadyRuntimeError\n }>({})\n const [readyErrors, nextError] = useMemo<\n [ReadyRuntimeError[], SupportedErrorEvent | null]\n >(() => {\n let ready: ReadyRuntimeError[] = []\n let next: SupportedErrorEvent | null = null\n\n // Ensure errors are displayed in the order they occurred in:\n for (let idx = 0; idx < errors.length; ++idx) {\n const e = errors[idx]\n const { id } = e\n if (id in lookups) {\n ready.push(lookups[id])\n continue\n }\n\n // Check for duplicate errors\n if (idx > 0) {\n const prev = errors[idx - 1]\n if (getErrorSignature(prev) === getErrorSignature(e)) {\n continue\n }\n }\n\n next = e\n break\n }\n\n return [ready, next]\n }, [errors, lookups])\n\n useEffect(() => {\n if (nextError == null) {\n return\n }\n let mounted = true\n\n getErrorByType(nextError, isAppDir).then(\n (resolved) => {\n // We don't care if the desired error changed while we were resolving,\n // thus we're not tracking it using a ref. Once the work has been done,\n // we'll store it.\n if (mounted) {\n setLookups((m) => ({ ...m, [resolved.id]: resolved }))\n }\n },\n () => {\n // TODO: handle this, though an edge case\n }\n )\n\n return () => {\n mounted = false\n }\n }, [nextError, isAppDir])\n\n return {\n readyErrors,\n // Total number of errors are based on the priority that\n // will be displayed. Since build error and root layout\n // missing tags won't be dismissed until resolved, the\n // total number of errors may be fixed to their length.\n totalErrorCount: rootLayoutMissingTags?.length\n ? 1\n : !!buildError\n ? 1\n : readyErrors.length,\n }\n}\n"],"names":["useMemo","useState","useEffect","ACTION_UNHANDLED_ERROR","ACTION_UNHANDLED_REJECTION","getErrorByType","getErrorSignature","ev","event","type","reason","name","message","stack","useErrorHook","state","isAppDir","errors","rootLayoutMissingTags","buildError","lookups","setLookups","readyErrors","nextError","ready","next","idx","length","e","id","push","prev","mounted","then","resolved","m","totalErrorCount"],"mappings":"AAMA,SAASA,OAAO,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,QAAO;AACpD,SACEC,sBAAsB,EACtBC,0BAA0B,QACrB,qBAAoB;AAC3B,SACEC,cAAc,QAET,iDAAgD;AAOvD,SAASC,kBAAkBC,EAAuB;IAChD,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,OAAQC,MAAMC,IAAI;QAChB,KAAKN;QACL,KAAKC;Y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EAAEK;oBAAS,CAAA;YACrD;QACF,GACA;QACE,yCAAyC;QAC3C;QAGF,OAAO;YACLF,UAAU;QACZ;IACF,GAAG;QAACT;QAAWP;KAAS;IAExB,OAAO;QACLM;QACA,wDAAwD;QACxD,uDAAuD;QACvD,sDAAsD;QACtD,uDAAuD;QACvDc,iBAAiBlB,CAAAA,yCAAAA,sBAAuBS,MAAM,IAC1C,IACA,CAAC,CAACR,aACA,IACAG,YAAYK,MAAM;IAC1B;AACF"}
|
|
@@ -145,25 +145,51 @@ function createStackFrame(searchParams) {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
async function nativeTraceSource(frame) {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
const sourceURL = decodeURIComponent(frame.file);
|
|
149
|
+
let sourceMapPayload;
|
|
150
|
+
try {
|
|
151
|
+
var _findSourceMap;
|
|
152
|
+
sourceMapPayload = (_findSourceMap = findSourceMap(sourceURL)) == null ? void 0 : _findSourceMap.payload;
|
|
153
|
+
} catch (cause) {
|
|
154
|
+
throw Object.defineProperty(new Error("" + sourceURL + ": Invalid source map. Only conformant source maps can be used to find the original code.", {
|
|
155
|
+
cause
|
|
156
|
+
}), "__NEXT_ERROR_CODE", {
|
|
157
|
+
value: "E635",
|
|
158
|
+
enumerable: false
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (sourceMapPayload !== undefined) {
|
|
162
|
+
let consumer;
|
|
163
|
+
try {
|
|
164
|
+
consumer = await new SourceMapConsumer(sourceMapPayload);
|
|
165
|
+
} catch (cause) {
|
|
166
|
+
throw Object.defineProperty(new Error("" + sourceURL + ": Invalid source map. Only conformant source maps can be used to find the original code.", {
|
|
167
|
+
cause
|
|
168
|
+
}), "__NEXT_ERROR_CODE", {
|
|
169
|
+
value: "E635",
|
|
170
|
+
enumerable: false
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
let traced;
|
|
174
|
+
try {
|
|
152
175
|
var _frame_line, _frame_column;
|
|
153
176
|
const originalPosition = consumer.originalPositionFor({
|
|
154
177
|
line: (_frame_line = frame.line) != null ? _frame_line : 1,
|
|
155
178
|
column: (_frame_column = frame.column) != null ? _frame_column : 1
|
|
156
179
|
});
|
|
157
180
|
if (originalPosition.source === null) {
|
|
158
|
-
|
|
181
|
+
traced = null;
|
|
182
|
+
} else {
|
|
183
|
+
var _consumer_sourceContentFor;
|
|
184
|
+
const sourceContent = (_consumer_sourceContentFor = consumer.sourceContentFor(originalPosition.source, /* returnNullOnMissing */ true)) != null ? _consumer_sourceContentFor : null;
|
|
185
|
+
traced = {
|
|
186
|
+
originalPosition,
|
|
187
|
+
sourceContent
|
|
188
|
+
};
|
|
159
189
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
originalPosition,
|
|
164
|
-
sourceContent
|
|
165
|
-
};
|
|
166
|
-
});
|
|
190
|
+
} finally{
|
|
191
|
+
consumer.destroy();
|
|
192
|
+
}
|
|
167
193
|
if (traced !== null) {
|
|
168
194
|
var // We ignore the sourcemapped name since it won't be the correct name.
|
|
169
195
|
// The callsite will point to the column of the variable name instead of the
|
|
@@ -171,7 +197,7 @@ async function nativeTraceSource(frame) {
|
|
|
171
197
|
// TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.
|
|
172
198
|
_frame_methodName_replace, _frame_methodName, _originalPosition_source;
|
|
173
199
|
const { originalPosition, sourceContent } = traced;
|
|
174
|
-
const applicableSourceMap = findApplicableSourceMapPayload(frame,
|
|
200
|
+
const applicableSourceMap = findApplicableSourceMapPayload(frame, sourceMapPayload);
|
|
175
201
|
// TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.
|
|
176
202
|
let ignored = false;
|
|
177
203
|
if (applicableSourceMap === undefined) {
|