.
This commit is contained in:
Generated
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
import { getRouteMatcher } from '../../../../shared/lib/router/utils/route-matcher';
|
||||
import { getRouteRegex } from '../../../../shared/lib/router/utils/route-regex';
|
||||
/**
|
||||
* A matcher for the prerender manifest.
|
||||
*
|
||||
* This class is used to match the pathname to the dynamic route.
|
||||
*/ export 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 = getRouteMatcher(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
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-modules/app-page/helpers/prerender-manifest-matcher.ts"],"sourcesContent":["import type {\n DynamicPrerenderManifestRoute,\n PrerenderManifest,\n} from '../../../../build'\nimport type { DeepReadonly } from '../../../../shared/lib/deep-readonly'\nimport {\n getRouteMatcher,\n type RouteMatchFn,\n} from '../../../../shared/lib/router/utils/route-matcher'\nimport { getRouteRegex } from '../../../../shared/lib/router/utils/route-regex'\n\n/**\n * A matcher for a dynamic route.\n */\ntype Matcher = {\n /**\n * The matcher for the dynamic route. This is lazily created when the matcher\n * is first used.\n */\n matcher?: RouteMatchFn\n\n /**\n * The source of the dynamic route.\n */\n source: string\n\n /**\n * The route that matches the source.\n */\n route: DeepReadonly<DynamicPrerenderManifestRoute>\n}\n\nexport type PrerenderManifestMatch = {\n source: string\n route: DeepReadonly<DynamicPrerenderManifestRoute>\n}\n\n/**\n * A matcher for the prerender manifest.\n *\n * This class is used to match the pathname to the dynamic route.\n */\nexport class PrerenderManifestMatcher {\n private readonly matchers: Array<Matcher>\n constructor(\n pathname: string,\n prerenderManifest: DeepReadonly<PrerenderManifest>\n ) {\n this.matchers = Object.entries(prerenderManifest.dynamicRoutes)\n .filter(([source, route]) => {\n // If the pathname is a fallback source route, or the source route is\n // the same as the pathname, then we should include it in the matchers.\n return route.fallbackSourceRoute === pathname || source === pathname\n })\n .map(([source, route]) => ({ source, route }))\n }\n\n /**\n * Match the pathname to the dynamic route. If no match is found, an error is\n * thrown.\n *\n * @param pathname - The pathname to match.\n * @returns The dynamic route that matches the pathname.\n */\n public match(pathname: string): PrerenderManifestMatch | null {\n // Iterate over the matchers. They're already in the correct order of\n // specificity as they were inserted into the prerender manifest that way\n // and iterating over them with Object.entries guarantees that.\n for (const matcher of this.matchers) {\n // Lazily create the matcher, this is only done once per matcher.\n if (!matcher.matcher) {\n matcher.matcher = getRouteMatcher(getRouteRegex(matcher.source))\n }\n\n const match = matcher.matcher(pathname)\n if (match) {\n return {\n source: matcher.source,\n route: matcher.route,\n }\n }\n }\n\n return null\n }\n}\n"],"names":["getRouteMatcher","getRouteRegex","PrerenderManifestMatcher","constructor","pathname","prerenderManifest","matchers","Object","entries","dynamicRoutes","filter","source","route","fallbackSourceRoute","map","match","matcher"],"mappings":"AAKA,SACEA,eAAe,QAEV,oDAAmD;AAC1D,SAASC,aAAa,QAAQ,kDAAiD;AA4B/E;;;;CAIC,GACD,OAAO,MAAMC;IAEXC,YACEC,QAAgB,EAChBC,iBAAkD,CAClD;QACA,IAAI,CAACC,QAAQ,GAAGC,OAAOC,OAAO,CAACH,kBAAkBI,aAAa,EAC3DC,MAAM,CAAC,CAAC,CAACC,QAAQC,MAAM;YACtB,qEAAqE;YACrE,uEAAuE;YACvE,OAAOA,MAAMC,mBAAmB,KAAKT,YAAYO,WAAWP;QAC9D,GACCU,GAAG,CAAC,CAAC,CAACH,QAAQC,MAAM,GAAM,CAAA;gBAAED;gBAAQC;YAAM,CAAA;IAC/C;IAEA;;;;;;GAMC,GACD,AAAOG,MAAMX,QAAgB,EAAiC;QAC5D,qEAAqE;QACrE,yEAAyE;QACzE,+DAA+D;QAC/D,KAAK,MAAMY,WAAW,IAAI,CAACV,QAAQ,CAAE;YACnC,iEAAiE;YACjE,IAAI,CAACU,QAAQA,OAAO,EAAE;gBACpBA,QAAQA,OAAO,GAAGhB,gBAAgBC,cAAce,QAAQL,MAAM;YAChE;YAEA,MAAMI,QAAQC,QAAQA,OAAO,CAACZ;YAC9B,IAAIW,OAAO;gBACT,OAAO;oBACLJ,QAAQK,QAAQL,MAAM;oBACtBC,OAAOI,QAAQJ,KAAK;gBACtB;YACF;QACF;QAEA,OAAO;IACT;AACF","ignoreList":[0]}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './module'
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
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
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/app-page/module.compiled.js"],"sourcesContent":["if (process.env.NEXT_RUNTIME === 'edge') {\n module.exports = require('next/dist/server/route-modules/app-page/module.js')\n} else {\n if (process.env.__NEXT_EXPERIMENTAL_REACT) {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-page-turbo-experimental.runtime.dev.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-page-experimental.runtime.dev.js')\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-page-experimental.runtime.prod.js')\n }\n }\n } else {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-page-turbo.runtime.dev.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-page.runtime.dev.js')\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-page-turbo.runtime.prod.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-page.runtime.prod.js')\n }\n }\n }\n}\n"],"names":["process","env","NEXT_RUNTIME","module","exports","require","__NEXT_EXPERIMENTAL_REACT","NODE_ENV","TURBOPACK"],"mappings":"AAAA,IAAIA,QAAQC,GAAG,CAACC,YAAY,KAAK,QAAQ;IACvCC,OAAOC,OAAO,GAAGC,QAAQ;AAC3B,OAAO;IACL,IAAIL,QAAQC,GAAG,CAACK,yBAAyB,EAAE;QACzC,IAAIN,QAAQC,GAAG,CAACM,QAAQ,KAAK,eAAe;YAC1C,IAAIP,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF,OAAO;YACL,IAAIL,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF;IACF,OAAO;QACL,IAAIL,QAAQC,GAAG,CAACM,QAAQ,KAAK,eAAe;YAC1C,IAAIP,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF,OAAO;YACL,IAAIL,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF;IACF;AACF","ignoreList":[0]}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
import { addRequestMeta } from '../../request-meta';
|
||||
import { renderToHTMLOrFlight } from '../../app-render/app-render';
|
||||
import { RouteModule } from '../route-module';
|
||||
import * as vendoredContexts from './vendored/contexts/entrypoints';
|
||||
import { PrerenderManifestMatcher } from './helpers/prerender-manifest-matcher';
|
||||
import { NEXT_ROUTER_PREFETCH_HEADER, NEXT_ROUTER_SEGMENT_PREFETCH_HEADER, NEXT_ROUTER_STATE_TREE_HEADER, NEXT_URL, RSC_HEADER } from '../../../client/components/app-router-headers';
|
||||
import { isInterceptionRouteAppPath } from '../../../shared/lib/router/utils/interception-routes';
|
||||
import { RSCPathnameNormalizer } from '../../normalizers/request/rsc';
|
||||
import { SegmentPrefixRSCPathnameNormalizer } from '../../normalizers/request/segment-prefix-rsc';
|
||||
import { normalizeAppPageRequestUrl } from './normalize-request-url';
|
||||
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);
|
||||
}
|
||||
export class AppPageRouteModule extends 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(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[RSC_HEADER] = '1';
|
||||
req.headers[NEXT_ROUTER_PREFETCH_HEADER] = '1';
|
||||
req.headers[NEXT_ROUTER_SEGMENT_PREFETCH_HEADER] = segmentPath;
|
||||
addRequestMeta(req, 'isRSCRequest', true);
|
||||
addRequestMeta(req, 'isPrefetchRSCRequest', true);
|
||||
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[RSC_HEADER] = '1';
|
||||
addRequestMeta(req, 'isRSCRequest', true);
|
||||
} else {
|
||||
super.normalizeUrl(req, parsedUrl);
|
||||
}
|
||||
normalizeAppPageRequestUrl(req, parsedUrl.pathname || '/');
|
||||
}
|
||||
render(req, res, context) {
|
||||
return renderToHTMLOrFlight(req, res, context.page, context.query, context.fallbackRouteParams, context.renderOpts, context.serverComponentsHmrCache, context.sharedContext);
|
||||
}
|
||||
pathCouldBeIntercepted(resolvedPathname, interceptionRoutePatterns) {
|
||||
return isInterceptionRouteAppPath(resolvedPathname) || interceptionRoutePatterns.some((regexp)=>{
|
||||
return regexp.test(resolvedPathname);
|
||||
});
|
||||
}
|
||||
getVaryHeader(resolvedPathname, interceptionRoutePatterns) {
|
||||
const baseVaryHeader = `${RSC_HEADER}, ${NEXT_ROUTER_STATE_TREE_HEADER}, ${NEXT_ROUTER_PREFETCH_HEADER}, ${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}, ${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 RSCPathnameNormalizer(),
|
||||
segmentPrefetchRSC: new SegmentPrefixRSCPathnameNormalizer()
|
||||
};
|
||||
}
|
||||
}
|
||||
const vendored = {
|
||||
'react-rsc': vendoredReactRSC,
|
||||
'react-ssr': vendoredReactSSR,
|
||||
contexts: vendoredContexts
|
||||
};
|
||||
export { renderToHTMLOrFlight, vendored };
|
||||
export default AppPageRouteModule;
|
||||
|
||||
//# sourceMappingURL=module.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+14
@@ -0,0 +1,14 @@
|
||||
export 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
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/app-page/module.render.ts"],"sourcesContent":["import type { AppPageRender } from '../../app-render/app-render'\n\nexport const lazyRenderAppPage: AppPageRender = (...args) => {\n if (process.env.NEXT_MINIMAL) {\n throw new Error(\"Can't use lazyRenderAppPage in minimal mode\")\n } else {\n const render: AppPageRender = (\n require('./module.compiled') as typeof import('./module.compiled')\n ).renderToHTMLOrFlight\n\n return render(...args)\n }\n}\n"],"names":["lazyRenderAppPage","args","process","env","NEXT_MINIMAL","Error","render","require","renderToHTMLOrFlight"],"mappings":"AAEA,OAAO,MAAMA,oBAAmC,CAAC,GAAGC;IAClD,IAAIC,QAAQC,GAAG,CAACC,YAAY,EAAE;QAC5B,MAAM,qBAAwD,CAAxD,IAAIC,MAAM,gDAAV,qBAAA;mBAAA;wBAAA;0BAAA;QAAuD;IAC/D,OAAO;QACL,MAAMC,SAAwB,AAC5BC,QAAQ,qBACRC,oBAAoB;QAEtB,OAAOF,UAAUL;IACnB;AACF,EAAC","ignoreList":[0]}
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import { parseReqUrl } from '../../../lib/url';
|
||||
import { formatUrl } from '../../../shared/lib/router/utils/format-url';
|
||||
export function normalizeAppPageRequestUrl(req, pathname) {
|
||||
if (!req.url) {
|
||||
return;
|
||||
}
|
||||
const normalizedUrl = parseReqUrl(req.url);
|
||||
if (!normalizedUrl) {
|
||||
return;
|
||||
}
|
||||
normalizedUrl.pathname = pathname;
|
||||
req.url = formatUrl(normalizedUrl);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=normalize-request-url.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/app-page/normalize-request-url.ts"],"sourcesContent":["import type { IncomingMessage } from 'http'\n\nimport type { BaseNextRequest } from '../../base-http'\nimport { parseReqUrl } from '../../../lib/url'\nimport { formatUrl } from '../../../shared/lib/router/utils/format-url'\n\nexport function normalizeAppPageRequestUrl(\n req: Pick<IncomingMessage | BaseNextRequest, 'url'>,\n pathname: string\n) {\n if (!req.url) {\n return\n }\n\n const normalizedUrl = parseReqUrl(req.url)\n if (!normalizedUrl) {\n return\n }\n\n normalizedUrl.pathname = pathname\n req.url = formatUrl(normalizedUrl)\n}\n"],"names":["parseReqUrl","formatUrl","normalizeAppPageRequestUrl","req","pathname","url","normalizedUrl"],"mappings":"AAGA,SAASA,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,SAAS,QAAQ,8CAA6C;AAEvE,OAAO,SAASC,2BACdC,GAAmD,EACnDC,QAAgB;IAEhB,IAAI,CAACD,IAAIE,GAAG,EAAE;QACZ;IACF;IAEA,MAAMC,gBAAgBN,YAAYG,IAAIE,GAAG;IACzC,IAAI,CAACC,eAAe;QAClB;IACF;IAEAA,cAAcF,QAAQ,GAAGA;IACzBD,IAAIE,GAAG,GAAGJ,UAAUK;AACtB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['contexts'].AppRouterContext;
|
||||
|
||||
//# sourceMappingURL=app-router-context.js.map
|
||||
node_modules/next/dist/esm/server/route-modules/app-page/vendored/contexts/app-router-context.js.map
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/contexts/app-router-context.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['contexts'].AppRouterContext\n"],"names":["module","exports","require","vendored","AppRouterContext"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,WAAW,CAACC,gBAAgB","ignoreList":[0]}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
export * as HeadManagerContext from '../../../../../shared/lib/head-manager-context.shared-runtime';
|
||||
export * as ServerInsertedHtml from '../../../../../shared/lib/server-inserted-html.shared-runtime';
|
||||
export * as AppRouterContext from '../../../../../shared/lib/app-router-context.shared-runtime';
|
||||
export * as HooksClientContext from '../../../../../shared/lib/hooks-client-context.shared-runtime';
|
||||
export * as RouterContext from '../../../../../shared/lib/router-context.shared-runtime';
|
||||
export * as ImageConfigContext from '../../../../../shared/lib/image-config-context.shared-runtime';
|
||||
|
||||
//# sourceMappingURL=entrypoints.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/contexts/entrypoints.ts"],"sourcesContent":["export * as HeadManagerContext from '../../../../../shared/lib/head-manager-context.shared-runtime'\nexport * as ServerInsertedHtml from '../../../../../shared/lib/server-inserted-html.shared-runtime'\nexport * as AppRouterContext from '../../../../../shared/lib/app-router-context.shared-runtime'\nexport * as HooksClientContext from '../../../../../shared/lib/hooks-client-context.shared-runtime'\nexport * as RouterContext from '../../../../../shared/lib/router-context.shared-runtime'\nexport * as ImageConfigContext from '../../../../../shared/lib/image-config-context.shared-runtime'\n"],"names":["HeadManagerContext","ServerInsertedHtml","AppRouterContext","HooksClientContext","RouterContext","ImageConfigContext"],"mappings":"AAAA,OAAO,KAAKA,kBAAkB,MAAM,gEAA+D;AACnG,OAAO,KAAKC,kBAAkB,MAAM,gEAA+D;AACnG,OAAO,KAAKC,gBAAgB,MAAM,8DAA6D;AAC/F,OAAO,KAAKC,kBAAkB,MAAM,gEAA+D;AACnG,OAAO,KAAKC,aAAa,MAAM,0DAAyD;AACxF,OAAO,KAAKC,kBAAkB,MAAM,gEAA+D","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['contexts'].HeadManagerContext;
|
||||
|
||||
//# sourceMappingURL=head-manager-context.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/contexts/head-manager-context.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['contexts'].HeadManagerContext\n"],"names":["module","exports","require","vendored","HeadManagerContext"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,WAAW,CAACC,kBAAkB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['contexts'].HooksClientContext;
|
||||
|
||||
//# sourceMappingURL=hooks-client-context.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/contexts/hooks-client-context.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['contexts'].HooksClientContext\n"],"names":["module","exports","require","vendored","HooksClientContext"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,WAAW,CAACC,kBAAkB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['contexts'].ImageConfigContext;
|
||||
|
||||
//# sourceMappingURL=image-config-context.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/contexts/image-config-context.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['contexts'].ImageConfigContext\n"],"names":["module","exports","require","vendored","ImageConfigContext"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,WAAW,CAACC,kBAAkB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['contexts'].RouterContext;
|
||||
|
||||
//# sourceMappingURL=router-context.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/contexts/router-context.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['contexts'].RouterContext\n"],"names":["module","exports","require","vendored","RouterContext"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,WAAW,CAACC,aAAa","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['contexts'].ServerInsertedHtml;
|
||||
|
||||
//# sourceMappingURL=server-inserted-html.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/contexts/server-inserted-html.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['contexts'].ServerInsertedHtml\n"],"names":["module","exports","require","vendored","ServerInsertedHtml"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,WAAW,CAACC,kBAAkB","ignoreList":[0]}
|
||||
Generated
Vendored
+50
@@ -0,0 +1,50 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as ReactJsxDevRuntime from 'react/jsx-dev-runtime';
|
||||
import * as ReactJsxRuntime from 'react/jsx-runtime';
|
||||
import * as ReactCompilerRuntime from 'react/compiler-runtime';
|
||||
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');
|
||||
}
|
||||
}
|
||||
export { React, ReactJsxDevRuntime, ReactJsxRuntime, ReactCompilerRuntime, ReactDOM, ReactServerDOMTurbopackServer, ReactServerDOMTurbopackStatic, ReactServerDOMWebpackServer, ReactServerDOMWebpackStatic, };
|
||||
|
||||
//# sourceMappingURL=entrypoints.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/entrypoints.ts"],"sourcesContent":["import * as React from 'react'\nimport * as ReactDOM from 'react-dom'\nimport * as ReactJsxDevRuntime from 'react/jsx-dev-runtime'\nimport * as ReactJsxRuntime from 'react/jsx-runtime'\nimport * as ReactCompilerRuntime from 'react/compiler-runtime'\n\nfunction getAltProxyForBindingsDEV(\n type: 'Turbopack' | 'Webpack',\n pkg:\n | 'react-server-dom-turbopack/server'\n | 'react-server-dom-turbopack/static'\n | 'react-server-dom-webpack/server'\n | 'react-server-dom-webpack/static'\n) {\n if (process.env.NODE_ENV === 'development') {\n const altType = type === 'Turbopack' ? 'Webpack' : 'Turbopack'\n const altPkg = pkg.replace(new RegExp(type, 'gi'), altType.toLowerCase())\n\n return new Proxy(\n {},\n {\n get(_, prop: string) {\n throw new Error(\n `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.`\n )\n },\n }\n )\n }\n}\n\nlet ReactServerDOMTurbopackServer, ReactServerDOMWebpackServer\nlet ReactServerDOMTurbopackStatic, ReactServerDOMWebpackStatic\n\nif (process.env.TURBOPACK) {\n ReactServerDOMTurbopackServer =\n // @ts-expect-error -- TODO: Add types\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('react-server-dom-turbopack/server') as typeof import('react-server-dom-turbopack/server')\n if (process.env.NODE_ENV === 'development') {\n ReactServerDOMWebpackServer = getAltProxyForBindingsDEV(\n 'Turbopack',\n 'react-server-dom-turbopack/server'\n )\n }\n ReactServerDOMTurbopackStatic =\n // @ts-expect-error -- TODO: Add types\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('react-server-dom-turbopack/static') as typeof import('react-server-dom-turbopack/static')\n if (process.env.NODE_ENV === 'development') {\n ReactServerDOMWebpackStatic = getAltProxyForBindingsDEV(\n 'Turbopack',\n 'react-server-dom-turbopack/static'\n )\n }\n} else {\n ReactServerDOMWebpackServer =\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('react-server-dom-webpack/server') as typeof import('react-server-dom-webpack/server')\n if (process.env.NODE_ENV === 'development') {\n ReactServerDOMTurbopackServer = getAltProxyForBindingsDEV(\n 'Webpack',\n 'react-server-dom-webpack/server'\n )\n }\n ReactServerDOMWebpackStatic =\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('react-server-dom-webpack/static') as typeof import('react-server-dom-webpack/static')\n if (process.env.NODE_ENV === 'development') {\n ReactServerDOMTurbopackStatic = getAltProxyForBindingsDEV(\n 'Webpack',\n 'react-server-dom-webpack/static'\n )\n }\n}\n\nexport {\n React,\n ReactJsxDevRuntime,\n ReactJsxRuntime,\n ReactCompilerRuntime,\n ReactDOM,\n ReactServerDOMTurbopackServer,\n ReactServerDOMTurbopackStatic,\n ReactServerDOMWebpackServer,\n ReactServerDOMWebpackStatic,\n}\n"],"names":["React","ReactDOM","ReactJsxDevRuntime","ReactJsxRuntime","ReactCompilerRuntime","getAltProxyForBindingsDEV","type","pkg","process","env","NODE_ENV","altType","altPkg","replace","RegExp","toLowerCase","Proxy","get","_","prop","Error","ReactServerDOMTurbopackServer","ReactServerDOMWebpackServer","ReactServerDOMTurbopackStatic","ReactServerDOMWebpackStatic","TURBOPACK","require"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAC9B,YAAYC,cAAc,YAAW;AACrC,YAAYC,wBAAwB,wBAAuB;AAC3D,YAAYC,qBAAqB,oBAAmB;AACpD,YAAYC,0BAA0B,yBAAwB;AAE9D,SAASC,0BACPC,IAA6B,EAC7BC,GAIqC;IAErC,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,MAAMC,UAAUL,SAAS,cAAc,YAAY;QACnD,MAAMM,SAASL,IAAIM,OAAO,CAAC,IAAIC,OAAOR,MAAM,OAAOK,QAAQI,WAAW;QAEtE,OAAO,IAAIC,MACT,CAAC,GACD;YACEC,KAAIC,CAAC,EAAEC,IAAY;gBACjB,MAAM,qBAEL,CAFK,IAAIC,MACR,CAAC,gBAAgB,EAAEd,KAAK,WAAW,EAAEC,IAAI,oDAAoD,EAAEY,KAAK,WAAW,EAAER,QAAQ,WAAW,EAAEC,OAAO,yEAAyE,CAAC,GADnN,qBAAA;2BAAA;gCAAA;kCAAA;gBAEN;YACF;QACF;IAEJ;AACF;AAEA,IAAIS,+BAA+BC;AACnC,IAAIC,+BAA+BC;AAEnC,IAAIhB,QAAQC,GAAG,CAACgB,SAAS,EAAE;IACzBJ,gCACE,sCAAsC;IACtC,6DAA6D;IAC7DK,QAAQ;IACV,IAAIlB,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1CY,8BAA8BjB,0BAC5B,aACA;IAEJ;IACAkB,gCACE,sCAAsC;IACtC,6DAA6D;IAC7DG,QAAQ;IACV,IAAIlB,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1Cc,8BAA8BnB,0BAC5B,aACA;IAEJ;AACF,OAAO;IACLiB,8BACE,6DAA6D;IAC7DI,QAAQ;IACV,IAAIlB,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1CW,gCAAgChB,0BAC9B,WACA;IAEJ;IACAmB,8BACE,6DAA6D;IAC7DE,QAAQ;IACV,IAAIlB,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1Ca,gCAAgClB,0BAC9B,WACA;IAEJ;AACF;AAEA,SACEL,KAAK,EACLE,kBAAkB,EAClBC,eAAe,EACfC,oBAAoB,EACpBH,QAAQ,EACRoB,6BAA6B,EAC7BE,6BAA6B,EAC7BD,2BAA2B,EAC3BE,2BAA2B,KAC5B","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactCompilerRuntime;
|
||||
|
||||
//# sourceMappingURL=react-compiler-runtime.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-compiler-runtime.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactCompilerRuntime\n"],"names":["module","exports","require","vendored","ReactCompilerRuntime"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,oBAAoB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactDOM;
|
||||
|
||||
//# sourceMappingURL=react-dom.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-dom.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactDOM\n"],"names":["module","exports","require","vendored","ReactDOM"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,QAAQ","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactJsxDevRuntime;
|
||||
|
||||
//# sourceMappingURL=react-jsx-dev-runtime.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-jsx-dev-runtime.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactJsxDevRuntime\n"],"names":["module","exports","require","vendored","ReactJsxDevRuntime"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,kBAAkB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactJsxRuntime;
|
||||
|
||||
//# sourceMappingURL=react-jsx-runtime.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-jsx-runtime.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactJsxRuntime\n"],"names":["module","exports","require","vendored","ReactJsxRuntime"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,eAAe","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMTurbopackServer;
|
||||
|
||||
//# sourceMappingURL=react-server-dom-turbopack-server.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-server.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactServerDOMTurbopackServer\n"],"names":["module","exports","require","vendored","ReactServerDOMTurbopackServer"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,6BAA6B","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMTurbopackStatic;
|
||||
|
||||
//# sourceMappingURL=react-server-dom-turbopack-static.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-server-dom-turbopack-static.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactServerDOMTurbopackStatic\n"],"names":["module","exports","require","vendored","ReactServerDOMTurbopackStatic"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,6BAA6B","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMWebpackServer;
|
||||
|
||||
//# sourceMappingURL=react-server-dom-webpack-server.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-server-dom-webpack-server.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactServerDOMWebpackServer\n"],"names":["module","exports","require","vendored","ReactServerDOMWebpackServer"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,2BAA2B","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].ReactServerDOMWebpackStatic;
|
||||
|
||||
//# sourceMappingURL=react-server-dom-webpack-static.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react-server-dom-webpack-static.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.ReactServerDOMWebpackStatic\n"],"names":["module","exports","require","vendored","ReactServerDOMWebpackStatic"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,2BAA2B","ignoreList":[0]}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-rsc'].React;
|
||||
|
||||
//# sourceMappingURL=react.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/rsc/react.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-rsc']!.React\n"],"names":["module","exports","require","vendored","React"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,KAAK","ignoreList":[0]}
|
||||
Generated
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as ReactJsxDevRuntime from 'react/jsx-dev-runtime';
|
||||
import * as ReactJsxRuntime from 'react/jsx-runtime';
|
||||
import * as ReactCompilerRuntime from 'react/compiler-runtime';
|
||||
import * as ReactDOMServer from 'react-dom/server';
|
||||
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');
|
||||
}
|
||||
}
|
||||
export { React, ReactJsxDevRuntime, ReactJsxRuntime, ReactCompilerRuntime, ReactDOM, ReactDOMServer, ReactServerDOMTurbopackClient, ReactServerDOMWebpackClient, };
|
||||
|
||||
//# sourceMappingURL=entrypoints.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/entrypoints.ts"],"sourcesContent":["import * as React from 'react'\nimport * as ReactDOM from 'react-dom'\nimport * as ReactJsxDevRuntime from 'react/jsx-dev-runtime'\nimport * as ReactJsxRuntime from 'react/jsx-runtime'\nimport * as ReactCompilerRuntime from 'react/compiler-runtime'\n\nimport * as ReactDOMServer from 'react-dom/server'\n\nfunction getAltProxyForBindingsDEV(\n type: 'Turbopack' | 'Webpack',\n pkg: 'react-server-dom-turbopack/client' | 'react-server-dom-webpack/client'\n) {\n if (process.env.NODE_ENV === 'development') {\n const altType = type === 'Turbopack' ? 'Webpack' : 'Turbopack'\n const altPkg = pkg.replace(new RegExp(type, 'gi'), altType.toLowerCase())\n\n return new Proxy(\n {},\n {\n get(_, prop: string) {\n throw new Error(\n `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.`\n )\n },\n }\n )\n }\n}\n\nlet ReactServerDOMTurbopackClient, ReactServerDOMWebpackClient\nif (process.env.TURBOPACK) {\n ReactServerDOMTurbopackClient =\n // @ts-expect-error -- TODO: Add types\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('react-server-dom-turbopack/client') as typeof import('react-server-dom-turbopack/client')\n if (process.env.NODE_ENV === 'development') {\n ReactServerDOMWebpackClient = getAltProxyForBindingsDEV(\n 'Turbopack',\n 'react-server-dom-turbopack/client'\n )\n }\n} else {\n ReactServerDOMWebpackClient =\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('react-server-dom-webpack/client') as typeof import('react-server-dom-webpack/client')\n if (process.env.NODE_ENV === 'development') {\n ReactServerDOMTurbopackClient = getAltProxyForBindingsDEV(\n 'Webpack',\n 'react-server-dom-webpack/client'\n )\n }\n}\n\nexport {\n React,\n ReactJsxDevRuntime,\n ReactJsxRuntime,\n ReactCompilerRuntime,\n ReactDOM,\n ReactDOMServer,\n ReactServerDOMTurbopackClient,\n ReactServerDOMWebpackClient,\n}\n"],"names":["React","ReactDOM","ReactJsxDevRuntime","ReactJsxRuntime","ReactCompilerRuntime","ReactDOMServer","getAltProxyForBindingsDEV","type","pkg","process","env","NODE_ENV","altType","altPkg","replace","RegExp","toLowerCase","Proxy","get","_","prop","Error","ReactServerDOMTurbopackClient","ReactServerDOMWebpackClient","TURBOPACK","require"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAC9B,YAAYC,cAAc,YAAW;AACrC,YAAYC,wBAAwB,wBAAuB;AAC3D,YAAYC,qBAAqB,oBAAmB;AACpD,YAAYC,0BAA0B,yBAAwB;AAE9D,YAAYC,oBAAoB,mBAAkB;AAElD,SAASC,0BACPC,IAA6B,EAC7BC,GAA4E;IAE5E,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,MAAMC,UAAUL,SAAS,cAAc,YAAY;QACnD,MAAMM,SAASL,IAAIM,OAAO,CAAC,IAAIC,OAAOR,MAAM,OAAOK,QAAQI,WAAW;QAEtE,OAAO,IAAIC,MACT,CAAC,GACD;YACEC,KAAIC,CAAC,EAAEC,IAAY;gBACjB,MAAM,qBAEL,CAFK,IAAIC,MACR,CAAC,gBAAgB,EAAEd,KAAK,WAAW,EAAEC,IAAI,oDAAoD,EAAEY,KAAK,WAAW,EAAER,QAAQ,WAAW,EAAEC,OAAO,yEAAyE,CAAC,GADnN,qBAAA;2BAAA;gCAAA;kCAAA;gBAEN;YACF;QACF;IAEJ;AACF;AAEA,IAAIS,+BAA+BC;AACnC,IAAId,QAAQC,GAAG,CAACc,SAAS,EAAE;IACzBF,gCACE,sCAAsC;IACtC,6DAA6D;IAC7DG,QAAQ;IACV,IAAIhB,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1CY,8BAA8BjB,0BAC5B,aACA;IAEJ;AACF,OAAO;IACLiB,8BACE,6DAA6D;IAC7DE,QAAQ;IACV,IAAIhB,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1CW,gCAAgChB,0BAC9B,WACA;IAEJ;AACF;AAEA,SACEN,KAAK,EACLE,kBAAkB,EAClBC,eAAe,EACfC,oBAAoB,EACpBH,QAAQ,EACRI,cAAc,EACdiB,6BAA6B,EAC7BC,2BAA2B,KAC5B","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactCompilerRuntime;
|
||||
|
||||
//# sourceMappingURL=react-compiler-runtime.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react-compiler-runtime.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.ReactCompilerRuntime\n"],"names":["module","exports","require","vendored","ReactCompilerRuntime"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,oBAAoB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactDOMServer;
|
||||
|
||||
//# sourceMappingURL=react-dom-server.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react-dom-server.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.ReactDOMServer\n"],"names":["module","exports","require","vendored","ReactDOMServer"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,cAAc","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactDOM;
|
||||
|
||||
//# sourceMappingURL=react-dom.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react-dom.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.ReactDOM\n"],"names":["module","exports","require","vendored","ReactDOM"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,QAAQ","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactJsxDevRuntime;
|
||||
|
||||
//# sourceMappingURL=react-jsx-dev-runtime.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react-jsx-dev-runtime.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.ReactJsxDevRuntime\n"],"names":["module","exports","require","vendored","ReactJsxDevRuntime"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,kBAAkB","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactJsxRuntime;
|
||||
|
||||
//# sourceMappingURL=react-jsx-runtime.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react-jsx-runtime.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.ReactJsxRuntime\n"],"names":["module","exports","require","vendored","ReactJsxRuntime"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,eAAe","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactServerDOMTurbopackClient;
|
||||
|
||||
//# sourceMappingURL=react-server-dom-turbopack-client.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react-server-dom-turbopack-client.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.ReactServerDOMTurbopackClient\n"],"names":["module","exports","require","vendored","ReactServerDOMTurbopackClient"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,6BAA6B","ignoreList":[0]}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].ReactServerDOMWebpackClient;
|
||||
|
||||
//# sourceMappingURL=react-server-dom-webpack-client.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react-server-dom-webpack-client.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.ReactServerDOMWebpackClient\n"],"names":["module","exports","require","vendored","ReactServerDOMWebpackClient"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,2BAA2B","ignoreList":[0]}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['react-ssr'].React;
|
||||
|
||||
//# sourceMappingURL=react.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/app-page/vendored/ssr/react.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['react-ssr']!.React\n"],"names":["module","exports","require","vendored","React"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,YAAY,CAAEC,KAAK","ignoreList":[0]}
|
||||
Generated
Vendored
+75
@@ -0,0 +1,75 @@
|
||||
import { HTTP_METHODS } from '../../../web/http';
|
||||
const AUTOMATIC_ROUTE_METHODS = [
|
||||
'HEAD',
|
||||
'OPTIONS'
|
||||
];
|
||||
function handleMethodNotAllowedResponse() {
|
||||
return new Response(null, {
|
||||
status: 405
|
||||
});
|
||||
}
|
||||
export 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_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_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
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-modules/app-route/helpers/auto-implement-methods.ts"],"sourcesContent":["import type { AppRouteHandlerFn, AppRouteHandlers } from '../module'\n\nimport { HTTP_METHODS, type HTTP_METHOD } from '../../../web/http'\n\nconst AUTOMATIC_ROUTE_METHODS = ['HEAD', 'OPTIONS'] as const\n\nfunction handleMethodNotAllowedResponse(): Response {\n return new Response(null, { status: 405 })\n}\n\nexport function autoImplementMethods(\n handlers: AppRouteHandlers\n): Record<HTTP_METHOD, AppRouteHandlerFn> {\n // Loop through all the HTTP methods to create the initial methods object.\n // Each of the methods will be set to the 405 response handler.\n const methods: Record<HTTP_METHOD, AppRouteHandlerFn> = HTTP_METHODS.reduce(\n (acc, method) => ({\n ...acc,\n // If the userland module implements the method, then use it. Otherwise,\n // use the 405 response handler.\n [method]: handlers[method] ?? handleMethodNotAllowedResponse,\n }),\n {} as Record<HTTP_METHOD, AppRouteHandlerFn>\n )\n\n // Get all the methods that could be automatically implemented that were not\n // implemented by the userland module.\n const implemented = new Set(HTTP_METHODS.filter((method) => handlers[method]))\n const missing = AUTOMATIC_ROUTE_METHODS.filter(\n (method) => !implemented.has(method)\n )\n\n // Loop over the missing methods to automatically implement them if we can.\n for (const method of missing) {\n // If the userland module doesn't implement the HEAD method, then\n // we'll automatically implement it by calling the GET method (if it\n // exists).\n if (method === 'HEAD') {\n if (handlers.GET) {\n // Implement the HEAD method by calling the GET method.\n methods.HEAD = handlers.GET\n\n // Mark it as implemented.\n implemented.add('HEAD')\n }\n continue\n }\n\n // If OPTIONS is not provided then implement it.\n if (method === 'OPTIONS') {\n // TODO: check if HEAD is implemented, if so, use it to add more headers\n\n // Get all the methods that were implemented by the userland module.\n const allow: HTTP_METHOD[] = ['OPTIONS', ...implemented]\n\n // If the list of methods doesn't include HEAD, but it includes GET, then\n // add HEAD as it's automatically implemented.\n if (!implemented.has('HEAD') && implemented.has('GET')) {\n allow.push('HEAD')\n }\n\n // Sort and join the list with commas to create the `Allow` header. See:\n // https://httpwg.org/specs/rfc9110.html#field.allow\n const headers = { Allow: allow.sort().join(', ') }\n\n // Implement the OPTIONS method by returning a 204 response with the\n // `Allow` header.\n methods.OPTIONS = () => new Response(null, { status: 204, headers })\n\n // Mark this method as implemented.\n implemented.add('OPTIONS')\n\n continue\n }\n\n throw new Error(\n `Invariant: should handle all automatic implementable methods, got method: ${method}`\n )\n }\n\n return methods\n}\n"],"names":["HTTP_METHODS","AUTOMATIC_ROUTE_METHODS","handleMethodNotAllowedResponse","Response","status","autoImplementMethods","handlers","methods","reduce","acc","method","implemented","Set","filter","missing","has","GET","HEAD","add","allow","push","headers","Allow","sort","join","OPTIONS","Error"],"mappings":"AAEA,SAASA,YAAY,QAA0B,oBAAmB;AAElE,MAAMC,0BAA0B;IAAC;IAAQ;CAAU;AAEnD,SAASC;IACP,OAAO,IAAIC,SAAS,MAAM;QAAEC,QAAQ;IAAI;AAC1C;AAEA,OAAO,SAASC,qBACdC,QAA0B;IAE1B,0EAA0E;IAC1E,+DAA+D;IAC/D,MAAMC,UAAkDP,aAAaQ,MAAM,CACzE,CAACC,KAAKC,SAAY,CAAA;YAChB,GAAGD,GAAG;YACN,wEAAwE;YACxE,gCAAgC;YAChC,CAACC,OAAO,EAAEJ,QAAQ,CAACI,OAAO,IAAIR;QAChC,CAAA,GACA,CAAC;IAGH,4EAA4E;IAC5E,sCAAsC;IACtC,MAAMS,cAAc,IAAIC,IAAIZ,aAAaa,MAAM,CAAC,CAACH,SAAWJ,QAAQ,CAACI,OAAO;IAC5E,MAAMI,UAAUb,wBAAwBY,MAAM,CAC5C,CAACH,SAAW,CAACC,YAAYI,GAAG,CAACL;IAG/B,2EAA2E;IAC3E,KAAK,MAAMA,UAAUI,QAAS;QAC5B,iEAAiE;QACjE,oEAAoE;QACpE,WAAW;QACX,IAAIJ,WAAW,QAAQ;YACrB,IAAIJ,SAASU,GAAG,EAAE;gBAChB,uDAAuD;gBACvDT,QAAQU,IAAI,GAAGX,SAASU,GAAG;gBAE3B,0BAA0B;gBAC1BL,YAAYO,GAAG,CAAC;YAClB;YACA;QACF;QAEA,gDAAgD;QAChD,IAAIR,WAAW,WAAW;YACxB,wEAAwE;YAExE,oEAAoE;YACpE,MAAMS,QAAuB;gBAAC;mBAAcR;aAAY;YAExD,yEAAyE;YACzE,8CAA8C;YAC9C,IAAI,CAACA,YAAYI,GAAG,CAAC,WAAWJ,YAAYI,GAAG,CAAC,QAAQ;gBACtDI,MAAMC,IAAI,CAAC;YACb;YAEA,wEAAwE;YACxE,oDAAoD;YACpD,MAAMC,UAAU;gBAAEC,OAAOH,MAAMI,IAAI,GAAGC,IAAI,CAAC;YAAM;YAEjD,oEAAoE;YACpE,kBAAkB;YAClBjB,QAAQkB,OAAO,GAAG,IAAM,IAAItB,SAAS,MAAM;oBAAEC,QAAQ;oBAAKiB;gBAAQ;YAElE,mCAAmC;YACnCV,YAAYO,GAAG,CAAC;YAEhB;QACF;QAEA,MAAM,qBAEL,CAFK,IAAIQ,MACR,CAAC,0EAA0E,EAAEhB,QAAQ,GADjF,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,OAAOH;AACT","ignoreList":[0]}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Cleans a URL by stripping the protocol, host, and search params.
|
||||
*
|
||||
* @param urlString the url to clean
|
||||
* @returns the cleaned url
|
||||
*/ export function cleanURL(url) {
|
||||
const u = new URL(url);
|
||||
u.host = 'localhost:3000';
|
||||
u.search = '';
|
||||
u.protocol = 'http';
|
||||
return u;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=clean-url.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-modules/app-route/helpers/clean-url.ts"],"sourcesContent":["/**\n * Cleans a URL by stripping the protocol, host, and search params.\n *\n * @param urlString the url to clean\n * @returns the cleaned url\n */\n\nexport function cleanURL(url: string | URL): URL {\n const u = new URL(url)\n u.host = 'localhost:3000'\n u.search = ''\n u.protocol = 'http'\n return u\n}\n"],"names":["cleanURL","url","u","URL","host","search","protocol"],"mappings":"AAAA;;;;;CAKC,GAED,OAAO,SAASA,SAASC,GAAiB;IACxC,MAAMC,IAAI,IAAIC,IAAIF;IAClBC,EAAEE,IAAI,GAAG;IACTF,EAAEG,MAAM,GAAG;IACXH,EAAEI,QAAQ,GAAG;IACb,OAAOJ;AACT","ignoreList":[0]}
|
||||
node_modules/next/dist/esm/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.js
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Get pathname from absolute path.
|
||||
*
|
||||
* @param absolutePath the absolute path
|
||||
* @returns the pathname
|
||||
*/ export 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
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-modules/app-route/helpers/get-pathname-from-absolute-path.ts"],"sourcesContent":["/**\n * Get pathname from absolute path.\n *\n * @param absolutePath the absolute path\n * @returns the pathname\n */\nexport function getPathnameFromAbsolutePath(absolutePath: string) {\n // Remove prefix including app dir\n let appDir = '/app/'\n if (!absolutePath.includes(appDir)) {\n appDir = '\\\\app\\\\'\n }\n const [, ...parts] = absolutePath.split(appDir)\n const relativePath = appDir[0] + parts.join(appDir)\n\n // remove extension\n const pathname = relativePath.split('.').slice(0, -1).join('.')\n return pathname\n}\n"],"names":["getPathnameFromAbsolutePath","absolutePath","appDir","includes","parts","split","relativePath","join","pathname","slice"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA,4BAA4BC,YAAoB;IAC9D,kCAAkC;IAClC,IAAIC,SAAS;IACb,IAAI,CAACD,aAAaE,QAAQ,CAACD,SAAS;QAClCA,SAAS;IACX;IACA,MAAM,GAAG,GAAGE,MAAM,GAAGH,aAAaI,KAAK,CAACH;IACxC,MAAMI,eAAeJ,MAAM,CAAC,EAAE,GAAGE,MAAMG,IAAI,CAACL;IAE5C,mBAAmB;IACnB,MAAMM,WAAWF,aAAaD,KAAK,CAAC,KAAKI,KAAK,CAAC,GAAG,CAAC,GAAGF,IAAI,CAAC;IAC3D,OAAOC;AACT","ignoreList":[0]}
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// route handlers are only statically optimized if they define
|
||||
// one of these top-level configs manually
|
||||
// - dynamic = 'force-static'
|
||||
// - dynamic = 'error'
|
||||
// - revalidate > 0
|
||||
// - revalidate = false
|
||||
// - generateStaticParams
|
||||
export 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
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-modules/app-route/helpers/is-static-gen-enabled.ts"],"sourcesContent":["import type { AppRouteModule } from '../module.compiled'\n\n// route handlers are only statically optimized if they define\n// one of these top-level configs manually\n// - dynamic = 'force-static'\n// - dynamic = 'error'\n// - revalidate > 0\n// - revalidate = false\n// - generateStaticParams\nexport function isStaticGenEnabled(\n mod: AppRouteModule['routeModule']['userland']\n) {\n return (\n mod.dynamic === 'force-static' ||\n mod.dynamic === 'error' ||\n mod.revalidate === false ||\n (mod.revalidate !== undefined && mod.revalidate > 0) ||\n typeof mod.generateStaticParams == 'function'\n )\n}\n"],"names":["isStaticGenEnabled","mod","dynamic","revalidate","undefined","generateStaticParams"],"mappings":"AAEA,8DAA8D;AAC9D,0CAA0C;AAC1C,+BAA+B;AAC/B,wBAAwB;AACxB,qBAAqB;AACrB,yBAAyB;AACzB,2BAA2B;AAC3B,OAAO,SAASA,mBACdC,GAA8C;IAE9C,OACEA,IAAIC,OAAO,KAAK,kBAChBD,IAAIC,OAAO,KAAK,WAChBD,IAAIE,UAAU,KAAK,SAClBF,IAAIE,UAAU,KAAKC,aAAaH,IAAIE,UAAU,GAAG,KAClD,OAAOF,IAAII,oBAAoB,IAAI;AAEvC","ignoreList":[0]}
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Converts the query into params.
|
||||
*
|
||||
* @param query the query to convert to params
|
||||
* @returns the params
|
||||
*/ export 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
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-modules/app-route/helpers/parsed-url-query-to-params.ts"],"sourcesContent":["import type { ParsedUrlQuery } from 'querystring'\n\n/**\n * Converts the query into params.\n *\n * @param query the query to convert to params\n * @returns the params\n */\nexport function parsedUrlQueryToParams(\n query: ParsedUrlQuery\n): Record<string, string | string[]> {\n const params: Record<string, string | string[]> = {}\n\n for (const [key, value] of Object.entries(query)) {\n if (typeof value === 'undefined') continue\n params[key] = value\n }\n\n return params\n}\n"],"names":["parsedUrlQueryToParams","query","params","key","value","Object","entries"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,SAASA,uBACdC,KAAqB;IAErB,MAAMC,SAA4C,CAAC;IAEnD,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,OAAQ;QAChD,IAAI,OAAOG,UAAU,aAAa;QAClCF,MAAM,CAACC,IAAI,GAAGC;IAChB;IAEA,OAAOF;AACT","ignoreList":[0]}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './module'
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
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
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/app-route/module.compiled.js"],"sourcesContent":["if (process.env.NEXT_RUNTIME === 'edge') {\n module.exports = require('next/dist/server/route-modules/app-route/module.js')\n} else {\n if (process.env.__NEXT_EXPERIMENTAL_REACT) {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.dev.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.dev.js')\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo-experimental.runtime.prod.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route-experimental.runtime.prod.js')\n }\n }\n } else {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.dev.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route.runtime.dev.js')\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/app-route-turbo.runtime.prod.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/app-route.runtime.prod.js')\n }\n }\n }\n}\n"],"names":["process","env","NEXT_RUNTIME","module","exports","require","__NEXT_EXPERIMENTAL_REACT","NODE_ENV","TURBOPACK"],"mappings":"AAAA,IAAIA,QAAQC,GAAG,CAACC,YAAY,KAAK,QAAQ;IACvCC,OAAOC,OAAO,GAAGC,QAAQ;AAC3B,OAAO;IACL,IAAIL,QAAQC,GAAG,CAACK,yBAAyB,EAAE;QACzC,IAAIN,QAAQC,GAAG,CAACM,QAAQ,KAAK,eAAe;YAC1C,IAAIP,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF,OAAO;YACL,IAAIL,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF;IACF,OAAO;QACL,IAAIL,QAAQC,GAAG,CAACM,QAAQ,KAAK,eAAe;YAC1C,IAAIP,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF,OAAO;YACL,IAAIL,QAAQC,GAAG,CAACO,SAAS,EAAE;gBACzBL,OAAOC,OAAO,GAAGC,QAAQ;YAC3B,OAAO;gBACLF,OAAOC,OAAO,GAAGC,QAAQ;YAC3B;QACF;IACF;AACF","ignoreList":[0]}
|
||||
+838
@@ -0,0 +1,838 @@
|
||||
import { RouteModule } from '../route-module';
|
||||
import { createRequestStoreForAPI } from '../../async-storage/request-store';
|
||||
import { createWorkStore } from '../../async-storage/work-store';
|
||||
import { HTTP_METHODS, isHTTPMethod } from '../../web/http';
|
||||
import { getImplicitTags } from '../../lib/implicit-tags';
|
||||
import { patchFetch } from '../../lib/patch-fetch';
|
||||
import { getTracer } from '../../lib/trace/tracer';
|
||||
import { AppRouteRouteHandlersSpan } from '../../lib/trace/constants';
|
||||
import * as Log from '../../../build/output/log';
|
||||
import { autoImplementMethods } from './helpers/auto-implement-methods';
|
||||
import { appendMutableCookies } from '../../web/spec-extension/adapters/request-cookies';
|
||||
import { HeadersAdapter } from '../../web/spec-extension/adapters/headers';
|
||||
import { RequestCookiesAdapter } from '../../web/spec-extension/adapters/request-cookies';
|
||||
import { parsedUrlQueryToParams } from './helpers/parsed-url-query-to-params';
|
||||
import { Phase, printDebugThrownValueForProspectiveRender } from '../../app-render/prospective-render-utils';
|
||||
import * as serverHooks from '../../../client/components/hooks-server-context';
|
||||
import { DynamicServerError } from '../../../client/components/hooks-server-context';
|
||||
import { workAsyncStorage } from '../../app-render/work-async-storage.external';
|
||||
import { workUnitAsyncStorage } from '../../app-render/work-unit-async-storage.external';
|
||||
import { actionAsyncStorage } from '../../app-render/action-async-storage.external';
|
||||
import * as sharedModules from './shared-modules';
|
||||
import { getIsPossibleServerAction } from '../../lib/server-action-request-meta';
|
||||
import { RequestCookies } from 'next/dist/compiled/@edge-runtime/cookies';
|
||||
import { cleanURL } from './helpers/clean-url';
|
||||
import { StaticGenBailoutError } from '../../../client/components/static-generation-bailout';
|
||||
import { isStaticGenEnabled } from './helpers/is-static-gen-enabled';
|
||||
import { abortAndThrowOnSynchronousRequestDataAccess, postponeWithTracking, createDynamicTrackingState, getFirstDynamicReason } from '../../app-render/dynamic-rendering';
|
||||
import { ReflectAdapter } from '../../web/spec-extension/adapters/reflect';
|
||||
import { CacheSignal } from '../../app-render/cache-signal';
|
||||
import { scheduleImmediate } from '../../../lib/scheduler';
|
||||
import { createServerParamsForRoute } from '../../request/params';
|
||||
import { getRedirectStatusCodeFromError, getURLFromRedirectError } from '../../../client/components/redirect';
|
||||
import { isRedirectError } from '../../../client/components/redirect-error';
|
||||
import { getAccessFallbackHTTPStatus, isHTTPAccessFallbackError } from '../../../client/components/http-access-fallback/http-access-fallback';
|
||||
import { RedirectStatusCode } from '../../../client/components/redirect-status-code';
|
||||
import { INFINITE_CACHE } from '../../../lib/constants';
|
||||
import { executeRevalidates } from '../../revalidation-utils';
|
||||
import { trackPendingModules } from '../../app-render/module-loading/track-module-loading.external';
|
||||
import { InvariantError } from '../../../shared/lib/invariant-error';
|
||||
import { createPrerenderResumeDataCache } from '../../resume-data-cache/resume-data-cache';
|
||||
export class WrappedNextRouterError {
|
||||
constructor(error, headers){
|
||||
this.error = error;
|
||||
this.headers = headers;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* AppRouteRouteHandler is the handler for app routes.
|
||||
*/ export class AppRouteRouteModule extends RouteModule {
|
||||
static #_ = this.sharedModules = sharedModules;
|
||||
constructor({ userland, definition, distDir, relativeProjectDir, resolvedPagePath, nextConfigOutput }){
|
||||
super({
|
||||
userland,
|
||||
definition,
|
||||
distDir,
|
||||
relativeProjectDir
|
||||
}), /**
|
||||
* A reference to the request async storage.
|
||||
*/ this.workUnitAsyncStorage = workUnitAsyncStorage, /**
|
||||
* A reference to the static generation async storage.
|
||||
*/ this.workAsyncStorage = workAsyncStorage, /**
|
||||
* An interface to call server hooks which interact with the underlying
|
||||
* storage.
|
||||
*/ this.serverHooks = serverHooks, /**
|
||||
* A reference to the mutation related async storage, such as mutations of
|
||||
* cookies.
|
||||
*/ this.actionAsyncStorage = actionAsyncStorage;
|
||||
this.resolvedPagePath = resolvedPagePath;
|
||||
this.nextConfigOutput = nextConfigOutput;
|
||||
// Automatically implement some methods if they aren't implemented by the
|
||||
// userland module.
|
||||
this.methods = autoImplementMethods(userland);
|
||||
// Get the non-static methods for this route.
|
||||
this.hasNonStaticMethods = hasNonStaticMethods(userland);
|
||||
// Get the dynamic property from the userland module.
|
||||
this.dynamic = this.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 (!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_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_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 (!isHTTPMethod(method)) return ()=>new Response(null, {
|
||||
status: 400
|
||||
});
|
||||
// Return the handler.
|
||||
return this.methods[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.
|
||||
patchFetch({
|
||||
workAsyncStorage: this.workAsyncStorage,
|
||||
workUnitAsyncStorage: this.workUnitAsyncStorage
|
||||
});
|
||||
const handlerContext = {
|
||||
params: context.params ? createServerParamsForRoute(parsedUrlQueryToParams(context.params)) : undefined
|
||||
};
|
||||
const resolvePendingRevalidations = ()=>{
|
||||
const maybeRevalidatesPromise = 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 ? 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();
|
||||
let dynamicTracking = 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 = 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: INFINITE_CACHE,
|
||||
stale: 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) {
|
||||
printDebugThrownValueForProspectiveRender(err, workStore.route, 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) {
|
||||
printDebugThrownValueForProspectiveRender(err, workStore.route, Phase.ProspectiveRender);
|
||||
}
|
||||
});
|
||||
}
|
||||
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 = getFirstDynamicReason(dynamicTracking);
|
||||
if (dynamicReason) {
|
||||
throw Object.defineProperty(new 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 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 = 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: INFINITE_CACHE,
|
||||
stale: INFINITE_CACHE,
|
||||
tags: [
|
||||
...implicitTags.tags
|
||||
],
|
||||
prerenderResumeDataCache,
|
||||
renderResumeDataCache: null,
|
||||
hmrRefreshHash: undefined,
|
||||
varyParamsAccumulator: null
|
||||
};
|
||||
let responseHandled = false;
|
||||
res = await new Promise((resolve, reject)=>{
|
||||
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);
|
||||
scheduleImmediate(()=>{
|
||||
if (!bodyHandled) {
|
||||
bodyHandled = true;
|
||||
finalController.abort();
|
||||
reject(createCacheComponentsError(workStore.route));
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
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: INFINITE_CACHE,
|
||||
stale: INFINITE_CACHE,
|
||||
tags: [
|
||||
...implicitTags.tags
|
||||
]
|
||||
};
|
||||
res = await workUnitAsyncStorage.run(prerenderStore, handler, request, handlerContext);
|
||||
}
|
||||
} else {
|
||||
res = await workUnitAsyncStorage.run(requestStore, handler, request, handlerContext);
|
||||
}
|
||||
} catch (err) {
|
||||
if (isRedirectError(err)) {
|
||||
const url = 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
|
||||
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.SeeOther : getRedirectStatusCodeFromError(err),
|
||||
headers
|
||||
});
|
||||
} else if (isHTTPAccessFallbackError(err)) {
|
||||
const httpStatus = 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 (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.
|
||||
const handler = this.resolve(req.method);
|
||||
// Get the context for the static generation.
|
||||
const staticGenerationContext = {
|
||||
page: this.definition.page,
|
||||
renderOpts: context.renderOpts,
|
||||
buildId: context.sharedContext.buildId,
|
||||
previouslyRevalidatedTags: []
|
||||
};
|
||||
// Add the fetchCache option to the renderOpts.
|
||||
staticGenerationContext.renderOpts.fetchCache = this.userland.fetchCache;
|
||||
const actionStore = {
|
||||
isAppRoute: true,
|
||||
isAction: getIsPossibleServerAction(req)
|
||||
};
|
||||
const implicitTags = await getImplicitTags(this.definition.page, req.nextUrl.pathname, // App Routes don't support unknown route params.
|
||||
null);
|
||||
const requestStore = createRequestStoreForAPI(req, req.nextUrl, implicitTags, undefined, context.previewProps);
|
||||
const 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 (this.hasNonStaticMethods) {
|
||||
if (workStore.isStaticGeneration) {
|
||||
const err = Object.defineProperty(new 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.
|
||||
switch(this.dynamic){
|
||||
case 'force-dynamic':
|
||||
{
|
||||
// Routes of generated paths should be dynamic
|
||||
workStore.forceDynamic = true;
|
||||
if (workStore.isStaticGeneration) {
|
||||
const err = Object.defineProperty(new 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:
|
||||
this.dynamic;
|
||||
}
|
||||
const tracer = getTracer();
|
||||
// Update the root span attribute for the route.
|
||||
const { pathname } = this.definition;
|
||||
tracer.setRootSpanAttribute('next.route', pathname);
|
||||
return tracer.trace(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;
|
||||
}
|
||||
}
|
||||
export default AppRouteRouteModule;
|
||||
/**
|
||||
* Gets all the method names for handlers that are not considered static.
|
||||
*
|
||||
* @param handlers the handlers from the userland module
|
||||
* @returns the method names that are not considered static or false if all
|
||||
* methods are static
|
||||
*/ export 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] = HeadersAdapter.seal(new Headers({})));
|
||||
case 'cookies':
|
||||
return target[cookiesSymbol] || (target[cookiesSymbol] = RequestCookiesAdapter.seal(new 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 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] = 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 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 = workUnitAsyncStorage.getStore();
|
||||
trackDynamic(workStore, workUnitStore, `nextUrl.${prop}`);
|
||||
return ReflectAdapter.get(target, prop, receiver);
|
||||
}
|
||||
case 'clone':
|
||||
return target[urlCloneSymbol] || (target[urlCloneSymbol] = ()=>new Proxy(target.clone(), nextUrlHandlers));
|
||||
default:
|
||||
return 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 = 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 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 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 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 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 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 ReflectAdapter.get(target, prop, receiver);
|
||||
}
|
||||
}
|
||||
};
|
||||
function createCacheComponentsError(route) {
|
||||
return Object.defineProperty(new 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 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 abortAndThrowOnSynchronousRequestDataAccess(store.route, expression, error, workUnitStore);
|
||||
case 'prerender-client':
|
||||
case 'validation-client':
|
||||
throw Object.defineProperty(new 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('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 postponeWithTracking(store.route, expression, workUnitStore.dynamicTracking);
|
||||
case 'prerender-legacy':
|
||||
workUnitStore.revalidate = 0;
|
||||
const err = Object.defineProperty(new 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
|
||||
+1
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
||||
// 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 :(
|
||||
export * as appRouterContext from '../../../shared/lib/app-router-context.shared-runtime';
|
||||
|
||||
//# sourceMappingURL=shared-modules.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/app-route/shared-modules.ts"],"sourcesContent":["// the name of the export has to be the camelCase version of the file name (without the extension)\n// TODO: remove this. We need it because using notFound from next/navigation imports this file :(\nexport * as appRouterContext from '../../../shared/lib/app-router-context.shared-runtime'\n"],"names":["appRouterContext"],"mappings":"AAAA,kGAAkG;AAClG,iGAAiG;AACjG,OAAO,KAAKA,gBAAgB,MAAM,wDAAuD","ignoreList":[0]}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { RouteKind } from '../route-kind';
|
||||
export function isAppRouteRouteModule(routeModule) {
|
||||
return routeModule.definition.kind === RouteKind.APP_ROUTE;
|
||||
}
|
||||
export function isAppPageRouteModule(routeModule) {
|
||||
return routeModule.definition.kind === RouteKind.APP_PAGE;
|
||||
}
|
||||
export function isPagesRouteModule(routeModule) {
|
||||
return routeModule.definition.kind === RouteKind.PAGES;
|
||||
}
|
||||
export function isPagesAPIRouteModule(routeModule) {
|
||||
return routeModule.definition.kind === RouteKind.PAGES_API;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=checks.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/route-modules/checks.ts"],"sourcesContent":["import type { AppRouteRouteModule } from './app-route/module'\nimport type { AppPageRouteModule } from './app-page/module'\nimport type { PagesRouteModule } from './pages/module'\nimport type { PagesAPIRouteModule } from './pages-api/module'\n\nimport type { RouteModule } from './route-module'\n\nimport { RouteKind } from '../route-kind'\n\nexport function isAppRouteRouteModule(\n routeModule: RouteModule\n): routeModule is AppRouteRouteModule {\n return routeModule.definition.kind === RouteKind.APP_ROUTE\n}\n\nexport function isAppPageRouteModule(\n routeModule: RouteModule\n): routeModule is AppPageRouteModule {\n return routeModule.definition.kind === RouteKind.APP_PAGE\n}\n\nexport function isPagesRouteModule(\n routeModule: RouteModule\n): routeModule is PagesRouteModule {\n return routeModule.definition.kind === RouteKind.PAGES\n}\n\nexport function isPagesAPIRouteModule(\n routeModule: RouteModule\n): routeModule is PagesAPIRouteModule {\n return routeModule.definition.kind === RouteKind.PAGES_API\n}\n"],"names":["RouteKind","isAppRouteRouteModule","routeModule","definition","kind","APP_ROUTE","isAppPageRouteModule","APP_PAGE","isPagesRouteModule","PAGES","isPagesAPIRouteModule","PAGES_API"],"mappings":"AAOA,SAASA,SAAS,QAAQ,gBAAe;AAEzC,OAAO,SAASC,sBACdC,WAAwB;IAExB,OAAOA,YAAYC,UAAU,CAACC,IAAI,KAAKJ,UAAUK,SAAS;AAC5D;AAEA,OAAO,SAASC,qBACdJ,WAAwB;IAExB,OAAOA,YAAYC,UAAU,CAACC,IAAI,KAAKJ,UAAUO,QAAQ;AAC3D;AAEA,OAAO,SAASC,mBACdN,WAAwB;IAExB,OAAOA,YAAYC,UAAU,CAACC,IAAI,KAAKJ,UAAUS,KAAK;AACxD;AAEA,OAAO,SAASC,sBACdR,WAAwB;IAExB,OAAOA,YAAYC,UAAU,CAACC,IAAI,KAAKJ,UAAUW,SAAS;AAC5D","ignoreList":[0]}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './module'
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
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
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/pages-api/module.compiled.js"],"sourcesContent":["if (process.env.NEXT_RUNTIME === 'edge') {\n module.exports = require('next/dist/server/route-modules/pages-api/module.js')\n} else {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/pages-api-turbo.runtime.dev.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/pages-api.runtime.dev.js')\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/pages-api-turbo.runtime.prod.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/pages-api.runtime.prod.js')\n }\n }\n}\n"],"names":["process","env","NEXT_RUNTIME","module","exports","require","NODE_ENV","TURBOPACK"],"mappings":"AAAA,IAAIA,QAAQC,GAAG,CAACC,YAAY,KAAK,QAAQ;IACvCC,OAAOC,OAAO,GAAGC,QAAQ;AAC3B,OAAO;IACL,IAAIL,QAAQC,GAAG,CAACK,QAAQ,KAAK,eAAe;QAC1C,IAAIN,QAAQC,GAAG,CAACM,SAAS,EAAE;YACzBJ,OAAOC,OAAO,GAAGC,QAAQ;QAC3B,OAAO;YACLF,OAAOC,OAAO,GAAGC,QAAQ;QAC3B;IACF,OAAO;QACL,IAAIL,QAAQC,GAAG,CAACM,SAAS,EAAE;YACzBJ,OAAOC,OAAO,GAAGC,QAAQ;QAC3B,OAAO;YACLF,OAAOC,OAAO,GAAGC,QAAQ;QAC3B;IACF;AACF","ignoreList":[0]}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { wrapApiHandler } from '../../api-utils';
|
||||
import { RouteModule } from '../route-module';
|
||||
import { apiResolver } from '../../api-utils/node/api-resolver';
|
||||
export class PagesAPIRouteModule extends 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 = wrapApiHandler(options.definition.page, 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);
|
||||
}
|
||||
}
|
||||
export default PagesAPIRouteModule;
|
||||
|
||||
//# sourceMappingURL=module.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+32
@@ -0,0 +1,32 @@
|
||||
import App from '../../../../pages/_app';
|
||||
import Document from '../../../../pages/_document';
|
||||
import { RouteKind } from '../../../route-kind';
|
||||
import * as moduleError from '../../../../pages/_error';
|
||||
import PagesRouteModule from '../module';
|
||||
import { getHandler } from '../pages-handler';
|
||||
export const routeModule = new PagesRouteModule({
|
||||
// TODO: add descriptor for internal error page
|
||||
definition: {
|
||||
kind: RouteKind.PAGES,
|
||||
page: '/_error',
|
||||
pathname: '/_error',
|
||||
filename: '',
|
||||
bundlePath: ''
|
||||
},
|
||||
distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',
|
||||
relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',
|
||||
components: {
|
||||
App,
|
||||
Document
|
||||
},
|
||||
userland: moduleError
|
||||
});
|
||||
export const handler = getHandler({
|
||||
srcPage: '/_error',
|
||||
routeModule,
|
||||
userland: moduleError,
|
||||
config: {},
|
||||
isFallbackError: true
|
||||
});
|
||||
|
||||
//# sourceMappingURL=_error.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../src/server/route-modules/pages/builtin/_error.tsx"],"sourcesContent":["import App from '../../../../pages/_app'\nimport Document from '../../../../pages/_document'\nimport { RouteKind } from '../../../route-kind'\n\nimport * as moduleError from '../../../../pages/_error'\n\nimport PagesRouteModule from '../module'\nimport { getHandler } from '../pages-handler'\n\nexport const routeModule = new PagesRouteModule({\n // TODO: add descriptor for internal error page\n definition: {\n kind: RouteKind.PAGES,\n page: '/_error',\n pathname: '/_error',\n filename: '',\n bundlePath: '',\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n components: {\n App,\n Document,\n },\n userland: moduleError,\n})\n\nexport const handler = getHandler({\n srcPage: '/_error',\n routeModule,\n userland: moduleError,\n config: {},\n isFallbackError: true,\n})\n"],"names":["App","Document","RouteKind","moduleError","PagesRouteModule","getHandler","routeModule","definition","kind","PAGES","page","pathname","filename","bundlePath","distDir","process","env","__NEXT_RELATIVE_DIST_DIR","relativeProjectDir","__NEXT_RELATIVE_PROJECT_DIR","components","userland","handler","srcPage","config","isFallbackError"],"mappings":"AAAA,OAAOA,SAAS,yBAAwB;AACxC,OAAOC,cAAc,8BAA6B;AAClD,SAASC,SAAS,QAAQ,sBAAqB;AAE/C,YAAYC,iBAAiB,2BAA0B;AAEvD,OAAOC,sBAAsB,YAAW;AACxC,SAASC,UAAU,QAAQ,mBAAkB;AAE7C,OAAO,MAAMC,cAAc,IAAIF,iBAAiB;IAC9C,+CAA+C;IAC/CG,YAAY;QACVC,MAAMN,UAAUO,KAAK;QACrBC,MAAM;QACNC,UAAU;QACVC,UAAU;QACVC,YAAY;IACd;IACAC,SAASC,QAAQC,GAAG,CAACC,wBAAwB,IAAI;IACjDC,oBAAoBH,QAAQC,GAAG,CAACG,2BAA2B,IAAI;IAC/DC,YAAY;QACVpB;QACAC;IACF;IACAoB,UAAUlB;AACZ,GAAE;AAEF,OAAO,MAAMmB,UAAUjB,WAAW;IAChCkB,SAAS;IACTjB;IACAe,UAAUlB;IACVqB,QAAQ,CAAC;IACTC,iBAAiB;AACnB,GAAE","ignoreList":[0]}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './module'
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
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
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/pages/module.compiled.js"],"sourcesContent":["if (process.env.NEXT_RUNTIME === 'edge') {\n module.exports = require('next/dist/server/route-modules/pages/module.js')\n} else {\n if (process.env.NODE_ENV === 'development') {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/pages-turbo.runtime.dev.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/pages.runtime.dev.js')\n }\n } else {\n if (process.env.TURBOPACK) {\n module.exports = require('next/dist/compiled/next-server/pages-turbo.runtime.prod.js')\n } else {\n module.exports = require('next/dist/compiled/next-server/pages.runtime.prod.js')\n }\n }\n}\n"],"names":["process","env","NEXT_RUNTIME","module","exports","require","NODE_ENV","TURBOPACK"],"mappings":"AAAA,IAAIA,QAAQC,GAAG,CAACC,YAAY,KAAK,QAAQ;IACvCC,OAAOC,OAAO,GAAGC,QAAQ;AAC3B,OAAO;IACL,IAAIL,QAAQC,GAAG,CAACK,QAAQ,KAAK,eAAe;QAC1C,IAAIN,QAAQC,GAAG,CAACM,SAAS,EAAE;YACzBJ,OAAOC,OAAO,GAAGC,QAAQ;QAC3B,OAAO;YACLF,OAAOC,OAAO,GAAGC,QAAQ;QAC3B;IACF,OAAO;QACL,IAAIL,QAAQC,GAAG,CAACM,SAAS,EAAE;YACzBJ,OAAOC,OAAO,GAAGC,QAAQ;QAC3B,OAAO;YACLF,OAAOC,OAAO,GAAGC,QAAQ;QAC3B;IACF;AACF","ignoreList":[0]}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { RouteModule } from '../route-module';
|
||||
import { renderToHTMLImpl, renderToHTML } from '../../render';
|
||||
import * as vendoredContexts from './vendored/contexts/entrypoints';
|
||||
export class PagesRouteModule extends RouteModule {
|
||||
constructor(options){
|
||||
super(options);
|
||||
this.components = options.components;
|
||||
}
|
||||
render(req, res, context) {
|
||||
return renderToHTMLImpl(req, res, context.page, context.query, context.renderOpts, {
|
||||
App: this.components.App,
|
||||
Document: this.components.Document
|
||||
}, context.sharedContext, context.renderContext);
|
||||
}
|
||||
}
|
||||
const vendored = {
|
||||
contexts: vendoredContexts
|
||||
};
|
||||
// needed for the static build
|
||||
export { renderToHTML, vendored };
|
||||
export default PagesRouteModule;
|
||||
|
||||
//# sourceMappingURL=module.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+14
@@ -0,0 +1,14 @@
|
||||
export 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
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/server/route-modules/pages/module.render.ts"],"sourcesContent":["import type { PagesRender } from '../../render'\n\nexport const lazyRenderPagesPage: PagesRender = (...args) => {\n if (process.env.NEXT_MINIMAL) {\n throw new Error(\"Can't use lazyRenderPagesPage in minimal mode\")\n } else {\n const render: PagesRender = (\n require('./module.compiled') as typeof import('./module.compiled')\n ).renderToHTML\n\n return render(...args)\n }\n}\n"],"names":["lazyRenderPagesPage","args","process","env","NEXT_MINIMAL","Error","render","require","renderToHTML"],"mappings":"AAEA,OAAO,MAAMA,sBAAmC,CAAC,GAAGC;IAClD,IAAIC,QAAQC,GAAG,CAACC,YAAY,EAAE;QAC5B,MAAM,qBAA0D,CAA1D,IAAIC,MAAM,kDAAV,qBAAA;mBAAA;wBAAA;0BAAA;QAAyD;IACjE,OAAO;QACL,MAAMC,SAAsB,AAC1BC,QAAQ,qBACRC,YAAY;QAEd,OAAOF,UAAUL;IACnB;AACF,EAAC","ignoreList":[0]}
|
||||
+530
@@ -0,0 +1,530 @@
|
||||
import { RouteKind } from '../../route-kind';
|
||||
import { BaseServerSpan } from '../../lib/trace/constants';
|
||||
import { getTracer, SpanKind } from '../../lib/trace/tracer';
|
||||
import { formatUrl } from '../../../shared/lib/router/utils/format-url';
|
||||
import { addRequestMeta, getRequestMeta, setRequestMeta } from '../../request-meta';
|
||||
import { interopDefault } from '../../app-render/interop-default';
|
||||
import { getRevalidateReason } from '../../instrumentation/utils';
|
||||
import { normalizeDataPath } from '../../../shared/lib/page-path/normalize-data-path';
|
||||
import { CachedRouteKind } from '../../response-cache';
|
||||
import { getCacheControlHeader } from '../../lib/cache-control';
|
||||
import { normalizeRepeatedSlashes } from '../../../shared/lib/utils';
|
||||
import { getRedirectStatus } from '../../../lib/redirect-status';
|
||||
import { CACHE_ONE_YEAR_SECONDS, HTML_CONTENT_TYPE_HEADER, JSON_CONTENT_TYPE_HEADER, NEXT_NAV_DEPLOYMENT_ID_HEADER } from '../../../lib/constants';
|
||||
import path from 'path';
|
||||
import { sendRenderResult } from '../../send-payload';
|
||||
import RenderResult from '../../render-result';
|
||||
import { toResponseCacheEntry } from '../../response-cache/utils';
|
||||
import { NoFallbackError } from '../../../shared/lib/no-fallback-error.external';
|
||||
import { RedirectStatusCode } from '../../../client/components/redirect-status-code';
|
||||
import { isBot } from '../../../shared/lib/router/utils/is-bot';
|
||||
import { addPathPrefix } from '../../../shared/lib/router/utils/add-path-prefix';
|
||||
import { removeTrailingSlash } from '../../../shared/lib/router/utils/remove-trailing-slash';
|
||||
export 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) {
|
||||
setRequestMeta(req, ctx.requestMeta);
|
||||
}
|
||||
if (routeModule.isDev) {
|
||||
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(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 = removeTrailingSlash(locale ? 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 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 && isBot(req.headers['user-agent'] || '') || isMinimalMode) {
|
||||
isIsrFallback = false;
|
||||
}
|
||||
const tracer = getTracer();
|
||||
const activeSpan = tracer.getActiveScopeSpan();
|
||||
try {
|
||||
var _parsedUrl_pathname;
|
||||
const method = req.method || 'GET';
|
||||
const resolvedUrl = formatUrl({
|
||||
pathname: nextConfig.trailingSlash ? `${encodedResolvedPathname}${!encodedResolvedPathname.endsWith('/') && ((_parsedUrl_pathname = parsedUrl.pathname) == null ? void 0 : _parsedUrl_pathname.endsWith('/')) ? '/' : ''}` : 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: getRequestMeta(req, 'developmentNotFoundSourcePage')
|
||||
},
|
||||
sharedContext: {
|
||||
buildId,
|
||||
customServer: Boolean(routerServerContext == null ? void 0 : routerServerContext.isCustomServer) || undefined,
|
||||
deploymentId,
|
||||
clientAssetToken
|
||||
},
|
||||
renderOpts: {
|
||||
params,
|
||||
routeModule,
|
||||
page: srcPage,
|
||||
pageConfig: config || {},
|
||||
Component: 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 ? formatUrl({
|
||||
// we use the original URL pathname less the _next/data prefix if
|
||||
// present
|
||||
pathname: isNextDataRequest ? normalizeDataPath(originalPathname) : originalPathname,
|
||||
query: originalQuery
|
||||
}) : resolvedUrl,
|
||||
isOnDemandRevalidate,
|
||||
ErrorDebug: getRequestMeta(req, 'PagesErrorDebug'),
|
||||
err: getRequestMeta(req, 'invokeError'),
|
||||
// needed for experimental.optimizeCss feature
|
||||
distDir: path.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: CachedRouteKind.REDIRECT,
|
||||
props: metadata.pageData ?? metadata.flightData
|
||||
},
|
||||
cacheControl
|
||||
};
|
||||
}
|
||||
return {
|
||||
value: {
|
||||
kind: 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') !== 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: 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 toResponseCacheEntry(previousFallbackCacheEntry);
|
||||
}
|
||||
return doRender();
|
||||
}, {
|
||||
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) === CachedRouteKind.PAGES) {
|
||||
return {
|
||||
value: {
|
||||
kind: CachedRouteKind.PAGES,
|
||||
html: new RenderResult(Buffer.from(previousCacheEntry.value.html), {
|
||||
contentType: 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.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 = 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: 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', 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
|
||||
addRequestMeta(req, 'notFoundRevalidate', (_result_cacheControl1 = result.cacheControl) == null ? void 0 : _result_cacheControl1.revalidate);
|
||||
res.statusCode = 404;
|
||||
if (isNextDataRequest) {
|
||||
if (deploymentId) {
|
||||
res.setHeader(NEXT_NAV_DEPLOYMENT_ID_HEADER, deploymentId);
|
||||
}
|
||||
res.end('{"notFound":true}');
|
||||
return;
|
||||
}
|
||||
return await render404();
|
||||
}
|
||||
if (result.value.kind === CachedRouteKind.REDIRECT) {
|
||||
if (isNextDataRequest) {
|
||||
if (deploymentId) {
|
||||
res.setHeader(NEXT_NAV_DEPLOYMENT_ID_HEADER, deploymentId);
|
||||
}
|
||||
res.setHeader('content-type', 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 = getRedirectStatus(redirect);
|
||||
const { basePath } = nextConfig;
|
||||
if (basePath && redirect.basePath !== false && redirect.destination.startsWith('/')) {
|
||||
redirect.destination = `${basePath}${redirect.destination}`;
|
||||
}
|
||||
if (redirect.destination.startsWith('/')) {
|
||||
redirect.destination = normalizeRepeatedSlashes(redirect.destination);
|
||||
}
|
||||
res.statusCode = statusCode;
|
||||
res.setHeader('Location', redirect.destination);
|
||||
if (statusCode === RedirectStatusCode.PermanentRedirect) {
|
||||
res.setHeader('Refresh', `0;url=${redirect.destination}`);
|
||||
}
|
||||
res.end(redirect.destination);
|
||||
};
|
||||
await handleRedirect(result.value.props);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (result.value.kind !== 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 (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(NEXT_NAV_DEPLOYMENT_ID_HEADER, deploymentId);
|
||||
}
|
||||
}
|
||||
await sendRenderResult({
|
||||
req,
|
||||
res,
|
||||
// If we are rendering the error page it's not a data request
|
||||
// anymore
|
||||
result: isNextDataRequest && !isErrorPage && !is500Page ? new RenderResult(Buffer.from(JSON.stringify(result.value.pageData)), {
|
||||
contentType: 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(BaseServerSpan.handleRequest, {
|
||||
spanName: `${method} ${srcPage}`,
|
||||
kind: SpanKind.SERVER,
|
||||
attributes: {
|
||||
'http.method': method,
|
||||
'http.target': req.url
|
||||
}
|
||||
}, handleResponse));
|
||||
}
|
||||
} catch (err) {
|
||||
if (!(err instanceof NoFallbackError)) {
|
||||
const silenceLog = false;
|
||||
await routeModule.onRequestError(req, err, {
|
||||
routerKind: 'Pages Router',
|
||||
routePath: srcPage,
|
||||
routeType: 'render',
|
||||
revalidateReason: getRevalidateReason({
|
||||
isStaticGeneration: hasStaticProps,
|
||||
isOnDemandRevalidate
|
||||
})
|
||||
}, silenceLog, routerServerContext);
|
||||
}
|
||||
// rethrow so that we can handle serving error page
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//# sourceMappingURL=pages-handler.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = require('../../module.compiled').vendored['contexts'].AppRouterContext;
|
||||
|
||||
//# sourceMappingURL=app-router-context.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../../../src/server/route-modules/pages/vendored/contexts/app-router-context.ts"],"sourcesContent":["module.exports = (\n require('../../module.compiled') as typeof import('../../module.compiled')\n).vendored['contexts'].AppRouterContext\n"],"names":["module","exports","require","vendored","AppRouterContext"],"mappings":"AAAAA,OAAOC,OAAO,GAAG,AACfC,QAAQ,yBACRC,QAAQ,CAAC,WAAW,CAACC,gBAAgB","ignoreList":[0]}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user