next 15.4.0-canary.42 → 15.4.0-canary.43
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.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/utils.d.ts +1 -0
- package/dist/build/utils.js +9 -0
- package/dist/build/utils.js.map +1 -1
- package/dist/build/webpack-config.js +20 -4
- package/dist/build/webpack-config.js.map +1 -1
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js +2 -2
- package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js +2 -2
- package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.dev.js +2 -2
- package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
- package/dist/compiled/next-server/pages.runtime.prod.js +2 -2
- package/dist/compiled/next-server/pages.runtime.prod.js.map +1 -1
- package/dist/compiled/next-server/server.runtime.prod.js +1 -1
- 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/utils.js +5 -0
- package/dist/esm/build/utils.js.map +1 -1
- package/dist/esm/build/webpack-config.js +21 -5
- package/dist/esm/build/webpack-config.js.map +1 -1
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/base-server.js +1 -1
- package/dist/esm/server/base-server.js.map +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/typescript/rules/client-boundary.js +2 -1
- package/dist/esm/server/typescript/rules/client-boundary.js.map +1 -1
- package/dist/esm/server/web/adapter.js +4 -1
- package/dist/esm/server/web/adapter.js.map +1 -1
- package/dist/esm/server/web/sandbox/sandbox.js +1 -0
- package/dist/esm/server/web/sandbox/sandbox.js.map +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/server/base-server.js +1 -1
- package/dist/server/base-server.js.map +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/typescript/rules/client-boundary.js +2 -1
- package/dist/server/typescript/rules/client-boundary.js.map +1 -1
- package/dist/server/web/adapter.js +4 -1
- package/dist/server/web/adapter.js.map +1 -1
- package/dist/server/web/sandbox/sandbox.js +1 -0
- package/dist/server/web/sandbox/sandbox.js.map +1 -1
- package/dist/shared/lib/canary-only.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
@@ -139,7 +139,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
|
|
139
139
|
}
|
140
140
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
141
141
|
const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
142
|
-
version: "15.4.0-canary.
|
142
|
+
version: "15.4.0-canary.43"
|
143
143
|
});
|
144
144
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
145
145
|
// of the current `next dev` invocation.
|
@@ -257,7 +257,7 @@ class HotReloaderWebpack {
|
|
257
257
|
this.previewProps = previewProps;
|
258
258
|
this.rewrites = rewrites;
|
259
259
|
this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
260
|
-
version: "15.4.0-canary.
|
260
|
+
version: "15.4.0-canary.43"
|
261
261
|
});
|
262
262
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
263
263
|
// of the current `next dev` invocation.
|
@@ -75,7 +75,7 @@ function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, maxEx
|
|
75
75
|
} else {
|
76
76
|
bundlerSuffix = '';
|
77
77
|
}
|
78
|
-
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.4.0-canary.
|
78
|
+
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.4.0-canary.43"}`))}${bundlerSuffix}`);
|
79
79
|
if (appUrl) {
|
80
80
|
_log.bootstrap(`- Local: ${appUrl}`);
|
81
81
|
}
|
@@ -110,7 +110,7 @@ async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup, server
|
|
110
110
|
async function startServer(serverOptions) {
|
111
111
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
112
112
|
let { port } = serverOptions;
|
113
|
-
process.title = `next-server (v${"15.4.0-canary.
|
113
|
+
process.title = `next-server (v${"15.4.0-canary.43"})`;
|
114
114
|
let handlersReady = ()=>{};
|
115
115
|
let handlersError = ()=>{};
|
116
116
|
let handlersPromise = new Promise((resolve, reject)=>{
|
@@ -48,7 +48,8 @@ const clientBoundary = {
|
|
48
48
|
const propTypeInfo = typeChecker.getTypeAtLocation(propType);
|
49
49
|
const typeDeclarationNode = (_propTypeInfo_symbol = propTypeInfo.symbol) == null ? void 0 : (_propTypeInfo_symbol_getDeclarations = _propTypeInfo_symbol.getDeclarations()) == null ? void 0 : _propTypeInfo_symbol_getDeclarations[0];
|
50
50
|
if (typeDeclarationNode) {
|
51
|
-
if (ts.isFunctionTypeNode(typeDeclarationNode))
|
51
|
+
if (ts.isFunctionTypeNode(typeDeclarationNode) || // someFunc(): void
|
52
|
+
ts.isMethodSignature(typeDeclarationNode)) {
|
52
53
|
// By convention, props named "action" can accept functions since we
|
53
54
|
// assume these are Server Actions. Structurally, there's no
|
54
55
|
// difference between a Server Action and a normal function until
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/server/typescript/rules/client-boundary.ts"],"sourcesContent":["// This module provides intellisense for all components that has the `\"use client\"` directive.\n\nimport { NEXT_TS_ERRORS } from '../constant'\nimport { getTs, getTypeChecker } from '../utils'\nimport type tsModule from 'typescript/lib/tsserverlibrary'\n\nconst clientBoundary = {\n getSemanticDiagnosticsForExportVariableStatement(\n source: tsModule.SourceFile,\n node: tsModule.VariableStatement\n ) {\n const ts = getTs()\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n if (ts.isVariableDeclarationList(node.declarationList)) {\n for (const declaration of node.declarationList.declarations) {\n const initializer = declaration.initializer\n if (initializer && ts.isArrowFunction(initializer)) {\n diagnostics.push(\n ...clientBoundary.getSemanticDiagnosticsForFunctionExport(\n source,\n initializer\n )\n )\n }\n }\n }\n\n return diagnostics\n },\n\n getSemanticDiagnosticsForFunctionExport(\n source: tsModule.SourceFile,\n node: tsModule.FunctionDeclaration | tsModule.ArrowFunction\n ) {\n const ts = getTs()\n const typeChecker = getTypeChecker()\n if (!typeChecker) return []\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n const isErrorFile = /[\\\\/]error\\.tsx?$/.test(source.fileName)\n const isGlobalErrorFile = /[\\\\/]global-error\\.tsx?$/.test(source.fileName)\n\n const props = node.parameters?.[0]\n if (props) {\n const propsType = typeChecker.getTypeAtLocation(props)\n const typeNode = propsType.symbol?.getDeclarations()?.[0]\n\n if (typeNode && ts.isTypeLiteralNode(typeNode)) {\n for (const member of typeNode.members) {\n if (ts.isPropertySignature(member)) {\n const propName = member.name.getText()\n const propType = member.type\n\n if (propType) {\n const propTypeInfo = typeChecker.getTypeAtLocation(propType)\n const typeDeclarationNode =\n propTypeInfo.symbol?.getDeclarations()?.[0]\n\n if (typeDeclarationNode) {\n if (ts.isFunctionTypeNode(typeDeclarationNode)) {\n // By convention, props named \"action\" can accept functions since we\n // assume these are Server Actions. Structurally, there's no\n // difference between a Server Action and a normal function until\n // TypeScript exposes directives in the type of a function. This\n // will miss accidentally passing normal functions but a false\n // negative is better than a false positive given how frequent the\n // false-positive would be.\n const maybeServerAction =\n propName === 'action' || /.+Action$/.test(propName)\n\n // There's a special case for the error file that the `reset` prop\n // is allowed to be a function:\n // https://github.com/vercel/next.js/issues/46573\n const isErrorReset =\n (isErrorFile || isGlobalErrorFile) && propName === 'reset'\n\n if (!maybeServerAction && !isErrorReset) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText:\n `Props must be serializable for components in the \"use client\" entry file. ` +\n `\"${propName}\" is a function that's not a Server Action. ` +\n `Rename \"${propName}\" either to \"action\" or have its name end with \"Action\" e.g. \"${propName}Action\" to indicate it is a Server Action.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n } else if (\n // Show warning for not serializable props.\n ts.isConstructorTypeNode(typeDeclarationNode) ||\n ts.isClassDeclaration(typeDeclarationNode)\n ) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText: `Props must be serializable for components in the \"use client\" entry file, \"${propName}\" is invalid.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n }\n }\n }\n }\n }\n }\n\n return diagnostics\n },\n}\n\nexport default clientBoundary\n"],"names":["clientBoundary","getSemanticDiagnosticsForExportVariableStatement","source","node","ts","getTs","diagnostics","isVariableDeclarationList","declarationList","declaration","declarations","initializer","isArrowFunction","push","getSemanticDiagnosticsForFunctionExport","typeChecker","getTypeChecker","isErrorFile","test","fileName","isGlobalErrorFile","props","parameters","propsType","getTypeAtLocation","typeNode","symbol","getDeclarations","isTypeLiteralNode","member","members","isPropertySignature","propName","name","getText","propType","type","propTypeInfo","typeDeclarationNode","isFunctionTypeNode","maybeServerAction","isErrorReset","file","category","DiagnosticCategory","Warning","code","NEXT_TS_ERRORS","INVALID_CLIENT_ENTRY_PROP","messageText","start","getStart","length","getWidth","isConstructorTypeNode","isClassDeclaration"],"mappings":"AAAA,8FAA8F;;;;;+
|
1
|
+
{"version":3,"sources":["../../../../src/server/typescript/rules/client-boundary.ts"],"sourcesContent":["// This module provides intellisense for all components that has the `\"use client\"` directive.\n\nimport { NEXT_TS_ERRORS } from '../constant'\nimport { getTs, getTypeChecker } from '../utils'\nimport type tsModule from 'typescript/lib/tsserverlibrary'\n\nconst clientBoundary = {\n getSemanticDiagnosticsForExportVariableStatement(\n source: tsModule.SourceFile,\n node: tsModule.VariableStatement\n ) {\n const ts = getTs()\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n if (ts.isVariableDeclarationList(node.declarationList)) {\n for (const declaration of node.declarationList.declarations) {\n const initializer = declaration.initializer\n if (initializer && ts.isArrowFunction(initializer)) {\n diagnostics.push(\n ...clientBoundary.getSemanticDiagnosticsForFunctionExport(\n source,\n initializer\n )\n )\n }\n }\n }\n\n return diagnostics\n },\n\n getSemanticDiagnosticsForFunctionExport(\n source: tsModule.SourceFile,\n node: tsModule.FunctionDeclaration | tsModule.ArrowFunction\n ) {\n const ts = getTs()\n const typeChecker = getTypeChecker()\n if (!typeChecker) return []\n\n const diagnostics: tsModule.Diagnostic[] = []\n\n const isErrorFile = /[\\\\/]error\\.tsx?$/.test(source.fileName)\n const isGlobalErrorFile = /[\\\\/]global-error\\.tsx?$/.test(source.fileName)\n\n const props = node.parameters?.[0]\n if (props) {\n const propsType = typeChecker.getTypeAtLocation(props)\n const typeNode = propsType.symbol?.getDeclarations()?.[0]\n\n if (typeNode && ts.isTypeLiteralNode(typeNode)) {\n for (const member of typeNode.members) {\n if (ts.isPropertySignature(member)) {\n const propName = member.name.getText()\n const propType = member.type\n\n if (propType) {\n const propTypeInfo = typeChecker.getTypeAtLocation(propType)\n const typeDeclarationNode =\n propTypeInfo.symbol?.getDeclarations()?.[0]\n\n if (typeDeclarationNode) {\n if (\n ts.isFunctionTypeNode(typeDeclarationNode) ||\n // someFunc(): void\n ts.isMethodSignature(typeDeclarationNode)\n ) {\n // By convention, props named \"action\" can accept functions since we\n // assume these are Server Actions. Structurally, there's no\n // difference between a Server Action and a normal function until\n // TypeScript exposes directives in the type of a function. This\n // will miss accidentally passing normal functions but a false\n // negative is better than a false positive given how frequent the\n // false-positive would be.\n const maybeServerAction =\n propName === 'action' || /.+Action$/.test(propName)\n\n // There's a special case for the error file that the `reset` prop\n // is allowed to be a function:\n // https://github.com/vercel/next.js/issues/46573\n const isErrorReset =\n (isErrorFile || isGlobalErrorFile) && propName === 'reset'\n\n if (!maybeServerAction && !isErrorReset) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText:\n `Props must be serializable for components in the \"use client\" entry file. ` +\n `\"${propName}\" is a function that's not a Server Action. ` +\n `Rename \"${propName}\" either to \"action\" or have its name end with \"Action\" e.g. \"${propName}Action\" to indicate it is a Server Action.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n } else if (\n // Show warning for not serializable props.\n ts.isConstructorTypeNode(typeDeclarationNode) ||\n ts.isClassDeclaration(typeDeclarationNode)\n ) {\n diagnostics.push({\n file: source,\n category: ts.DiagnosticCategory.Warning,\n code: NEXT_TS_ERRORS.INVALID_CLIENT_ENTRY_PROP,\n messageText: `Props must be serializable for components in the \"use client\" entry file, \"${propName}\" is invalid.`,\n start: propType.getStart(),\n length: propType.getWidth(),\n })\n }\n }\n }\n }\n }\n }\n }\n\n return diagnostics\n },\n}\n\nexport default clientBoundary\n"],"names":["clientBoundary","getSemanticDiagnosticsForExportVariableStatement","source","node","ts","getTs","diagnostics","isVariableDeclarationList","declarationList","declaration","declarations","initializer","isArrowFunction","push","getSemanticDiagnosticsForFunctionExport","typeChecker","getTypeChecker","isErrorFile","test","fileName","isGlobalErrorFile","props","parameters","propsType","getTypeAtLocation","typeNode","symbol","getDeclarations","isTypeLiteralNode","member","members","isPropertySignature","propName","name","getText","propType","type","propTypeInfo","typeDeclarationNode","isFunctionTypeNode","isMethodSignature","maybeServerAction","isErrorReset","file","category","DiagnosticCategory","Warning","code","NEXT_TS_ERRORS","INVALID_CLIENT_ENTRY_PROP","messageText","start","getStart","length","getWidth","isConstructorTypeNode","isClassDeclaration"],"mappings":"AAAA,8FAA8F;;;;;+BAyH9F;;;eAAA;;;0BAvH+B;uBACO;AAGtC,MAAMA,iBAAiB;IACrBC,kDACEC,MAA2B,EAC3BC,IAAgC;QAEhC,MAAMC,KAAKC,IAAAA,YAAK;QAEhB,MAAMC,cAAqC,EAAE;QAE7C,IAAIF,GAAGG,yBAAyB,CAACJ,KAAKK,eAAe,GAAG;YACtD,KAAK,MAAMC,eAAeN,KAAKK,eAAe,CAACE,YAAY,CAAE;gBAC3D,MAAMC,cAAcF,YAAYE,WAAW;gBAC3C,IAAIA,eAAeP,GAAGQ,eAAe,CAACD,cAAc;oBAClDL,YAAYO,IAAI,IACXb,eAAec,uCAAuC,CACvDZ,QACAS;gBAGN;YACF;QACF;QAEA,OAAOL;IACT;IAEAQ,yCACEZ,MAA2B,EAC3BC,IAA2D;YAW7CA;QATd,MAAMC,KAAKC,IAAAA,YAAK;QAChB,MAAMU,cAAcC,IAAAA,qBAAc;QAClC,IAAI,CAACD,aAAa,OAAO,EAAE;QAE3B,MAAMT,cAAqC,EAAE;QAE7C,MAAMW,cAAc,oBAAoBC,IAAI,CAAChB,OAAOiB,QAAQ;QAC5D,MAAMC,oBAAoB,2BAA2BF,IAAI,CAAChB,OAAOiB,QAAQ;QAEzE,MAAME,SAAQlB,mBAAAA,KAAKmB,UAAU,qBAAfnB,gBAAiB,CAAC,EAAE;QAClC,IAAIkB,OAAO;gBAEQE,mCAAAA;YADjB,MAAMA,YAAY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AEA,SAAS,0CAA0C,CAAC;4CAC1ImB,OAAOhB,SAASiB,QAAQ;4CACxBC,QAAQlB,SAASmB,QAAQ;wCAC3B;oCACF;gCACF,OAAO,IACL,2CAA2C;gCAC3ClD,GAAGmD,qBAAqB,CAACjB,wBACzBlC,GAAGoD,kBAAkB,CAAClB,sBACtB;oCACAhC,YAAYO,IAAI,CAAC;wCACf8B,MAAMzC;wCACN0C,UAAUxC,GAAGyC,kBAAkB,CAACC,OAAO;wCACvCC,MAAMC,wBAAc,CAACC,yBAAyB;wCAC9CC,aAAa,CAAC,2EAA2E,EAAElB,SAAS,aAAa,CAAC;wCAClHmB,OAAOhB,SAASiB,QAAQ;wCACxBC,QAAQlB,SAASmB,QAAQ;oCAC3B;gCACF;4BACF;wBACF;oBACF;gBACF;YACF;QACF;QAEA,OAAOhD;IACT;AACF;MAEA,WAAeN","ignoreList":[0]}
|
@@ -164,7 +164,10 @@ async function adapter(params) {
|
|
164
164
|
value: true
|
165
165
|
});
|
166
166
|
}
|
167
|
-
if (
|
167
|
+
if (// If we are inside of the next start sandbox
|
168
|
+
// leverage the shared instance if not we need
|
169
|
+
// to create a fresh cache instance each time
|
170
|
+
!globalThis.__incrementalCacheShared && params.IncrementalCache) {
|
168
171
|
;
|
169
172
|
globalThis.__incrementalCache = new params.IncrementalCache({
|
170
173
|
appDir: true,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/server/web/adapter.ts"],"sourcesContent":["import type { RequestData, FetchEventResult } from './types'\nimport type { RequestInit } from './spec-extension/request'\nimport { PageSignatureError } from './error'\nimport { fromNodeOutgoingHttpHeaders, normalizeNextQueryParam } from './utils'\nimport {\n NextFetchEvent,\n getWaitUntilPromiseFromEvent,\n} from './spec-extension/fetch-event'\nimport { NextRequest } from './spec-extension/request'\nimport { NextResponse } from './spec-extension/response'\nimport {\n parseRelativeURL,\n getRelativeURL,\n} from '../../shared/lib/router/utils/relativize-url'\nimport { NextURL } from './next-url'\nimport { stripInternalSearchParams } from '../internal-utils'\nimport { normalizeRscURL } from '../../shared/lib/router/utils/app-paths'\nimport {\n FLIGHT_HEADERS,\n NEXT_REWRITTEN_PATH_HEADER,\n NEXT_REWRITTEN_QUERY_HEADER,\n RSC_HEADER,\n} from '../../client/components/app-router-headers'\nimport { ensureInstrumentationRegistered } from './globals'\nimport { createRequestStoreForAPI } from '../async-storage/request-store'\nimport { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'\nimport { createWorkStore } from '../async-storage/work-store'\nimport { workAsyncStorage } from '../app-render/work-async-storage.external'\nimport { NEXT_ROUTER_PREFETCH_HEADER } from '../../client/components/app-router-headers'\nimport { getTracer } from '../lib/trace/tracer'\nimport type { TextMapGetter } from 'next/dist/compiled/@opentelemetry/api'\nimport { MiddlewareSpan } from '../lib/trace/constants'\nimport { CloseController } from './web-on-close'\nimport { getEdgePreviewProps } from './get-edge-preview-props'\nimport { getBuiltinRequestContext } from '../after/builtin-request-context'\nimport { getImplicitTags } from '../lib/implicit-tags'\n\nexport class NextRequestHint extends NextRequest {\n sourcePage: string\n fetchMetrics: FetchEventResult['fetchMetrics'] | undefined\n\n constructor(params: {\n init: RequestInit\n input: Request | string\n page: string\n }) {\n super(params.input, params.init)\n this.sourcePage = params.page\n }\n\n get request() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n respondWith() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n waitUntil() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n}\n\nconst headersGetter: TextMapGetter<Headers> = {\n keys: (headers) => Array.from(headers.keys()),\n get: (headers, key) => headers.get(key) ?? undefined,\n}\n\nexport type AdapterOptions = {\n handler: (req: NextRequestHint, event: NextFetchEvent) => Promise<Response>\n page: string\n request: RequestData\n IncrementalCache?: typeof import('../lib/incremental-cache').IncrementalCache\n}\n\nlet propagator: <T>(request: NextRequestHint, fn: () => T) => T = (\n request,\n fn\n) => {\n const tracer = getTracer()\n return tracer.withPropagatedContext(request.headers, fn, headersGetter)\n}\n\nlet testApisIntercepted = false\n\nfunction ensureTestApisIntercepted() {\n if (!testApisIntercepted) {\n testApisIntercepted = true\n if (process.env.NEXT_PRIVATE_TEST_PROXY === 'true') {\n const {\n interceptTestApis,\n wrapRequestHandler,\n } = require('next/dist/experimental/testmode/server-edge')\n interceptTestApis()\n propagator = wrapRequestHandler(propagator)\n }\n }\n}\n\nexport async function adapter(\n params: AdapterOptions\n): Promise<FetchEventResult> {\n ensureTestApisIntercepted()\n await ensureInstrumentationRegistered()\n\n // TODO-APP: use explicit marker for this\n const isEdgeRendering =\n typeof (globalThis as any).__BUILD_MANIFEST !== 'undefined'\n\n params.request.url = normalizeRscURL(params.request.url)\n\n const requestURL = new NextURL(params.request.url, {\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n // Iterator uses an index to keep track of the current iteration. Because of deleting and appending below we can't just use the iterator.\n // Instead we use the keys before iteration.\n const keys = [...requestURL.searchParams.keys()]\n for (const key of keys) {\n const value = requestURL.searchParams.getAll(key)\n\n const normalizedKey = normalizeNextQueryParam(key)\n if (normalizedKey) {\n requestURL.searchParams.delete(normalizedKey)\n for (const val of value) {\n requestURL.searchParams.append(normalizedKey, val)\n }\n requestURL.searchParams.delete(key)\n }\n }\n\n // Ensure users only see page requests, never data requests.\n const buildId = requestURL.buildId\n requestURL.buildId = ''\n\n const requestHeaders = fromNodeOutgoingHttpHeaders(params.request.headers)\n const isNextDataRequest = requestHeaders.has('x-nextjs-data')\n const isRSCRequest = requestHeaders.get(RSC_HEADER) === '1'\n\n if (isNextDataRequest && requestURL.pathname === '/index') {\n requestURL.pathname = '/'\n }\n\n const flightHeaders = new Map()\n\n // Headers should only be stripped for middleware\n if (!isEdgeRendering) {\n for (const header of FLIGHT_HEADERS) {\n const key = header.toLowerCase()\n const value = requestHeaders.get(key)\n if (value !== null) {\n flightHeaders.set(key, value)\n requestHeaders.delete(key)\n }\n }\n }\n\n const normalizeURL = process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE\n ? new URL(params.request.url)\n : requestURL\n\n const request = new NextRequestHint({\n page: params.page,\n // Strip internal query parameters off the request.\n input: stripInternalSearchParams(normalizeURL).toString(),\n init: {\n body: params.request.body,\n headers: requestHeaders,\n method: params.request.method,\n nextConfig: params.request.nextConfig,\n signal: params.request.signal,\n },\n })\n\n /**\n * This allows to identify the request as a data request. The user doesn't\n * need to know about this property neither use it. We add it for testing\n * purposes.\n */\n if (isNextDataRequest) {\n Object.defineProperty(request, '__isData', {\n enumerable: false,\n value: true,\n })\n }\n\n if (\n !(globalThis as any).__incrementalCache &&\n (params as any).IncrementalCache\n ) {\n ;(globalThis as any).__incrementalCache = new (\n params as any\n ).IncrementalCache({\n appDir: true,\n fetchCache: true,\n minimalMode: process.env.NODE_ENV !== 'development',\n fetchCacheKeyPrefix: process.env.__NEXT_FETCH_CACHE_KEY_PREFIX,\n dev: process.env.NODE_ENV === 'development',\n requestHeaders: params.request.headers as any,\n requestProtocol: 'https',\n getPrerenderManifest: () => {\n return {\n version: -1 as any, // letting us know this doesn't conform to spec\n routes: {},\n dynamicRoutes: {},\n notFoundRoutes: [],\n preview: getEdgePreviewProps(),\n }\n },\n })\n }\n\n // if we're in an edge runtime sandbox, we should use the waitUntil\n // that we receive from the enclosing NextServer\n const outerWaitUntil =\n params.request.waitUntil ?? getBuiltinRequestContext()?.waitUntil\n\n const event = new NextFetchEvent({\n request,\n page: params.page,\n context: outerWaitUntil ? { waitUntil: outerWaitUntil } : undefined,\n })\n let response\n let cookiesFromResponse\n\n response = await propagator(request, () => {\n // we only care to make async storage available for middleware\n const isMiddleware =\n params.page === '/middleware' || params.page === '/src/middleware'\n\n if (isMiddleware) {\n // if we're in an edge function, we only get a subset of `nextConfig` (no `experimental`),\n // so we have to inject it via DefinePlugin.\n // in `next start` this will be passed normally (see `NextNodeServer.runMiddleware`).\n\n const waitUntil = event.waitUntil.bind(event)\n const closeController = new CloseController()\n\n return getTracer().trace(\n MiddlewareSpan.execute,\n {\n spanName: `middleware ${request.method} ${request.nextUrl.pathname}`,\n attributes: {\n 'http.target': request.nextUrl.pathname,\n 'http.method': request.method,\n },\n },\n async () => {\n try {\n const onUpdateCookies = (cookies: Array<string>) => {\n cookiesFromResponse = cookies\n }\n const previewProps = getEdgePreviewProps()\n const page = '/' // Fake Work\n const fallbackRouteParams = null\n\n const implicitTags = await getImplicitTags(\n page,\n request.nextUrl,\n fallbackRouteParams\n )\n\n const requestStore = createRequestStoreForAPI(\n request,\n request.nextUrl,\n implicitTags,\n onUpdateCookies,\n previewProps\n )\n\n const workStore = createWorkStore({\n page,\n fallbackRouteParams,\n renderOpts: {\n cacheLifeProfiles:\n params.request.nextConfig?.experimental?.cacheLife,\n experimental: {\n isRoutePPREnabled: false,\n dynamicIO: false,\n authInterrupts:\n !!params.request.nextConfig?.experimental?.authInterrupts,\n },\n supportsDynamicResponse: true,\n waitUntil,\n onClose: closeController.onClose.bind(closeController),\n onAfterTaskError: undefined,\n },\n requestEndedState: { ended: false },\n isPrefetchRequest: request.headers.has(\n NEXT_ROUTER_PREFETCH_HEADER\n ),\n buildId: buildId ?? '',\n previouslyRevalidatedTags: [],\n })\n\n return await workAsyncStorage.run(workStore, () =>\n workUnitAsyncStorage.run(\n requestStore,\n params.handler,\n request,\n event\n )\n )\n } finally {\n // middleware cannot stream, so we can consider the response closed\n // as soon as the handler returns.\n // we can delay running it until a bit later --\n // if it's needed, we'll have a `waitUntil` lock anyway.\n setTimeout(() => {\n closeController.dispatchClose()\n }, 0)\n }\n }\n )\n }\n return params.handler(request, event)\n })\n\n // check if response is a Response object\n if (response && !(response instanceof Response)) {\n throw new TypeError('Expected an instance of Response to be returned')\n }\n\n if (response && cookiesFromResponse) {\n response.headers.set('set-cookie', cookiesFromResponse)\n }\n\n /**\n * For rewrites we must always include the locale in the final pathname\n * so we re-create the NextURL forcing it to include it when the it is\n * an internal rewrite. Also we make sure the outgoing rewrite URL is\n * a data URL if the request was a data request.\n */\n const rewrite = response?.headers.get('x-middleware-rewrite')\n if (response && rewrite && (isRSCRequest || !isEdgeRendering)) {\n const destination = new NextURL(rewrite, {\n forceLocale: true,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE && !isEdgeRendering) {\n if (destination.host === request.nextUrl.host) {\n destination.buildId = buildId || destination.buildId\n response.headers.set('x-middleware-rewrite', String(destination))\n }\n }\n\n /**\n * When the request is a data request we must show if there was a rewrite\n * with an internal header so the client knows which component to load\n * from the data request.\n */\n const { url: relativeDestination, isRelative } = parseRelativeURL(\n destination.toString(),\n requestURL.toString()\n )\n\n if (\n !isEdgeRendering &&\n isNextDataRequest &&\n // if the rewrite is external and external rewrite\n // resolving config is enabled don't add this header\n // so the upstream app can set it instead\n !(\n process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE &&\n relativeDestination.match(/http(s)?:\\/\\//)\n )\n ) {\n response.headers.set('x-nextjs-rewrite', relativeDestination)\n }\n\n // If this is an RSC request, and the pathname or search has changed, and\n // this isn't an external rewrite, we need to set the rewritten pathname and\n // query headers.\n if (isRSCRequest && isRelative) {\n if (requestURL.pathname !== destination.pathname) {\n response.headers.set(NEXT_REWRITTEN_PATH_HEADER, destination.pathname)\n }\n if (requestURL.search !== destination.search) {\n response.headers.set(\n NEXT_REWRITTEN_QUERY_HEADER,\n // remove the leading ? from the search string\n destination.search.slice(1)\n )\n }\n }\n }\n\n /**\n * For redirects we will not include the locale in case when it is the\n * default and we must also make sure the outgoing URL is a data one if\n * the incoming request was a data request.\n */\n const redirect = response?.headers.get('Location')\n if (response && redirect && !isEdgeRendering) {\n const redirectURL = new NextURL(redirect, {\n forceLocale: false,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n /**\n * Responses created from redirects have immutable headers so we have\n * to clone the response to be able to modify it.\n */\n response = new Response(response.body, response)\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {\n if (redirectURL.host === requestURL.host) {\n redirectURL.buildId = buildId || redirectURL.buildId\n response.headers.set('Location', redirectURL.toString())\n }\n }\n\n /**\n * When the request is a data request we can't use the location header as\n * it may end up with CORS error. Instead we map to an internal header so\n * the client knows the destination.\n */\n if (isNextDataRequest) {\n response.headers.delete('Location')\n response.headers.set(\n 'x-nextjs-redirect',\n getRelativeURL(redirectURL.toString(), requestURL.toString())\n )\n }\n }\n\n const finalResponse = response ? response : NextResponse.next()\n\n // Flight headers are not overridable / removable so they are applied at the end.\n const middlewareOverrideHeaders = finalResponse.headers.get(\n 'x-middleware-override-headers'\n )\n const overwrittenHeaders: string[] = []\n if (middlewareOverrideHeaders) {\n for (const [key, value] of flightHeaders) {\n finalResponse.headers.set(`x-middleware-request-${key}`, value)\n overwrittenHeaders.push(key)\n }\n\n if (overwrittenHeaders.length > 0) {\n finalResponse.headers.set(\n 'x-middleware-override-headers',\n middlewareOverrideHeaders + ',' + overwrittenHeaders.join(',')\n )\n }\n }\n\n return {\n response: finalResponse,\n waitUntil: getWaitUntilPromiseFromEvent(event) ?? Promise.resolve(),\n fetchMetrics: request.fetchMetrics,\n }\n}\n"],"names":["NextRequestHint","adapter","NextRequest","constructor","params","input","init","sourcePage","page","request","PageSignatureError","respondWith","waitUntil","headersGetter","keys","headers","Array","from","get","key","undefined","propagator","fn","tracer","getTracer","withPropagatedContext","testApisIntercepted","ensureTestApisIntercepted","process","env","NEXT_PRIVATE_TEST_PROXY","interceptTestApis","wrapRequestHandler","require","getBuiltinRequestContext","ensureInstrumentationRegistered","isEdgeRendering","globalThis","__BUILD_MANIFEST","url","normalizeRscURL","requestURL","NextURL","nextConfig","searchParams","value","getAll","normalizedKey","normalizeNextQueryParam","delete","val","append","buildId","requestHeaders","fromNodeOutgoingHttpHeaders","isNextDataRequest","has","isRSCRequest","RSC_HEADER","pathname","flightHeaders","Map","header","FLIGHT_HEADERS","toLowerCase","set","normalizeURL","__NEXT_NO_MIDDLEWARE_URL_NORMALIZE","URL","stripInternalSearchParams","toString","body","method","signal","Object","defineProperty","enumerable","__incrementalCache","IncrementalCache","appDir","fetchCache","minimalMode","NODE_ENV","fetchCacheKeyPrefix","__NEXT_FETCH_CACHE_KEY_PREFIX","dev","requestProtocol","getPrerenderManifest","version","routes","dynamicRoutes","notFoundRoutes","preview","getEdgePreviewProps","outerWaitUntil","event","NextFetchEvent","context","response","cookiesFromResponse","isMiddleware","bind","closeController","CloseController","trace","MiddlewareSpan","execute","spanName","nextUrl","attributes","onUpdateCookies","cookies","previewProps","fallbackRouteParams","implicitTags","getImplicitTags","requestStore","createRequestStoreForAPI","workStore","createWorkStore","renderOpts","cacheLifeProfiles","experimental","cacheLife","isRoutePPREnabled","dynamicIO","authInterrupts","supportsDynamicResponse","onClose","onAfterTaskError","requestEndedState","ended","isPrefetchRequest","NEXT_ROUTER_PREFETCH_HEADER","previouslyRevalidatedTags","workAsyncStorage","run","workUnitAsyncStorage","handler","setTimeout","dispatchClose","Response","TypeError","rewrite","destination","forceLocale","host","String","relativeDestination","isRelative","parseRelativeURL","__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE","match","NEXT_REWRITTEN_PATH_HEADER","search","NEXT_REWRITTEN_QUERY_HEADER","slice","redirect","redirectURL","getRelativeURL","finalResponse","NextResponse","next","middlewareOverrideHeaders","overwrittenHeaders","push","length","join","getWaitUntilPromiseFromEvent","Promise","resolve","fetchMetrics"],"mappings":";;;;;;;;;;;;;;;IAqCaA,eAAe;eAAfA;;IA8DSC,OAAO;eAAPA;;;uBAjGa;uBACkC;4BAI9D;yBACqB;0BACC;+BAItB;yBACiB;+BACkB;0BACV;kCAMzB;yBACyC;8BACP;8CACJ;2BACL;0CACC;wBAEP;2BAEK;4BACC;qCACI;uCACK;8BACT;AAEzB,MAAMD,wBAAwBE,oBAAW;IAI9CC,YAAYC,MAIX,CAAE;QACD,KAAK,CAACA,OAAOC,KAAK,EAAED,OAAOE,IAAI;QAC/B,IAAI,CAACC,UAAU,GAAGH,OAA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G,IAAI,CAAC;QAE9D;IACF;IAEA,OAAO;QACLrE,UAAU8D;QACVpJ,WAAW4J,IAAAA,wCAA4B,EAACzE,UAAU0E,QAAQC,OAAO;QACjEC,cAAclK,QAAQkK,YAAY;IACpC;AACF","ignoreList":[0]}
|
1
|
+
{"version":3,"sources":["../../../src/server/web/adapter.ts"],"sourcesContent":["import type { RequestData, FetchEventResult } from './types'\nimport type { RequestInit } from './spec-extension/request'\nimport { PageSignatureError } from './error'\nimport { fromNodeOutgoingHttpHeaders, normalizeNextQueryParam } from './utils'\nimport {\n NextFetchEvent,\n getWaitUntilPromiseFromEvent,\n} from './spec-extension/fetch-event'\nimport { NextRequest } from './spec-extension/request'\nimport { NextResponse } from './spec-extension/response'\nimport {\n parseRelativeURL,\n getRelativeURL,\n} from '../../shared/lib/router/utils/relativize-url'\nimport { NextURL } from './next-url'\nimport { stripInternalSearchParams } from '../internal-utils'\nimport { normalizeRscURL } from '../../shared/lib/router/utils/app-paths'\nimport {\n FLIGHT_HEADERS,\n NEXT_REWRITTEN_PATH_HEADER,\n NEXT_REWRITTEN_QUERY_HEADER,\n RSC_HEADER,\n} from '../../client/components/app-router-headers'\nimport { ensureInstrumentationRegistered } from './globals'\nimport { createRequestStoreForAPI } from '../async-storage/request-store'\nimport { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'\nimport { createWorkStore } from '../async-storage/work-store'\nimport { workAsyncStorage } from '../app-render/work-async-storage.external'\nimport { NEXT_ROUTER_PREFETCH_HEADER } from '../../client/components/app-router-headers'\nimport { getTracer } from '../lib/trace/tracer'\nimport type { TextMapGetter } from 'next/dist/compiled/@opentelemetry/api'\nimport { MiddlewareSpan } from '../lib/trace/constants'\nimport { CloseController } from './web-on-close'\nimport { getEdgePreviewProps } from './get-edge-preview-props'\nimport { getBuiltinRequestContext } from '../after/builtin-request-context'\nimport { getImplicitTags } from '../lib/implicit-tags'\n\nexport class NextRequestHint extends NextRequest {\n sourcePage: string\n fetchMetrics: FetchEventResult['fetchMetrics'] | undefined\n\n constructor(params: {\n init: RequestInit\n input: Request | string\n page: string\n }) {\n super(params.input, params.init)\n this.sourcePage = params.page\n }\n\n get request() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n respondWith() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n\n waitUntil() {\n throw new PageSignatureError({ page: this.sourcePage })\n }\n}\n\nconst headersGetter: TextMapGetter<Headers> = {\n keys: (headers) => Array.from(headers.keys()),\n get: (headers, key) => headers.get(key) ?? undefined,\n}\n\nexport type AdapterOptions = {\n handler: (req: NextRequestHint, event: NextFetchEvent) => Promise<Response>\n page: string\n request: RequestData\n IncrementalCache?: typeof import('../lib/incremental-cache').IncrementalCache\n}\n\nlet propagator: <T>(request: NextRequestHint, fn: () => T) => T = (\n request,\n fn\n) => {\n const tracer = getTracer()\n return tracer.withPropagatedContext(request.headers, fn, headersGetter)\n}\n\nlet testApisIntercepted = false\n\nfunction ensureTestApisIntercepted() {\n if (!testApisIntercepted) {\n testApisIntercepted = true\n if (process.env.NEXT_PRIVATE_TEST_PROXY === 'true') {\n const {\n interceptTestApis,\n wrapRequestHandler,\n } = require('next/dist/experimental/testmode/server-edge')\n interceptTestApis()\n propagator = wrapRequestHandler(propagator)\n }\n }\n}\n\nexport async function adapter(\n params: AdapterOptions\n): Promise<FetchEventResult> {\n ensureTestApisIntercepted()\n await ensureInstrumentationRegistered()\n\n // TODO-APP: use explicit marker for this\n const isEdgeRendering =\n typeof (globalThis as any).__BUILD_MANIFEST !== 'undefined'\n\n params.request.url = normalizeRscURL(params.request.url)\n\n const requestURL = new NextURL(params.request.url, {\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n // Iterator uses an index to keep track of the current iteration. Because of deleting and appending below we can't just use the iterator.\n // Instead we use the keys before iteration.\n const keys = [...requestURL.searchParams.keys()]\n for (const key of keys) {\n const value = requestURL.searchParams.getAll(key)\n\n const normalizedKey = normalizeNextQueryParam(key)\n if (normalizedKey) {\n requestURL.searchParams.delete(normalizedKey)\n for (const val of value) {\n requestURL.searchParams.append(normalizedKey, val)\n }\n requestURL.searchParams.delete(key)\n }\n }\n\n // Ensure users only see page requests, never data requests.\n const buildId = requestURL.buildId\n requestURL.buildId = ''\n\n const requestHeaders = fromNodeOutgoingHttpHeaders(params.request.headers)\n const isNextDataRequest = requestHeaders.has('x-nextjs-data')\n const isRSCRequest = requestHeaders.get(RSC_HEADER) === '1'\n\n if (isNextDataRequest && requestURL.pathname === '/index') {\n requestURL.pathname = '/'\n }\n\n const flightHeaders = new Map()\n\n // Headers should only be stripped for middleware\n if (!isEdgeRendering) {\n for (const header of FLIGHT_HEADERS) {\n const key = header.toLowerCase()\n const value = requestHeaders.get(key)\n if (value !== null) {\n flightHeaders.set(key, value)\n requestHeaders.delete(key)\n }\n }\n }\n\n const normalizeURL = process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE\n ? new URL(params.request.url)\n : requestURL\n\n const request = new NextRequestHint({\n page: params.page,\n // Strip internal query parameters off the request.\n input: stripInternalSearchParams(normalizeURL).toString(),\n init: {\n body: params.request.body,\n headers: requestHeaders,\n method: params.request.method,\n nextConfig: params.request.nextConfig,\n signal: params.request.signal,\n },\n })\n\n /**\n * This allows to identify the request as a data request. The user doesn't\n * need to know about this property neither use it. We add it for testing\n * purposes.\n */\n if (isNextDataRequest) {\n Object.defineProperty(request, '__isData', {\n enumerable: false,\n value: true,\n })\n }\n\n if (\n // If we are inside of the next start sandbox\n // leverage the shared instance if not we need\n // to create a fresh cache instance each time\n !(globalThis as any).__incrementalCacheShared &&\n (params as any).IncrementalCache\n ) {\n ;(globalThis as any).__incrementalCache = new (\n params as any\n ).IncrementalCache({\n appDir: true,\n fetchCache: true,\n minimalMode: process.env.NODE_ENV !== 'development',\n fetchCacheKeyPrefix: process.env.__NEXT_FETCH_CACHE_KEY_PREFIX,\n dev: process.env.NODE_ENV === 'development',\n requestHeaders: params.request.headers as any,\n requestProtocol: 'https',\n getPrerenderManifest: () => {\n return {\n version: -1 as any, // letting us know this doesn't conform to spec\n routes: {},\n dynamicRoutes: {},\n notFoundRoutes: [],\n preview: getEdgePreviewProps(),\n }\n },\n })\n }\n\n // if we're in an edge runtime sandbox, we should use the waitUntil\n // that we receive from the enclosing NextServer\n const outerWaitUntil =\n params.request.waitUntil ?? getBuiltinRequestContext()?.waitUntil\n\n const event = new NextFetchEvent({\n request,\n page: params.page,\n context: outerWaitUntil ? { waitUntil: outerWaitUntil } : undefined,\n })\n let response\n let cookiesFromResponse\n\n response = await propagator(request, () => {\n // we only care to make async storage available for middleware\n const isMiddleware =\n params.page === '/middleware' || params.page === '/src/middleware'\n\n if (isMiddleware) {\n // if we're in an edge function, we only get a subset of `nextConfig` (no `experimental`),\n // so we have to inject it via DefinePlugin.\n // in `next start` this will be passed normally (see `NextNodeServer.runMiddleware`).\n\n const waitUntil = event.waitUntil.bind(event)\n const closeController = new CloseController()\n\n return getTracer().trace(\n MiddlewareSpan.execute,\n {\n spanName: `middleware ${request.method} ${request.nextUrl.pathname}`,\n attributes: {\n 'http.target': request.nextUrl.pathname,\n 'http.method': request.method,\n },\n },\n async () => {\n try {\n const onUpdateCookies = (cookies: Array<string>) => {\n cookiesFromResponse = cookies\n }\n const previewProps = getEdgePreviewProps()\n const page = '/' // Fake Work\n const fallbackRouteParams = null\n\n const implicitTags = await getImplicitTags(\n page,\n request.nextUrl,\n fallbackRouteParams\n )\n\n const requestStore = createRequestStoreForAPI(\n request,\n request.nextUrl,\n implicitTags,\n onUpdateCookies,\n previewProps\n )\n\n const workStore = createWorkStore({\n page,\n fallbackRouteParams,\n renderOpts: {\n cacheLifeProfiles:\n params.request.nextConfig?.experimental?.cacheLife,\n experimental: {\n isRoutePPREnabled: false,\n dynamicIO: false,\n authInterrupts:\n !!params.request.nextConfig?.experimental?.authInterrupts,\n },\n supportsDynamicResponse: true,\n waitUntil,\n onClose: closeController.onClose.bind(closeController),\n onAfterTaskError: undefined,\n },\n requestEndedState: { ended: false },\n isPrefetchRequest: request.headers.has(\n NEXT_ROUTER_PREFETCH_HEADER\n ),\n buildId: buildId ?? '',\n previouslyRevalidatedTags: [],\n })\n\n return await workAsyncStorage.run(workStore, () =>\n workUnitAsyncStorage.run(\n requestStore,\n params.handler,\n request,\n event\n )\n )\n } finally {\n // middleware cannot stream, so we can consider the response closed\n // as soon as the handler returns.\n // we can delay running it until a bit later --\n // if it's needed, we'll have a `waitUntil` lock anyway.\n setTimeout(() => {\n closeController.dispatchClose()\n }, 0)\n }\n }\n )\n }\n return params.handler(request, event)\n })\n\n // check if response is a Response object\n if (response && !(response instanceof Response)) {\n throw new TypeError('Expected an instance of Response to be returned')\n }\n\n if (response && cookiesFromResponse) {\n response.headers.set('set-cookie', cookiesFromResponse)\n }\n\n /**\n * For rewrites we must always include the locale in the final pathname\n * so we re-create the NextURL forcing it to include it when the it is\n * an internal rewrite. Also we make sure the outgoing rewrite URL is\n * a data URL if the request was a data request.\n */\n const rewrite = response?.headers.get('x-middleware-rewrite')\n if (response && rewrite && (isRSCRequest || !isEdgeRendering)) {\n const destination = new NextURL(rewrite, {\n forceLocale: true,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE && !isEdgeRendering) {\n if (destination.host === request.nextUrl.host) {\n destination.buildId = buildId || destination.buildId\n response.headers.set('x-middleware-rewrite', String(destination))\n }\n }\n\n /**\n * When the request is a data request we must show if there was a rewrite\n * with an internal header so the client knows which component to load\n * from the data request.\n */\n const { url: relativeDestination, isRelative } = parseRelativeURL(\n destination.toString(),\n requestURL.toString()\n )\n\n if (\n !isEdgeRendering &&\n isNextDataRequest &&\n // if the rewrite is external and external rewrite\n // resolving config is enabled don't add this header\n // so the upstream app can set it instead\n !(\n process.env.__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE &&\n relativeDestination.match(/http(s)?:\\/\\//)\n )\n ) {\n response.headers.set('x-nextjs-rewrite', relativeDestination)\n }\n\n // If this is an RSC request, and the pathname or search has changed, and\n // this isn't an external rewrite, we need to set the rewritten pathname and\n // query headers.\n if (isRSCRequest && isRelative) {\n if (requestURL.pathname !== destination.pathname) {\n response.headers.set(NEXT_REWRITTEN_PATH_HEADER, destination.pathname)\n }\n if (requestURL.search !== destination.search) {\n response.headers.set(\n NEXT_REWRITTEN_QUERY_HEADER,\n // remove the leading ? from the search string\n destination.search.slice(1)\n )\n }\n }\n }\n\n /**\n * For redirects we will not include the locale in case when it is the\n * default and we must also make sure the outgoing URL is a data one if\n * the incoming request was a data request.\n */\n const redirect = response?.headers.get('Location')\n if (response && redirect && !isEdgeRendering) {\n const redirectURL = new NextURL(redirect, {\n forceLocale: false,\n headers: params.request.headers,\n nextConfig: params.request.nextConfig,\n })\n\n /**\n * Responses created from redirects have immutable headers so we have\n * to clone the response to be able to modify it.\n */\n response = new Response(response.body, response)\n\n if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {\n if (redirectURL.host === requestURL.host) {\n redirectURL.buildId = buildId || redirectURL.buildId\n response.headers.set('Location', redirectURL.toString())\n }\n }\n\n /**\n * When the request is a data request we can't use the location header as\n * it may end up with CORS error. Instead we map to an internal header so\n * the client knows the destination.\n */\n if (isNextDataRequest) {\n response.headers.delete('Location')\n response.headers.set(\n 'x-nextjs-redirect',\n getRelativeURL(redirectURL.toString(), requestURL.toString())\n )\n }\n }\n\n const finalResponse = response ? response : NextResponse.next()\n\n // Flight headers are not overridable / removable so they are applied at the end.\n const middlewareOverrideHeaders = finalResponse.headers.get(\n 'x-middleware-override-headers'\n )\n const overwrittenHeaders: string[] = []\n if (middlewareOverrideHeaders) {\n for (const [key, value] of flightHeaders) {\n finalResponse.headers.set(`x-middleware-request-${key}`, value)\n overwrittenHeaders.push(key)\n }\n\n if (overwrittenHeaders.length > 0) {\n finalResponse.headers.set(\n 'x-middleware-override-headers',\n middlewareOverrideHeaders + ',' + overwrittenHeaders.join(',')\n )\n }\n }\n\n return {\n response: finalResponse,\n waitUntil: getWaitUntilPromiseFromEvent(event) ?? Promise.resolve(),\n fetchMetrics: request.fetchMetrics,\n }\n}\n"],"names":["NextRequestHint","adapter","NextRequest","constructor","params","input","init","sourcePage","page","request","PageSignatureError","respondWith","waitUntil","headersGetter","keys","headers","Array","from","get","key","undefined","propagator","fn","tracer","getTracer","withPropagatedContext","testApisIntercepted","ensureTestApisIntercepted","process","env","NEXT_PRIVATE_TEST_PROXY","interceptTestApis","wrapRequestHandler","require","getBuiltinRequestContext","ensureInstrumentationRegistered","isEdgeRendering","globalThis","__BUILD_MANIFEST","url","normalizeRscURL","requestURL","NextURL","nextConfig","searchParams","value","getAll","normalizedKey","normalizeNextQueryParam","delete","val","append","buildId","requestHeaders","fromNodeOutgoingHttpHeaders","isNextDataRequest","has","isRSCRequest","RSC_HEADER","pathname","flightHeaders","Map","header","FLIGHT_HEADERS","toLowerCase","set","normalizeURL","__NEXT_NO_MIDDLEWARE_URL_NORMALIZE","URL","stripInternalSearchParams","toString","body","method","signal","Object","defineProperty","enumerable","__incrementalCacheShared","IncrementalCache","__incrementalCache","appDir","fetchCache","minimalMode","NODE_ENV","fetchCacheKeyPrefix","__NEXT_FETCH_CACHE_KEY_PREFIX","dev","requestProtocol","getPrerenderManifest","version","routes","dynamicRoutes","notFoundRoutes","preview","getEdgePreviewProps","outerWaitUntil","event","NextFetchEvent","context","response","cookiesFromResponse","isMiddleware","bind","closeController","CloseController","trace","MiddlewareSpan","execute","spanName","nextUrl","attributes","onUpdateCookies","cookies","previewProps","fallbackRouteParams","implicitTags","getImplicitTags","requestStore","createRequestStoreForAPI","workStore","createWorkStore","renderOpts","cacheLifeProfiles","experimental","cacheLife","isRoutePPREnabled","dynamicIO","authInterrupts","supportsDynamicResponse","onClose","onAfterTaskError","requestEndedState","ended","isPrefetchRequest","NEXT_ROUTER_PREFETCH_HEADER","previouslyRevalidatedTags","workAsyncStorage","run","workUnitAsyncStorage","handler","setTimeout","dispatchClose","Response","TypeError","rewrite","destination","forceLocale","host","String","relativeDestination","isRelative","parseRelativeURL","__NEXT_EXTERNAL_MIDDLEWARE_REWRITE_RESOLVE","match","NEXT_REWRITTEN_PATH_HEADER","search","NEXT_REWRITTEN_QUERY_HEADER","slice","redirect","redirectURL","getRelativeURL","finalResponse","NextResponse","next","middlewareOverrideHeaders","overwrittenHeaders","push","length","join","getWaitUntilPromiseFromEvent","Promise","resolve","fetchMetrics"],"mappings":";;;;;;;;;;;;;;;IAqCaA,eAAe;eAAfA;;IA8DSC,OAAO;eAAPA;;;uBAjGa;uBACkC;4BAI9D;yBACqB;0BACC;+BAItB;yBACiB;+BACkB;0BACV;kCAMzB;yBACyC;8BACP;8CACJ;2BACL;0CACC;wBAEP;2BAEK;4BACC;qCACI;uCACK;8BACT;AAEzB,MAAMD,wBAAwBE,oBAAW;IAI9CC,YAAYC,MAIX,CAAE;QACD,KAAK,CAACA,OAAOC,KAAK,EAAED,OAAOE,IAAI;QAC/B,IAAI,CAACC,UAAU,GAAGH,OAAOI,IAAI;IAC/B;IAEA,IAAIC,UAAU;QACZ,MAAM,qBAAiD,CAAjD,IAAIC,yBAAkB,CAAC;YAAEF,MAAM,IAAI,CAACD,UAAU;QAAC,IAA/C,qBAAA;mBAAA;wBAAA;0BAAA;QAAgD;IACxD;IAEAI,cAAc;QACZ,MAAM,qBAAiD,CAAjD,IAAID,yBAAkB,CAAC;YAAEF,MAAM,IAAI,CAACD,UAAU;QAAC,IAA/C,qBAAA;mBAAA;wBAAA;0BAAA;QAAgD;IACxD;IAEAK,YAAY;QACV,MAAM,qBAAiD,CAAjD,IAAIF,yBAAkB,CAAC;YAAEF,MAAM,IAAI,CAACD,UAAU;QAAC,IAA/C,qBAAA;mBAAA;wBAAA;0BAAA;QAAgD;IACxD;AACF;AAEA,MAAMM,gBAAwC;IAC5CC,MAAM,CAACC,UAAYC,MAAMC,IAAI,CAACF,QAAQD,IAAI;IAC1CI,KAAK,CAACH,SAASI,MAAQJ,QAAQG,GAAG,CAACC,QAAQC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AEA;;;;KAIC,GACD,IAAIf,mBAAmB;YACrB4C,SAASpF,OAAO,CAACkC,MAAM,CAAC;YACxBkD,SAASpF,OAAO,CAACkD,GAAG,CAClB,qBACA+F,IAAAA,6BAAc,EAACD,YAAYzF,QAAQ,IAAI7B,WAAW6B,QAAQ;QAE9D;IACF;IAEA,MAAM2F,gBAAgB9D,WAAWA,WAAW+D,sBAAY,CAACC,IAAI;IAE7D,iFAAiF;IACjF,MAAMC,4BAA4BH,cAAclJ,OAAO,CAACG,GAAG,CACzD;IAEF,MAAMmJ,qBAA+B,EAAE;IACvC,IAAID,2BAA2B;QAC7B,KAAK,MAAM,CAACjJ,KAAK0B,MAAM,IAAIe,cAAe;YACxCqG,cAAclJ,OAAO,CAACkD,GAAG,CAAC,CAAC,qBAAqB,EAAE9C,KAAK,EAAE0B;YACzDwH,mBAAmBC,IAAI,CAACnJ;QAC1B;QAEA,IAAIkJ,mBAAmBE,MAAM,GAAG,GAAG;YACjCN,cAAclJ,OAAO,CAACkD,GAAG,CACvB,iCACAmG,4BAA4B,MAAMC,mBAAmBG,IAAI,CAAC;QAE9D;IACF;IAEA,OAAO;QACLrE,UAAU8D;QACVrJ,WAAW6J,IAAAA,wCAA4B,EAACzE,UAAU0E,QAAQC,OAAO;QACjEC,cAAcnK,QAAQmK,YAAY;IACpC;AACF","ignoreList":[0]}
|
@@ -66,6 +66,7 @@ async function getRuntimeContext(params) {
|
|
66
66
|
distDir: params.distDir
|
67
67
|
});
|
68
68
|
if (params.incrementalCache) {
|
69
|
+
runtime.context.globalThis.__incrementalCacheShared = true;
|
69
70
|
runtime.context.globalThis.__incrementalCache = params.incrementalCache;
|
70
71
|
}
|
71
72
|
if (params.serverComponentsHmrCache) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/server/web/sandbox/sandbox.ts"],"sourcesContent":["import type { NodejsRequestData, FetchEventResult, RequestData } from '../types'\nimport type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin'\nimport type { EdgeRuntime } from 'next/dist/compiled/edge-runtime'\nimport {\n getModuleContext,\n requestStore,\n edgeSandboxNextRequestContext,\n} from './context'\nimport { requestToBodyStream } from '../../body-streams'\nimport { NEXT_RSC_UNION_QUERY } from '../../../client/components/app-router-headers'\nimport type { ServerComponentsHmrCache } from '../../response-cache'\nimport {\n getBuiltinRequestContext,\n type BuiltinRequestContextValue,\n} from '../../after/builtin-request-context'\n\nexport const ErrorSource = Symbol('SandboxError')\n\nconst FORBIDDEN_HEADERS = [\n 'content-length',\n 'content-encoding',\n 'transfer-encoding',\n]\n\ninterface RunnerFnParams {\n name: string\n onError?: (err: unknown) => void\n onWarning?: (warn: Error) => void\n paths: string[]\n request: NodejsRequestData\n useCache: boolean\n edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm' | 'env'>\n distDir: string\n incrementalCache?: any\n serverComponentsHmrCache?: ServerComponentsHmrCache\n}\n\ntype RunnerFn = (params: RunnerFnParams) => Promise<FetchEventResult>\n\n/**\n * Decorates the runner function making sure all errors it can produce are\n * tagged with `edge-server` so they can properly be rendered in dev.\n */\nfunction withTaggedErrors(fn: RunnerFn): RunnerFn {\n if (process.env.NODE_ENV === 'development') {\n const { getServerError } =\n require('../../../client/components/react-dev-overlay/server/middleware-webpack') as typeof import('../../../client/components/react-dev-overlay/server/middleware-webpack')\n\n return (params) =>\n fn(params)\n .then((result) => ({\n ...result,\n waitUntil: result?.waitUntil?.catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead. Verify that it does not increase the runtime size.\n throw getServerError(error, 'edge-server')\n }),\n }))\n .catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead\n throw getServerError(error, 'edge-server')\n })\n }\n\n return fn\n}\n\nexport async function getRuntimeContext(\n params: Omit<RunnerFnParams, 'request'>\n): Promise<EdgeRuntime<any>> {\n const { runtime, evaluateInContext } = await getModuleContext({\n moduleName: params.name,\n onWarning: params.onWarning ?? (() => {}),\n onError: params.onError ?? (() => {}),\n useCache: params.useCache !== false,\n edgeFunctionEntry: params.edgeFunctionEntry,\n distDir: params.distDir,\n })\n\n if (params.incrementalCache) {\n runtime.context.globalThis.__incrementalCache = params.incrementalCache\n }\n\n if (params.serverComponentsHmrCache) {\n runtime.context.globalThis.__serverComponentsHmrCache =\n params.serverComponentsHmrCache\n }\n\n for (const paramPath of params.paths) {\n evaluateInContext(paramPath)\n }\n return runtime\n}\n\nexport const run = withTaggedErrors(async function runWithTaggedErrors(params) {\n const runtime = await getRuntimeContext(params)\n\n const edgeFunction: (args: {\n request: RequestData\n }) => Promise<FetchEventResult> = (\n await runtime.context._ENTRIES[`middleware_${params.name}`]\n ).default\n\n const cloned = !['HEAD', 'GET'].includes(params.request.method)\n ? params.request.body?.cloneBodyStream()\n : undefined\n\n const KUint8Array = runtime.evaluate('Uint8Array')\n const urlInstance = new URL(params.request.url)\n urlInstance.searchParams.delete(NEXT_RSC_UNION_QUERY)\n\n params.request.url = urlInstance.toString()\n\n const headers = new Headers()\n for (const [key, value] of Object.entries(params.request.headers)) {\n headers.set(key, value?.toString() ?? '')\n }\n\n try {\n let result: FetchEventResult | undefined = undefined\n const builtinRequestCtx: BuiltinRequestContextValue = {\n ...getBuiltinRequestContext(),\n // FIXME(after):\n // arguably, this is an abuse of \"@next/request-context\" --\n // it'd make more sense to simply forward its existing value into the sandbox (in `createModuleContext`)\n // but here we're using it to just pass in `waitUntil` regardless if we were running in this context or not.\n waitUntil: params.request.waitUntil,\n }\n await edgeSandboxNextRequestContext.run(builtinRequestCtx, () =>\n requestStore.run({ headers }, async () => {\n result = await edgeFunction({\n request: {\n ...params.request,\n body:\n cloned &&\n requestToBodyStream(runtime.context, KUint8Array, cloned),\n },\n })\n for (const headerName of FORBIDDEN_HEADERS) {\n result.response.headers.delete(headerName)\n }\n })\n )\n\n if (!result) throw new Error('Edge function did not return a response')\n return result\n } finally {\n await params.request.body?.finalize()\n }\n})\n"],"names":["ErrorSource","getRuntimeContext","run","Symbol","FORBIDDEN_HEADERS","withTaggedErrors","fn","process","env","NODE_ENV","getServerError","require","params","then","result","waitUntil","catch","error","runtime","evaluateInContext","getModuleContext","moduleName","name","onWarning","onError","useCache","edgeFunctionEntry","distDir","incrementalCache","context","globalThis","__incrementalCache","serverComponentsHmrCache","__serverComponentsHmrCache","paramPath","paths","runWithTaggedErrors","edgeFunction","_ENTRIES","default","cloned","includes","request","method","body","cloneBodyStream","undefined","KUint8Array","evaluate","urlInstance","URL","url","searchParams","delete","NEXT_RSC_UNION_QUERY","toString","headers","Headers","key","value","Object","entries","set","builtinRequestCtx","getBuiltinRequestContext","edgeSandboxNextRequestContext","requestStore","requestToBodyStream","headerName","response","Error","finalize"],"mappings":";;;;;;;;;;;;;;;;IAgBaA,WAAW;eAAXA;;IAkDSC,iBAAiB;eAAjBA;;
|
1
|
+
{"version":3,"sources":["../../../../src/server/web/sandbox/sandbox.ts"],"sourcesContent":["import type { NodejsRequestData, FetchEventResult, RequestData } from '../types'\nimport type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin'\nimport type { EdgeRuntime } from 'next/dist/compiled/edge-runtime'\nimport {\n getModuleContext,\n requestStore,\n edgeSandboxNextRequestContext,\n} from './context'\nimport { requestToBodyStream } from '../../body-streams'\nimport { NEXT_RSC_UNION_QUERY } from '../../../client/components/app-router-headers'\nimport type { ServerComponentsHmrCache } from '../../response-cache'\nimport {\n getBuiltinRequestContext,\n type BuiltinRequestContextValue,\n} from '../../after/builtin-request-context'\n\nexport const ErrorSource = Symbol('SandboxError')\n\nconst FORBIDDEN_HEADERS = [\n 'content-length',\n 'content-encoding',\n 'transfer-encoding',\n]\n\ninterface RunnerFnParams {\n name: string\n onError?: (err: unknown) => void\n onWarning?: (warn: Error) => void\n paths: string[]\n request: NodejsRequestData\n useCache: boolean\n edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm' | 'env'>\n distDir: string\n incrementalCache?: any\n serverComponentsHmrCache?: ServerComponentsHmrCache\n}\n\ntype RunnerFn = (params: RunnerFnParams) => Promise<FetchEventResult>\n\n/**\n * Decorates the runner function making sure all errors it can produce are\n * tagged with `edge-server` so they can properly be rendered in dev.\n */\nfunction withTaggedErrors(fn: RunnerFn): RunnerFn {\n if (process.env.NODE_ENV === 'development') {\n const { getServerError } =\n require('../../../client/components/react-dev-overlay/server/middleware-webpack') as typeof import('../../../client/components/react-dev-overlay/server/middleware-webpack')\n\n return (params) =>\n fn(params)\n .then((result) => ({\n ...result,\n waitUntil: result?.waitUntil?.catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead. Verify that it does not increase the runtime size.\n throw getServerError(error, 'edge-server')\n }),\n }))\n .catch((error) => {\n // TODO: used COMPILER_NAMES.edgeServer instead\n throw getServerError(error, 'edge-server')\n })\n }\n\n return fn\n}\n\nexport async function getRuntimeContext(\n params: Omit<RunnerFnParams, 'request'>\n): Promise<EdgeRuntime<any>> {\n const { runtime, evaluateInContext } = await getModuleContext({\n moduleName: params.name,\n onWarning: params.onWarning ?? (() => {}),\n onError: params.onError ?? (() => {}),\n useCache: params.useCache !== false,\n edgeFunctionEntry: params.edgeFunctionEntry,\n distDir: params.distDir,\n })\n\n if (params.incrementalCache) {\n runtime.context.globalThis.__incrementalCacheShared = true\n runtime.context.globalThis.__incrementalCache = params.incrementalCache\n }\n\n if (params.serverComponentsHmrCache) {\n runtime.context.globalThis.__serverComponentsHmrCache =\n params.serverComponentsHmrCache\n }\n\n for (const paramPath of params.paths) {\n evaluateInContext(paramPath)\n }\n return runtime\n}\n\nexport const run = withTaggedErrors(async function runWithTaggedErrors(params) {\n const runtime = await getRuntimeContext(params)\n\n const edgeFunction: (args: {\n request: RequestData\n }) => Promise<FetchEventResult> = (\n await runtime.context._ENTRIES[`middleware_${params.name}`]\n ).default\n\n const cloned = !['HEAD', 'GET'].includes(params.request.method)\n ? params.request.body?.cloneBodyStream()\n : undefined\n\n const KUint8Array = runtime.evaluate('Uint8Array')\n const urlInstance = new URL(params.request.url)\n urlInstance.searchParams.delete(NEXT_RSC_UNION_QUERY)\n\n params.request.url = urlInstance.toString()\n\n const headers = new Headers()\n for (const [key, value] of Object.entries(params.request.headers)) {\n headers.set(key, value?.toString() ?? '')\n }\n\n try {\n let result: FetchEventResult | undefined = undefined\n const builtinRequestCtx: BuiltinRequestContextValue = {\n ...getBuiltinRequestContext(),\n // FIXME(after):\n // arguably, this is an abuse of \"@next/request-context\" --\n // it'd make more sense to simply forward its existing value into the sandbox (in `createModuleContext`)\n // but here we're using it to just pass in `waitUntil` regardless if we were running in this context or not.\n waitUntil: params.request.waitUntil,\n }\n await edgeSandboxNextRequestContext.run(builtinRequestCtx, () =>\n requestStore.run({ headers }, async () => {\n result = await edgeFunction({\n request: {\n ...params.request,\n body:\n cloned &&\n requestToBodyStream(runtime.context, KUint8Array, cloned),\n },\n })\n for (const headerName of FORBIDDEN_HEADERS) {\n result.response.headers.delete(headerName)\n }\n })\n )\n\n if (!result) throw new Error('Edge function did not return a response')\n return result\n } finally {\n await params.request.body?.finalize()\n }\n})\n"],"names":["ErrorSource","getRuntimeContext","run","Symbol","FORBIDDEN_HEADERS","withTaggedErrors","fn","process","env","NODE_ENV","getServerError","require","params","then","result","waitUntil","catch","error","runtime","evaluateInContext","getModuleContext","moduleName","name","onWarning","onError","useCache","edgeFunctionEntry","distDir","incrementalCache","context","globalThis","__incrementalCacheShared","__incrementalCache","serverComponentsHmrCache","__serverComponentsHmrCache","paramPath","paths","runWithTaggedErrors","edgeFunction","_ENTRIES","default","cloned","includes","request","method","body","cloneBodyStream","undefined","KUint8Array","evaluate","urlInstance","URL","url","searchParams","delete","NEXT_RSC_UNION_QUERY","toString","headers","Headers","key","value","Object","entries","set","builtinRequestCtx","getBuiltinRequestContext","edgeSandboxNextRequestContext","requestStore","requestToBodyStream","headerName","response","Error","finalize"],"mappings":";;;;;;;;;;;;;;;;IAgBaA,WAAW;eAAXA;;IAkDSC,iBAAiB;eAAjBA;;IA4BTC,GAAG;eAAHA;;;yB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;oBAC1BK,SAAS;wBACP,GAAG/B,OAAO+B,OAAO;wBACjBE,MACEJ,UACA2B,IAAAA,gCAAmB,EAAClD,QAAQW,OAAO,EAAEmB,aAAaP;oBACtD;gBACF;gBACA,KAAK,MAAM4B,cAAcjE,kBAAmB;oBAC1CU,OAAOwD,QAAQ,CAACb,OAAO,CAACH,MAAM,CAACe;gBACjC;YACF;QAGF,IAAI,CAACvD,QAAQ,MAAM,qBAAoD,CAApD,IAAIyD,MAAM,4CAAV,qBAAA;mBAAA;wBAAA;0BAAA;QAAmD;QACtE,OAAOzD;IACT,SAAU;YACFF;QAAN,QAAMA,wBAAAA,OAAO+B,OAAO,CAACE,IAAI,qBAAnBjC,sBAAqB4D,QAAQ;IACrC;AACF","ignoreList":[0]}
|
@@ -22,7 +22,7 @@ _export(exports, {
|
|
22
22
|
});
|
23
23
|
function isStableBuild() {
|
24
24
|
var _process_env___NEXT_VERSION;
|
25
|
-
return !((_process_env___NEXT_VERSION = "15.4.0-canary.
|
25
|
+
return !((_process_env___NEXT_VERSION = "15.4.0-canary.43") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
26
26
|
}
|
27
27
|
class CanaryOnlyError extends Error {
|
28
28
|
constructor(arg){
|
@@ -11,11 +11,11 @@ Object.defineProperty(exports, "eventCliSessionStopped", {
|
|
11
11
|
const EVENT_VERSION = 'NEXT_CLI_SESSION_STOPPED';
|
12
12
|
function eventCliSessionStopped(event) {
|
13
13
|
// This should be an invariant, if it fails our build tooling is broken.
|
14
|
-
if (typeof "15.4.0-canary.
|
14
|
+
if (typeof "15.4.0-canary.43" !== 'string') {
|
15
15
|
return [];
|
16
16
|
}
|
17
17
|
const payload = {
|
18
|
-
nextVersion: "15.4.0-canary.
|
18
|
+
nextVersion: "15.4.0-canary.43",
|
19
19
|
nodeVersion: process.version,
|
20
20
|
cliCommand: event.cliCommand,
|
21
21
|
durationMilliseconds: event.durationMilliseconds,
|
@@ -36,12 +36,12 @@ function hasBabelConfig(dir) {
|
|
36
36
|
function eventCliSession(dir, nextConfig, event) {
|
37
37
|
var _nextConfig_experimental_staleTimes, _nextConfig_experimental_staleTimes1, _nextConfig_experimental_reactCompiler, _nextConfig_experimental_reactCompiler1;
|
38
38
|
// This should be an invariant, if it fails our build tooling is broken.
|
39
|
-
if (typeof "15.4.0-canary.
|
39
|
+
if (typeof "15.4.0-canary.43" !== 'string') {
|
40
40
|
return [];
|
41
41
|
}
|
42
42
|
const { images, i18n } = nextConfig || {};
|
43
43
|
const payload = {
|
44
|
-
nextVersion: "15.4.0-canary.
|
44
|
+
nextVersion: "15.4.0-canary.43",
|
45
45
|
nodeVersion: process.version,
|
46
46
|
cliCommand: event.cliCommand,
|
47
47
|
isSrcDir: event.isSrcDir,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "next",
|
3
|
-
"version": "15.4.0-canary.
|
3
|
+
"version": "15.4.0-canary.43",
|
4
4
|
"description": "The React Framework",
|
5
5
|
"main": "./dist/server/next.js",
|
6
6
|
"license": "MIT",
|
@@ -100,7 +100,7 @@
|
|
100
100
|
]
|
101
101
|
},
|
102
102
|
"dependencies": {
|
103
|
-
"@next/env": "15.4.0-canary.
|
103
|
+
"@next/env": "15.4.0-canary.43",
|
104
104
|
"@swc/helpers": "0.5.15",
|
105
105
|
"caniuse-lite": "^1.0.30001579",
|
106
106
|
"postcss": "8.4.31",
|
@@ -130,14 +130,14 @@
|
|
130
130
|
},
|
131
131
|
"optionalDependencies": {
|
132
132
|
"sharp": "^0.34.1",
|
133
|
-
"@next/swc-darwin-arm64": "15.4.0-canary.
|
134
|
-
"@next/swc-darwin-x64": "15.4.0-canary.
|
135
|
-
"@next/swc-linux-arm64-gnu": "15.4.0-canary.
|
136
|
-
"@next/swc-linux-arm64-musl": "15.4.0-canary.
|
137
|
-
"@next/swc-linux-x64-gnu": "15.4.0-canary.
|
138
|
-
"@next/swc-linux-x64-musl": "15.4.0-canary.
|
139
|
-
"@next/swc-win32-arm64-msvc": "15.4.0-canary.
|
140
|
-
"@next/swc-win32-x64-msvc": "15.4.0-canary.
|
133
|
+
"@next/swc-darwin-arm64": "15.4.0-canary.43",
|
134
|
+
"@next/swc-darwin-x64": "15.4.0-canary.43",
|
135
|
+
"@next/swc-linux-arm64-gnu": "15.4.0-canary.43",
|
136
|
+
"@next/swc-linux-arm64-musl": "15.4.0-canary.43",
|
137
|
+
"@next/swc-linux-x64-gnu": "15.4.0-canary.43",
|
138
|
+
"@next/swc-linux-x64-musl": "15.4.0-canary.43",
|
139
|
+
"@next/swc-win32-arm64-msvc": "15.4.0-canary.43",
|
140
|
+
"@next/swc-win32-x64-msvc": "15.4.0-canary.43"
|
141
141
|
},
|
142
142
|
"devDependencies": {
|
143
143
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
@@ -170,11 +170,11 @@
|
|
170
170
|
"@jest/types": "29.5.0",
|
171
171
|
"@mswjs/interceptors": "0.23.0",
|
172
172
|
"@napi-rs/triples": "1.2.0",
|
173
|
-
"@next/font": "15.4.0-canary.
|
174
|
-
"@next/polyfill-module": "15.4.0-canary.
|
175
|
-
"@next/polyfill-nomodule": "15.4.0-canary.
|
176
|
-
"@next/react-refresh-utils": "15.4.0-canary.
|
177
|
-
"@next/swc": "15.4.0-canary.
|
173
|
+
"@next/font": "15.4.0-canary.43",
|
174
|
+
"@next/polyfill-module": "15.4.0-canary.43",
|
175
|
+
"@next/polyfill-nomodule": "15.4.0-canary.43",
|
176
|
+
"@next/react-refresh-utils": "15.4.0-canary.43",
|
177
|
+
"@next/swc": "15.4.0-canary.43",
|
178
178
|
"@opentelemetry/api": "1.6.0",
|
179
179
|
"@playwright/test": "1.41.2",
|
180
180
|
"@rspack/core": "1.3.9",
|