next 15.2.1-canary.1 → 15.2.1-canary.2
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/handle-externals.d.ts +2 -3
- package/dist/build/handle-externals.js +4 -4
- package/dist/build/handle-externals.js.map +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack/plugins/build-manifest-plugin.js +3 -5
- package/dist/build/webpack/plugins/build-manifest-plugin.js.map +1 -1
- package/dist/build/webpack/plugins/css-minimizer-plugin.js +2 -2
- package/dist/build/webpack/plugins/css-minimizer-plugin.js.map +1 -1
- package/dist/build/webpack/plugins/minify-webpack-plugin/src/index.js +2 -2
- package/dist/build/webpack/plugins/minify-webpack-plugin/src/index.js.map +1 -1
- package/dist/build/webpack/plugins/next-trace-entrypoints-plugin.d.ts +1 -3
- package/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js +5 -6
- package/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js.map +1 -1
- package/dist/build/webpack/utils.d.ts +3 -1
- package/dist/build/webpack/utils.js +10 -0
- package/dist/build/webpack/utils.js.map +1 -1
- package/dist/build/webpack-config.js +2 -4
- package/dist/build/webpack-config.js.map +1 -1
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/components/react-dev-overlay/server/shared.d.ts +0 -3
- package/dist/client/components/react-dev-overlay/server/shared.js.map +1 -1
- package/dist/client/components/react-dev-overlay/ui/styles/colors.js +1 -1
- package/dist/client/components/react-dev-overlay/ui/styles/colors.js.map +1 -1
- package/dist/client/components/react-dev-overlay/utils/stack-frame.d.ts +11 -3
- package/dist/client/components/react-dev-overlay/utils/stack-frame.js +2 -5
- package/dist/client/components/react-dev-overlay/utils/stack-frame.js.map +1 -1
- package/dist/client/components/router-reducer/reducers/navigate-reducer.js +29 -9
- package/dist/client/components/router-reducer/reducers/navigate-reducer.js.map +1 -1
- package/dist/client/components/segment-cache/navigation.d.ts +5 -1
- package/dist/client/components/segment-cache/navigation.js +28 -19
- package/dist/client/components/segment-cache/navigation.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/esm/build/handle-externals.js +4 -4
- package/dist/esm/build/handle-externals.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/plugins/build-manifest-plugin.js +3 -5
- package/dist/esm/build/webpack/plugins/build-manifest-plugin.js.map +1 -1
- package/dist/esm/build/webpack/plugins/css-minimizer-plugin.js +2 -2
- package/dist/esm/build/webpack/plugins/css-minimizer-plugin.js.map +1 -1
- package/dist/esm/build/webpack/plugins/minify-webpack-plugin/src/index.js +2 -2
- package/dist/esm/build/webpack/plugins/minify-webpack-plugin/src/index.js.map +1 -1
- package/dist/esm/build/webpack/plugins/next-trace-entrypoints-plugin.js +5 -6
- package/dist/esm/build/webpack/plugins/next-trace-entrypoints-plugin.js.map +1 -1
- package/dist/esm/build/webpack/utils.js +6 -0
- package/dist/esm/build/webpack/utils.js.map +1 -1
- package/dist/esm/build/webpack-config.js +2 -4
- package/dist/esm/build/webpack-config.js.map +1 -1
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/components/react-dev-overlay/server/shared.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/styles/colors.js +1 -1
- package/dist/esm/client/components/react-dev-overlay/ui/styles/colors.js.map +1 -1
- package/dist/esm/client/components/react-dev-overlay/utils/stack-frame.js +2 -5
- package/dist/esm/client/components/react-dev-overlay/utils/stack-frame.js.map +1 -1
- package/dist/esm/client/components/router-reducer/reducers/navigate-reducer.js +29 -9
- package/dist/esm/client/components/router-reducer/reducers/navigate-reducer.js.map +1 -1
- package/dist/esm/client/components/segment-cache/navigation.js +28 -19
- package/dist/esm/client/components/segment-cache/navigation.js.map +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/lib/server-external-packages.json +4 -0
- 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/lib/server-external-packages.json +4 -0
- 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/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
@@ -1,5 +1,4 @@
|
|
1
1
|
import type { StackFrame } from 'stacktrace-parser';
|
2
|
-
export type SourcePackage = 'react' | 'next';
|
3
2
|
export interface OriginalStackFramesRequest {
|
4
3
|
frames: StackFrame[];
|
5
4
|
isServer: boolean;
|
@@ -13,8 +12,6 @@ export interface OriginalStackFrameResponse {
|
|
13
12
|
ignored: boolean;
|
14
13
|
}) | null;
|
15
14
|
originalCodeFrame?: string | null;
|
16
|
-
/** We use this to group frames in the error overlay */
|
17
|
-
sourcePackage?: SourcePackage | null;
|
18
15
|
}
|
19
16
|
/**
|
20
17
|
* It looks up the code frame of the traced source.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/shared.ts"],"sourcesContent":["import type { StackFrame } from 'stacktrace-parser'\nimport { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'\nimport isInternal from '../../../../shared/lib/is-internal'\n\nexport
|
1
|
+
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/shared.ts"],"sourcesContent":["import type { StackFrame } from 'stacktrace-parser'\nimport { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'\nimport isInternal from '../../../../shared/lib/is-internal'\n\nexport interface OriginalStackFramesRequest {\n frames: StackFrame[]\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n}\n\nexport type OriginalStackFramesResponse = OriginalStackFrameResponseResult[]\n\nexport type OriginalStackFrameResponseResult =\n PromiseSettledResult<OriginalStackFrameResponse>\n\nexport interface OriginalStackFrameResponse {\n originalStackFrame?: (StackFrame & { ignored: boolean }) | null\n originalCodeFrame?: string | null\n}\n\n/**\n * It looks up the code frame of the traced source.\n * @note It ignores Next.js/React internals, as these can often be huge bundled files.\n */\nexport function getOriginalCodeFrame(\n frame: StackFrame,\n source: string | null,\n colors: boolean = process.stdout.isTTY\n): string | null {\n if (!source || isInternal(frame.file)) {\n return null\n }\n\n return codeFrameColumns(\n source,\n {\n start: {\n // 1-based, but -1 means start line without highlighting\n line: frame.lineNumber ?? -1,\n // 1-based, but 0 means whole line without column highlighting\n column: frame.column ?? 0,\n },\n },\n { forceColor: colors }\n )\n}\n"],"names":["getOriginalCodeFrame","frame","source","colors","process","stdout","isTTY","isInternal","file","codeFrameColumns","start","line","lineNumber","column","forceColor"],"mappings":";;;;+BAyBgBA;;;eAAAA;;;;2BAxBiB;qEACV;AAuBhB,SAASA,qBACdC,KAAiB,EACjBC,MAAqB,EACrBC,MAAsC;IAAtCA,IAAAA,mBAAAA,SAAkBC,QAAQC,MAAM,CAACC,KAAK;IAEtC,IAAI,CAACJ,UAAUK,IAAAA,mBAAU,EAACN,MAAMO,IAAI,GAAG;QACrC,OAAO;IACT;QAOYP,mBAEEA;IAPd,OAAOQ,IAAAA,2BAAgB,EACrBP,QACA;QACEQ,OAAO;YACL,wDAAwD;YACxDC,MAAMV,CAAAA,oBAAAA,MAAMW,UAAU,YAAhBX,oBAAoB,CAAC;YAC3B,8DAA8D;YAC9DY,QAAQZ,CAAAA,gBAAAA,MAAMY,MAAM,YAAZZ,gBAAgB;QAC1B;IACF,GACA;QAAEa,YAAYX;IAAO;AAEzB"}
|
@@ -13,7 +13,7 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
13
13
|
const _css = require("../../utils/css");
|
14
14
|
function _templateObject() {
|
15
15
|
const data = _tagged_template_literal_loose._([
|
16
|
-
'\n :host {\n /* \n * CAUTION: THIS IS A WORKAROUND!\n * For now, we use @babel/code-frame to parse the code frame which does not support option to change the color.\n * x-ref: https://github.com/babel/babel/blob/efa52324ff835b794c48080f14877b6caf32cd15/packages/babel-code-frame/src/defs.ts#L40-L54\n * So, we do a workaround mapping to change the color matching the theme.\n *\n * For example, in @babel/code-frame, the "keyword" is mapped to ANSI "cyan".\n * We want the "keyword" to use the "syntax-keyword" color in the theme.\n * So, we map the "cyan" to the "syntax-keyword" in the theme.\n */\n /* cyan: keyword */\n --color-ansi-cyan: var(--color-syntax-keyword);\n /* yellow: capitalized, jsxIdentifier, punctuation */\n --color-ansi-yellow: var(--color-syntax-
|
16
|
+
'\n :host {\n /* \n * CAUTION: THIS IS A WORKAROUND!\n * For now, we use @babel/code-frame to parse the code frame which does not support option to change the color.\n * x-ref: https://github.com/babel/babel/blob/efa52324ff835b794c48080f14877b6caf32cd15/packages/babel-code-frame/src/defs.ts#L40-L54\n * So, we do a workaround mapping to change the color matching the theme.\n *\n * For example, in @babel/code-frame, the "keyword" is mapped to ANSI "cyan".\n * We want the "keyword" to use the "syntax-keyword" color in the theme.\n * So, we map the "cyan" to the "syntax-keyword" in the theme.\n */\n /* cyan: keyword */\n --color-ansi-cyan: var(--color-syntax-keyword);\n /* yellow: capitalized, jsxIdentifier, punctuation */\n --color-ansi-yellow: var(--color-syntax-function);\n /* magenta: number, regex */\n --color-ansi-magenta: var(--color-syntax-keyword);\n /* green: string */\n --color-ansi-green: var(--color-syntax-string);\n /* gray (bright black): comment, gutter */\n --color-ansi-bright-black: var(--color-syntax-comment);\n\n /* Ansi - Temporary */\n --color-ansi-selection: var(--color-gray-alpha-300);\n --color-ansi-bg: var(--color-background-200);\n --color-ansi-fg: var(--color-gray-1000);\n\n --color-ansi-white: var(--color-gray-700);\n --color-ansi-black: var(--color-gray-200);\n --color-ansi-blue: var(--color-blue-700);\n --color-ansi-red: var(--color-red-700);\n --color-ansi-bright-white: var(--color-gray-1000);\n --color-ansi-bright-blue: var(--color-blue-800);\n --color-ansi-bright-cyan: var(--color-blue-800);\n --color-ansi-bright-green: var(--color-green-800);\n --color-ansi-bright-magenta: var(--color-blue-800);\n --color-ansi-bright-red: var(--color-red-800);\n --color-ansi-bright-yellow: var(--color-amber-900);\n\n /* Background Light */\n --color-background-100: #ffffff;\n --color-background-200: #fafafa;\n\n /* Syntax Light */\n --color-syntax-comment: #545454;\n --color-syntax-constant: #171717;\n --color-syntax-function: #0054ad;\n --color-syntax-keyword: #a51850;\n --color-syntax-link: #066056;\n --color-syntax-parameter: #8f3e00;\n --color-syntax-punctuation: #171717;\n --color-syntax-string: #036157;\n --color-syntax-string-expression: #066056;\n\n /* Gray Scale Light */\n --color-gray-100: #f2f2f2;\n --color-gray-200: #ebebeb;\n --color-gray-300: #e6e6e6;\n --color-gray-400: #eaeaea;\n --color-gray-500: #c9c9c9;\n --color-gray-600: #a8a8a8;\n --color-gray-700: #8f8f8f;\n --color-gray-800: #7d7d7d;\n --color-gray-900: #666666;\n --color-gray-1000: #171717;\n\n /* Gray Alpha Scale Light */\n --color-gray-alpha-100: rgba(0, 0, 0, 0.05);\n --color-gray-alpha-200: rgba(0, 0, 0, 0.081);\n --color-gray-alpha-300: rgba(0, 0, 0, 0.1);\n --color-gray-alpha-400: rgba(0, 0, 0, 0.08);\n --color-gray-alpha-500: rgba(0, 0, 0, 0.21);\n --color-gray-alpha-600: rgba(0, 0, 0, 0.34);\n --color-gray-alpha-700: rgba(0, 0, 0, 0.44);\n --color-gray-alpha-800: rgba(0, 0, 0, 0.51);\n --color-gray-alpha-900: rgba(0, 0, 0, 0.605);\n --color-gray-alpha-1000: rgba(0, 0, 0, 0.91);\n\n /* Blue Scale Light */\n --color-blue-100: #f0f7ff;\n --color-blue-200: #edf6ff;\n --color-blue-300: #e1f0ff;\n --color-blue-400: #cde7ff;\n --color-blue-500: #99ceff;\n --color-blue-600: #52aeff;\n --color-blue-700: #0070f3;\n --color-blue-800: #0060d1;\n --color-blue-900: #0067d6;\n --color-blue-1000: #0025ad;\n\n /* Red Scale Light */\n --color-red-100: #fff0f0;\n --color-red-200: #ffebeb;\n --color-red-300: #ffe5e5;\n --color-red-400: #fdd8d8;\n --color-red-500: #f8baba;\n --color-red-600: #f87274;\n --color-red-700: #e5484d;\n --color-red-800: #da3036;\n --color-red-900: #ca2a30;\n --color-red-1000: #381316;\n\n /* Amber Scale Light */\n --color-amber-100: #fff6e5;\n --color-amber-200: #fff4d5;\n --color-amber-300: #fef0cd;\n --color-amber-400: #ffddbf;\n --color-amber-500: #ffc96b;\n --color-amber-600: #f5b047;\n --color-amber-700: #ffb224;\n --color-amber-800: #ff990a;\n --color-amber-900: #a35200;\n --color-amber-1000: #4e2009;\n\n /* Green Scale Light */\n --color-green-100: #effbef;\n --color-green-200: #eafaea;\n --color-green-300: #dcf6dc;\n --color-green-400: #c8f1c9;\n --color-green-500: #99e59f;\n --color-green-600: #6cda76;\n --color-green-700: #46a758;\n --color-green-800: #388e4a;\n --color-green-900: #297c3b;\n --color-green-1000: #18311e;\n\n /* Turbopack Light - Temporary */\n --color-turbopack-text-red: #ff1e56;\n --color-turbopack-text-blue: #0096ff;\n --color-turbopack-border-red: #f0adbe;\n --color-turbopack-border-blue: #adccea;\n --color-turbopack-background-red: #fff7f9;\n --color-turbopack-background-blue: #f6fbff;\n }\n '
|
17
17
|
]);
|
18
18
|
_templateObject = function() {
|
19
19
|
return data;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/ui/styles/colors.tsx"],"sourcesContent":["import { css } from '../../utils/css'\n\nexport function Colors() {\n return (\n <style>\n {css`\n :host {\n /* \n * CAUTION: THIS IS A WORKAROUND!\n * For now, we use @babel/code-frame to parse the code frame which does not support option to change the color.\n * x-ref: https://github.com/babel/babel/blob/efa52324ff835b794c48080f14877b6caf32cd15/packages/babel-code-frame/src/defs.ts#L40-L54\n * So, we do a workaround mapping to change the color matching the theme.\n *\n * For example, in @babel/code-frame, the \"keyword\" is mapped to ANSI \"cyan\".\n * We want the \"keyword\" to use the \"syntax-keyword\" color in the theme.\n * So, we map the \"cyan\" to the \"syntax-keyword\" in the theme.\n */\n /* cyan: keyword */\n --color-ansi-cyan: var(--color-syntax-keyword);\n /* yellow: capitalized, jsxIdentifier, punctuation */\n --color-ansi-yellow: var(--color-syntax-
|
1
|
+
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/ui/styles/colors.tsx"],"sourcesContent":["import { css } from '../../utils/css'\n\nexport function Colors() {\n return (\n <style>\n {css`\n :host {\n /* \n * CAUTION: THIS IS A WORKAROUND!\n * For now, we use @babel/code-frame to parse the code frame which does not support option to change the color.\n * x-ref: https://github.com/babel/babel/blob/efa52324ff835b794c48080f14877b6caf32cd15/packages/babel-code-frame/src/defs.ts#L40-L54\n * So, we do a workaround mapping to change the color matching the theme.\n *\n * For example, in @babel/code-frame, the \"keyword\" is mapped to ANSI \"cyan\".\n * We want the \"keyword\" to use the \"syntax-keyword\" color in the theme.\n * So, we map the \"cyan\" to the \"syntax-keyword\" in the theme.\n */\n /* cyan: keyword */\n --color-ansi-cyan: var(--color-syntax-keyword);\n /* yellow: capitalized, jsxIdentifier, punctuation */\n --color-ansi-yellow: var(--color-syntax-function);\n /* magenta: number, regex */\n --color-ansi-magenta: var(--color-syntax-keyword);\n /* green: string */\n --color-ansi-green: var(--color-syntax-string);\n /* gray (bright black): comment, gutter */\n --color-ansi-bright-black: var(--color-syntax-comment);\n\n /* Ansi - Temporary */\n --color-ansi-selection: var(--color-gray-alpha-300);\n --color-ansi-bg: var(--color-background-200);\n --color-ansi-fg: var(--color-gray-1000);\n\n --color-ansi-white: var(--color-gray-700);\n --color-ansi-black: var(--color-gray-200);\n --color-ansi-blue: var(--color-blue-700);\n --color-ansi-red: var(--color-red-700);\n --color-ansi-bright-white: var(--color-gray-1000);\n --color-ansi-bright-blue: var(--color-blue-800);\n --color-ansi-bright-cyan: var(--color-blue-800);\n --color-ansi-bright-green: var(--color-green-800);\n --color-ansi-bright-magenta: var(--color-blue-800);\n --color-ansi-bright-red: var(--color-red-800);\n --color-ansi-bright-yellow: var(--color-amber-900);\n\n /* Background Light */\n --color-background-100: #ffffff;\n --color-background-200: #fafafa;\n\n /* Syntax Light */\n --color-syntax-comment: #545454;\n --color-syntax-constant: #171717;\n --color-syntax-function: #0054ad;\n --color-syntax-keyword: #a51850;\n --color-syntax-link: #066056;\n --color-syntax-parameter: #8f3e00;\n --color-syntax-punctuation: #171717;\n --color-syntax-string: #036157;\n --color-syntax-string-expression: #066056;\n\n /* Gray Scale Light */\n --color-gray-100: #f2f2f2;\n --color-gray-200: #ebebeb;\n --color-gray-300: #e6e6e6;\n --color-gray-400: #eaeaea;\n --color-gray-500: #c9c9c9;\n --color-gray-600: #a8a8a8;\n --color-gray-700: #8f8f8f;\n --color-gray-800: #7d7d7d;\n --color-gray-900: #666666;\n --color-gray-1000: #171717;\n\n /* Gray Alpha Scale Light */\n --color-gray-alpha-100: rgba(0, 0, 0, 0.05);\n --color-gray-alpha-200: rgba(0, 0, 0, 0.081);\n --color-gray-alpha-300: rgba(0, 0, 0, 0.1);\n --color-gray-alpha-400: rgba(0, 0, 0, 0.08);\n --color-gray-alpha-500: rgba(0, 0, 0, 0.21);\n --color-gray-alpha-600: rgba(0, 0, 0, 0.34);\n --color-gray-alpha-700: rgba(0, 0, 0, 0.44);\n --color-gray-alpha-800: rgba(0, 0, 0, 0.51);\n --color-gray-alpha-900: rgba(0, 0, 0, 0.605);\n --color-gray-alpha-1000: rgba(0, 0, 0, 0.91);\n\n /* Blue Scale Light */\n --color-blue-100: #f0f7ff;\n --color-blue-200: #edf6ff;\n --color-blue-300: #e1f0ff;\n --color-blue-400: #cde7ff;\n --color-blue-500: #99ceff;\n --color-blue-600: #52aeff;\n --color-blue-700: #0070f3;\n --color-blue-800: #0060d1;\n --color-blue-900: #0067d6;\n --color-blue-1000: #0025ad;\n\n /* Red Scale Light */\n --color-red-100: #fff0f0;\n --color-red-200: #ffebeb;\n --color-red-300: #ffe5e5;\n --color-red-400: #fdd8d8;\n --color-red-500: #f8baba;\n --color-red-600: #f87274;\n --color-red-700: #e5484d;\n --color-red-800: #da3036;\n --color-red-900: #ca2a30;\n --color-red-1000: #381316;\n\n /* Amber Scale Light */\n --color-amber-100: #fff6e5;\n --color-amber-200: #fff4d5;\n --color-amber-300: #fef0cd;\n --color-amber-400: #ffddbf;\n --color-amber-500: #ffc96b;\n --color-amber-600: #f5b047;\n --color-amber-700: #ffb224;\n --color-amber-800: #ff990a;\n --color-amber-900: #a35200;\n --color-amber-1000: #4e2009;\n\n /* Green Scale Light */\n --color-green-100: #effbef;\n --color-green-200: #eafaea;\n --color-green-300: #dcf6dc;\n --color-green-400: #c8f1c9;\n --color-green-500: #99e59f;\n --color-green-600: #6cda76;\n --color-green-700: #46a758;\n --color-green-800: #388e4a;\n --color-green-900: #297c3b;\n --color-green-1000: #18311e;\n\n /* Turbopack Light - Temporary */\n --color-turbopack-text-red: #ff1e56;\n --color-turbopack-text-blue: #0096ff;\n --color-turbopack-border-red: #f0adbe;\n --color-turbopack-border-blue: #adccea;\n --color-turbopack-background-red: #fff7f9;\n --color-turbopack-background-blue: #f6fbff;\n }\n `}\n </style>\n )\n}\n"],"names":["Colors","style","css"],"mappings":";;;;+BAEgBA;;;eAAAA;;;;;qBAFI;;;;;;;;;;AAEb,SAASA;IACd,qBACE,qBAACC;sBACEC,QAAG;;AA0IV"}
|
@@ -1,11 +1,19 @@
|
|
1
1
|
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser';
|
2
2
|
import type { OriginalStackFrameResponse } from '../server/shared';
|
3
|
-
export interface
|
4
|
-
error:
|
5
|
-
reason:
|
3
|
+
export interface ResolvedOriginalStackFrame extends OriginalStackFrameResponse {
|
4
|
+
error: false;
|
5
|
+
reason: null;
|
6
6
|
external: boolean;
|
7
7
|
ignored: boolean;
|
8
8
|
sourceStackFrame: StackFrame;
|
9
9
|
}
|
10
|
+
export interface RejectedOriginalStackFrame extends OriginalStackFrameResponse {
|
11
|
+
error: true;
|
12
|
+
reason: string;
|
13
|
+
external: boolean;
|
14
|
+
ignored: boolean;
|
15
|
+
sourceStackFrame: StackFrame;
|
16
|
+
}
|
17
|
+
export type OriginalStackFrame = ResolvedOriginalStackFrame | RejectedOriginalStackFrame;
|
10
18
|
export declare function getOriginalStackFrames(frames: StackFrame[], type: 'server' | 'edge-server' | null, isAppDir: boolean): Promise<OriginalStackFrame[]>;
|
11
19
|
export declare function getFrameSource(frame: StackFrame): string;
|
@@ -26,11 +26,11 @@ function getOriginalStackFrame(source, response) {
|
|
26
26
|
async function _getOriginalStackFrame() {
|
27
27
|
var _body_originalStackFrame;
|
28
28
|
if (response.status === 'rejected') {
|
29
|
-
|
29
|
+
throw Object.defineProperty(new Error(response.reason), "__NEXT_ERROR_CODE", {
|
30
30
|
value: "E394",
|
31
31
|
enumerable: false,
|
32
32
|
configurable: true
|
33
|
-
})
|
33
|
+
});
|
34
34
|
}
|
35
35
|
const body = response.value;
|
36
36
|
return {
|
@@ -40,7 +40,6 @@ function getOriginalStackFrame(source, response) {
|
|
40
40
|
sourceStackFrame: source,
|
41
41
|
originalStackFrame: body.originalStackFrame,
|
42
42
|
originalCodeFrame: body.originalCodeFrame || null,
|
43
|
-
sourcePackage: body.sourcePackage,
|
44
43
|
ignored: ((_body_originalStackFrame = body.originalStackFrame) == null ? void 0 : _body_originalStackFrame.ignored) || false
|
45
44
|
};
|
46
45
|
}
|
@@ -53,7 +52,6 @@ function getOriginalStackFrame(source, response) {
|
|
53
52
|
sourceStackFrame: source,
|
54
53
|
originalStackFrame: null,
|
55
54
|
originalCodeFrame: null,
|
56
|
-
sourcePackage: null,
|
57
55
|
ignored: true
|
58
56
|
});
|
59
57
|
}
|
@@ -66,7 +64,6 @@ function getOriginalStackFrame(source, response) {
|
|
66
64
|
sourceStackFrame: source,
|
67
65
|
originalStackFrame: null,
|
68
66
|
originalCodeFrame: null,
|
69
|
-
sourcePackage: null,
|
70
67
|
ignored: false
|
71
68
|
};
|
72
69
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/stack-frame.ts"],"sourcesContent":["import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport type {\n OriginalStackFrameResponse,\n OriginalStackFrameResponseResult,\n OriginalStackFramesRequest,\n} from '../server/shared'\nimport {\n isWebpackInternalResource,\n formatFrameSourceFile,\n} from './webpack-module-path'\nexport interface
|
1
|
+
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/stack-frame.ts"],"sourcesContent":["import type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport type {\n OriginalStackFrameResponse,\n OriginalStackFrameResponseResult,\n OriginalStackFramesRequest,\n} from '../server/shared'\nimport {\n isWebpackInternalResource,\n formatFrameSourceFile,\n} from './webpack-module-path'\n\nexport interface ResolvedOriginalStackFrame extends OriginalStackFrameResponse {\n error: false\n reason: null\n external: boolean\n ignored: boolean\n sourceStackFrame: StackFrame\n}\n\nexport interface RejectedOriginalStackFrame extends OriginalStackFrameResponse {\n error: true\n reason: string\n external: boolean\n ignored: boolean\n sourceStackFrame: StackFrame\n}\n\nexport type OriginalStackFrame =\n | ResolvedOriginalStackFrame\n | RejectedOriginalStackFrame\n\nfunction getOriginalStackFrame(\n source: StackFrame,\n response: OriginalStackFrameResponseResult\n): Promise<OriginalStackFrame> {\n async function _getOriginalStackFrame(): Promise<ResolvedOriginalStackFrame> {\n if (response.status === 'rejected') {\n throw new Error(response.reason)\n }\n\n const body: OriginalStackFrameResponse = response.value\n\n return {\n error: false,\n reason: null,\n external: false,\n sourceStackFrame: source,\n originalStackFrame: body.originalStackFrame,\n originalCodeFrame: body.originalCodeFrame || null,\n ignored: body.originalStackFrame?.ignored || false,\n }\n }\n\n // TODO: merge this section into ignoredList handling\n if (source.file === 'file://' || source.file?.match(/https?:\\/\\//)) {\n return Promise.resolve({\n error: false,\n reason: null,\n external: true,\n sourceStackFrame: source,\n originalStackFrame: null,\n originalCodeFrame: null,\n ignored: true,\n })\n }\n\n return _getOriginalStackFrame().catch(\n (err: Error): RejectedOriginalStackFrame => ({\n error: true,\n reason: err?.message ?? err?.toString() ?? 'Unknown Error',\n external: false,\n sourceStackFrame: source,\n originalStackFrame: null,\n originalCodeFrame: null,\n ignored: false,\n })\n )\n}\n\nexport async function getOriginalStackFrames(\n frames: StackFrame[],\n type: 'server' | 'edge-server' | null,\n isAppDir: boolean\n): Promise<OriginalStackFrame[]> {\n const req: OriginalStackFramesRequest = {\n frames,\n isServer: type === 'server',\n isEdgeServer: type === 'edge-server',\n isAppDirectory: isAppDir,\n }\n\n let res: Response | undefined = undefined\n let reason: string | undefined = undefined\n try {\n res = await fetch('/__nextjs_original-stack-frames', {\n method: 'POST',\n body: JSON.stringify(req),\n })\n } catch (e) {\n reason = e + ''\n }\n\n // When fails to fetch the original stack frames, we reject here to be\n // caught at `_getOriginalStackFrame()` and return the stack frames so\n // that the error overlay can render.\n if (res && res.ok && res.status !== 204) {\n const data = await res.json()\n return Promise.all(\n frames.map((frame, index) => getOriginalStackFrame(frame, data[index]))\n )\n } else {\n if (res) {\n reason = await res.text()\n }\n }\n return Promise.all(\n frames.map((frame) =>\n getOriginalStackFrame(frame, {\n status: 'rejected',\n reason: `Failed to fetch the original stack frames ${reason ? `: ${reason}` : ''}`,\n })\n )\n )\n}\n\nexport function getFrameSource(frame: StackFrame): string {\n if (!frame.file) return ''\n\n const isWebpackFrame = isWebpackInternalResource(frame.file)\n\n let str = ''\n // Skip URL parsing for webpack internal file paths.\n if (isWebpackFrame) {\n str = formatFrameSourceFile(frame.file)\n } else {\n try {\n const u = new URL(frame.file)\n\n let parsedPath = ''\n // Strip the origin for same-origin scripts.\n if (globalThis.location?.origin !== u.origin) {\n // URLs can be valid without an `origin`, so long as they have a\n // `protocol`. However, `origin` is preferred.\n if (u.origin === 'null') {\n parsedPath += u.protocol\n } else {\n parsedPath += u.origin\n }\n }\n\n // Strip query string information as it's typically too verbose to be\n // meaningful.\n parsedPath += u.pathname\n str = formatFrameSourceFile(parsedPath)\n } catch {\n str = formatFrameSourceFile(frame.file)\n }\n }\n\n if (!isWebpackInternalResource(frame.file) && frame.lineNumber != null) {\n if (str) {\n if (frame.column != null) {\n str += ` (${frame.lineNumber}:${frame.column})`\n } else {\n str += ` (${frame.lineNumber})`\n }\n }\n }\n return str\n}\n"],"names":["getFrameSource","getOriginalStackFrames","getOriginalStackFrame","source","response","_getOriginalStackFrame","body","status","Error","reason","value","error","external","sourceStackFrame","originalStackFrame","originalCodeFrame","ignored","file","match","Promise","resolve","catch","err","message","toString","frames","type","isAppDir","req","isServer","isEdgeServer","isAppDirectory","res","undefined","fetch","method","JSON","stringify","e","ok","data","json","all","map","frame","index","text","isWebpackFrame","isWebpackInternalResource","str","formatFrameSourceFile","globalThis","u","URL","parsedPath","location","origin","protocol","pathname","lineNumber","column"],"mappings":";;;;;;;;;;;;;;;IA6HgBA,cAAc;eAAdA;;IA9CMC,sBAAsB;eAAtBA;;;mCAtEf;AAsBP,SAASC,sBACPC,MAAkB,EAClBC,QAA0C;QAqBTD;IAnBjC,eAAeE;YAcFC;QAbX,IAAIF,SAASG,MAAM,KAAK,YAAY;YAClC,MAAM,qBAA0B,CAA1B,IAAIC,MAAMJ,SAASK,MAAM,GAAzB,qBAAA;uBAAA;4BAAA;8BAAA;YAAyB;QACjC;QAEA,MAAMH,OAAmCF,SAASM,KAAK;QAEvD,OAAO;YACLC,OAAO;YACPF,QAAQ;YACRG,UAAU;YACVC,kBAAkBV;YAClBW,oBAAoB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AIL,MAAMgB,MAAM,IAAI,MAAM;gBACxBX,OAAO,AAAC,OAAIL,MAAMe,UAAU,GAAC,MAAGf,MAAMgB,MAAM,GAAC;YAC/C,OAAO;gBACLX,OAAO,AAAC,OAAIL,MAAMe,UAAU,GAAC;YAC/B;QACF;IACF;IACA,OAAOV;AACT"}
|
@@ -89,7 +89,7 @@ function triggerLazyFetchForLeafSegments(newCache, currentCache, flightSegmentPa
|
|
89
89
|
}
|
90
90
|
return appliedPatch;
|
91
91
|
}
|
92
|
-
function handleNavigationResult(state, mutable, pendingPush, result) {
|
92
|
+
function handleNavigationResult(url, state, mutable, pendingPush, result) {
|
93
93
|
switch(result.tag){
|
94
94
|
case _navigation.NavigationResultTag.MPA:
|
95
95
|
{
|
@@ -98,8 +98,27 @@ function handleNavigationResult(state, mutable, pendingPush, result) {
|
|
98
98
|
return handleExternalUrl(state, mutable, newUrl, pendingPush);
|
99
99
|
}
|
100
100
|
case _navigation.NavigationResultTag.NoOp:
|
101
|
-
|
102
|
-
|
101
|
+
{
|
102
|
+
// The server responded with no change to the current page. However, if
|
103
|
+
// the URL changed, we still need to update that.
|
104
|
+
const newCanonicalUrl = result.data.canonicalUrl;
|
105
|
+
mutable.canonicalUrl = newCanonicalUrl;
|
106
|
+
// Check if the only thing that changed was the hash fragment.
|
107
|
+
const oldUrl = new URL(state.canonicalUrl, url);
|
108
|
+
const onlyHashChange = // We don't need to compare the origins, because client-driven
|
109
|
+
// navigations are always same-origin.
|
110
|
+
url.pathname === oldUrl.pathname && url.search === oldUrl.search && url.hash !== oldUrl.hash;
|
111
|
+
if (onlyHashChange) {
|
112
|
+
// The only updated part of the URL is the hash.
|
113
|
+
mutable.onlyHashChange = true;
|
114
|
+
mutable.shouldScroll = result.data.shouldScroll;
|
115
|
+
mutable.hashFragment = url.hash;
|
116
|
+
// Setting this to an empty array triggers a scroll for all new and
|
117
|
+
// updated segments. See `ScrollAndFocusHandler` for more details.
|
118
|
+
mutable.scrollableSegments = [];
|
119
|
+
}
|
120
|
+
return (0, _handlemutable.handleMutable)(state, mutable);
|
121
|
+
}
|
103
122
|
case _navigation.NavigationResultTag.Success:
|
104
123
|
{
|
105
124
|
// Received a new result.
|
@@ -108,13 +127,12 @@ function handleNavigationResult(state, mutable, pendingPush, result) {
|
|
108
127
|
mutable.canonicalUrl = result.data.canonicalUrl;
|
109
128
|
mutable.scrollableSegments = result.data.scrollableSegments;
|
110
129
|
mutable.shouldScroll = result.data.shouldScroll;
|
111
|
-
|
112
|
-
// mutable.hashFragment = hash
|
130
|
+
mutable.hashFragment = result.data.hash;
|
113
131
|
return (0, _handlemutable.handleMutable)(state, mutable);
|
114
132
|
}
|
115
133
|
case _navigation.NavigationResultTag.Async:
|
116
134
|
{
|
117
|
-
return result.data.then((asyncResult)=>handleNavigationResult(state, mutable, pendingPush, asyncResult), // If the navigation failed, return the current state.
|
135
|
+
return result.data.then((asyncResult)=>handleNavigationResult(url, state, mutable, pendingPush, asyncResult), // If the navigation failed, return the current state.
|
118
136
|
// TODO: This matches the current behavior but we need to do something
|
119
137
|
// better here if the network fails.
|
120
138
|
()=>{
|
@@ -122,8 +140,10 @@ function handleNavigationResult(state, mutable, pendingPush, result) {
|
|
122
140
|
});
|
123
141
|
}
|
124
142
|
default:
|
125
|
-
|
126
|
-
|
143
|
+
{
|
144
|
+
result;
|
145
|
+
return state;
|
146
|
+
}
|
127
147
|
}
|
128
148
|
}
|
129
149
|
function navigateReducer(state, action) {
|
@@ -157,7 +177,7 @@ function navigateReducer(state, action) {
|
|
157
177
|
// it will return a sync result if the navigation was prefetched. Hence
|
158
178
|
// a result type that's more complicated than you might expect.
|
159
179
|
const result = (0, _navigation.navigate)(url, state.cache, state.tree, state.nextUrl, shouldScroll);
|
160
|
-
return handleNavigationResult(state, mutable, pendingPush, result);
|
180
|
+
return handleNavigationResult(url, state, mutable, pendingPush, result);
|
161
181
|
}
|
162
182
|
const prefetchValues = (0, _prefetchcacheutils.getOrCreatePrefetchCacheEntry)({
|
163
183
|
url,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/navigate-reducer.ts"],"sourcesContent":["import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'\nimport type {\n FlightRouterState,\n FlightSegmentPath,\n} from '../../../../server/app-render/types'\nimport { fetchServerResponse } from '../fetch-server-response'\nimport { createHrefFromUrl } from '../create-href-from-url'\nimport { invalidateCacheBelowFlightSegmentPath } from '../invalidate-cache-below-flight-segmentpath'\nimport { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree'\nimport { shouldHardNavigate } from '../should-hard-navigate'\nimport { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout'\nimport {\n PrefetchCacheEntryStatus,\n type Mutable,\n type NavigateAction,\n type ReadonlyReducerState,\n type ReducerState,\n} from '../router-reducer-types'\nimport { handleMutable } from '../handle-mutable'\nimport { applyFlightData } from '../apply-flight-data'\nimport { prefetchQueue } from './prefetch-reducer'\nimport { createEmptyCacheNode } from '../../app-router'\nimport { DEFAULT_SEGMENT_KEY } from '../../../../shared/lib/segment'\nimport { listenForDynamicRequest, startPPRNavigation } from '../ppr-navigations'\nimport {\n getOrCreatePrefetchCacheEntry,\n prunePrefetchCache,\n} from '../prefetch-cache-utils'\nimport { clearCacheNodeDataForSegmentPath } from '../clear-cache-node-data-for-segment-path'\nimport { handleAliasedPrefetchEntry } from '../aliased-prefetch-navigations'\nimport {\n navigate as navigateUsingSegmentCache,\n NavigationResultTag,\n type NavigationResult,\n} from '../../segment-cache/navigation'\n\nexport function handleExternalUrl(\n state: ReadonlyReducerState,\n mutable: Mutable,\n url: string,\n pendingPush: boolean\n) {\n mutable.mpaNavigation = true\n mutable.canonicalUrl = url\n mutable.pendingPush = pendingPush\n mutable.scrollableSegments = undefined\n\n return handleMutable(state, mutable)\n}\n\nfunction generateSegmentsFromPatch(\n flightRouterPatch: FlightRouterState\n): FlightSegmentPath[] {\n const segments: FlightSegmentPath[] = []\n const [segment, parallelRoutes] = flightRouterPatch\n\n if (Object.keys(parallelRoutes).length === 0) {\n return [[segment]]\n }\n\n for (const [parallelRouteKey, parallelRoute] of Object.entries(\n parallelRoutes\n )) {\n for (const childSegment of generateSegmentsFromPatch(parallelRoute)) {\n // If the segment is empty, it means we are at the root of the tree\n if (segment === '') {\n segments.push([parallelRouteKey, ...childSegment])\n } else {\n segments.push([segment, parallelRouteKey, ...childSegment])\n }\n }\n }\n\n return segments\n}\n\nfunction triggerLazyFetchForLeafSegments(\n newCache: CacheNode,\n currentCache: CacheNode,\n flightSegmentPath: FlightSegmentPath,\n treePatch: FlightRouterState\n) {\n let appliedPatch = false\n\n newCache.rsc = currentCache.rsc\n newCache.prefetchRsc = currentCache.prefetchRsc\n newCache.loading = currentCache.loading\n newCache.parallelRoutes = new Map(currentCache.parallelRoutes)\n\n const segmentPathsToFill = generateSegmentsFromPatch(treePatch).map(\n (segment) => [...flightSegmentPath, ...segment]\n )\n\n for (const segmentPaths of segmentPathsToFill) {\n clearCacheNodeDataForSegmentPath(newCache, currentCache, segmentPaths)\n\n appliedPatch = true\n }\n\n return appliedPatch\n}\n\nfunction handleNavigationResult(\n state: ReadonlyReducerState,\n mutable: Mutable,\n pendingPush: boolean,\n result: NavigationResult\n): ReducerState {\n switch (result.tag) {\n case NavigationResultTag.MPA: {\n // Perform an MPA navigation.\n const newUrl = result.data\n return handleExternalUrl(state, mutable, newUrl, pendingPush)\n }\n case NavigationResultTag.NoOp:\n // The server responded with no change to the current page.\n return handleMutable(state, mutable)\n case NavigationResultTag.Success: {\n // Received a new result.\n mutable.cache = result.data.cacheNode\n mutable.patchedTree = result.data.flightRouterState\n mutable.canonicalUrl = result.data.canonicalUrl\n mutable.scrollableSegments = result.data.scrollableSegments\n mutable.shouldScroll = result.data.shouldScroll\n // TODO: Not yet implemented\n // mutable.hashFragment = hash\n return handleMutable(state, mutable)\n }\n case NavigationResultTag.Async: {\n return result.data.then(\n (asyncResult) =>\n handleNavigationResult(state, mutable, pendingPush, asyncResult),\n // If the navigation failed, return the current state.\n // TODO: This matches the current behavior but we need to do something\n // better here if the network fails.\n () => {\n return state\n }\n )\n }\n default:\n const _exhaustiveCheck: never = result\n return state\n }\n}\n\nexport function navigateReducer(\n state: ReadonlyReducerState,\n action: NavigateAction\n): ReducerState {\n const { url, isExternalUrl, navigateType, shouldScroll, allowAliasing } =\n action\n const mutable: Mutable = {}\n const { hash } = url\n const href = createHrefFromUrl(url)\n const pendingPush = navigateType === 'push'\n // we want to prune the prefetch cache on every navigation to avoid it growing too large\n prunePrefetchCache(state.prefetchCache)\n\n mutable.preserveCustomHistoryState = false\n mutable.pendingPush = pendingPush\n\n if (isExternalUrl) {\n return handleExternalUrl(state, mutable, url.toString(), pendingPush)\n }\n\n // Handles case where `<meta http-equiv=\"refresh\">` tag is present,\n // which will trigger an MPA navigation.\n if (document.getElementById('__next-page-redirect')) {\n return handleExternalUrl(state, mutable, href, pendingPush)\n }\n\n if (process.env.__NEXT_CLIENT_SEGMENT_CACHE) {\n // (Very Early Experimental Feature) Segment Cache\n //\n // Bypass the normal prefetch cache and use the new per-segment cache\n // implementation instead. This is only supported if PPR is enabled, too.\n //\n // Temporary glue code between the router reducer and the new navigation\n // implementation. Eventually we'll rewrite the router reducer to a\n // state machine.\n // TODO: Currently this always returns an async result, but in the future\n // it will return a sync result if the navigation was prefetched. Hence\n // a result type that's more complicated than you might expect.\n const result = navigateUsingSegmentCache(\n url,\n state.cache,\n state.tree,\n state.nextUrl,\n shouldScroll\n )\n return handleNavigationResult(state, mutable, pendingPush, result)\n }\n\n const prefetchValues = getOrCreatePrefetchCacheEntry({\n url,\n nextUrl: state.nextUrl,\n tree: state.tree,\n prefetchCache: state.prefetchCache,\n allowAliasing,\n })\n const { treeAtTimeOfPrefetch, data } = prefetchValues\n\n prefetchQueue.bump(data)\n\n return data.then(\n ({ flightData, canonicalUrl: canonicalUrlOverride, postponed }) => {\n let isFirstRead = false\n // we only want to mark this once\n if (!prefetchValues.lastUsedTime) {\n // important: we should only mark the cache node as dirty after we unsuspend from the call above\n prefetchValues.lastUsedTime = Date.now()\n isFirstRead = true\n }\n\n // Handle case when navigating to page in `pages` from `app`\n if (typeof flightData === 'string') {\n return handleExternalUrl(state, mutable, flightData, pendingPush)\n }\n\n const updatedCanonicalUrl = canonicalUrlOverride\n ? createHrefFromUrl(canonicalUrlOverride)\n : href\n\n const onlyHashChange =\n !!hash &&\n state.canonicalUrl.split('#', 1)[0] ===\n updatedCanonicalUrl.split('#', 1)[0]\n\n // If only the hash has changed, the server hasn't sent us any new data. We can just update\n // the mutable properties responsible for URL and scroll handling and return early.\n if (onlyHashChange) {\n mutable.onlyHashChange = true\n mutable.canonicalUrl = updatedCanonicalUrl\n mutable.shouldScroll = shouldScroll\n mutable.hashFragment = hash\n mutable.scrollableSegments = []\n return handleMutable(state, mutable)\n }\n\n if (prefetchValues.aliased) {\n const result = handleAliasedPrefetchEntry(\n state,\n flightData,\n url,\n mutable\n )\n\n // We didn't return new router state because we didn't apply the aliased entry for some reason.\n // We'll re-invoke the navigation handler but ensure that we don't attempt to use the aliased entry. This\n // will create an on-demand prefetch entry.\n if (result === false) {\n return navigateReducer(state, { ...action, allowAliasing: false })\n }\n\n return result\n }\n\n let currentTree = state.tree\n let currentCache = state.cache\n let scrollableSegments: FlightSegmentPath[] = []\n for (const normalizedFlightData of flightData) {\n const {\n pathToSegment: flightSegmentPath,\n seedData,\n head,\n isHeadPartial,\n isRootRender,\n } = normalizedFlightData\n let treePatch = normalizedFlightData.tree\n\n // TODO-APP: remove ''\n const flightSegmentPathWithLeadingEmpty = ['', ...flightSegmentPath]\n\n // Create new tree based on the flightSegmentPath and router state patch\n let newTree = applyRouterStatePatchToTree(\n // TODO-APP: remove ''\n flightSegmentPathWithLeadingEmpty,\n currentTree,\n treePatch,\n href\n )\n\n // If the tree patch can't be applied to the current tree then we use the tree at time of prefetch\n // TODO-APP: This should instead fill in the missing pieces in `currentTree` with the data from `treeAtTimeOfPrefetch`, then apply the patch.\n if (newTree === null) {\n newTree = applyRouterStatePatchToTree(\n // TODO-APP: remove ''\n flightSegmentPathWithLeadingEmpty,\n treeAtTimeOfPrefetch,\n treePatch,\n href\n )\n }\n\n if (newTree !== null) {\n if (\n // This is just a paranoid check. When a route is PPRed, the server\n // will send back a static response that's rendered from\n // the root. If for some reason it doesn't, we fall back to the\n // non-PPR implementation.\n // TODO: We should get rid of the else branch and do all navigations\n // via startPPRNavigation. The current structure is just\n // an incremental step.\n seedData &&\n isRootRender &&\n postponed\n ) {\n const task = startPPRNavigation(\n currentCache,\n currentTree,\n treePatch,\n seedData,\n head,\n isHeadPartial,\n scrollableSegments\n )\n\n if (task !== null) {\n if (task.route === null) {\n // Detected a change to the root layout. Perform an full-\n // page navigation.\n return handleExternalUrl(state, mutable, href, pendingPush)\n }\n // Use the tree computed by startPPRNavigation instead\n // of the one computed by applyRouterStatePatchToTree.\n // TODO: We should remove applyRouterStatePatchToTree\n // from the PPR path entirely.\n const patchedRouterState: FlightRouterState = task.route\n newTree = patchedRouterState\n\n const newCache = task.node\n if (newCache !== null) {\n // We've created a new Cache Node tree that contains a prefetched\n // version of the next page. This can be rendered instantly.\n mutable.cache = newCache\n }\n const dynamicRequestTree = task.dynamicRequestTree\n if (dynamicRequestTree !== null) {\n // The prefetched tree has dynamic holes in it. We initiate a\n // dynamic request to fill them in.\n //\n // Do not block on the result. We'll immediately render the Cache\n // Node tree and suspend on the dynamic parts. When the request\n // comes in, we'll fill in missing data and ping React to\n // re-render. Unlike the lazy fetching model in the non-PPR\n // implementation, this is modeled as a single React update +\n // streaming, rather than multiple top-level updates. (However,\n // even in the new model, we'll still need to sometimes update the\n // root multiple times per navigation, like if the server sends us\n // a different response than we expected. For now, we revert back\n // to the lazy fetching mechanism in that case.)\n const dynamicRequest = fetchServerResponse(url, {\n flightRouterState: dynamicRequestTree,\n nextUrl: state.nextUrl,\n })\n\n listenForDynamicRequest(task, dynamicRequest)\n // We store the dynamic request on the `lazyData` property of the CacheNode\n // because we're not going to await the dynamic request here. Since we're not blocking\n // on the dynamic request, `layout-router` will\n // task.node.lazyData = dynamicRequest\n } else {\n // The prefetched tree does not contain dynamic holes — it's\n // fully static. We can skip the dynamic request.\n }\n } else {\n // Nothing changed, so reuse the old cache.\n // TODO: What if the head changed but not any of the segment data?\n // Is that possible? If so, we should clone the whole tree and\n // update the head.\n newTree = treePatch\n }\n } else {\n // The static response does not include any dynamic holes, so\n // there's no need to do a second request.\n // TODO: As an incremental step this just reverts back to the\n // non-PPR implementation. We can simplify this branch further,\n // given that PPR prefetches are always static and return the whole\n // tree. Or in the meantime we could factor it out into a\n // separate function.\n\n if (isNavigatingToNewRootLayout(currentTree, newTree)) {\n return handleExternalUrl(state, mutable, href, pendingPush)\n }\n\n const cache: CacheNode = createEmptyCacheNode()\n let applied = false\n\n if (\n prefetchValues.status === PrefetchCacheEntryStatus.stale &&\n !isFirstRead\n ) {\n // When we have a stale prefetch entry, we only want to re-use the loading state of the route we're navigating to, to support instant loading navigations\n // this will trigger a lazy fetch for the actual page data by nulling the `rsc` and `prefetchRsc` values for page data,\n // while copying over the `loading` for the segment that contains the page data.\n // We only do this on subsequent reads, as otherwise there'd be no loading data to re-use.\n\n // We skip this branch if only the hash fragment has changed, as we don't want to trigger a lazy fetch in that case\n applied = triggerLazyFetchForLeafSegments(\n cache,\n currentCache,\n flightSegmentPath,\n treePatch\n )\n // since we re-used the stale cache's loading state & refreshed the data,\n // update the `lastUsedTime` so that it can continue to be re-used for the next 30s\n prefetchValues.lastUsedTime = Date.now()\n } else {\n applied = applyFlightData(\n currentCache,\n cache,\n normalizedFlightData,\n prefetchValues\n )\n }\n\n const hardNavigate = shouldHardNavigate(\n // TODO-APP: remove ''\n flightSegmentPathWithLeadingEmpty,\n currentTree\n )\n\n if (hardNavigate) {\n // Copy rsc for the root node of the cache.\n cache.rsc = currentCache.rsc\n cache.prefetchRsc = currentCache.prefetchRsc\n\n invalidateCacheBelowFlightSegmentPath(\n cache,\n currentCache,\n flightSegmentPath\n )\n // Ensure the existing cache value is used when the cache was not invalidated.\n mutable.cache = cache\n } else if (applied) {\n mutable.cache = cache\n // If we applied the cache, we update the \"current cache\" value so any other\n // segments in the FlightDataPath will be able to reference the updated cache.\n currentCache = cache\n }\n\n for (const subSegment of generateSegmentsFromPatch(treePatch)) {\n const scrollableSegmentPath = [\n ...flightSegmentPath,\n ...subSegment,\n ]\n // Filter out the __DEFAULT__ paths as they shouldn't be scrolled to in this case.\n if (\n scrollableSegmentPath[scrollableSegmentPath.length - 1] !==\n DEFAULT_SEGMENT_KEY\n ) {\n scrollableSegments.push(scrollableSegmentPath)\n }\n }\n }\n\n currentTree = newTree\n }\n }\n\n mutable.patchedTree = currentTree\n mutable.canonicalUrl = updatedCanonicalUrl\n mutable.scrollableSegments = scrollableSegments\n mutable.hashFragment = hash\n mutable.shouldScroll = shouldScroll\n\n return handleMutable(state, mutable)\n },\n () => state\n )\n}\n"],"names":["handleExternalUrl","navigateReducer","state","mutable","url","pendingPush","mpaNavigation","canonicalUrl","scrollableSegments","undefined","handleMutable","generateSegmentsFromPatch","flightRouterPatch","segments","segment","parallelRoutes","Object","keys","length","parallelRouteKey","parallelRoute","entries","childSegment","push","triggerLazyFetchForLeafSegments","newCache","currentCache","flightSegmentPath","treePatch","appliedPatch","rsc","prefetchRsc","loading","Map","segmentPathsToFill","map","segmentPaths","clearCacheNodeDataForSegmentPath","handleNavigationResult","result","tag","NavigationResultTag","MPA","newUrl","data","NoOp","Success","cache","cacheNode","patchedTree","flightRouterState","shouldScroll","Async","then","asyncResult","_exhaustiveCheck","action","isExternalUrl","navigateType","allowAliasing","hash","href","createHrefFromUrl","prunePrefetchCache","prefetchCache","preserveCustomHistoryState","toString","document","getElementById","process","env","__NEXT_CLIENT_SEGMENT_CACHE","navigateUsingSegmentCache","tree","nextUrl","prefetchValues","getOrCreatePrefetchCacheEntry","treeAtTimeOfPrefetch","prefetchQueue","bump","flightData","canonicalUrlOverride","postponed","isFirstRead","lastUsedTime","Date","now","updatedCanonicalUrl","onlyHashChange","split","hashFragment","aliased","handleAliasedPrefetchEntry","currentTree","normalizedFlightData","pathToSegment","seedData","head","isHeadPartial","isRootRender","flightSegmentPathWithLeadingEmpty","newTree","applyRouterStatePatchToTree","task","startPPRNavigation","route","patchedRouterState","node","dynamicRequestTree","dynamicRequest","fetchServerResponse","listenForDynamicRequest","isNavigatingToNewRootLayout","createEmptyCacheNode","applied","status","PrefetchCacheEntryStatus","stale","applyFlightData","hardNavigate","shouldHardNavigate","invalidateCacheBelowFlightSegmentPath","subSegment","scrollableSegmentPath","DEFAULT_SEGMENT_KEY"],"mappings":";;;;;;;;;;;;;;;IAoCgBA,iBAAiB;eAAjBA;;IA8GAC,eAAe;eAAfA;;;qCA7IoB;mCACF;uDACoB;6CACV;oCACT;6CACS;oCAOrC;+BACuB;iCACE;iCACF;2BACO;yBACD;gCACwB;oCAIrD;kDAC0C;4CACN;4BAKpC;AAEA,SAASD,kBACdE,KAA2B,EAC3BC,OAAgB,EAChBC,GAAW,EACXC,WAAoB;IAEpBF,QAAQG,aAAa,GAAG;IACxBH,QAAQI,YAAY,GAAGH;IACvBD,QAAQE,WAAW,GAAGA;IACtBF,QAAQK,kBAAkB,GAAGC;IAE7B,OAAOC,IAAAA,4BAAa,EAACR,OAAOC;AAC9B;AAEA,SAASQ,0BACPC,iBAAoC;IAEpC,MAAMC,WAAgC,EAAE;IACxC,MAAM,CAACC,SAASC,eAAe,GAAGH;IAElC,IAAII,OAAOC,IAAI,CAACF,gBAAgBG,MAAM,KAAK,GAAG;QAC5C,OAAO;YAAC;gBAACJ;aAAQ;SAAC;IACpB;IAEA,KAAK,MAAM,CAACK,kBAAkBC,cAAc,IAAIJ,OAAOK,OAAO,CAC5DN,gBACC;QACD,KAAK,MAAMO,gBAAgBX,0BAA0BS,eAAgB;YACnE,mEAAmE;YACnE,IAAIN,YAAY,IAAI;gBAClBD,SAASU,IAAI,CAAC;oBAACJ;uBAAqBG;iBAAa;YACnD,O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AAOC;IAC9B,GACA,IAAMD;AAEV"}
|
1
|
+
{"version":3,"sources":["../../../../../src/client/components/router-reducer/reducers/navigate-reducer.ts"],"sourcesContent":["import type { CacheNode } from '../../../../shared/lib/app-router-context.shared-runtime'\nimport type {\n FlightRouterState,\n FlightSegmentPath,\n} from '../../../../server/app-render/types'\nimport { fetchServerResponse } from '../fetch-server-response'\nimport { createHrefFromUrl } from '../create-href-from-url'\nimport { invalidateCacheBelowFlightSegmentPath } from '../invalidate-cache-below-flight-segmentpath'\nimport { applyRouterStatePatchToTree } from '../apply-router-state-patch-to-tree'\nimport { shouldHardNavigate } from '../should-hard-navigate'\nimport { isNavigatingToNewRootLayout } from '../is-navigating-to-new-root-layout'\nimport {\n PrefetchCacheEntryStatus,\n type Mutable,\n type NavigateAction,\n type ReadonlyReducerState,\n type ReducerState,\n} from '../router-reducer-types'\nimport { handleMutable } from '../handle-mutable'\nimport { applyFlightData } from '../apply-flight-data'\nimport { prefetchQueue } from './prefetch-reducer'\nimport { createEmptyCacheNode } from '../../app-router'\nimport { DEFAULT_SEGMENT_KEY } from '../../../../shared/lib/segment'\nimport { listenForDynamicRequest, startPPRNavigation } from '../ppr-navigations'\nimport {\n getOrCreatePrefetchCacheEntry,\n prunePrefetchCache,\n} from '../prefetch-cache-utils'\nimport { clearCacheNodeDataForSegmentPath } from '../clear-cache-node-data-for-segment-path'\nimport { handleAliasedPrefetchEntry } from '../aliased-prefetch-navigations'\nimport {\n navigate as navigateUsingSegmentCache,\n NavigationResultTag,\n type NavigationResult,\n} from '../../segment-cache/navigation'\n\nexport function handleExternalUrl(\n state: ReadonlyReducerState,\n mutable: Mutable,\n url: string,\n pendingPush: boolean\n) {\n mutable.mpaNavigation = true\n mutable.canonicalUrl = url\n mutable.pendingPush = pendingPush\n mutable.scrollableSegments = undefined\n\n return handleMutable(state, mutable)\n}\n\nfunction generateSegmentsFromPatch(\n flightRouterPatch: FlightRouterState\n): FlightSegmentPath[] {\n const segments: FlightSegmentPath[] = []\n const [segment, parallelRoutes] = flightRouterPatch\n\n if (Object.keys(parallelRoutes).length === 0) {\n return [[segment]]\n }\n\n for (const [parallelRouteKey, parallelRoute] of Object.entries(\n parallelRoutes\n )) {\n for (const childSegment of generateSegmentsFromPatch(parallelRoute)) {\n // If the segment is empty, it means we are at the root of the tree\n if (segment === '') {\n segments.push([parallelRouteKey, ...childSegment])\n } else {\n segments.push([segment, parallelRouteKey, ...childSegment])\n }\n }\n }\n\n return segments\n}\n\nfunction triggerLazyFetchForLeafSegments(\n newCache: CacheNode,\n currentCache: CacheNode,\n flightSegmentPath: FlightSegmentPath,\n treePatch: FlightRouterState\n) {\n let appliedPatch = false\n\n newCache.rsc = currentCache.rsc\n newCache.prefetchRsc = currentCache.prefetchRsc\n newCache.loading = currentCache.loading\n newCache.parallelRoutes = new Map(currentCache.parallelRoutes)\n\n const segmentPathsToFill = generateSegmentsFromPatch(treePatch).map(\n (segment) => [...flightSegmentPath, ...segment]\n )\n\n for (const segmentPaths of segmentPathsToFill) {\n clearCacheNodeDataForSegmentPath(newCache, currentCache, segmentPaths)\n\n appliedPatch = true\n }\n\n return appliedPatch\n}\n\nfunction handleNavigationResult(\n url: URL,\n state: ReadonlyReducerState,\n mutable: Mutable,\n pendingPush: boolean,\n result: NavigationResult\n): ReducerState {\n switch (result.tag) {\n case NavigationResultTag.MPA: {\n // Perform an MPA navigation.\n const newUrl = result.data\n return handleExternalUrl(state, mutable, newUrl, pendingPush)\n }\n case NavigationResultTag.NoOp: {\n // The server responded with no change to the current page. However, if\n // the URL changed, we still need to update that.\n const newCanonicalUrl = result.data.canonicalUrl\n mutable.canonicalUrl = newCanonicalUrl\n\n // Check if the only thing that changed was the hash fragment.\n const oldUrl = new URL(state.canonicalUrl, url)\n const onlyHashChange =\n // We don't need to compare the origins, because client-driven\n // navigations are always same-origin.\n url.pathname === oldUrl.pathname &&\n url.search === oldUrl.search &&\n url.hash !== oldUrl.hash\n if (onlyHashChange) {\n // The only updated part of the URL is the hash.\n mutable.onlyHashChange = true\n mutable.shouldScroll = result.data.shouldScroll\n mutable.hashFragment = url.hash\n // Setting this to an empty array triggers a scroll for all new and\n // updated segments. See `ScrollAndFocusHandler` for more details.\n mutable.scrollableSegments = []\n }\n\n return handleMutable(state, mutable)\n }\n case NavigationResultTag.Success: {\n // Received a new result.\n mutable.cache = result.data.cacheNode\n mutable.patchedTree = result.data.flightRouterState\n mutable.canonicalUrl = result.data.canonicalUrl\n mutable.scrollableSegments = result.data.scrollableSegments\n mutable.shouldScroll = result.data.shouldScroll\n mutable.hashFragment = result.data.hash\n return handleMutable(state, mutable)\n }\n case NavigationResultTag.Async: {\n return result.data.then(\n (asyncResult) =>\n handleNavigationResult(url, state, mutable, pendingPush, asyncResult),\n // If the navigation failed, return the current state.\n // TODO: This matches the current behavior but we need to do something\n // better here if the network fails.\n () => {\n return state\n }\n )\n }\n default: {\n result satisfies never\n return state\n }\n }\n}\n\nexport function navigateReducer(\n state: ReadonlyReducerState,\n action: NavigateAction\n): ReducerState {\n const { url, isExternalUrl, navigateType, shouldScroll, allowAliasing } =\n action\n const mutable: Mutable = {}\n const { hash } = url\n const href = createHrefFromUrl(url)\n const pendingPush = navigateType === 'push'\n // we want to prune the prefetch cache on every navigation to avoid it growing too large\n prunePrefetchCache(state.prefetchCache)\n\n mutable.preserveCustomHistoryState = false\n mutable.pendingPush = pendingPush\n\n if (isExternalUrl) {\n return handleExternalUrl(state, mutable, url.toString(), pendingPush)\n }\n\n // Handles case where `<meta http-equiv=\"refresh\">` tag is present,\n // which will trigger an MPA navigation.\n if (document.getElementById('__next-page-redirect')) {\n return handleExternalUrl(state, mutable, href, pendingPush)\n }\n\n if (process.env.__NEXT_CLIENT_SEGMENT_CACHE) {\n // (Very Early Experimental Feature) Segment Cache\n //\n // Bypass the normal prefetch cache and use the new per-segment cache\n // implementation instead. This is only supported if PPR is enabled, too.\n //\n // Temporary glue code between the router reducer and the new navigation\n // implementation. Eventually we'll rewrite the router reducer to a\n // state machine.\n // TODO: Currently this always returns an async result, but in the future\n // it will return a sync result if the navigation was prefetched. Hence\n // a result type that's more complicated than you might expect.\n const result = navigateUsingSegmentCache(\n url,\n state.cache,\n state.tree,\n state.nextUrl,\n shouldScroll\n )\n return handleNavigationResult(url, state, mutable, pendingPush, result)\n }\n\n const prefetchValues = getOrCreatePrefetchCacheEntry({\n url,\n nextUrl: state.nextUrl,\n tree: state.tree,\n prefetchCache: state.prefetchCache,\n allowAliasing,\n })\n const { treeAtTimeOfPrefetch, data } = prefetchValues\n\n prefetchQueue.bump(data)\n\n return data.then(\n ({ flightData, canonicalUrl: canonicalUrlOverride, postponed }) => {\n let isFirstRead = false\n // we only want to mark this once\n if (!prefetchValues.lastUsedTime) {\n // important: we should only mark the cache node as dirty after we unsuspend from the call above\n prefetchValues.lastUsedTime = Date.now()\n isFirstRead = true\n }\n\n // Handle case when navigating to page in `pages` from `app`\n if (typeof flightData === 'string') {\n return handleExternalUrl(state, mutable, flightData, pendingPush)\n }\n\n const updatedCanonicalUrl = canonicalUrlOverride\n ? createHrefFromUrl(canonicalUrlOverride)\n : href\n\n const onlyHashChange =\n !!hash &&\n state.canonicalUrl.split('#', 1)[0] ===\n updatedCanonicalUrl.split('#', 1)[0]\n\n // If only the hash has changed, the server hasn't sent us any new data. We can just update\n // the mutable properties responsible for URL and scroll handling and return early.\n if (onlyHashChange) {\n mutable.onlyHashChange = true\n mutable.canonicalUrl = updatedCanonicalUrl\n mutable.shouldScroll = shouldScroll\n mutable.hashFragment = hash\n mutable.scrollableSegments = []\n return handleMutable(state, mutable)\n }\n\n if (prefetchValues.aliased) {\n const result = handleAliasedPrefetchEntry(\n state,\n flightData,\n url,\n mutable\n )\n\n // We didn't return new router state because we didn't apply the aliased entry for some reason.\n // We'll re-invoke the navigation handler but ensure that we don't attempt to use the aliased entry. This\n // will create an on-demand prefetch entry.\n if (result === false) {\n return navigateReducer(state, { ...action, allowAliasing: false })\n }\n\n return result\n }\n\n let currentTree = state.tree\n let currentCache = state.cache\n let scrollableSegments: FlightSegmentPath[] = []\n for (const normalizedFlightData of flightData) {\n const {\n pathToSegment: flightSegmentPath,\n seedData,\n head,\n isHeadPartial,\n isRootRender,\n } = normalizedFlightData\n let treePatch = normalizedFlightData.tree\n\n // TODO-APP: remove ''\n const flightSegmentPathWithLeadingEmpty = ['', ...flightSegmentPath]\n\n // Create new tree based on the flightSegmentPath and router state patch\n let newTree = applyRouterStatePatchToTree(\n // TODO-APP: remove ''\n flightSegmentPathWithLeadingEmpty,\n currentTree,\n treePatch,\n href\n )\n\n // If the tree patch can't be applied to the current tree then we use the tree at time of prefetch\n // TODO-APP: This should instead fill in the missing pieces in `currentTree` with the data from `treeAtTimeOfPrefetch`, then apply the patch.\n if (newTree === null) {\n newTree = applyRouterStatePatchToTree(\n // TODO-APP: remove ''\n flightSegmentPathWithLeadingEmpty,\n treeAtTimeOfPrefetch,\n treePatch,\n href\n )\n }\n\n if (newTree !== null) {\n if (\n // This is just a paranoid check. When a route is PPRed, the server\n // will send back a static response that's rendered from\n // the root. If for some reason it doesn't, we fall back to the\n // non-PPR implementation.\n // TODO: We should get rid of the else branch and do all navigations\n // via startPPRNavigation. The current structure is just\n // an incremental step.\n seedData &&\n isRootRender &&\n postponed\n ) {\n const task = startPPRNavigation(\n currentCache,\n currentTree,\n treePatch,\n seedData,\n head,\n isHeadPartial,\n scrollableSegments\n )\n\n if (task !== null) {\n if (task.route === null) {\n // Detected a change to the root layout. Perform an full-\n // page navigation.\n return handleExternalUrl(state, mutable, href, pendingPush)\n }\n // Use the tree computed by startPPRNavigation instead\n // of the one computed by applyRouterStatePatchToTree.\n // TODO: We should remove applyRouterStatePatchToTree\n // from the PPR path entirely.\n const patchedRouterState: FlightRouterState = task.route\n newTree = patchedRouterState\n\n const newCache = task.node\n if (newCache !== null) {\n // We've created a new Cache Node tree that contains a prefetched\n // version of the next page. This can be rendered instantly.\n mutable.cache = newCache\n }\n const dynamicRequestTree = task.dynamicRequestTree\n if (dynamicRequestTree !== null) {\n // The prefetched tree has dynamic holes in it. We initiate a\n // dynamic request to fill them in.\n //\n // Do not block on the result. We'll immediately render the Cache\n // Node tree and suspend on the dynamic parts. When the request\n // comes in, we'll fill in missing data and ping React to\n // re-render. Unlike the lazy fetching model in the non-PPR\n // implementation, this is modeled as a single React update +\n // streaming, rather than multiple top-level updates. (However,\n // even in the new model, we'll still need to sometimes update the\n // root multiple times per navigation, like if the server sends us\n // a different response than we expected. For now, we revert back\n // to the lazy fetching mechanism in that case.)\n const dynamicRequest = fetchServerResponse(url, {\n flightRouterState: dynamicRequestTree,\n nextUrl: state.nextUrl,\n })\n\n listenForDynamicRequest(task, dynamicRequest)\n // We store the dynamic request on the `lazyData` property of the CacheNode\n // because we're not going to await the dynamic request here. Since we're not blocking\n // on the dynamic request, `layout-router` will\n // task.node.lazyData = dynamicRequest\n } else {\n // The prefetched tree does not contain dynamic holes — it's\n // fully static. We can skip the dynamic request.\n }\n } else {\n // Nothing changed, so reuse the old cache.\n // TODO: What if the head changed but not any of the segment data?\n // Is that possible? If so, we should clone the whole tree and\n // update the head.\n newTree = treePatch\n }\n } else {\n // The static response does not include any dynamic holes, so\n // there's no need to do a second request.\n // TODO: As an incremental step this just reverts back to the\n // non-PPR implementation. We can simplify this branch further,\n // given that PPR prefetches are always static and return the whole\n // tree. Or in the meantime we could factor it out into a\n // separate function.\n\n if (isNavigatingToNewRootLayout(currentTree, newTree)) {\n return handleExternalUrl(state, mutable, href, pendingPush)\n }\n\n const cache: CacheNode = createEmptyCacheNode()\n let applied = false\n\n if (\n prefetchValues.status === PrefetchCacheEntryStatus.stale &&\n !isFirstRead\n ) {\n // When we have a stale prefetch entry, we only want to re-use the loading state of the route we're navigating to, to support instant loading navigations\n // this will trigger a lazy fetch for the actual page data by nulling the `rsc` and `prefetchRsc` values for page data,\n // while copying over the `loading` for the segment that contains the page data.\n // We only do this on subsequent reads, as otherwise there'd be no loading data to re-use.\n\n // We skip this branch if only the hash fragment has changed, as we don't want to trigger a lazy fetch in that case\n applied = triggerLazyFetchForLeafSegments(\n cache,\n currentCache,\n flightSegmentPath,\n treePatch\n )\n // since we re-used the stale cache's loading state & refreshed the data,\n // update the `lastUsedTime` so that it can continue to be re-used for the next 30s\n prefetchValues.lastUsedTime = Date.now()\n } else {\n applied = applyFlightData(\n currentCache,\n cache,\n normalizedFlightData,\n prefetchValues\n )\n }\n\n const hardNavigate = shouldHardNavigate(\n // TODO-APP: remove ''\n flightSegmentPathWithLeadingEmpty,\n currentTree\n )\n\n if (hardNavigate) {\n // Copy rsc for the root node of the cache.\n cache.rsc = currentCache.rsc\n cache.prefetchRsc = currentCache.prefetchRsc\n\n invalidateCacheBelowFlightSegmentPath(\n cache,\n currentCache,\n flightSegmentPath\n )\n // Ensure the existing cache value is used when the cache was not invalidated.\n mutable.cache = cache\n } else if (applied) {\n mutable.cache = cache\n // If we applied the cache, we update the \"current cache\" value so any other\n // segments in the FlightDataPath will be able to reference the updated cache.\n currentCache = cache\n }\n\n for (const subSegment of generateSegmentsFromPatch(treePatch)) {\n const scrollableSegmentPath = [\n ...flightSegmentPath,\n ...subSegment,\n ]\n // Filter out the __DEFAULT__ paths as they shouldn't be scrolled to in this case.\n if (\n scrollableSegmentPath[scrollableSegmentPath.length - 1] !==\n DEFAULT_SEGMENT_KEY\n ) {\n scrollableSegments.push(scrollableSegmentPath)\n }\n }\n }\n\n currentTree = newTree\n }\n }\n\n mutable.patchedTree = currentTree\n mutable.canonicalUrl = updatedCanonicalUrl\n mutable.scrollableSegments = scrollableSegments\n mutable.hashFragment = hash\n mutable.shouldScroll = shouldScroll\n\n return handleMutable(state, mutable)\n },\n () => state\n )\n}\n"],"names":["handleExternalUrl","navigateReducer","state","mutable","url","pendingPush","mpaNavigation","canonicalUrl","scrollableSegments","undefined","handleMutable","generateSegmentsFromPatch","flightRouterPatch","segments","segment","parallelRoutes","Object","keys","length","parallelRouteKey","parallelRoute","entries","childSegment","push","triggerLazyFetchForLeafSegments","newCache","currentCache","flightSegmentPath","treePatch","appliedPatch","rsc","prefetchRsc","loading","Map","segmentPathsToFill","map","segmentPaths","clearCacheNodeDataForSegmentPath","handleNavigationResult","result","tag","NavigationResultTag","MPA","newUrl","data","NoOp","newCanonicalUrl","oldUrl","URL","onlyHashChange","pathname","search","hash","shouldScroll","hashFragment","Success","cache","cacheNode","patchedTree","flightRouterState","Async","then","asyncResult","action","isExternalUrl","navigateType","allowAliasing","href","createHrefFromUrl","prunePrefetchCache","prefetchCache","preserveCustomHistoryState","toString","document","getElementById","process","env","__NEXT_CLIENT_SEGMENT_CACHE","navigateUsingSegmentCache","tree","nextUrl","prefetchValues","getOrCreatePrefetchCacheEntry","treeAtTimeOfPrefetch","prefetchQueue","bump","flightData","canonicalUrlOverride","postponed","isFirstRead","lastUsedTime","Date","now","updatedCanonicalUrl","split","aliased","handleAliasedPrefetchEntry","currentTree","normalizedFlightData","pathToSegment","seedData","head","isHeadPartial","isRootRender","flightSegmentPathWithLeadingEmpty","newTree","applyRouterStatePatchToTree","task","startPPRNavigation","route","patchedRouterState","node","dynamicRequestTree","dynamicRequest","fetchServerResponse","listenForDynamicRequest","isNavigatingToNewRootLayout","createEmptyCacheNode","applied","status","PrefetchCacheEntryStatus","stale","applyFlightData","hardNavigate","shouldHardNavigate","invalidateCacheBelowFlightSegmentPath","subSegment","scrollableSegmentPath","DEFAULT_SEGMENT_KEY"],"mappings":";;;;;;;;;;;;;;;IAoCgBA,iBAAiB;eAAjBA;;IAsIAC,eAAe;eAAfA;;;qCArKoB;mCACF;uDACoB;6CACV;oCACT;6CACS;oCAOrC;+BACuB;iCACE;iCACF;2BACO;yBACD;gCACwB;oCAIrD;kDAC0C;4CACN;4BAKpC;AAEA,SAASD,kBACdE,KAA2B,EAC3BC,OAAgB,EAChBC,GAAW,EACXC,WAAoB;IAEpBF,QAAQG,aAAa,GAAG;IACxBH,QAAQI,YAAY,GAAGH;IACvBD,QAAQE,WAAW,GAAGA;IACtBF,QAAQK,kBAAkB,GAAGC;IAE7B,OAAO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: NavigationResultTag.NoOp;
|
15
|
-
data:
|
15
|
+
data: {
|
16
|
+
canonicalUrl: string;
|
17
|
+
shouldScroll: boolean;
|
18
|
+
};
|
16
19
|
};
|
17
20
|
type SuccessfulNavigationResult = {
|
18
21
|
tag: NavigationResultTag.Success;
|
@@ -22,6 +25,7 @@ type SuccessfulNavigationResult = {
|
|
22
25
|
canonicalUrl: string;
|
23
26
|
scrollableSegments: Array<FlightSegmentPath>;
|
24
27
|
shouldScroll: boolean;
|
28
|
+
hash: string;
|
25
29
|
};
|
26
30
|
};
|
27
31
|
type AsyncNavigationResult = {
|
@@ -32,10 +32,6 @@ var NavigationResultTag = /*#__PURE__*/ function(NavigationResultTag) {
|
|
32
32
|
NavigationResultTag[NavigationResultTag["Async"] = 3] = "Async";
|
33
33
|
return NavigationResultTag;
|
34
34
|
}({});
|
35
|
-
const noOpNavigationResult = {
|
36
|
-
tag: 2,
|
37
|
-
data: null
|
38
|
-
};
|
39
35
|
function navigate(url, currentCacheNode, currentFlightRouterState, nextUrl, shouldScroll) {
|
40
36
|
const now = Date.now();
|
41
37
|
const cacheKey = (0, _cachekey.createCacheKey)(url.href, nextUrl);
|
@@ -47,16 +43,16 @@ function navigate(url, currentCacheNode, currentFlightRouterState, nextUrl, shou
|
|
47
43
|
const prefetchSeedData = snapshot.seedData;
|
48
44
|
const prefetchHead = route.head;
|
49
45
|
const isPrefetchHeadPartial = route.isHeadPartial;
|
50
|
-
const
|
51
|
-
return navigateUsingPrefetchedRouteTree(url, nextUrl, currentCacheNode, currentFlightRouterState, prefetchFlightRouterState, prefetchSeedData, prefetchHead, isPrefetchHeadPartial,
|
46
|
+
const newCanonicalUrl = route.canonicalUrl;
|
47
|
+
return navigateUsingPrefetchedRouteTree(url, nextUrl, currentCacheNode, currentFlightRouterState, prefetchFlightRouterState, prefetchSeedData, prefetchHead, isPrefetchHeadPartial, newCanonicalUrl, shouldScroll, url.hash);
|
52
48
|
}
|
53
49
|
// There's no matching prefetch for this route in the cache.
|
54
50
|
return {
|
55
51
|
tag: 3,
|
56
|
-
data: navigateDynamicallyWithNoPrefetch(url, nextUrl, currentCacheNode, currentFlightRouterState, shouldScroll)
|
52
|
+
data: navigateDynamicallyWithNoPrefetch(url, nextUrl, currentCacheNode, currentFlightRouterState, shouldScroll, url.hash)
|
57
53
|
};
|
58
54
|
}
|
59
|
-
function navigateUsingPrefetchedRouteTree(url, nextUrl, currentCacheNode, currentFlightRouterState, prefetchFlightRouterState, prefetchSeedData, prefetchHead, isPrefetchHeadPartial, canonicalUrl, shouldScroll) {
|
55
|
+
function navigateUsingPrefetchedRouteTree(url, nextUrl, currentCacheNode, currentFlightRouterState, prefetchFlightRouterState, prefetchSeedData, prefetchHead, isPrefetchHeadPartial, canonicalUrl, shouldScroll, hash) {
|
60
56
|
// Recursively construct a prefetch tree by reading from the Segment Cache. To
|
61
57
|
// maintain compatibility, we output the same data structures as the old
|
62
58
|
// prefetching implementation: FlightRouterState and CacheNodeSeedData.
|
@@ -77,12 +73,19 @@ function navigateUsingPrefetchedRouteTree(url, nextUrl, currentCacheNode, curren
|
|
77
73
|
// The prefetched tree does not contain dynamic holes — it's
|
78
74
|
// fully static. We can skip the dynamic request.
|
79
75
|
}
|
80
|
-
return navigationTaskToResult(task, currentCacheNode, canonicalUrl, scrollableSegments, shouldScroll);
|
76
|
+
return navigationTaskToResult(task, currentCacheNode, canonicalUrl, scrollableSegments, shouldScroll, hash);
|
81
77
|
}
|
82
|
-
// The server sent back an empty tree patch. There's nothing to update
|
83
|
-
|
78
|
+
// The server sent back an empty tree patch. There's nothing to update, except
|
79
|
+
// possibly the URL.
|
80
|
+
return {
|
81
|
+
tag: 2,
|
82
|
+
data: {
|
83
|
+
canonicalUrl,
|
84
|
+
shouldScroll
|
85
|
+
}
|
86
|
+
};
|
84
87
|
}
|
85
|
-
function navigationTaskToResult(task, currentCacheNode, canonicalUrl, scrollableSegments, shouldScroll) {
|
88
|
+
function navigationTaskToResult(task, currentCacheNode, canonicalUrl, scrollableSegments, shouldScroll, hash) {
|
86
89
|
const flightRouterState = task.route;
|
87
90
|
if (flightRouterState === null) {
|
88
91
|
// When no router state is provided, it signals that we should perform an
|
@@ -100,7 +103,8 @@ function navigationTaskToResult(task, currentCacheNode, canonicalUrl, scrollable
|
|
100
103
|
cacheNode: newCacheNode !== null ? newCacheNode : currentCacheNode,
|
101
104
|
canonicalUrl,
|
102
105
|
scrollableSegments,
|
103
|
-
shouldScroll
|
106
|
+
shouldScroll,
|
107
|
+
hash
|
104
108
|
}
|
105
109
|
};
|
106
110
|
}
|
@@ -168,7 +172,7 @@ function readRenderSnapshotFromCache(now, tree) {
|
|
168
172
|
]
|
169
173
|
};
|
170
174
|
}
|
171
|
-
async function navigateDynamicallyWithNoPrefetch(url, nextUrl, currentCacheNode, currentFlightRouterState, shouldScroll) {
|
175
|
+
async function navigateDynamicallyWithNoPrefetch(url, nextUrl, currentCacheNode, currentFlightRouterState, shouldScroll, hash) {
|
172
176
|
// Runs when a navigation happens but there's no cached prefetch we can use.
|
173
177
|
// Don't bother to wait for a prefetch response; go straight to a full
|
174
178
|
// navigation that contains both static and dynamic data in a single stream.
|
@@ -185,8 +189,6 @@ async function navigateDynamicallyWithNoPrefetch(url, nextUrl, currentCacheNode,
|
|
185
189
|
nextUrl
|
186
190
|
});
|
187
191
|
const { flightData, canonicalUrl: canonicalUrlOverride } = await promiseForDynamicServerResponse;
|
188
|
-
// TODO: Detect if the only thing that changed was the hash, like we do in
|
189
|
-
// in navigateReducer
|
190
192
|
if (typeof flightData === 'string') {
|
191
193
|
// This is an MPA navigation.
|
192
194
|
const newUrl = flightData;
|
@@ -224,10 +226,17 @@ async function navigateDynamicallyWithNoPrefetch(url, nextUrl, currentCacheNode,
|
|
224
226
|
// The prefetched tree does not contain dynamic holes — it's
|
225
227
|
// fully static. We don't need to process the server response further.
|
226
228
|
}
|
227
|
-
return navigationTaskToResult(task, currentCacheNode, canonicalUrl, scrollableSegments, shouldScroll);
|
229
|
+
return navigationTaskToResult(task, currentCacheNode, canonicalUrl, scrollableSegments, shouldScroll, hash);
|
228
230
|
}
|
229
|
-
// The server sent back an empty tree patch. There's nothing to update
|
230
|
-
|
231
|
+
// The server sent back an empty tree patch. There's nothing to update, except
|
232
|
+
// possibly the URL.
|
233
|
+
return {
|
234
|
+
tag: 2,
|
235
|
+
data: {
|
236
|
+
canonicalUrl,
|
237
|
+
shouldScroll
|
238
|
+
}
|
239
|
+
};
|
231
240
|
}
|
232
241
|
function simulatePrefetchTreeUsingDynamicTreePatch(currentTree, flightData) {
|
233
242
|
// Takes the current FlightRouterState and applies the router state patch
|