fix update build

This commit is contained in:
2026-07-14 10:40:44 +05:30
parent d8083177ce
commit 3917d58464
1441 changed files with 360224 additions and 66332 deletions

View File

@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PrerenderManifestMatcher", {
enumerable: true,
get: function() {
return PrerenderManifestMatcher;
}
});
const _routematcher = require("../../../../shared/lib/router/utils/route-matcher");
const _routeregex = require("../../../../shared/lib/router/utils/route-regex");
class PrerenderManifestMatcher {
constructor(pathname, prerenderManifest){
this.matchers = Object.entries(prerenderManifest.dynamicRoutes).filter(([source, route])=>{
// If the pathname is a fallback source route, or the source route is
// the same as the pathname, then we should include it in the matchers.
return route.fallbackSourceRoute === pathname || source === pathname;
}).map(([source, route])=>({
source,
route
}));
}
/**
* Match the pathname to the dynamic route. If no match is found, an error is
* thrown.
*
* @param pathname - The pathname to match.
* @returns The dynamic route that matches the pathname.
*/ match(pathname) {
// Iterate over the matchers. They're already in the correct order of
// specificity as they were inserted into the prerender manifest that way
// and iterating over them with Object.entries guarantees that.
for (const matcher of this.matchers){
// Lazily create the matcher, this is only done once per matcher.
if (!matcher.matcher) {
matcher.matcher = (0, _routematcher.getRouteMatcher)((0, _routeregex.getRouteRegex)(matcher.source));
}
const match = matcher.matcher(pathname);
if (match) {
return {
source: matcher.source,
route: matcher.route
};
}
}
return null;
}
}
//# sourceMappingURL=prerender-manifest-matcher.js.map

View File

@@ -0,0 +1,36 @@
"use strict";
if (process.env.NEXT_RUNTIME === 'edge') {
module.exports = require('next/dist/server/route-modules/app-page/module.js');
} else {
if (process.env.__NEXT_EXPERIMENTAL_REACT) {
if (process.env.NODE_ENV === 'development') {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-page-turbo-experimental.runtime.dev.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-page-experimental.runtime.dev.js');
}
} else {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-page-experimental.runtime.prod.js');
}
}
} else {
if (process.env.NODE_ENV === 'development') {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-page-turbo.runtime.dev.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-page.runtime.dev.js');
}
} else {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-page-turbo.runtime.prod.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-page.runtime.prod.js');
}
}
}
}
//# sourceMappingURL=module.compiled.js.map

View File

@@ -0,0 +1,162 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
AppPageRouteModule: null,
default: null,
renderToHTMLOrFlight: null,
vendored: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
AppPageRouteModule: function() {
return AppPageRouteModule;
},
default: function() {
return _default;
},
renderToHTMLOrFlight: function() {
return _apprender.renderToHTMLOrFlight;
},
vendored: function() {
return vendored;
}
});
const _requestmeta = require("../../request-meta");
const _apprender = require("../../app-render/app-render");
const _routemodule = require("../route-module");
const _entrypoints = /*#__PURE__*/ _interop_require_wildcard(require("./vendored/contexts/entrypoints"));
const _prerendermanifestmatcher = require("./helpers/prerender-manifest-matcher");
const _approuterheaders = require("../../../client/components/app-router-headers");
const _interceptionroutes = require("../../../shared/lib/router/utils/interception-routes");
const _rsc = require("../../normalizers/request/rsc");
const _segmentprefixrsc = require("../../normalizers/request/segment-prefix-rsc");
const _normalizerequesturl = require("./normalize-request-url");
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
let vendoredReactRSC;
let vendoredReactSSR;
// the vendored Reacts are loaded from their original source in the edge runtime
if (process.env.NEXT_RUNTIME !== 'edge') {
vendoredReactRSC = require('./vendored/rsc/entrypoints');
vendoredReactSSR = require('./vendored/ssr/entrypoints');
// In Node environments we need to access the correct React instance from external modules such
// as global patches. We register the loaded React instances here.
const { registerServerReact, registerClientReact } = require('../../runtime-reacts.external');
registerServerReact(vendoredReactRSC.React);
registerClientReact(vendoredReactSSR.React);
}
class AppPageRouteModule extends _routemodule.RouteModule {
match(pathname, prerenderManifest) {
// Lazily create the matcher based on the provided prerender manifest.
let matcher = this.matchers.get(prerenderManifest);
if (!matcher) {
matcher = new _prerendermanifestmatcher.PrerenderManifestMatcher(this.definition.pathname, prerenderManifest);
this.matchers.set(prerenderManifest, matcher);
}
// Match the pathname to the dynamic route.
return matcher.match(pathname);
}
normalizeUrl(req, parsedUrl) {
if (this.normalizers.segmentPrefetchRSC.match(parsedUrl.pathname || '/')) {
const result = this.normalizers.segmentPrefetchRSC.extract(parsedUrl.pathname || '/');
if (!result) return false;
const { originalPathname, segmentPath } = result;
parsedUrl.pathname = originalPathname;
// Mark the request as a router prefetch request.
req.headers[_approuterheaders.RSC_HEADER] = '1';
req.headers[_approuterheaders.NEXT_ROUTER_PREFETCH_HEADER] = '1';
req.headers[_approuterheaders.NEXT_ROUTER_SEGMENT_PREFETCH_HEADER] = segmentPath;
(0, _requestmeta.addRequestMeta)(req, 'isRSCRequest', true);
(0, _requestmeta.addRequestMeta)(req, 'isPrefetchRSCRequest', true);
(0, _requestmeta.addRequestMeta)(req, 'segmentPrefetchRSCRequest', segmentPath);
} else if (this.normalizers.rsc.match(parsedUrl.pathname || '/')) {
parsedUrl.pathname = this.normalizers.rsc.normalize(parsedUrl.pathname || '/', true);
// Mark the request as a RSC request.
req.headers[_approuterheaders.RSC_HEADER] = '1';
(0, _requestmeta.addRequestMeta)(req, 'isRSCRequest', true);
} else {
super.normalizeUrl(req, parsedUrl);
}
(0, _normalizerequesturl.normalizeAppPageRequestUrl)(req, parsedUrl.pathname || '/');
}
render(req, res, context) {
return (0, _apprender.renderToHTMLOrFlight)(req, res, context.page, context.query, context.fallbackRouteParams, context.renderOpts, context.serverComponentsHmrCache, context.sharedContext);
}
pathCouldBeIntercepted(resolvedPathname, interceptionRoutePatterns) {
return (0, _interceptionroutes.isInterceptionRouteAppPath)(resolvedPathname) || interceptionRoutePatterns.some((regexp)=>{
return regexp.test(resolvedPathname);
});
}
getVaryHeader(resolvedPathname, interceptionRoutePatterns) {
const baseVaryHeader = `${_approuterheaders.RSC_HEADER}, ${_approuterheaders.NEXT_ROUTER_STATE_TREE_HEADER}, ${_approuterheaders.NEXT_ROUTER_PREFETCH_HEADER}, ${_approuterheaders.NEXT_ROUTER_SEGMENT_PREFETCH_HEADER}`;
if (this.pathCouldBeIntercepted(resolvedPathname, interceptionRoutePatterns)) {
// Interception route responses can vary based on the `Next-URL` header.
// We use the Vary header to signal this behavior to the client to properly cache the response.
return `${baseVaryHeader}, ${_approuterheaders.NEXT_URL}`;
} else {
// We don't need to include `Next-URL` in the Vary header for non-interception routes since it won't affect the response.
// We also set this header for pages to avoid caching issues when navigating between pages and app.
return baseVaryHeader;
}
}
constructor(...args){
super(...args), this.matchers = new WeakMap(), this.normalizers = {
rsc: new _rsc.RSCPathnameNormalizer(),
segmentPrefetchRSC: new _segmentprefixrsc.SegmentPrefixRSCPathnameNormalizer()
};
}
}
const vendored = {
'react-rsc': vendoredReactRSC,
'react-ssr': vendoredReactSSR,
contexts: _entrypoints
};
const _default = AppPageRouteModule;
//# sourceMappingURL=module.js.map

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "lazyRenderAppPage", {
enumerable: true,
get: function() {
return lazyRenderAppPage;
}
});
const lazyRenderAppPage = (...args)=>{
if (process.env.NEXT_MINIMAL) {
throw Object.defineProperty(new Error("Can't use lazyRenderAppPage in minimal mode"), "__NEXT_ERROR_CODE", {
value: "E256",
enumerable: false,
configurable: true
});
} else {
const render = require('./module.compiled').renderToHTMLOrFlight;
return render(...args);
}
};
//# sourceMappingURL=module.render.js.map

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "normalizeAppPageRequestUrl", {
enumerable: true,
get: function() {
return normalizeAppPageRequestUrl;
}
});
const _url = require("../../../lib/url");
const _formaturl = require("../../../shared/lib/router/utils/format-url");
function normalizeAppPageRequestUrl(req, pathname) {
if (!req.url) {
return;
}
const normalizedUrl = (0, _url.parseReqUrl)(req.url);
if (!normalizedUrl) {
return;
}
normalizedUrl.pathname = pathname;
req.url = (0, _formaturl.formatUrl)(normalizedUrl);
}
//# sourceMappingURL=normalize-request-url.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].AppRouterContext;
//# sourceMappingURL=app-router-context.js.map

View File

@@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
AppRouterContext: null,
HeadManagerContext: null,
HooksClientContext: null,
ImageConfigContext: null,
RouterContext: null,
ServerInsertedHtml: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
AppRouterContext: function() {
return _approutercontextsharedruntime;
},
HeadManagerContext: function() {
return _headmanagercontextsharedruntime;
},
HooksClientContext: function() {
return _hooksclientcontextsharedruntime;
},
ImageConfigContext: function() {
return _imageconfigcontextsharedruntime;
},
RouterContext: function() {
return _routercontextsharedruntime;
},
ServerInsertedHtml: function() {
return _serverinsertedhtmlsharedruntime;
}
});
const _headmanagercontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/head-manager-context.shared-runtime"));
const _serverinsertedhtmlsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/server-inserted-html.shared-runtime"));
const _approutercontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/app-router-context.shared-runtime"));
const _hooksclientcontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/hooks-client-context.shared-runtime"));
const _routercontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/router-context.shared-runtime"));
const _imageconfigcontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/image-config-context.shared-runtime"));
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
//# sourceMappingURL=entrypoints.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].HeadManagerContext;
//# sourceMappingURL=head-manager-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].HooksClientContext;
//# sourceMappingURL=hooks-client-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].ImageConfigContext;
//# sourceMappingURL=image-config-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].RouterContext;
//# sourceMappingURL=router-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].ServerInsertedHtml;
//# sourceMappingURL=server-inserted-html.js.map

View File

@@ -0,0 +1,140 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
React: null,
ReactCompilerRuntime: null,
ReactDOM: null,
ReactJsxDevRuntime: null,
ReactJsxRuntime: null,
ReactServerDOMTurbopackServer: null,
ReactServerDOMTurbopackStatic: null,
ReactServerDOMWebpackServer: null,
ReactServerDOMWebpackStatic: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
React: function() {
return _react;
},
ReactCompilerRuntime: function() {
return _compilerruntime;
},
ReactDOM: function() {
return _reactdom;
},
ReactJsxDevRuntime: function() {
return _jsxdevruntime;
},
ReactJsxRuntime: function() {
return _jsxruntime;
},
ReactServerDOMTurbopackServer: function() {
return ReactServerDOMTurbopackServer;
},
ReactServerDOMTurbopackStatic: function() {
return ReactServerDOMTurbopackStatic;
},
ReactServerDOMWebpackServer: function() {
return ReactServerDOMWebpackServer;
},
ReactServerDOMWebpackStatic: function() {
return ReactServerDOMWebpackStatic;
}
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _reactdom = /*#__PURE__*/ _interop_require_wildcard(require("react-dom"));
const _jsxdevruntime = /*#__PURE__*/ _interop_require_wildcard(require("react/jsx-dev-runtime"));
const _jsxruntime = /*#__PURE__*/ _interop_require_wildcard(require("react/jsx-runtime"));
const _compilerruntime = /*#__PURE__*/ _interop_require_wildcard(require("react/compiler-runtime"));
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
function getAltProxyForBindingsDEV(type, pkg) {
if (process.env.NODE_ENV === 'development') {
const altType = type === 'Turbopack' ? 'Webpack' : 'Turbopack';
const altPkg = pkg.replace(new RegExp(type, 'gi'), altType.toLowerCase());
return new Proxy({}, {
get (_, prop) {
throw Object.defineProperty(new Error(`Expected to use ${type} bindings (${pkg}) for React but the current process is referencing '${prop}' from the ${altType} bindings (${altPkg}). This is likely a bug in our integration of the Next.js server runtime.`), "__NEXT_ERROR_CODE", {
value: "E253",
enumerable: false,
configurable: true
});
}
});
}
}
let ReactServerDOMTurbopackServer, ReactServerDOMWebpackServer;
let ReactServerDOMTurbopackStatic, ReactServerDOMWebpackStatic;
if (process.env.TURBOPACK) {
ReactServerDOMTurbopackServer = // @ts-expect-error -- TODO: Add types
// eslint-disable-next-line import/no-extraneous-dependencies
require('react-server-dom-turbopack/server');
if (process.env.NODE_ENV === 'development') {
ReactServerDOMWebpackServer = getAltProxyForBindingsDEV('Turbopack', 'react-server-dom-turbopack/server');
}
ReactServerDOMTurbopackStatic = // @ts-expect-error -- TODO: Add types
// eslint-disable-next-line import/no-extraneous-dependencies
require('react-server-dom-turbopack/static');
if (process.env.NODE_ENV === 'development') {
ReactServerDOMWebpackStatic = getAltProxyForBindingsDEV('Turbopack', 'react-server-dom-turbopack/static');
}
} else {
ReactServerDOMWebpackServer = // eslint-disable-next-line import/no-extraneous-dependencies
require('react-server-dom-webpack/server');
if (process.env.NODE_ENV === 'development') {
ReactServerDOMTurbopackServer = getAltProxyForBindingsDEV('Webpack', 'react-server-dom-webpack/server');
}
ReactServerDOMWebpackStatic = // eslint-disable-next-line import/no-extraneous-dependencies
require('react-server-dom-webpack/static');
if (process.env.NODE_ENV === 'development') {
ReactServerDOMTurbopackStatic = getAltProxyForBindingsDEV('Webpack', 'react-server-dom-webpack/static');
}
}
//# sourceMappingURL=entrypoints.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactCompilerRuntime;
//# sourceMappingURL=react-compiler-runtime.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactDOM;
//# sourceMappingURL=react-dom.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactJsxDevRuntime;
//# sourceMappingURL=react-jsx-dev-runtime.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactJsxRuntime;
//# sourceMappingURL=react-jsx-runtime.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMTurbopackServer;
//# sourceMappingURL=react-server-dom-turbopack-server.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMTurbopackStatic;
//# sourceMappingURL=react-server-dom-turbopack-static.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMWebpackServer;
//# sourceMappingURL=react-server-dom-webpack-server.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMWebpackStatic;
//# sourceMappingURL=react-server-dom-webpack-static.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-rsc'].React;
//# sourceMappingURL=react.js.map

View File

@@ -0,0 +1,125 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
React: null,
ReactCompilerRuntime: null,
ReactDOM: null,
ReactDOMServer: null,
ReactJsxDevRuntime: null,
ReactJsxRuntime: null,
ReactServerDOMTurbopackClient: null,
ReactServerDOMWebpackClient: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
React: function() {
return _react;
},
ReactCompilerRuntime: function() {
return _compilerruntime;
},
ReactDOM: function() {
return _reactdom;
},
ReactDOMServer: function() {
return _server;
},
ReactJsxDevRuntime: function() {
return _jsxdevruntime;
},
ReactJsxRuntime: function() {
return _jsxruntime;
},
ReactServerDOMTurbopackClient: function() {
return ReactServerDOMTurbopackClient;
},
ReactServerDOMWebpackClient: function() {
return ReactServerDOMWebpackClient;
}
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _reactdom = /*#__PURE__*/ _interop_require_wildcard(require("react-dom"));
const _jsxdevruntime = /*#__PURE__*/ _interop_require_wildcard(require("react/jsx-dev-runtime"));
const _jsxruntime = /*#__PURE__*/ _interop_require_wildcard(require("react/jsx-runtime"));
const _compilerruntime = /*#__PURE__*/ _interop_require_wildcard(require("react/compiler-runtime"));
const _server = /*#__PURE__*/ _interop_require_wildcard(require("react-dom/server"));
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
function getAltProxyForBindingsDEV(type, pkg) {
if (process.env.NODE_ENV === 'development') {
const altType = type === 'Turbopack' ? 'Webpack' : 'Turbopack';
const altPkg = pkg.replace(new RegExp(type, 'gi'), altType.toLowerCase());
return new Proxy({}, {
get (_, prop) {
throw Object.defineProperty(new Error(`Expected to use ${type} bindings (${pkg}) for React but the current process is referencing '${prop}' from the ${altType} bindings (${altPkg}). This is likely a bug in our integration of the Next.js server runtime.`), "__NEXT_ERROR_CODE", {
value: "E253",
enumerable: false,
configurable: true
});
}
});
}
}
let ReactServerDOMTurbopackClient, ReactServerDOMWebpackClient;
if (process.env.TURBOPACK) {
ReactServerDOMTurbopackClient = // @ts-expect-error -- TODO: Add types
// eslint-disable-next-line import/no-extraneous-dependencies
require('react-server-dom-turbopack/client');
if (process.env.NODE_ENV === 'development') {
ReactServerDOMWebpackClient = getAltProxyForBindingsDEV('Turbopack', 'react-server-dom-turbopack/client');
}
} else {
ReactServerDOMWebpackClient = // eslint-disable-next-line import/no-extraneous-dependencies
require('react-server-dom-webpack/client');
if (process.env.NODE_ENV === 'development') {
ReactServerDOMTurbopackClient = getAltProxyForBindingsDEV('Webpack', 'react-server-dom-webpack/client');
}
}
//# sourceMappingURL=entrypoints.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactCompilerRuntime;
//# sourceMappingURL=react-compiler-runtime.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactDOMServer;
//# sourceMappingURL=react-dom-server.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactDOM;
//# sourceMappingURL=react-dom.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactJsxDevRuntime;
//# sourceMappingURL=react-jsx-dev-runtime.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactJsxRuntime;
//# sourceMappingURL=react-jsx-runtime.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactServerDOMTurbopackClient;
//# sourceMappingURL=react-server-dom-turbopack-client.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactServerDOMWebpackClient;
//# sourceMappingURL=react-server-dom-webpack-client.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['react-ssr'].React;
//# sourceMappingURL=react.js.map

View File

@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "autoImplementMethods", {
enumerable: true,
get: function() {
return autoImplementMethods;
}
});
const _http = require("../../../web/http");
const AUTOMATIC_ROUTE_METHODS = [
'HEAD',
'OPTIONS'
];
function handleMethodNotAllowedResponse() {
return new Response(null, {
status: 405
});
}
function autoImplementMethods(handlers) {
// Loop through all the HTTP methods to create the initial methods object.
// Each of the methods will be set to the 405 response handler.
const methods = _http.HTTP_METHODS.reduce((acc, method)=>({
...acc,
// If the userland module implements the method, then use it. Otherwise,
// use the 405 response handler.
[method]: handlers[method] ?? handleMethodNotAllowedResponse
}), {});
// Get all the methods that could be automatically implemented that were not
// implemented by the userland module.
const implemented = new Set(_http.HTTP_METHODS.filter((method)=>handlers[method]));
const missing = AUTOMATIC_ROUTE_METHODS.filter((method)=>!implemented.has(method));
// Loop over the missing methods to automatically implement them if we can.
for (const method of missing){
// If the userland module doesn't implement the HEAD method, then
// we'll automatically implement it by calling the GET method (if it
// exists).
if (method === 'HEAD') {
if (handlers.GET) {
// Implement the HEAD method by calling the GET method.
methods.HEAD = handlers.GET;
// Mark it as implemented.
implemented.add('HEAD');
}
continue;
}
// If OPTIONS is not provided then implement it.
if (method === 'OPTIONS') {
// TODO: check if HEAD is implemented, if so, use it to add more headers
// Get all the methods that were implemented by the userland module.
const allow = [
'OPTIONS',
...implemented
];
// If the list of methods doesn't include HEAD, but it includes GET, then
// add HEAD as it's automatically implemented.
if (!implemented.has('HEAD') && implemented.has('GET')) {
allow.push('HEAD');
}
// Sort and join the list with commas to create the `Allow` header. See:
// https://httpwg.org/specs/rfc9110.html#field.allow
const headers = {
Allow: allow.sort().join(', ')
};
// Implement the OPTIONS method by returning a 204 response with the
// `Allow` header.
methods.OPTIONS = ()=>new Response(null, {
status: 204,
headers
});
// Mark this method as implemented.
implemented.add('OPTIONS');
continue;
}
throw Object.defineProperty(new Error(`Invariant: should handle all automatic implementable methods, got method: ${method}`), "__NEXT_ERROR_CODE", {
value: "E211",
enumerable: false,
configurable: true
});
}
return methods;
}
//# sourceMappingURL=auto-implement-methods.js.map

View File

@@ -0,0 +1,24 @@
/**
* Cleans a URL by stripping the protocol, host, and search params.
*
* @param urlString the url to clean
* @returns the cleaned url
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "cleanURL", {
enumerable: true,
get: function() {
return cleanURL;
}
});
function cleanURL(url) {
const u = new URL(url);
u.host = 'localhost:3000';
u.search = '';
u.protocol = 'http';
return u;
}
//# sourceMappingURL=clean-url.js.map

View File

@@ -0,0 +1,29 @@
/**
* Get pathname from absolute path.
*
* @param absolutePath the absolute path
* @returns the pathname
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getPathnameFromAbsolutePath", {
enumerable: true,
get: function() {
return getPathnameFromAbsolutePath;
}
});
function getPathnameFromAbsolutePath(absolutePath) {
// Remove prefix including app dir
let appDir = '/app/';
if (!absolutePath.includes(appDir)) {
appDir = '\\app\\';
}
const [, ...parts] = absolutePath.split(appDir);
const relativePath = appDir[0] + parts.join(appDir);
// remove extension
const pathname = relativePath.split('.').slice(0, -1).join('.');
return pathname;
}
//# sourceMappingURL=get-pathname-from-absolute-path.js.map

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "isStaticGenEnabled", {
enumerable: true,
get: function() {
return isStaticGenEnabled;
}
});
function isStaticGenEnabled(mod) {
return mod.dynamic === 'force-static' || mod.dynamic === 'error' || mod.revalidate === false || mod.revalidate !== undefined && mod.revalidate > 0 || typeof mod.generateStaticParams == 'function';
}
//# sourceMappingURL=is-static-gen-enabled.js.map

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "parsedUrlQueryToParams", {
enumerable: true,
get: function() {
return parsedUrlQueryToParams;
}
});
function parsedUrlQueryToParams(query) {
const params = {};
for (const [key, value] of Object.entries(query)){
if (typeof value === 'undefined') continue;
params[key] = value;
}
return params;
}
//# sourceMappingURL=parsed-url-query-to-params.js.map

View File

@@ -0,0 +1,36 @@
"use strict";
if (process.env.NEXT_RUNTIME === 'edge') {
module.exports = require('next/dist/server/route-modules/app-route/module.js');
} else {
if (process.env.__NEXT_EXPERIMENTAL_REACT) {
if (process.env.NODE_ENV === 'development') {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.dev.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.dev.js');
}
} else {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.prod.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.prod.js');
}
}
} else {
if (process.env.NODE_ENV === 'development') {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.dev.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-route.runtime.dev.js');
}
} else {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.prod.js');
} else {
module.exports = require('next/dist/compiled/next-server/app-route.runtime.prod.js');
}
}
}
}
//# sourceMappingURL=module.compiled.js.map

View File

@@ -0,0 +1,915 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
AppRouteRouteModule: null,
WrappedNextRouterError: null,
default: null,
hasNonStaticMethods: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
AppRouteRouteModule: function() {
return AppRouteRouteModule;
},
WrappedNextRouterError: function() {
return WrappedNextRouterError;
},
default: function() {
return _default;
},
hasNonStaticMethods: function() {
return hasNonStaticMethods;
}
});
const _routemodule = require("../route-module");
const _requeststore = require("../../async-storage/request-store");
const _workstore = require("../../async-storage/work-store");
const _http = require("../../web/http");
const _implicittags = require("../../lib/implicit-tags");
const _patchfetch = require("../../lib/patch-fetch");
const _tracer = require("../../lib/trace/tracer");
const _constants = require("../../lib/trace/constants");
const _log = /*#__PURE__*/ _interop_require_wildcard(require("../../../build/output/log"));
const _autoimplementmethods = require("./helpers/auto-implement-methods");
const _requestcookies = require("../../web/spec-extension/adapters/request-cookies");
const _headers = require("../../web/spec-extension/adapters/headers");
const _parsedurlquerytoparams = require("./helpers/parsed-url-query-to-params");
const _prospectiverenderutils = require("../../app-render/prospective-render-utils");
const _hooksservercontext = /*#__PURE__*/ _interop_require_wildcard(require("../../../client/components/hooks-server-context"));
const _workasyncstorageexternal = require("../../app-render/work-async-storage.external");
const _workunitasyncstorageexternal = require("../../app-render/work-unit-async-storage.external");
const _actionasyncstorageexternal = require("../../app-render/action-async-storage.external");
const _sharedmodules = /*#__PURE__*/ _interop_require_wildcard(require("./shared-modules"));
const _serveractionrequestmeta = require("../../lib/server-action-request-meta");
const _cookies = require("next/dist/compiled/@edge-runtime/cookies");
const _cleanurl = require("./helpers/clean-url");
const _staticgenerationbailout = require("../../../client/components/static-generation-bailout");
const _isstaticgenenabled = require("./helpers/is-static-gen-enabled");
const _dynamicrendering = require("../../app-render/dynamic-rendering");
const _reflect = require("../../web/spec-extension/adapters/reflect");
const _cachesignal = require("../../app-render/cache-signal");
const _scheduler = require("../../../lib/scheduler");
const _params = require("../../request/params");
const _redirect = require("../../../client/components/redirect");
const _redirecterror = require("../../../client/components/redirect-error");
const _httpaccessfallback = require("../../../client/components/http-access-fallback/http-access-fallback");
const _redirectstatuscode = require("../../../client/components/redirect-status-code");
const _constants1 = require("../../../lib/constants");
const _revalidationutils = require("../../revalidation-utils");
const _trackmoduleloadingexternal = require("../../app-render/module-loading/track-module-loading.external");
const _invarianterror = require("../../../shared/lib/invariant-error");
const _resumedatacache = require("../../resume-data-cache/resume-data-cache");
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
class WrappedNextRouterError {
constructor(error, headers){
this.error = error;
this.headers = headers;
}
}
class AppRouteRouteModule extends _routemodule.RouteModule {
static #_ = this.sharedModules = _sharedmodules;
constructor({ userland, getUserland, definition, distDir, relativeProjectDir, resolvedPagePath, nextConfigOutput }){
super({
userland: userland,
definition,
distDir,
relativeProjectDir
}), /**
* A reference to the request async storage.
*/ this.workUnitAsyncStorage = _workunitasyncstorageexternal.workUnitAsyncStorage, /**
* A reference to the static generation async storage.
*/ this.workAsyncStorage = _workasyncstorageexternal.workAsyncStorage, /**
* An interface to call server hooks which interact with the underlying
* storage.
*/ this.serverHooks = _hooksservercontext, /**
* A reference to the mutation related async storage, such as mutations of
* cookies.
*/ this.actionAsyncStorage = _actionasyncstorageexternal.actionAsyncStorage;
this.resolvedPagePath = resolvedPagePath;
this.nextConfigOutput = nextConfigOutput;
this._getUserland = getUserland;
// Automatically implement some methods if they aren't implemented by the
// userland module.
this.methods = (0, _autoimplementmethods.autoImplementMethods)(userland);
// Get the non-static methods for this route.
this.hasNonStaticMethods = hasNonStaticMethods(userland);
// Get the dynamic property from the userland module.
this.dynamic = userland.dynamic;
if (this.nextConfigOutput === 'export') {
if (this.dynamic === 'force-dynamic') {
throw Object.defineProperty(new Error(`export const dynamic = "force-dynamic" on page "${definition.pathname}" cannot be used with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html-export`), "__NEXT_ERROR_CODE", {
value: "E278",
enumerable: false,
configurable: true
});
} else if (!(0, _isstaticgenenabled.isStaticGenEnabled)(this.userland) && this.userland['GET']) {
throw Object.defineProperty(new Error(`export const dynamic = "force-static"/export const revalidate not configured on route "${definition.pathname}" with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html-export`), "__NEXT_ERROR_CODE", {
value: "E301",
enumerable: false,
configurable: true
});
} else {
this.dynamic = 'error';
}
}
// We only warn in development after here, so return if we're not in
// development.
if (process.env.NODE_ENV === 'development') {
// Print error in development if the exported handlers are in lowercase, only
// uppercase handlers are supported.
const lowercased = _http.HTTP_METHODS.map((method)=>method.toLowerCase());
for (const method of lowercased){
if (method in this.userland) {
_log.error(`Detected lowercase method '${method}' in '${this.resolvedPagePath}'. Export the uppercase '${method.toUpperCase()}' method name to fix this error.`);
}
}
// Print error if the module exports a default handler, they must use named
// exports for each HTTP method.
if ('default' in this.userland) {
_log.error(`Detected default export in '${this.resolvedPagePath}'. Export a named export for each HTTP method instead.`);
}
// If there is no methods exported by this module, then return a not found
// response.
if (!_http.HTTP_METHODS.some((method)=>method in this.userland)) {
_log.error(`No HTTP methods exported in '${this.resolvedPagePath}'. Export a named export for each HTTP method.`);
}
}
}
/**
* Resolves the handler function for the given method.
*
* @param method the requested method
* @returns the handler function for the given method
*/ resolve(method) {
// Ensure that the requested method is a valid method (to prevent RCE's).
if (!(0, _http.isHTTPMethod)(method)) return ()=>new Response(null, {
status: 400
});
return (0, _autoimplementmethods.autoImplementMethods)(this.userland)[method];
}
/**
* Like resolve(), but re-fetches the userland module on every call via the
* async getter. Only used in Turbopack dev mode, where server HMR disposes
* modules between requests. The async wrapper also unwraps async-module
* Promises produced by ESM-only serverExternalPackages.
*/ async resolveWithGetter(method, getUserland) {
if (!(0, _http.isHTTPMethod)(method)) return ()=>new Response(null, {
status: 400
});
const userland = await getUserland();
return (0, _autoimplementmethods.autoImplementMethods)(userland)[method];
}
async do(handler, actionStore, workStore, // @TODO refactor to not take this argument but instead construct the RequestStore
// inside this function. Right now we get passed a RequestStore even when
// we're going to do a prerender. We should probably just split do up into prexecute and execute
requestStore, implicitTags, request, context) {
const isStaticGeneration = workStore.isStaticGeneration;
const cacheComponentsEnabled = !!context.renderOpts.cacheComponents;
// Patch the global fetch.
(0, _patchfetch.patchFetch)({
workAsyncStorage: this.workAsyncStorage,
workUnitAsyncStorage: this.workUnitAsyncStorage
});
const handlerContext = {
params: context.params ? (0, _params.createServerParamsForRoute)((0, _parsedurlquerytoparams.parsedUrlQueryToParams)(context.params)) : undefined
};
const resolvePendingRevalidations = ()=>{
const maybeRevalidatesPromise = (0, _revalidationutils.executeRevalidates)(workStore);
if (maybeRevalidatesPromise !== false) {
context.renderOpts.pendingWaitUntil = maybeRevalidatesPromise.finally(()=>{
if (process.env.NEXT_PRIVATE_DEBUG_CACHE) {
console.log('pending revalidates promise finished for:', requestStore.url.pathname + requestStore.url.search);
}
});
}
};
let prerenderStore = null;
let res;
try {
if (isStaticGeneration) {
const userlandRevalidate = this.userland.revalidate;
const defaultRevalidate = // If the static generation store does not have a revalidate value
// set, then we should set it the revalidate value from the userland
// module or default to false.
userlandRevalidate === false || userlandRevalidate === undefined ? _constants1.INFINITE_CACHE : userlandRevalidate;
if (cacheComponentsEnabled) {
/**
* When we are attempting to statically prerender the GET handler of a route.ts module
* and cacheComponents is on we follow a similar pattern to rendering.
*
* We first run the handler letting caches fill. If something synchronously dynamic occurs
* during this prospective render then we can infer it will happen on every render and we
* just bail out of prerendering.
*
* Next we run the handler again and we check if we get a result back in a microtask.
* Next.js expects the return value to be a Response or a Thenable that resolves to a Response.
* Unfortunately Response's do not allow for accessing the response body synchronously or in
* a microtask so we need to allow one more task to unwrap the response body. This is a slightly
* different semantic than what we have when we render and it means that certain tasks can still
* execute before a prerender completes such as a carefully timed setImmediate.
*
* Functionally though IO should still take longer than the time it takes to unwrap the response body
* so our heuristic of excluding any IO should be preserved.
*/ const prospectiveController = new AbortController();
let prospectiveRenderIsDynamic = false;
const cacheSignal = new _cachesignal.CacheSignal();
let dynamicTracking = (0, _dynamicrendering.createDynamicTrackingState)(undefined);
// TODO: Route handlers are never resumed, so it's counter-intuitive
// to use an RDC here. However, we need the data cache to store cached
// results in memory during the prospective prerender, so that they
// can be retrieved during the final prerender within microtasks. This
// is crucial when doing revalidations of a deployed route handler,
// where the default cache handler does not do any in-memory caching.
// We should replace the `prerenderResumeDataCache` and
// `renderResumeDataCache` with a single `dataCache` property that is
// conceptually not tied to resuming, and also avoids the unnecessary
// complexity of using a mutable and an immutable resume data cache.
const prerenderResumeDataCache = (0, _resumedatacache.createPrerenderResumeDataCache)();
const prospectiveRoutePrerenderStore = prerenderStore = {
type: 'prerender',
phase: 'action',
// This replicates prior behavior where rootParams is empty in routes
// TODO we need to make this have the proper rootParams for this route
rootParams: {},
fallbackRouteParams: null,
implicitTags,
renderSignal: prospectiveController.signal,
controller: prospectiveController,
cacheSignal,
// During prospective render we don't use a controller
// because we need to let all caches fill.
dynamicTracking,
allowEmptyStaticShell: false,
revalidate: defaultRevalidate,
expire: _constants1.INFINITE_CACHE,
stale: _constants1.INFINITE_CACHE,
tags: [
...implicitTags.tags
],
prerenderResumeDataCache,
renderResumeDataCache: null,
hmrRefreshHash: undefined,
varyParamsAccumulator: null
};
let prospectiveResult;
try {
prospectiveResult = this.workUnitAsyncStorage.run(prospectiveRoutePrerenderStore, handler, request, handlerContext);
} catch (err) {
if (prospectiveController.signal.aborted) {
// the route handler called an API which is always dynamic
// there is no need to try again
prospectiveRenderIsDynamic = true;
} else if (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
}
}
if (typeof prospectiveResult === 'object' && prospectiveResult !== null && typeof prospectiveResult.then === 'function') {
// The handler returned a Thenable. We'll listen for rejections to determine
// if the route is erroring for dynamic reasons.
;
prospectiveResult.then(()=>{}, (err)=>{
if (prospectiveController.signal.aborted) {
// the route handler called an API which is always dynamic
// there is no need to try again
prospectiveRenderIsDynamic = true;
} else if (process.env.NEXT_DEBUG_BUILD) {
(0, _prospectiverenderutils.printDebugThrownValueForProspectiveRender)(err, workStore.route, _prospectiverenderutils.Phase.ProspectiveRender);
}
});
}
(0, _trackmoduleloadingexternal.trackPendingModules)(cacheSignal);
await cacheSignal.cacheReady();
if (prospectiveRenderIsDynamic) {
// the route handler called an API which is always dynamic
// there is no need to try again
const dynamicReason = (0, _dynamicrendering.getFirstDynamicReason)(dynamicTracking);
if (dynamicReason) {
throw Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${workStore.route} couldn't be rendered statically because it used \`${dynamicReason}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
value: "E558",
enumerable: false,
configurable: true
});
} else {
console.error('Expected Next.js to keep track of reason for opting out of static rendering but one was not found. This is a bug in Next.js');
throw Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${workStore.route} couldn't be rendered statically because it used a dynamic API. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
value: "E577",
enumerable: false,
configurable: true
});
}
}
// TODO start passing this controller to the route handler. We should expose
// it so the handler to abort inflight requests and other operations if we abort
// the prerender.
const finalController = new AbortController();
dynamicTracking = (0, _dynamicrendering.createDynamicTrackingState)(undefined);
const finalRoutePrerenderStore = prerenderStore = {
type: 'prerender',
phase: 'action',
rootParams: {},
fallbackRouteParams: null,
implicitTags,
renderSignal: finalController.signal,
controller: finalController,
cacheSignal: null,
dynamicTracking,
allowEmptyStaticShell: false,
revalidate: defaultRevalidate,
expire: _constants1.INFINITE_CACHE,
stale: _constants1.INFINITE_CACHE,
tags: [
...implicitTags.tags
],
prerenderResumeDataCache,
renderResumeDataCache: null,
hmrRefreshHash: undefined,
varyParamsAccumulator: null
};
let responseHandled = false;
res = await new Promise((resolve, reject)=>{
(0, _scheduler.scheduleImmediate)(async ()=>{
try {
const result = await this.workUnitAsyncStorage.run(finalRoutePrerenderStore, handler, request, handlerContext);
if (responseHandled) {
// we already rejected in the followup task
return;
} else if (!(result instanceof Response)) {
// This is going to error but we let that happen below
resolve(result);
return;
}
responseHandled = true;
let bodyHandled = false;
result.arrayBuffer().then((body)=>{
if (!bodyHandled) {
bodyHandled = true;
resolve(new Response(body, {
headers: result.headers,
status: result.status,
statusText: result.statusText
}));
}
}, reject);
(0, _scheduler.scheduleImmediate)(()=>{
if (!bodyHandled) {
bodyHandled = true;
finalController.abort();
reject(createCacheComponentsError(workStore.route));
}
});
} catch (err) {
reject(err);
}
});
(0, _scheduler.scheduleImmediate)(()=>{
if (!responseHandled) {
responseHandled = true;
finalController.abort();
reject(createCacheComponentsError(workStore.route));
}
});
});
if (finalController.signal.aborted) {
// We aborted from within the execution
throw createCacheComponentsError(workStore.route);
} else {
// We didn't abort during the execution. We can abort now as a matter of semantics
// though at the moment nothing actually consumes this signal so it won't halt any
// inflight work.
finalController.abort();
}
} else {
prerenderStore = {
type: 'prerender-legacy',
phase: 'action',
rootParams: {},
implicitTags,
revalidate: defaultRevalidate,
expire: _constants1.INFINITE_CACHE,
stale: _constants1.INFINITE_CACHE,
tags: [
...implicitTags.tags
]
};
res = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(prerenderStore, handler, request, handlerContext);
}
} else {
res = await _workunitasyncstorageexternal.workUnitAsyncStorage.run(requestStore, handler, request, handlerContext);
}
} catch (err) {
if ((0, _redirecterror.isRedirectError)(err)) {
const url = (0, _redirect.getURLFromRedirectError)(err);
if (!url) {
throw Object.defineProperty(new Error('Invariant: Unexpected redirect url format'), "__NEXT_ERROR_CODE", {
value: "E399",
enumerable: false,
configurable: true
});
}
// We need to capture any headers that should be sent on
// the response.
const headers = new Headers({
Location: url
});
// Let's append any cookies that were added by the
// cookie API.
// TODO leaving the gate here b/c it indicates that we might not actually want to do this
// on every `do` call. During prerender there should be no mutableCookies because
(0, _requestcookies.appendMutableCookies)(headers, requestStore.mutableCookies);
resolvePendingRevalidations();
// Return the redirect response.
return new Response(null, {
// If we're in an action, we want to use a 303 redirect as we don't
// want the POST request to follow the redirect, as it could result in
// erroneous re-submissions.
status: actionStore.isAction ? _redirectstatuscode.RedirectStatusCode.SeeOther : (0, _redirect.getRedirectStatusCodeFromError)(err),
headers
});
} else if ((0, _httpaccessfallback.isHTTPAccessFallbackError)(err)) {
const httpStatus = (0, _httpaccessfallback.getAccessFallbackHTTPStatus)(err);
return new Response(null, {
status: httpStatus
});
}
throw err;
}
// Validate that the response is a valid response object.
if (!(res instanceof Response)) {
var _res_constructor;
const invalidType = res === null ? 'null' : res === undefined ? 'undefined' : typeof res === 'object' ? ((_res_constructor = res.constructor) == null ? void 0 : _res_constructor.name) || 'object' : typeof res;
throw Object.defineProperty(new Error(`No response is returned from route handler '${this.resolvedPagePath}'. ` + `Expected a Response object but received '${invalidType}' (method: ${request.method}, url: ${requestStore.url.pathname}). ` + `Ensure you return a \`Response\` or a \`NextResponse\` in all branches of your handler.`), "__NEXT_ERROR_CODE", {
value: "E985",
enumerable: false,
configurable: true
});
}
context.renderOpts.fetchMetrics = workStore.fetchMetrics;
resolvePendingRevalidations();
if (prerenderStore) {
var _prerenderStore_tags;
context.renderOpts.collectedTags = (_prerenderStore_tags = prerenderStore.tags) == null ? void 0 : _prerenderStore_tags.join(',');
context.renderOpts.collectedRevalidate = prerenderStore.revalidate;
context.renderOpts.collectedExpire = prerenderStore.expire;
context.renderOpts.collectedStale = prerenderStore.stale;
}
// It's possible cookies were set in the handler, so we need
// to merge the modified cookies and the returned response
// here.
const headers = new Headers(res.headers);
if ((0, _requestcookies.appendMutableCookies)(headers, requestStore.mutableCookies)) {
return new Response(res.body, {
status: res.status,
statusText: res.statusText,
headers
});
}
return res;
}
async handle(req, context) {
// Get the handler function for the given method. In Turbopack dev mode,
// use resolveWithGetter() to re-fetch the live userland on every request
// In all other modes, resolve() is synchronous.
const handler = this._getUserland ? await this.resolveWithGetter(req.method, this._getUserland) : this.resolve(req.method);
// Get the context for the static generation.
const staticGenerationContext = {
page: this.definition.page,
renderOpts: context.renderOpts,
buildId: context.sharedContext.buildId,
deploymentId: context.sharedContext.deploymentId,
previouslyRevalidatedTags: []
};
// Add the fetchCache option to the renderOpts.
staticGenerationContext.renderOpts.fetchCache = this.userland.fetchCache;
const actionStore = {
isAppRoute: true,
isAction: (0, _serveractionrequestmeta.getIsPossibleServerAction)(req)
};
const implicitTags = await (0, _implicittags.getImplicitTags)(this.definition.page, req.nextUrl.pathname, // App Routes don't support unknown route params.
null);
const requestStore = (0, _requeststore.createRequestStoreForAPI)(req, req.nextUrl, implicitTags, undefined, context.previewProps);
const workStore = (0, _workstore.createWorkStore)(staticGenerationContext);
// Run the handler with the request AsyncLocalStorage to inject the helper
// support. We set this to `unknown` because the type is not known until
// runtime when we do a instanceof check below.
const response = await this.actionAsyncStorage.run(actionStore, ()=>this.workUnitAsyncStorage.run(requestStore, ()=>this.workAsyncStorage.run(workStore, async ()=>{
// Check to see if we should bail out of static generation based on
// having non-static methods.
if (hasNonStaticMethods(this.userland)) {
if (workStore.isStaticGeneration) {
const err = Object.defineProperty(new _hooksservercontext.DynamicServerError('Route is configured with methods that cannot be statically generated.'), "__NEXT_ERROR_CODE", {
value: "E582",
enumerable: false,
configurable: true
});
workStore.dynamicUsageDescription = err.message;
workStore.dynamicUsageStack = err.stack;
throw err;
}
}
// We assume we can pass the original request through however we may end up
// proxying it in certain circumstances based on execution type and configuration
let request = req;
// Update the static generation store based on the dynamic property.
const { dynamic } = this.userland;
switch(dynamic){
case 'force-dynamic':
{
// Routes of generated paths should be dynamic
workStore.forceDynamic = true;
if (workStore.isStaticGeneration) {
const err = Object.defineProperty(new _hooksservercontext.DynamicServerError('Route is configured with dynamic = error which cannot be statically generated.'), "__NEXT_ERROR_CODE", {
value: "E703",
enumerable: false,
configurable: true
});
workStore.dynamicUsageDescription = err.message;
workStore.dynamicUsageStack = err.stack;
throw err;
}
break;
}
case 'force-static':
// The dynamic property is set to force-static, so we should
// force the page to be static.
workStore.forceStatic = true;
// We also Proxy the request to replace dynamic data on the request
// with empty stubs to allow for safely executing as static
request = new Proxy(req, forceStaticRequestHandlers);
break;
case 'error':
// The dynamic property is set to error, so we should throw an
// error if the page is being statically generated.
workStore.dynamicShouldError = true;
if (workStore.isStaticGeneration) request = new Proxy(req, requireStaticRequestHandlers);
break;
case undefined:
case 'auto':
// We proxy `NextRequest` to track dynamic access, and
// potentially bail out of static generation.
request = proxyNextRequest(req, workStore);
break;
default:
dynamic;
}
const tracer = (0, _tracer.getTracer)();
// Update the root span attribute for the route.
const { pathname } = this.definition;
tracer.setRootSpanAttribute('next.route', pathname);
return tracer.trace(_constants.AppRouteRouteHandlersSpan.runHandler, {
spanName: `executing api route (app) ${pathname}`,
attributes: {
'next.route': pathname
}
}, async ()=>this.do(handler, actionStore, workStore, requestStore, implicitTags, request, context));
})));
// If the handler did't return a valid response, then return the internal
// error response.
if (!(response instanceof Response)) {
// TODO: validate the correct handling behavior, maybe log something?
return new Response(null, {
status: 500
});
}
if (response.headers.has('x-middleware-rewrite')) {
throw Object.defineProperty(new Error('NextResponse.rewrite() was used in a app route handler, this is not currently supported. Please remove the invocation to continue.'), "__NEXT_ERROR_CODE", {
value: "E374",
enumerable: false,
configurable: true
});
}
if (response.headers.get('x-middleware-next') === '1') {
// TODO: move this error into the `NextResponse.next()` function.
throw Object.defineProperty(new Error('NextResponse.next() was used in a app route handler, this is not supported. See here for more info: https://nextjs.org/docs/messages/next-response-next-in-app-route-handler'), "__NEXT_ERROR_CODE", {
value: "E385",
enumerable: false,
configurable: true
});
}
return response;
}
}
const _default = AppRouteRouteModule;
function hasNonStaticMethods(handlers) {
if (// Order these by how common they are to be used
handlers.POST || handlers.PUT || handlers.DELETE || handlers.PATCH || handlers.OPTIONS) {
return true;
}
return false;
}
// These symbols will be used to stash cached values on Proxied requests without requiring
// additional closures or storage such as WeakMaps.
const nextURLSymbol = Symbol('nextUrl');
const requestCloneSymbol = Symbol('clone');
const urlCloneSymbol = Symbol('clone');
const searchParamsSymbol = Symbol('searchParams');
const hrefSymbol = Symbol('href');
const toStringSymbol = Symbol('toString');
const headersSymbol = Symbol('headers');
const cookiesSymbol = Symbol('cookies');
/**
* The general technique with these proxy handlers is to prioritize keeping them static
* by stashing computed values on the Proxy itself. This is safe because the Proxy is
* inaccessible to the consumer since all operations are forwarded
*/ const forceStaticRequestHandlers = {
get (target, prop, receiver) {
switch(prop){
case 'headers':
return target[headersSymbol] || (target[headersSymbol] = _headers.HeadersAdapter.seal(new Headers({})));
case 'cookies':
return target[cookiesSymbol] || (target[cookiesSymbol] = _requestcookies.RequestCookiesAdapter.seal(new _cookies.RequestCookies(new Headers({}))));
case 'nextUrl':
return target[nextURLSymbol] || (target[nextURLSymbol] = new Proxy(target.nextUrl, forceStaticNextUrlHandlers));
case 'url':
// we don't need to separately cache this we can just read the nextUrl
// and return the href since we know it will have been stripped of any
// dynamic parts. We access via the receiver to trigger the get trap
return receiver.nextUrl.href;
case 'geo':
case 'ip':
return undefined;
case 'clone':
return target[requestCloneSymbol] || (target[requestCloneSymbol] = ()=>new Proxy(// This is vaguely unsafe but it's required since NextRequest does not implement
// clone. The reason we might expect this to work in this context is the Proxy will
// respond with static-amenable values anyway somewhat restoring the interface.
// @TODO we need to rethink NextRequest and NextURL because they are not sufficientlly
// sophisticated to adequately represent themselves in all contexts. A better approach is
// to probably embed the static generation logic into the class itself removing the need
// for any kind of proxying
target.clone(), forceStaticRequestHandlers));
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
};
const forceStaticNextUrlHandlers = {
get (target, prop, receiver) {
switch(prop){
// URL properties
case 'search':
return '';
case 'searchParams':
return target[searchParamsSymbol] || (target[searchParamsSymbol] = new URLSearchParams());
case 'href':
return target[hrefSymbol] || (target[hrefSymbol] = (0, _cleanurl.cleanURL)(target.href).href);
case 'toJSON':
case 'toString':
return target[toStringSymbol] || (target[toStringSymbol] = ()=>receiver.href);
// NextUrl properties
case 'url':
// Currently nextURL does not expose url but our Docs indicate that it is an available property
// I am forcing this to undefined here to avoid accidentally exposing a dynamic value later if
// the underlying nextURL ends up adding this property
return undefined;
case 'clone':
return target[urlCloneSymbol] || (target[urlCloneSymbol] = ()=>new Proxy(target.clone(), forceStaticNextUrlHandlers));
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
};
function proxyNextRequest(request, workStore) {
const nextUrlHandlers = {
get (target, prop, receiver) {
switch(prop){
case 'search':
case 'searchParams':
case 'url':
case 'href':
case 'toJSON':
case 'toString':
case 'origin':
{
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
trackDynamic(workStore, workUnitStore, `nextUrl.${prop}`);
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
case 'clone':
return target[urlCloneSymbol] || (target[urlCloneSymbol] = ()=>new Proxy(target.clone(), nextUrlHandlers));
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
};
const nextRequestHandlers = {
get (target, prop) {
switch(prop){
case 'nextUrl':
return target[nextURLSymbol] || (target[nextURLSymbol] = new Proxy(target.nextUrl, nextUrlHandlers));
case 'headers':
case 'cookies':
case 'url':
case 'body':
case 'blob':
case 'json':
case 'text':
case 'arrayBuffer':
case 'formData':
{
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
trackDynamic(workStore, workUnitStore, `request.${prop}`);
// The receiver arg is intentionally the same as the target to fix an issue with
// edge runtime, where attempting to access internal slots with the wrong `this` context
// results in an error.
return _reflect.ReflectAdapter.get(target, prop, target);
}
case 'clone':
return target[requestCloneSymbol] || (target[requestCloneSymbol] = ()=>new Proxy(// This is vaguely unsafe but it's required since NextRequest does not implement
// clone. The reason we might expect this to work in this context is the Proxy will
// respond with static-amenable values anyway somewhat restoring the interface.
// @TODO we need to rethink NextRequest and NextURL because they are not sufficientlly
// sophisticated to adequately represent themselves in all contexts. A better approach is
// to probably embed the static generation logic into the class itself removing the need
// for any kind of proxying
target.clone(), nextRequestHandlers));
default:
// The receiver arg is intentionally the same as the target to fix an issue with
// edge runtime, where attempting to access internal slots with the wrong `this` context
// results in an error.
return _reflect.ReflectAdapter.get(target, prop, target);
}
}
};
return new Proxy(request, nextRequestHandlers);
}
const requireStaticRequestHandlers = {
get (target, prop, receiver) {
switch(prop){
case 'nextUrl':
return target[nextURLSymbol] || (target[nextURLSymbol] = new Proxy(target.nextUrl, requireStaticNextUrlHandlers));
case 'headers':
case 'cookies':
case 'url':
case 'body':
case 'blob':
case 'json':
case 'text':
case 'arrayBuffer':
case 'formData':
throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${target.nextUrl.pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`request.${prop}\`.`), "__NEXT_ERROR_CODE", {
value: "E611",
enumerable: false,
configurable: true
});
case 'clone':
return target[requestCloneSymbol] || (target[requestCloneSymbol] = ()=>new Proxy(// This is vaguely unsafe but it's required since NextRequest does not implement
// clone. The reason we might expect this to work in this context is the Proxy will
// respond with static-amenable values anyway somewhat restoring the interface.
// @TODO we need to rethink NextRequest and NextURL because they are not sufficientlly
// sophisticated to adequately represent themselves in all contexts. A better approach is
// to probably embed the static generation logic into the class itself removing the need
// for any kind of proxying
target.clone(), requireStaticRequestHandlers));
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
};
const requireStaticNextUrlHandlers = {
get (target, prop, receiver) {
switch(prop){
case 'search':
case 'searchParams':
case 'url':
case 'href':
case 'toJSON':
case 'toString':
case 'origin':
throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${target.pathname} with \`dynamic = "error"\` couldn't be rendered statically because it used \`nextUrl.${prop}\`.`), "__NEXT_ERROR_CODE", {
value: "E575",
enumerable: false,
configurable: true
});
case 'clone':
return target[urlCloneSymbol] || (target[urlCloneSymbol] = ()=>new Proxy(target.clone(), requireStaticNextUrlHandlers));
default:
return _reflect.ReflectAdapter.get(target, prop, receiver);
}
}
};
function createCacheComponentsError(route) {
return Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${route} couldn't be rendered statically because it used IO that was not cached. See more info here: https://nextjs.org/docs/messages/cache-components`), "__NEXT_ERROR_CODE", {
value: "E727",
enumerable: false,
configurable: true
});
}
function trackDynamic(store, workUnitStore, expression) {
if (store.dynamicShouldError) {
throw Object.defineProperty(new _staticgenerationbailout.StaticGenBailoutError(`Route ${store.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
value: "E553",
enumerable: false,
configurable: true
});
}
if (workUnitStore) {
switch(workUnitStore.type){
case 'cache':
case 'private-cache':
// TODO: Should we allow reading cookies and search params from the
// request for private caches in route handlers?
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
value: "E178",
enumerable: false,
configurable: true
});
case 'unstable-cache':
throw Object.defineProperty(new Error(`Route ${store.route} used "${expression}" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "${expression}" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
value: "E133",
enumerable: false,
configurable: true
});
case 'prerender':
const error = Object.defineProperty(new Error(`Route ${store.route} used ${expression} without first calling \`await connection()\`. See more info here: https://nextjs.org/docs/messages/next-prerender-sync-request`), "__NEXT_ERROR_CODE", {
value: "E261",
enumerable: false,
configurable: true
});
return (0, _dynamicrendering.abortAndThrowOnSynchronousRequestDataAccess)(store.route, expression, error, workUnitStore);
case 'prerender-client':
case 'validation-client':
throw Object.defineProperty(new _invarianterror.InvariantError('A client prerender store should not be used for a route handler.'), "__NEXT_ERROR_CODE", {
value: "E720",
enumerable: false,
configurable: true
});
case 'prerender-runtime':
throw Object.defineProperty(new _invarianterror.InvariantError('A runtime prerender store should not be used for a route handler.'), "__NEXT_ERROR_CODE", {
value: "E767",
enumerable: false,
configurable: true
});
case 'prerender-ppr':
return (0, _dynamicrendering.postponeWithTracking)(store.route, expression, workUnitStore.dynamicTracking);
case 'prerender-legacy':
workUnitStore.revalidate = 0;
const err = Object.defineProperty(new _hooksservercontext.DynamicServerError(`Route ${store.route} couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
value: "E558",
enumerable: false,
configurable: true
});
store.dynamicUsageDescription = expression;
store.dynamicUsageStack = err.stack;
throw err;
case 'request':
if (process.env.NODE_ENV !== 'production') {
// TODO: This is currently not really needed for route handlers, as it
// only controls the ISR status that's shown for pages.
workUnitStore.usedDynamic = true;
}
break;
case 'generate-static-params':
break;
default:
workUnitStore;
}
}
}
//# sourceMappingURL=module.js.map

View File

@@ -0,0 +1,56 @@
// the name of the export has to be the camelCase version of the file name (without the extension)
// TODO: remove this. We need it because using notFound from next/navigation imports this file :(
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "appRouterContext", {
enumerable: true,
get: function() {
return _approutercontextsharedruntime;
}
});
const _approutercontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../shared/lib/app-router-context.shared-runtime"));
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
//# sourceMappingURL=shared-modules.js.map

View File

@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
isAppPageRouteModule: null,
isAppRouteRouteModule: null,
isPagesAPIRouteModule: null,
isPagesRouteModule: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
isAppPageRouteModule: function() {
return isAppPageRouteModule;
},
isAppRouteRouteModule: function() {
return isAppRouteRouteModule;
},
isPagesAPIRouteModule: function() {
return isPagesAPIRouteModule;
},
isPagesRouteModule: function() {
return isPagesRouteModule;
}
});
const _routekind = require("../route-kind");
function isAppRouteRouteModule(routeModule) {
return routeModule.definition.kind === _routekind.RouteKind.APP_ROUTE;
}
function isAppPageRouteModule(routeModule) {
return routeModule.definition.kind === _routekind.RouteKind.APP_PAGE;
}
function isPagesRouteModule(routeModule) {
return routeModule.definition.kind === _routekind.RouteKind.PAGES;
}
function isPagesAPIRouteModule(routeModule) {
return routeModule.definition.kind === _routekind.RouteKind.PAGES_API;
}
//# sourceMappingURL=checks.js.map

View File

@@ -0,0 +1,20 @@
"use strict";
if (process.env.NEXT_RUNTIME === 'edge') {
module.exports = require('next/dist/server/route-modules/pages-api/module.js');
} else {
if (process.env.NODE_ENV === 'development') {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/pages-api-turbo.runtime.dev.js');
} else {
module.exports = require('next/dist/compiled/next-server/pages-api.runtime.dev.js');
}
} else {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/pages-api-turbo.runtime.prod.js');
} else {
module.exports = require('next/dist/compiled/next-server/pages-api.runtime.prod.js');
}
}
}
//# sourceMappingURL=module.compiled.js.map

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
PagesAPIRouteModule: null,
default: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
PagesAPIRouteModule: function() {
return PagesAPIRouteModule;
},
default: function() {
return _default;
}
});
const _apiutils = require("../../api-utils");
const _routemodule = require("../route-module");
const _apiresolver = require("../../api-utils/node/api-resolver");
class PagesAPIRouteModule extends _routemodule.RouteModule {
constructor(options){
super(options);
if (typeof options.userland.default !== 'function') {
throw Object.defineProperty(new Error(`Page ${options.definition.page} does not export a default function.`), "__NEXT_ERROR_CODE", {
value: "E379",
enumerable: false,
configurable: true
});
}
this.apiResolverWrapped = (0, _apiutils.wrapApiHandler)(options.definition.page, _apiresolver.apiResolver);
}
/**
*
* @param req the incoming server request
* @param res the outgoing server response
* @param context the context for the render
*/ async render(req, res, context) {
const { apiResolverWrapped } = this;
await apiResolverWrapped(req, res, context.query, this.userland, {
...context.previewProps,
trustHostHeader: context.trustHostHeader,
allowedRevalidateHeaderKeys: context.allowedRevalidateHeaderKeys,
hostname: context.hostname,
multiZoneDraftMode: context.multiZoneDraftMode,
dev: context.dev,
internalRevalidate: context.internalRevalidate
}, context.propagateError, context.dev, context.page, context.onError);
}
}
const _default = PagesAPIRouteModule;
//# sourceMappingURL=module.js.map

View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
handler: null,
routeModule: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
handler: function() {
return handler;
},
routeModule: function() {
return routeModule;
}
});
const _app = /*#__PURE__*/ _interop_require_default(require("../../../../pages/_app"));
const _document = /*#__PURE__*/ _interop_require_default(require("../../../../pages/_document"));
const _routekind = require("../../../route-kind");
const _error = /*#__PURE__*/ _interop_require_wildcard(require("../../../../pages/_error"));
const _module = /*#__PURE__*/ _interop_require_default(require("../module"));
const _pageshandler = require("../pages-handler");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
const routeModule = new _module.default({
// TODO: add descriptor for internal error page
definition: {
kind: _routekind.RouteKind.PAGES,
page: '/_error',
pathname: '/_error',
filename: '',
bundlePath: ''
},
distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',
relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',
components: {
App: _app.default,
Document: _document.default
},
userland: _error
});
const handler = (0, _pageshandler.getHandler)({
srcPage: '/_error',
routeModule,
userland: _error,
config: {},
isFallbackError: true
});
//# sourceMappingURL=_error.js.map

View File

@@ -0,0 +1,20 @@
"use strict";
if (process.env.NEXT_RUNTIME === 'edge') {
module.exports = require('next/dist/server/route-modules/pages/module.js');
} else {
if (process.env.NODE_ENV === 'development') {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/pages-turbo.runtime.dev.js');
} else {
module.exports = require('next/dist/compiled/next-server/pages.runtime.dev.js');
}
} else {
if (process.env.TURBOPACK) {
module.exports = require('next/dist/compiled/next-server/pages-turbo.runtime.prod.js');
} else {
module.exports = require('next/dist/compiled/next-server/pages.runtime.prod.js');
}
}
}
//# sourceMappingURL=module.compiled.js.map

View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
PagesRouteModule: null,
default: null,
renderToHTML: null,
vendored: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
PagesRouteModule: function() {
return PagesRouteModule;
},
default: function() {
return _default;
},
renderToHTML: function() {
return _render.renderToHTML;
},
vendored: function() {
return vendored;
}
});
const _routemodule = require("../route-module");
const _render = require("../../render");
const _entrypoints = /*#__PURE__*/ _interop_require_wildcard(require("./vendored/contexts/entrypoints"));
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
class PagesRouteModule extends _routemodule.RouteModule {
constructor(options){
super(options);
this.components = options.components;
}
render(req, res, context) {
return (0, _render.renderToHTMLImpl)(req, res, context.page, context.query, context.renderOpts, {
App: this.components.App,
Document: this.components.Document
}, context.sharedContext, context.renderContext);
}
}
const vendored = {
contexts: _entrypoints
};
const _default = PagesRouteModule;
//# sourceMappingURL=module.js.map

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "lazyRenderPagesPage", {
enumerable: true,
get: function() {
return lazyRenderPagesPage;
}
});
const lazyRenderPagesPage = (...args)=>{
if (process.env.NEXT_MINIMAL) {
throw Object.defineProperty(new Error("Can't use lazyRenderPagesPage in minimal mode"), "__NEXT_ERROR_CODE", {
value: "E272",
enumerable: false,
configurable: true
});
} else {
const render = require('./module.compiled').renderToHTML;
return render(...args);
}
};
//# sourceMappingURL=module.render.js.map

View File

@@ -0,0 +1,545 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getHandler", {
enumerable: true,
get: function() {
return getHandler;
}
});
const _routekind = require("../../route-kind");
const _constants = require("../../lib/trace/constants");
const _tracer = require("../../lib/trace/tracer");
const _formaturl = require("../../../shared/lib/router/utils/format-url");
const _requestmeta = require("../../request-meta");
const _interopdefault = require("../../app-render/interop-default");
const _utils = require("../../instrumentation/utils");
const _normalizedatapath = require("../../../shared/lib/page-path/normalize-data-path");
const _responsecache = require("../../response-cache");
const _cachecontrol = require("../../lib/cache-control");
const _utils1 = require("../../../shared/lib/utils");
const _redirectstatus = require("../../../lib/redirect-status");
const _constants1 = require("../../../lib/constants");
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
const _sendpayload = require("../../send-payload");
const _renderresult = /*#__PURE__*/ _interop_require_default(require("../../render-result"));
const _utils2 = require("../../response-cache/utils");
const _nofallbackerrorexternal = require("../../../shared/lib/no-fallback-error.external");
const _redirectstatuscode = require("../../../client/components/redirect-status-code");
const _isbot = require("../../../shared/lib/router/utils/is-bot");
const _addpathprefix = require("../../../shared/lib/router/utils/add-path-prefix");
const _removetrailingslash = require("../../../shared/lib/router/utils/remove-trailing-slash");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const getHandler = ({ srcPage: originalSrcPage, config, userland, routeModule, isFallbackError, getStaticPaths, getStaticProps, getServerSideProps })=>{
return async function handler(req, res, ctx) {
var _serverFilesManifest_config_experimental, _serverFilesManifest_config;
if (ctx.requestMeta) {
(0, _requestmeta.setRequestMeta)(req, ctx.requestMeta);
}
if (routeModule.isDev) {
(0, _requestmeta.addRequestMeta)(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());
}
let srcPage = originalSrcPage;
// turbopack doesn't normalize `/index` in the page name
// so we need to to process dynamic routes properly
// TODO: fix turbopack providing differing value from webpack
if (process.env.TURBOPACK) {
srcPage = srcPage.replace(/\/index$/, '') || '/';
} else if (srcPage === '/index') {
// we always normalize /index specifically
srcPage = '/';
}
const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;
const prepareResult = await routeModule.prepare(req, res, {
srcPage,
multiZoneDraftMode
});
if (!prepareResult) {
res.statusCode = 400;
res.end('Bad Request');
ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());
return;
}
const isMinimalMode = Boolean((0, _requestmeta.getRequestMeta)(req, 'minimalMode'));
const render404 = async ()=>{
// TODO: should route-module itself handle rendering the 404
if (routerServerContext == null ? void 0 : routerServerContext.render404) {
await routerServerContext.render404(req, res, parsedUrl, false);
} else {
res.end('This page could not be found');
}
};
const { buildId, query, params, parsedUrl, originalQuery, originalPathname, buildManifest, fallbackBuildManifest, nextFontManifest, serverFilesManifest, reactLoadableManifest, prerenderManifest, isDraftMode, isOnDemandRevalidate, revalidateOnlyGenerated, locale, locales, defaultLocale, routerServerContext, nextConfig, resolvedPathname, encodedResolvedPathname, deploymentId, clientAssetToken } = prepareResult;
const isExperimentalCompile = serverFilesManifest == null ? void 0 : (_serverFilesManifest_config = serverFilesManifest.config) == null ? void 0 : (_serverFilesManifest_config_experimental = _serverFilesManifest_config.experimental) == null ? void 0 : _serverFilesManifest_config_experimental.isExperimentalCompile;
const hasServerProps = Boolean(getServerSideProps);
const hasStaticProps = Boolean(getStaticProps);
const hasStaticPaths = Boolean(getStaticPaths);
const hasGetInitialProps = Boolean((userland.default || userland).getInitialProps);
let cacheKey = null;
let isIsrFallback = false;
let isNextDataRequest = prepareResult.isNextDataRequest && (hasStaticProps || hasServerProps);
const is404Page = srcPage === '/404';
const is500Page = srcPage === '/500';
const isErrorPage = srcPage === '/_error';
if (!routeModule.isDev && !isDraftMode && hasStaticProps) {
cacheKey = `${locale ? `/${locale}` : ''}${(srcPage === '/' || resolvedPathname === '/') && locale ? '' : resolvedPathname}`;
if (is404Page || is500Page || isErrorPage) {
cacheKey = `${locale ? `/${locale}` : ''}${srcPage}`;
}
// ensure /index and / is normalized to one key
cacheKey = cacheKey === '/index' ? '/' : cacheKey;
}
if (hasStaticPaths && !isDraftMode) {
const decodedPathname = (0, _removetrailingslash.removeTrailingSlash)(locale ? (0, _addpathprefix.addPathPrefix)(resolvedPathname, `/${locale}`) : resolvedPathname);
const isPrerendered = Boolean(prerenderManifest.routes[decodedPathname]) || prerenderManifest.notFoundRoutes.includes(decodedPathname);
const prerenderInfo = prerenderManifest.dynamicRoutes[srcPage];
if (prerenderInfo) {
if (prerenderInfo.fallback === false && !isPrerendered) {
if (nextConfig.adapterPath) {
return await render404();
}
throw new _nofallbackerrorexternal.NoFallbackError();
}
if (typeof prerenderInfo.fallback === 'string' && !isPrerendered && !isNextDataRequest) {
isIsrFallback = true;
}
}
}
// When serving a bot request, we want to serve a blocking render and not
// the prerendered page. This ensures that the correct content is served
// to the bot in the head.
if (isIsrFallback && (0, _isbot.isBot)(req.headers['user-agent'] || '') || isMinimalMode) {
isIsrFallback = false;
}
const tracer = (0, _tracer.getTracer)();
const activeSpan = tracer.getActiveScopeSpan();
try {
var _parsedUrl_pathname;
const method = req.method || 'GET';
const resolvedUrl = (0, _formaturl.formatUrl)({
pathname: nextConfig.trailingSlash ? `${encodedResolvedPathname}${!encodedResolvedPathname.endsWith('/') && ((_parsedUrl_pathname = parsedUrl.pathname) == null ? void 0 : _parsedUrl_pathname.endsWith('/')) ? '/' : ''}` : (0, _removetrailingslash.removeTrailingSlash)(encodedResolvedPathname || '/'),
// make sure to only add query values from original URL
query: hasStaticProps ? {} : originalQuery
});
let parentSpan;
const handleResponse = async (span)=>{
const responseGenerator = async ({ previousCacheEntry })=>{
var _previousCacheEntry_value;
const doRender = async ()=>{
try {
var _nextConfig_i18n;
return await routeModule.render(req, res, {
query: hasStaticProps && !isExperimentalCompile ? {
...params
} : {
...query,
...params
},
params,
page: srcPage,
renderContext: {
isDraftMode,
isFallback: isIsrFallback,
developmentNotFoundSourcePage: (0, _requestmeta.getRequestMeta)(req, 'developmentNotFoundSourcePage')
},
sharedContext: {
buildId,
customServer: Boolean(routerServerContext == null ? void 0 : routerServerContext.isCustomServer) || undefined,
deploymentId,
clientAssetToken
},
renderOpts: {
params,
routeModule,
page: srcPage,
pageConfig: config || {},
Component: (0, _interopdefault.interopDefault)(userland),
ComponentMod: userland,
getStaticProps,
getStaticPaths,
getServerSideProps,
supportsDynamicResponse: !hasStaticProps,
buildManifest: isFallbackError ? fallbackBuildManifest : buildManifest,
nextFontManifest,
reactLoadableManifest,
assetPrefix: nextConfig.assetPrefix,
previewProps: prerenderManifest.preview,
images: nextConfig.images,
nextConfigOutput: nextConfig.output,
optimizeCss: Boolean(nextConfig.experimental.optimizeCss),
nextScriptWorkers: Boolean(nextConfig.experimental.nextScriptWorkers),
domainLocales: (_nextConfig_i18n = nextConfig.i18n) == null ? void 0 : _nextConfig_i18n.domains,
crossOrigin: nextConfig.crossOrigin,
multiZoneDraftMode,
basePath: nextConfig.basePath,
disableOptimizedLoading: nextConfig.experimental.disableOptimizedLoading,
largePageDataBytes: nextConfig.experimental.largePageDataBytes,
isExperimentalCompile,
experimental: {
clientTraceMetadata: nextConfig.experimental.clientTraceMetadata || []
},
locale,
locales,
defaultLocale,
setIsrStatus: routerServerContext == null ? void 0 : routerServerContext.setIsrStatus,
isNextDataRequest: isNextDataRequest && (hasServerProps || hasStaticProps),
resolvedUrl,
// For getServerSideProps and getInitialProps we need to ensure we use the original URL
// and not the resolved URL to prevent a hydration mismatch on
// asPath
resolvedAsPath: hasServerProps || hasGetInitialProps ? (0, _formaturl.formatUrl)({
// we use the original URL pathname less the _next/data prefix if
// present
pathname: isNextDataRequest ? (0, _normalizedatapath.normalizeDataPath)(originalPathname) : originalPathname,
query: originalQuery
}) : resolvedUrl,
isOnDemandRevalidate,
ErrorDebug: (0, _requestmeta.getRequestMeta)(req, 'PagesErrorDebug'),
err: (0, _requestmeta.getRequestMeta)(req, 'invokeError'),
// needed for experimental.optimizeCss feature
distDir: _path.default.join(/* turbopackIgnore: true */ process.cwd(), routeModule.relativeProjectDir, routeModule.distDir)
}
}).then((renderResult)=>{
const { metadata } = renderResult;
let cacheControl = metadata.cacheControl;
if ('isNotFound' in metadata && metadata.isNotFound) {
return {
value: null,
cacheControl
};
}
// Handle `isRedirect`.
if (metadata.isRedirect) {
return {
value: {
kind: _responsecache.CachedRouteKind.REDIRECT,
props: metadata.pageData ?? metadata.flightData
},
cacheControl
};
}
return {
value: {
kind: _responsecache.CachedRouteKind.PAGES,
html: renderResult,
pageData: renderResult.metadata.pageData,
headers: renderResult.metadata.headers,
status: renderResult.metadata.statusCode
},
cacheControl
};
}).finally(()=>{
if (!span) return;
span.setAttributes({
'http.status_code': res.statusCode,
'next.rsc': false
});
const rootSpanAttributes = tracer.getRootSpanAttributes();
// We were unable to get attributes, probably OTEL is not enabled
if (!rootSpanAttributes) {
return;
}
if (rootSpanAttributes.get('next.span_type') !== _constants.BaseServerSpan.handleRequest) {
console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);
return;
}
const route = rootSpanAttributes.get('next.route');
if (route) {
const name = `${method} ${route}`;
span.setAttributes({
'next.route': route,
'http.route': route,
'next.span_name': name
});
span.updateName(name);
// Propagate http.route to the parent span if one exists
// (e.g. a platform-created HTTP span in adapter
// deployments).
if (parentSpan && parentSpan !== span) {
parentSpan.setAttribute('http.route', route);
parentSpan.updateName(name);
}
} else {
span.updateName(`${method} ${srcPage}`);
}
});
} catch (err) {
// if this is a background revalidate we need to report
// the request error here as it won't be bubbled
if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {
const silenceLog = false;
await routeModule.onRequestError(req, err, {
routerKind: 'Pages Router',
routePath: srcPage,
routeType: 'render',
revalidateReason: (0, _utils.getRevalidateReason)({
isStaticGeneration: hasStaticProps,
isOnDemandRevalidate
})
}, silenceLog, routerServerContext);
}
throw err;
}
};
// if we've already generated this page we no longer
// serve the fallback
if (previousCacheEntry) {
isIsrFallback = false;
}
if (isIsrFallback) {
const fallbackResponse = await routeModule.getResponseCache(req).get(routeModule.isDev ? null : locale ? `/${locale}${srcPage}` : srcPage, async ({ previousCacheEntry: previousFallbackCacheEntry = null })=>{
if (!routeModule.isDev) {
return (0, _utils2.toResponseCacheEntry)(previousFallbackCacheEntry);
}
return doRender();
}, {
routeKind: _routekind.RouteKind.PAGES,
isFallback: true,
isRoutePPREnabled: false,
isOnDemandRevalidate: false,
incrementalCache: await routeModule.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode),
waitUntil: ctx.waitUntil
});
if (fallbackResponse) {
// Remove the cache control from the response to prevent it from being
// used in the surrounding cache.
delete fallbackResponse.cacheControl;
fallbackResponse.isMiss = true;
return fallbackResponse;
}
}
if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {
res.statusCode = 404;
// on-demand revalidate always sets this header
res.setHeader('x-nextjs-cache', 'REVALIDATED');
res.end('This page could not be found');
return null;
}
if (isIsrFallback && (previousCacheEntry == null ? void 0 : (_previousCacheEntry_value = previousCacheEntry.value) == null ? void 0 : _previousCacheEntry_value.kind) === _responsecache.CachedRouteKind.PAGES) {
return {
value: {
kind: _responsecache.CachedRouteKind.PAGES,
html: new _renderresult.default(Buffer.from(previousCacheEntry.value.html), {
contentType: _constants1.HTML_CONTENT_TYPE_HEADER,
metadata: {
statusCode: previousCacheEntry.value.status,
headers: previousCacheEntry.value.headers
}
}),
pageData: {},
status: previousCacheEntry.value.status,
headers: previousCacheEntry.value.headers
},
cacheControl: {
revalidate: 0,
expire: undefined
}
};
}
return doRender();
};
const result = await routeModule.handleResponse({
cacheKey,
req,
nextConfig,
routeKind: _routekind.RouteKind.PAGES,
isOnDemandRevalidate,
revalidateOnlyGenerated,
waitUntil: ctx.waitUntil,
responseGenerator: responseGenerator,
prerenderManifest,
isMinimalMode
});
// if we got a cache hit this wasn't an ISR fallback
// but it wasn't generated during build so isn't in the
// prerender-manifest
if (isIsrFallback && !(result == null ? void 0 : result.isMiss)) {
isIsrFallback = false;
}
// response is finished is no cache entry
if (!result) {
return;
}
if (hasStaticProps && !isMinimalMode) {
res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : result.isMiss ? 'MISS' : result.isStale ? 'STALE' : 'HIT');
}
let cacheControl;
if (!hasStaticProps || isIsrFallback) {
if (!res.getHeader('Cache-Control')) {
cacheControl = {
revalidate: 0,
expire: undefined
};
}
} else if (is404Page) {
const notFoundRevalidate = (0, _requestmeta.getRequestMeta)(req, 'notFoundRevalidate');
cacheControl = {
revalidate: typeof notFoundRevalidate === 'undefined' ? 0 : notFoundRevalidate,
expire: undefined
};
} else if (is500Page) {
cacheControl = {
revalidate: 0,
expire: undefined
};
} else if (result.cacheControl) {
// If the cache entry has a cache control with a revalidate value that's
// a number, use it.
if (typeof result.cacheControl.revalidate === 'number') {
var _result_cacheControl;
if (result.cacheControl.revalidate < 1) {
throw Object.defineProperty(new Error(`Invalid revalidate configuration provided: ${result.cacheControl.revalidate} < 1`), "__NEXT_ERROR_CODE", {
value: "E22",
enumerable: false,
configurable: true
});
}
cacheControl = {
revalidate: result.cacheControl.revalidate,
expire: ((_result_cacheControl = result.cacheControl) == null ? void 0 : _result_cacheControl.expire) ?? nextConfig.expireTime
};
} else {
// revalidate: false
cacheControl = {
revalidate: _constants1.CACHE_ONE_YEAR_SECONDS,
expire: undefined
};
}
}
// If cache control is already set on the response we don't
// override it to allow users to customize it via next.config
if (cacheControl && !res.getHeader('Cache-Control')) {
res.setHeader('Cache-Control', (0, _cachecontrol.getCacheControlHeader)(cacheControl));
}
// notFound: true case
if (!result.value) {
var _result_cacheControl1;
// add revalidate metadata before rendering 404 page
// so that we can use this as source of truth for the
// cache-control header instead of what the 404 page returns
// for the revalidate value
(0, _requestmeta.addRequestMeta)(req, 'notFoundRevalidate', (_result_cacheControl1 = result.cacheControl) == null ? void 0 : _result_cacheControl1.revalidate);
res.statusCode = 404;
if (isNextDataRequest) {
if (deploymentId) {
res.setHeader(_constants1.NEXT_NAV_DEPLOYMENT_ID_HEADER, deploymentId);
}
res.end('{"notFound":true}');
return;
}
return await render404();
}
if (result.value.kind === _responsecache.CachedRouteKind.REDIRECT) {
if (isNextDataRequest) {
if (deploymentId) {
res.setHeader(_constants1.NEXT_NAV_DEPLOYMENT_ID_HEADER, deploymentId);
}
res.setHeader('content-type', _constants1.JSON_CONTENT_TYPE_HEADER);
res.end(JSON.stringify(result.value.props));
return;
} else {
const handleRedirect = (pageData)=>{
const redirect = {
destination: pageData.pageProps.__N_REDIRECT,
statusCode: pageData.pageProps.__N_REDIRECT_STATUS,
basePath: pageData.pageProps.__N_REDIRECT_BASE_PATH
};
const statusCode = (0, _redirectstatus.getRedirectStatus)(redirect);
const { basePath } = nextConfig;
if (basePath && redirect.basePath !== false && redirect.destination.startsWith('/')) {
redirect.destination = `${basePath}${redirect.destination}`;
}
if (redirect.destination.startsWith('/')) {
redirect.destination = (0, _utils1.normalizeRepeatedSlashes)(redirect.destination);
}
res.statusCode = statusCode;
res.setHeader('Location', redirect.destination);
if (statusCode === _redirectstatuscode.RedirectStatusCode.PermanentRedirect) {
res.setHeader('Refresh', `0;url=${redirect.destination}`);
}
res.end(redirect.destination);
};
await handleRedirect(result.value.props);
return null;
}
}
if (result.value.kind !== _responsecache.CachedRouteKind.PAGES) {
throw Object.defineProperty(new Error(`Invariant: received non-pages cache entry in pages handler`), "__NEXT_ERROR_CODE", {
value: "E695",
enumerable: false,
configurable: true
});
}
// In dev, we should not cache pages for any reason.
if (routeModule.isDev) {
res.setHeader('Cache-Control', 'no-cache, must-revalidate');
}
// Draft mode should never be cached
if (isDraftMode) {
res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');
}
// when invoking _error before pages/500 we don't actually
// send the _error response
if ((0, _requestmeta.getRequestMeta)(req, 'customErrorRender') || isErrorPage && isMinimalMode && res.statusCode === 500) {
return null;
}
// Add deployment ID header for data requests
if (isNextDataRequest && !isErrorPage && !is500Page) {
if (deploymentId) {
res.setHeader(_constants1.NEXT_NAV_DEPLOYMENT_ID_HEADER, deploymentId);
}
}
await (0, _sendpayload.sendRenderResult)({
req,
res,
// If we are rendering the error page it's not a data request
// anymore
result: isNextDataRequest && !isErrorPage && !is500Page ? new _renderresult.default(Buffer.from(JSON.stringify(result.value.pageData)), {
contentType: _constants1.JSON_CONTENT_TYPE_HEADER,
metadata: result.value.html.metadata
}) : result.value.html,
generateEtags: nextConfig.generateEtags,
poweredByHeader: nextConfig.poweredByHeader,
cacheControl: routeModule.isDev ? undefined : cacheControl
});
};
// TODO: activeSpan code path is for when wrapped by
// next-server can be removed when this is no longer used
if (activeSpan) {
await handleResponse();
} else {
parentSpan = tracer.getActiveScopeSpan();
await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(_constants.BaseServerSpan.handleRequest, {
spanName: `${method} ${srcPage}`,
kind: _tracer.SpanKind.SERVER,
attributes: {
'http.method': method,
'http.target': req.url
}
}, handleResponse));
}
} catch (err) {
if (!(err instanceof _nofallbackerrorexternal.NoFallbackError)) {
const silenceLog = false;
await routeModule.onRequestError(req, err, {
routerKind: 'Pages Router',
routePath: srcPage,
routeType: 'render',
revalidateReason: (0, _utils.getRevalidateReason)({
isStaticGeneration: hasStaticProps,
isOnDemandRevalidate
})
}, silenceLog, routerServerContext);
}
// rethrow so that we can handle serving error page
throw err;
}
};
};
//# sourceMappingURL=pages-handler.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].AppRouterContext;
//# sourceMappingURL=app-router-context.js.map

View File

@@ -0,0 +1,102 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
AppRouterContext: null,
HeadManagerContext: null,
HooksClientContext: null,
HtmlContext: null,
ImageConfigContext: null,
Loadable: null,
LoadableContext: null,
RouterContext: null,
ServerInsertedHtml: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
AppRouterContext: function() {
return _approutercontextsharedruntime;
},
HeadManagerContext: function() {
return _headmanagercontextsharedruntime;
},
HooksClientContext: function() {
return _hooksclientcontextsharedruntime;
},
HtmlContext: function() {
return _htmlcontextsharedruntime;
},
ImageConfigContext: function() {
return _imageconfigcontextsharedruntime;
},
Loadable: function() {
return _loadablesharedruntime;
},
LoadableContext: function() {
return _loadablecontextsharedruntime;
},
RouterContext: function() {
return _routercontextsharedruntime;
},
ServerInsertedHtml: function() {
return _serverinsertedhtmlsharedruntime;
}
});
const _routercontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/router-context.shared-runtime"));
const _loadablecontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/loadable-context.shared-runtime"));
const _loadablesharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/loadable.shared-runtime"));
const _imageconfigcontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/image-config-context.shared-runtime"));
const _htmlcontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/html-context.shared-runtime"));
const _hooksclientcontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/hooks-client-context.shared-runtime"));
const _headmanagercontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/head-manager-context.shared-runtime"));
const _approutercontextsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/app-router-context.shared-runtime"));
const _serverinsertedhtmlsharedruntime = /*#__PURE__*/ _interop_require_wildcard(require("../../../../../shared/lib/server-inserted-html.shared-runtime"));
function _getRequireWildcardCache(nodeInterop) {
if (typeof WeakMap !== "function") return null;
var cacheBabelInterop = new WeakMap();
var cacheNodeInterop = new WeakMap();
return (_getRequireWildcardCache = function(nodeInterop) {
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
})(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
if (!nodeInterop && obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache(nodeInterop);
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {
__proto__: null
};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
//# sourceMappingURL=entrypoints.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].HeadManagerContext;
//# sourceMappingURL=head-manager-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].HooksClientContext;
//# sourceMappingURL=hooks-client-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].HtmlContext;
//# sourceMappingURL=html-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].ImageConfigContext;
//# sourceMappingURL=image-config-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].LoadableContext;
//# sourceMappingURL=loadable-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].Loadable;
//# sourceMappingURL=loadable.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].RouterContext;
//# sourceMappingURL=router-context.js.map

View File

@@ -0,0 +1,4 @@
"use strict";
module.exports = require('../../module.compiled').vendored['contexts'].ServerInsertedHtml;
//# sourceMappingURL=server-inserted-html.js.map

View File

@@ -0,0 +1,660 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RouteModule", {
enumerable: true,
get: function() {
return RouteModule;
}
});
require("../../build/adapter/setup-node-env.external");
const _constants = require("../../shared/lib/constants");
const _url = require("../../lib/url");
const _normalizelocalepath = require("../../shared/lib/i18n/normalize-locale-path");
const _utils = require("../../shared/lib/router/utils");
const _removepathprefix = require("../../shared/lib/router/utils/remove-path-prefix");
const _serverutils = require("../server-utils");
const _detectdomainlocale = require("../../shared/lib/i18n/detect-domain-locale");
const _gethostname = require("../../shared/lib/get-hostname");
const _apiutils = require("../api-utils");
const _normalizedatapath = require("../../shared/lib/page-path/normalize-data-path");
const _pathhasprefix = require("../../shared/lib/router/utils/path-has-prefix");
const _requestmeta = require("../request-meta");
const _patchsetheader = require("../lib/patch-set-header");
const _normalizepagepath = require("../../shared/lib/page-path/normalize-page-path");
const _ismetadataroute = require("../../lib/metadata/is-metadata-route");
const _incrementalcache = require("../lib/incremental-cache");
const _handlers = require("../use-cache/handlers");
const _interopdefault = require("../app-render/interop-default");
const _routekind = require("../route-kind");
const _responsecache = /*#__PURE__*/ _interop_require_default(require("../response-cache"));
const _apppaths = require("../../shared/lib/router/utils/app-paths");
const _routerservercontext = require("../lib/router-utils/router-server-context");
const _decodepathparams = require("../lib/router-utils/decode-path-params");
const _removetrailingslash = require("../../shared/lib/router/utils/remove-trailing-slash");
const _isinterceptionrouterewrite = require("../../lib/is-interception-route-rewrite");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const dynamicImportEsmDefault = (id)=>import(/* webpackIgnore: true */ /* turbopackIgnore: true */ id).then((mod)=>mod.default || mod);
class RouteModule {
constructor({ userland, definition, distDir, relativeProjectDir }){
this.userland = userland;
this.definition = definition;
this.isDev = !!process.env.__NEXT_DEV_SERVER;
this.distDir = distDir;
this.relativeProjectDir = relativeProjectDir;
}
getRouterServerContext(req) {
var _routerServerGlobal_RouterServerContextSymbol;
const hostname = (0, _requestmeta.getRequestMeta)(req, 'hostname');
const revalidate = (0, _requestmeta.getRequestMeta)(req, 'revalidate');
const render404 = (0, _requestmeta.getRequestMeta)(req, 'render404');
const relativeProjectDir = (0, _requestmeta.getRequestMeta)(req, 'relativeProjectDir') || this.relativeProjectDir;
const routerServerContext = (_routerServerGlobal_RouterServerContextSymbol = _routerservercontext.routerServerGlobal[_routerservercontext.RouterServerContextSymbol]) == null ? void 0 : _routerServerGlobal_RouterServerContextSymbol[relativeProjectDir];
return {
...routerServerContext,
...hostname !== undefined ? {
hostname
} : {},
...revalidate !== undefined ? {
revalidate
} : {},
...render404 !== undefined ? {
render404
} : {}
};
}
normalizeUrl(_req, _parsedUrl) {}
async instrumentationOnRequestError(req, ...args) {
if (process.env.NEXT_RUNTIME === 'edge') {
const { getEdgeInstrumentationModule } = await import('../web/globals');
const instrumentation = await getEdgeInstrumentationModule();
if (instrumentation) {
await (instrumentation.onRequestError == null ? void 0 : instrumentation.onRequestError.call(instrumentation, ...args));
}
} else {
const { join } = require('node:path');
const absoluteProjectDir = join(/* turbopackIgnore: true */ process.cwd(), (0, _requestmeta.getRequestMeta)(req, 'relativeProjectDir') || this.relativeProjectDir);
const { instrumentationOnRequestError } = await import('../lib/router-utils/instrumentation-globals.external.js');
return instrumentationOnRequestError(absoluteProjectDir, this.distDir, ...args);
}
}
loadManifests(srcPage, projectDir) {
let result;
if (process.env.NEXT_RUNTIME === 'edge') {
var _self___RSC_MANIFEST;
const { getEdgePreviewProps } = require('../web/get-edge-preview-props');
const maybeJSONParse = (str)=>str ? JSON.parse(str) : undefined;
result = {
buildId: process.env.__NEXT_BUILD_ID || '',
buildManifest: self.__BUILD_MANIFEST,
fallbackBuildManifest: {},
reactLoadableManifest: maybeJSONParse(self.__REACT_LOADABLE_MANIFEST),
nextFontManifest: maybeJSONParse(self.__NEXT_FONT_MANIFEST),
prerenderManifest: {
routes: {},
dynamicRoutes: {},
notFoundRoutes: [],
version: 4,
preview: getEdgePreviewProps()
},
routesManifest: {
version: 4,
caseSensitive: Boolean(process.env.__NEXT_CASE_SENSITIVE_ROUTES),
basePath: process.env.__NEXT_BASE_PATH || '',
rewrites: process.env.__NEXT_REWRITES || {
beforeFiles: [],
afterFiles: [],
fallback: []
},
redirects: [],
headers: [],
onMatchHeaders: [],
i18n: process.env.__NEXT_I18N_CONFIG || undefined,
skipProxyUrlNormalize: Boolean(process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE)
},
serverFilesManifest: self.__SERVER_FILES_MANIFEST,
clientReferenceManifest: (_self___RSC_MANIFEST = self.__RSC_MANIFEST) == null ? void 0 : _self___RSC_MANIFEST[srcPage],
serverActionsManifest: maybeJSONParse(self.__RSC_SERVER_MANIFEST),
subresourceIntegrityManifest: maybeJSONParse(self.__SUBRESOURCE_INTEGRITY_MANIFEST),
dynamicCssManifest: maybeJSONParse(self.__DYNAMIC_CSS_MANIFEST),
interceptionRoutePatterns: (maybeJSONParse(self.__INTERCEPTION_ROUTE_REWRITE_MANIFEST) ?? []).map((rewrite)=>new RegExp(rewrite.regex))
};
} else {
var _clientReferenceManifest___RSC_MANIFEST;
if (!projectDir) {
throw Object.defineProperty(new Error('Invariant: projectDir is required for node runtime'), "__NEXT_ERROR_CODE", {
value: "E718",
enumerable: false,
configurable: true
});
}
const { loadManifestFromRelativePath } = require('../load-manifest.external');
const normalizedPagePath = (0, _normalizepagepath.normalizePagePath)(srcPage);
const router = this.definition.kind === _routekind.RouteKind.PAGES || this.definition.kind === _routekind.RouteKind.PAGES_API ? 'pages' : 'app';
const [routesManifest, prerenderManifest, buildManifest, fallbackBuildManifest, reactLoadableManifest, nextFontManifest, clientReferenceManifest, serverActionsManifest, subresourceIntegrityManifest, serverFilesManifest, buildId, dynamicCssManifest] = [
loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: _constants.ROUTES_MANIFEST,
shouldCache: !this.isDev
}),
loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: _constants.PRERENDER_MANIFEST,
shouldCache: !this.isDev
}),
loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: _constants.BUILD_MANIFEST,
shouldCache: !this.isDev
}),
srcPage === '/_error' ? loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: `fallback-${_constants.BUILD_MANIFEST}`,
shouldCache: !this.isDev,
handleMissing: true
}) : {},
loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: process.env.TURBOPACK ? `server/${router === 'app' ? 'app' : 'pages'}${normalizedPagePath}/${_constants.REACT_LOADABLE_MANIFEST}` : _constants.REACT_LOADABLE_MANIFEST,
handleMissing: true,
shouldCache: !this.isDev
}),
loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: `server/${_constants.NEXT_FONT_MANIFEST}.json`,
shouldCache: !this.isDev
}),
router === 'app' && !(0, _ismetadataroute.isStaticMetadataRoute)(srcPage) ? loadManifestFromRelativePath({
distDir: this.distDir,
projectDir,
useEval: true,
handleMissing: true,
manifest: `server/app${srcPage.replace(/%5F/g, '_') + '_' + _constants.CLIENT_REFERENCE_MANIFEST}.js`,
shouldCache: !this.isDev
}) : undefined,
router === 'app' ? loadManifestFromRelativePath({
distDir: this.distDir,
projectDir,
manifest: `server/${_constants.SERVER_REFERENCE_MANIFEST}.json`,
handleMissing: true,
shouldCache: !this.isDev
}) : {},
loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: `server/${_constants.SUBRESOURCE_INTEGRITY_MANIFEST}.json`,
handleMissing: true,
shouldCache: !this.isDev
}),
this.isDev ? undefined : loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
shouldCache: true,
manifest: `${_constants.SERVER_FILES_MANIFEST}.json`
}),
this.isDev ? 'development' : loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: _constants.BUILD_ID_FILE,
skipParse: true,
shouldCache: true
}),
loadManifestFromRelativePath({
projectDir,
distDir: this.distDir,
manifest: _constants.DYNAMIC_CSS_MANIFEST,
shouldCache: !this.isDev,
handleMissing: true
})
];
result = {
buildId,
buildManifest,
fallbackBuildManifest,
routesManifest,
nextFontManifest,
prerenderManifest,
serverFilesManifest,
reactLoadableManifest,
clientReferenceManifest: clientReferenceManifest == null ? void 0 : (_clientReferenceManifest___RSC_MANIFEST = clientReferenceManifest.__RSC_MANIFEST) == null ? void 0 : _clientReferenceManifest___RSC_MANIFEST[srcPage.replace(/%5F/g, '_')],
serverActionsManifest,
subresourceIntegrityManifest,
dynamicCssManifest,
interceptionRoutePatterns: routesManifest.rewrites.beforeFiles.filter(_isinterceptionrouterewrite.isInterceptionRouteRewrite).map((rewrite)=>new RegExp(rewrite.regex))
};
}
return result;
}
async loadCustomCacheHandlers(req, nextConfig) {
if (process.env.NEXT_RUNTIME !== 'edge') {
const { cacheMaxMemorySize, cacheHandlers } = nextConfig;
if (!cacheHandlers) return;
// If we've already initialized the cache handlers interface, don't do it
// again.
if (!(0, _handlers.initializeCacheHandlers)(cacheMaxMemorySize)) return;
for (const [kind, handler] of Object.entries(cacheHandlers)){
if (!handler) continue;
const { formatDynamicImportPath } = require('../../lib/format-dynamic-import-path');
const { join } = require('node:path');
const absoluteProjectDir = join(/* turbopackIgnore: true */ process.cwd(), (0, _requestmeta.getRequestMeta)(req, 'relativeProjectDir') || this.relativeProjectDir);
(0, _handlers.setCacheHandler)(kind, (0, _interopdefault.interopDefault)(await dynamicImportEsmDefault(formatDynamicImportPath(`${absoluteProjectDir}/${this.distDir}`, handler))));
}
}
}
async getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode) {
if (process.env.NEXT_RUNTIME === 'edge') {
return globalThis.__incrementalCache;
} else {
let CacheHandler;
const { cacheHandler } = nextConfig;
if (cacheHandler) {
const { formatDynamicImportPath } = require('../../lib/format-dynamic-import-path');
CacheHandler = (0, _interopdefault.interopDefault)(await dynamicImportEsmDefault(formatDynamicImportPath(this.distDir, cacheHandler)));
}
const { join } = require('node:path');
const projectDir = join(/* turbopackIgnore: true */ process.cwd(), (0, _requestmeta.getRequestMeta)(req, 'relativeProjectDir') || this.relativeProjectDir);
await this.loadCustomCacheHandlers(req, nextConfig);
// incremental-cache is request specific
// although can have shared caches in module scope
// per-cache handler
const incrementalCache = new _incrementalcache.IncrementalCache({
fs: require('../lib/node-fs-methods').nodeFs,
dev: this.isDev,
requestHeaders: req.headers,
allowedRevalidateHeaderKeys: nextConfig.experimental.allowedRevalidateHeaderKeys,
minimalMode: isMinimalMode,
serverDistDir: `${projectDir}/${this.distDir}/server`,
fetchCacheKeyPrefix: nextConfig.experimental.fetchCacheKeyPrefix,
maxMemoryCacheSize: nextConfig.cacheMaxMemorySize,
flushToDisk: !isMinimalMode && nextConfig.experimental.isrFlushToDisk,
getPrerenderManifest: ()=>prerenderManifest,
CurCacheHandler: CacheHandler
});
globalThis.__incrementalCache = incrementalCache;
return incrementalCache;
}
}
async onRequestError(req, err, errorContext, silenceLog, routerServerContext) {
if (!silenceLog) {
if (routerServerContext == null ? void 0 : routerServerContext.logErrorWithOriginalStack) {
routerServerContext.logErrorWithOriginalStack(err, 'app-dir');
} else {
console.error(err);
}
}
await this.instrumentationOnRequestError(req, err, {
path: req.url || '/',
headers: req.headers,
method: req.method || 'GET'
}, errorContext);
}
/** A more lightweight version of `prepare()` for only retrieving the config on edge */ getNextConfigEdge(req) {
var _nextConfig_experimental;
if (process.env.NEXT_RUNTIME !== 'edge') {
throw Object.defineProperty(new Error('Invariant: getNextConfigEdge must only be called in edge runtime'), "__NEXT_ERROR_CODE", {
value: "E968",
enumerable: false,
configurable: true
});
}
let serverFilesManifest = self.__SERVER_FILES_MANIFEST;
const routerServerContext = this.getRouterServerContext(req);
const nextConfig = (routerServerContext == null ? void 0 : routerServerContext.nextConfig) || (serverFilesManifest == null ? void 0 : serverFilesManifest.config);
if (!nextConfig) {
throw Object.defineProperty(new Error("Invariant: nextConfig couldn't be loaded"), "__NEXT_ERROR_CODE", {
value: "E969",
enumerable: false,
configurable: true
});
}
let deploymentId;
if ((_nextConfig_experimental = nextConfig.experimental) == null ? void 0 : _nextConfig_experimental.runtimeServerDeploymentId) {
if (!process.env.NEXT_DEPLOYMENT_ID) {
throw Object.defineProperty(new Error('process.env.NEXT_DEPLOYMENT_ID is missing but runtimeServerDeploymentId is enabled'), "__NEXT_ERROR_CODE", {
value: "E970",
enumerable: false,
configurable: true
});
}
deploymentId = process.env.NEXT_DEPLOYMENT_ID;
} else {
deploymentId = nextConfig.deploymentId || '';
}
return {
nextConfig,
deploymentId
};
}
async prepare(req, res, { srcPage, multiZoneDraftMode }) {
var _req_headers_xforwardedproto, _nextConfig_experimental;
let absoluteProjectDir;
// edge runtime handles loading instrumentation at the edge adapter level
if (process.env.NEXT_RUNTIME !== 'edge') {
if (res) {
(0, _patchsetheader.patchSetHeaderWithCookieSupport)(req, res);
}
const { join, relative } = require('node:path');
absoluteProjectDir = join(/* turbopackIgnore: true */ process.cwd(), (0, _requestmeta.getRequestMeta)(req, 'relativeProjectDir') || this.relativeProjectDir);
const absoluteDistDir = (0, _requestmeta.getRequestMeta)(req, 'distDir');
if (absoluteDistDir) {
this.distDir = relative(absoluteProjectDir, absoluteDistDir);
}
const { ensureInstrumentationRegistered } = await import('../lib/router-utils/instrumentation-globals.external.js');
// ensure instrumentation is registered and pass
// onRequestError below
ensureInstrumentationRegistered(absoluteProjectDir, this.distDir);
}
const manifests = this.loadManifests(srcPage, absoluteProjectDir);
const { routesManifest, prerenderManifest, serverFilesManifest } = manifests;
const { basePath, i18n, rewrites } = routesManifest;
const routerServerContext = this.getRouterServerContext(req);
const nextConfig = (routerServerContext == null ? void 0 : routerServerContext.nextConfig) || (serverFilesManifest == null ? void 0 : serverFilesManifest.config);
// Injected in base-server.ts
const protocol = ((_req_headers_xforwardedproto = req.headers['x-forwarded-proto']) == null ? void 0 : _req_headers_xforwardedproto.includes('https')) ? 'https' : 'http';
// When there are hostname and port we build an absolute URL
if (!(0, _requestmeta.getRequestMeta)(req, 'initURL')) {
const initUrl = (serverFilesManifest == null ? void 0 : serverFilesManifest.config.experimental.trustHostHeader) ? `${protocol}://${req.headers.host || 'localhost'}${req.url}` : `${protocol}://${(routerServerContext == null ? void 0 : routerServerContext.hostname) || 'localhost'}${req.url}`;
(0, _requestmeta.addRequestMeta)(req, 'initURL', initUrl);
(0, _requestmeta.addRequestMeta)(req, 'initProtocol', protocol);
}
if (basePath) {
req.url = (0, _removepathprefix.removePathPrefix)(req.url || '/', basePath);
}
const parsedUrl = (0, _url.parseReqUrl)(req.url || '/');
(0, _requestmeta.addRequestMeta)(req, 'initQuery', {
...parsedUrl == null ? void 0 : parsedUrl.query
});
// if we couldn't parse the URL we can't continue
if (!parsedUrl) {
return;
}
let isNextDataRequest = false;
if ((0, _pathhasprefix.pathHasPrefix)(parsedUrl.pathname || '/', '/_next/data')) {
isNextDataRequest = true;
parsedUrl.pathname = (0, _normalizedatapath.normalizeDataPath)(parsedUrl.pathname || '/');
}
this.normalizeUrl(req, parsedUrl);
let originalPathname = parsedUrl.pathname || '/';
const originalQuery = {
...parsedUrl.query
};
const pageIsDynamic = (0, _utils.isDynamicRoute)(srcPage);
let localeResult;
let detectedLocale;
if (i18n) {
localeResult = (0, _normalizelocalepath.normalizeLocalePath)(parsedUrl.pathname || '/', i18n.locales);
if (localeResult.detectedLocale) {
req.url = `${localeResult.pathname}${parsedUrl.search}`;
originalPathname = localeResult.pathname;
if (!detectedLocale) {
detectedLocale = localeResult.detectedLocale;
}
}
}
// Normalize the page path for route matching. The srcPage contains the
// internal page path (e.g., /app/[slug]/page), but route matchers expect
// the pathname format (e.g., /app/[slug]).
const normalizedSrcPage = (0, _apppaths.normalizeAppPath)(srcPage);
const serverUtils = (0, _serverutils.getServerUtils)({
page: normalizedSrcPage,
i18n,
basePath,
rewrites,
pageIsDynamic,
trailingSlash: process.env.__NEXT_TRAILING_SLASH,
caseSensitive: Boolean(routesManifest.caseSensitive)
});
const domainLocale = (0, _detectdomainlocale.detectDomainLocale)(i18n == null ? void 0 : i18n.domains, (0, _gethostname.getHostname)(parsedUrl, req.headers), detectedLocale);
if (Boolean(domainLocale)) {
(0, _requestmeta.addRequestMeta)(req, 'isLocaleDomain', Boolean(domainLocale));
}
const defaultLocale = (0, _requestmeta.getRequestMeta)(req, 'defaultLocale') || (domainLocale == null ? void 0 : domainLocale.defaultLocale) || (i18n == null ? void 0 : i18n.defaultLocale);
// Ensure parsedUrl.pathname includes locale before processing
// rewrites or they won't match correctly.
if (defaultLocale && !detectedLocale) {
parsedUrl.pathname = `/${defaultLocale}${parsedUrl.pathname === '/' ? '' : parsedUrl.pathname}`;
}
const locale = (0, _requestmeta.getRequestMeta)(req, 'locale') || detectedLocale || defaultLocale;
// we apply rewrites against cloned URL so that we don't
// modify the original with the rewrite destination
const { rewriteParams, rewrittenParsedUrl } = serverUtils.handleRewrites(req, parsedUrl);
const rewriteParamKeys = Object.keys(rewriteParams);
Object.assign(parsedUrl.query, rewrittenParsedUrl.query);
// after processing rewrites we want to remove locale
// from parsedUrl pathname
if (i18n) {
parsedUrl.pathname = (0, _normalizelocalepath.normalizeLocalePath)(parsedUrl.pathname || '/', i18n.locales).pathname;
rewrittenParsedUrl.pathname = (0, _normalizelocalepath.normalizeLocalePath)(rewrittenParsedUrl.pathname || '/', i18n.locales).pathname;
}
let params = (0, _requestmeta.getRequestMeta)(req, 'params');
// attempt parsing from pathname
if (!params && serverUtils.dynamicRouteMatcher) {
const paramsMatch = serverUtils.dynamicRouteMatcher((0, _normalizedatapath.normalizeDataPath)((rewrittenParsedUrl == null ? void 0 : rewrittenParsedUrl.pathname) || parsedUrl.pathname || '/'));
const paramsResult = serverUtils.normalizeDynamicRouteParams(paramsMatch || {}, true);
if (paramsResult.hasValidParams) {
params = paramsResult.params;
}
}
// Local "next start" expects the routing parsed query values
// to not be present in the URL although when deployed proxies
// will add query values from resolving the routes to pass to function.
// TODO: do we want to change expectations for "next start"
// to include these query values in the URL which affects asPath
// but would match deployed behavior, e.g. a rewrite from middleware
// that adds a query param would be in asPath as query but locally
// it won't be in the asPath but still available in the query object
const query = (0, _requestmeta.getRequestMeta)(req, 'query') || {
...parsedUrl.query
};
const routeParamKeys = new Set();
const combinedParamKeys = [];
// We don't include rewriteParamKeys in the combinedParamKeys
// for app router since the searchParams is populated from the
// URL so we don't want to strip the rewrite params from the URL
// so that searchParams can include them.
if (this.definition.kind === _routekind.RouteKind.PAGES || this.definition.kind === _routekind.RouteKind.PAGES_API) {
for (const key of [
...rewriteParamKeys,
...Object.keys(serverUtils.defaultRouteMatches || {})
]){
// We only want to filter rewrite param keys from the URL
// if they are matches from the URL e.g. the key/value matches
// before and after applying the rewrites /:path for /hello and
// { path: 'hello' } but not for { path: 'another' } and /hello
// TODO: we should prefix rewrite param keys the same as we do
// for dynamic routes so we can identify them properly
const originalValue = Array.isArray(originalQuery[key]) ? originalQuery[key].join('') : originalQuery[key];
const queryValue = Array.isArray(query[key]) ? query[key].join('') : query[key];
if (!(key in originalQuery) || originalValue === queryValue) {
combinedParamKeys.push(key);
}
}
}
serverUtils.normalizeCdnUrl(req, combinedParamKeys);
// When Next is not hosted in a single process, upstream proxies will add query values for route params that were used to match the route.
// Outside of that environment, there is no reason to do any normalization to honor those query values.
if (!(routerServerContext == null ? void 0 : routerServerContext.isWrappedByNextServer)) {
serverUtils.normalizeQueryParams(query, routeParamKeys);
} else {
serverUtils.filterInternalQuery(query, []);
}
serverUtils.filterInternalQuery(originalQuery, combinedParamKeys);
if (pageIsDynamic) {
const queryResult = serverUtils.normalizeDynamicRouteParams(query, true);
const paramsResult = serverUtils.normalizeDynamicRouteParams(params || {}, true);
let paramsToInterpolate;
if (// if both query and params are valid but one
// provided more information and the query params
// were nxtP prefixed rely on that one
query && params && paramsResult.hasValidParams && queryResult.hasValidParams && routeParamKeys.size > 0 && Object.keys(paramsResult.params).length <= Object.keys(queryResult.params).length) {
paramsToInterpolate = queryResult.params;
params = Object.assign(queryResult.params);
} else {
paramsToInterpolate = paramsResult.hasValidParams && params ? params : queryResult.hasValidParams ? query : {};
}
req.url = serverUtils.interpolateDynamicPath(req.url || '/', paramsToInterpolate);
parsedUrl.pathname = serverUtils.interpolateDynamicPath(parsedUrl.pathname || '/', paramsToInterpolate);
originalPathname = serverUtils.interpolateDynamicPath(originalPathname, paramsToInterpolate);
// try pulling from query if valid
if (!params) {
if (queryResult.hasValidParams) {
params = Object.assign({}, queryResult.params);
// If we pulled from query remove it so it's
// only in params
for(const key in serverUtils.defaultRouteMatches){
delete query[key];
}
} else {
// use final params from URL matching
const paramsMatch = serverUtils.dynamicRouteMatcher == null ? void 0 : serverUtils.dynamicRouteMatcher.call(serverUtils, (0, _normalizedatapath.normalizeDataPath)((localeResult == null ? void 0 : localeResult.pathname) || parsedUrl.pathname || '/'));
// we don't normalize these as they are allowed to be
// the literal slug matches here e.g. /blog/[slug]
// actually being requested
if (paramsMatch) {
params = Object.assign({}, paramsMatch);
}
}
}
}
// Remove any normalized params from the query if they
// weren't present as non-prefixed query key e.g.
// ?search=1&nxtPsearch=hello we don't delete search
for (const key of routeParamKeys){
if (!(key in originalQuery)) {
delete query[key];
// handle the case where there's collision and we
// normalized nxtPid=123 -> id=123 but user also
// sends id=456 as separate key
} else if (originalQuery[key] && query[key] && originalQuery[key] !== query[key]) {
query[key] = originalQuery[key];
}
}
const { isOnDemandRevalidate, revalidateOnlyGenerated } = (0, _apiutils.checkIsOnDemandRevalidate)(req, prerenderManifest.preview);
let isDraftMode = false;
let previewData;
// preview data relies on non-edge utils
if (process.env.NEXT_RUNTIME !== 'edge' && res) {
const { tryGetPreviewData } = require('../api-utils/node/try-get-preview-data');
previewData = tryGetPreviewData(req, res, prerenderManifest.preview, Boolean(multiZoneDraftMode));
isDraftMode = previewData !== false;
}
if (!nextConfig) {
throw Object.defineProperty(new Error("Invariant: nextConfig couldn't be loaded"), "__NEXT_ERROR_CODE", {
value: "E969",
enumerable: false,
configurable: true
});
}
if (process.env.NEXT_RUNTIME !== 'edge') {
const { installProcessErrorHandlers } = require('../node-environment-extensions/process-error-handlers');
installProcessErrorHandlers(Boolean(nextConfig.experimental.removeUncaughtErrorAndRejectionListeners));
}
let resolvedPathname = normalizedSrcPage;
if ((0, _utils.isDynamicRoute)(resolvedPathname) && params) {
resolvedPathname = serverUtils.interpolateDynamicPath(resolvedPathname, params);
}
if (resolvedPathname === '/index') {
resolvedPathname = '/';
}
if (res && Boolean(req.headers['x-nextjs-data']) && (!res.statusCode || res.statusCode === 200)) {
res.setHeader('x-nextjs-matched-path', (0, _removetrailingslash.removeTrailingSlash)(`${locale ? `/${locale}` : ''}${normalizedSrcPage}`));
}
const encodedResolvedPathname = resolvedPathname;
// we decode for cache key/manifest usage encoded is
// for URL building
try {
resolvedPathname = (0, _decodepathparams.decodePathParams)(resolvedPathname);
} catch (_) {}
resolvedPathname = (0, _removetrailingslash.removeTrailingSlash)(resolvedPathname);
(0, _requestmeta.addRequestMeta)(req, 'resolvedPathname', resolvedPathname);
let deploymentId;
if ((_nextConfig_experimental = nextConfig.experimental) == null ? void 0 : _nextConfig_experimental.runtimeServerDeploymentId) {
if (!process.env.NEXT_DEPLOYMENT_ID) {
throw Object.defineProperty(new Error('process.env.NEXT_DEPLOYMENT_ID is missing but runtimeServerDeploymentId is enabled'), "__NEXT_ERROR_CODE", {
value: "E970",
enumerable: false,
configurable: true
});
}
deploymentId = process.env.NEXT_DEPLOYMENT_ID;
} else {
deploymentId = nextConfig.deploymentId || '';
}
return {
query,
originalQuery,
originalPathname,
params,
parsedUrl,
locale,
isNextDataRequest,
locales: i18n == null ? void 0 : i18n.locales,
defaultLocale,
isDraftMode,
previewData,
pageIsDynamic,
resolvedPathname,
encodedResolvedPathname,
isOnDemandRevalidate,
revalidateOnlyGenerated,
...manifests,
// loadManifest returns a readonly object, but we don't want to propagate that throughout the
// whole codebase (for now)
nextConfig: nextConfig,
routerServerContext,
deploymentId,
clientAssetToken: nextConfig.experimental.immutableAssetToken || deploymentId
};
}
getResponseCache(req) {
if (!this.responseCache) {
const minimalMode = (0, _requestmeta.getRequestMeta)(req, 'minimalMode') ?? false;
this.responseCache = new _responsecache.default(minimalMode);
}
return this.responseCache;
}
async handleResponse({ req, nextConfig, cacheKey, routeKind, isFallback, prerenderManifest, isRoutePPREnabled, isOnDemandRevalidate, revalidateOnlyGenerated, responseGenerator, waitUntil, isMinimalMode }) {
const responseCache = this.getResponseCache(req);
const cacheEntry = await responseCache.get(cacheKey, responseGenerator, {
routeKind,
isFallback,
isRoutePPREnabled,
isOnDemandRevalidate,
isPrefetch: req.headers.purpose === 'prefetch',
// Use x-invocation-id header to scope the in-memory cache to a single
// revalidation request in minimal mode.
invocationID: req.headers['x-invocation-id'],
incrementalCache: await this.getIncrementalCache(req, nextConfig, prerenderManifest, isMinimalMode),
waitUntil
});
if (!cacheEntry) {
if (cacheKey && // revalidate only generated can bail even if cacheKey is provided
!(isOnDemandRevalidate && revalidateOnlyGenerated)) {
// A cache entry might not be generated if a response is written
// in `getInitialProps` or `getServerSideProps`, but those shouldn't
// have a cache key. If we do have a cache key but we don't end up
// with a cache entry, then either Next.js or the application has a
// bug that needs fixing.
throw Object.defineProperty(new Error('invariant: cache entry required but not generated'), "__NEXT_ERROR_CODE", {
value: "E62",
enumerable: false,
configurable: true
});
}
}
return cacheEntry;
}
}
//# sourceMappingURL=route-module.js.map