Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

12
node_modules/next/dist/export/routes/app-page.d.ts generated vendored Normal file
View File

@ -0,0 +1,12 @@
import type { ExportRouteResult, FileWriter } from '../types';
import type { RenderOpts } from '../../server/app-render/types';
import type { NextParsedUrlQuery } from '../../server/request-meta';
import type { MockedRequest, MockedResponse } from '../../server/lib/mock-request';
export declare const enum ExportedAppPageFiles {
HTML = "HTML",
FLIGHT = "FLIGHT",
PREFETCH_FLIGHT = "PREFETCH_FLIGHT",
META = "META",
POSTPONED = "POSTPONED"
}
export declare function exportAppPage(req: MockedRequest, res: MockedResponse, page: string, path: string, pathname: string, query: NextParsedUrlQuery, renderOpts: RenderOpts, htmlFilepath: string, debugOutput: boolean, isDynamicError: boolean, fileWriter: FileWriter): Promise<ExportRouteResult>;

148
node_modules/next/dist/export/routes/app-page.js generated vendored Normal file
View File

@ -0,0 +1,148 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ExportedAppPageFiles: null,
exportAppPage: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ExportedAppPageFiles: function() {
return ExportedAppPageFiles;
},
exportAppPage: function() {
return exportAppPage;
}
});
const _isdynamicusageerror = require("../helpers/is-dynamic-usage-error");
const _constants = require("../../lib/constants");
const _ciinfo = require("../../telemetry/ci-info");
const _modulerender = require("../../server/future/route-modules/app-page/module.render");
const _bailouttocsr = require("../../shared/lib/lazy-dynamic/bailout-to-csr");
var ExportedAppPageFiles;
(function(ExportedAppPageFiles) {
ExportedAppPageFiles["HTML"] = "HTML";
ExportedAppPageFiles["FLIGHT"] = "FLIGHT";
ExportedAppPageFiles["PREFETCH_FLIGHT"] = "PREFETCH_FLIGHT";
ExportedAppPageFiles["META"] = "META";
ExportedAppPageFiles["POSTPONED"] = "POSTPONED";
})(ExportedAppPageFiles || (ExportedAppPageFiles = {}));
async function exportAppPage(req, res, page, path, pathname, query, renderOpts, htmlFilepath, debugOutput, isDynamicError, fileWriter) {
let isDefaultNotFound = false;
// If the page is `/_not-found`, then we should update the page to be `/404`.
// UNDERSCORE_NOT_FOUND_ROUTE value used here, however we don't want to import it here as it causes constants to be inlined which we don't want here.
if (page === "/_not-found/page") {
isDefaultNotFound = true;
pathname = "/404";
}
try {
const result = await (0, _modulerender.lazyRenderAppPage)(req, res, pathname, query, renderOpts);
const html = result.toUnchunkedString();
const { metadata } = result;
const { flightData, revalidate = false, postponed, fetchTags } = metadata;
// Ensure we don't postpone without having PPR enabled.
if (postponed && !renderOpts.experimental.ppr) {
throw new Error("Invariant: page postponed without PPR being enabled");
}
if (revalidate === 0) {
if (isDynamicError) {
throw new Error(`Page with dynamic = "error" encountered dynamic data method on ${path}.`);
}
const { staticBailoutInfo = {} } = metadata;
if (revalidate === 0 && debugOutput && (staticBailoutInfo == null ? void 0 : staticBailoutInfo.description)) {
logDynamicUsageWarning({
path,
description: staticBailoutInfo.description,
stack: staticBailoutInfo.stack
});
}
return {
revalidate: 0
};
} else if (!flightData) {
throw new Error(`Invariant: failed to get page data for ${path}`);
} else if (renderOpts.experimental.ppr) {
// If PPR is enabled, we should emit the flight data as the prefetch
// payload.
await fileWriter("PREFETCH_FLIGHT", htmlFilepath.replace(/\.html$/, _constants.RSC_PREFETCH_SUFFIX), flightData);
} else {
// Writing the RSC payload to a file if we don't have PPR enabled.
await fileWriter("FLIGHT", htmlFilepath.replace(/\.html$/, _constants.RSC_SUFFIX), flightData);
}
const headers = {
...metadata.headers
};
// When PPR is enabled, we should grab the headers from the mocked response
// and add it to the headers.
if (renderOpts.experimental.ppr) {
Object.assign(headers, res.getHeaders());
}
if (fetchTags) {
headers[_constants.NEXT_CACHE_TAGS_HEADER] = fetchTags;
}
// Writing static HTML to a file.
await fileWriter("HTML", htmlFilepath, html ?? "", "utf8");
const isParallelRoute = /\/@\w+/.test(page);
const isNonSuccessfulStatusCode = res.statusCode > 300;
// When PPR is enabled, we don't always send 200 for routes that have been
// pregenerated, so we should grab the status code from the mocked
// response.
let status = renderOpts.experimental.ppr ? res.statusCode : undefined;
if (isDefaultNotFound) {
// Override the default /_not-found page status code to 404
status = 404;
} else if (isNonSuccessfulStatusCode && !isParallelRoute) {
// If it's parallel route the status from mock response is 404
status = res.statusCode;
}
// Writing the request metadata to a file.
const meta = {
status,
headers,
postponed
};
await fileWriter("META", htmlFilepath.replace(/\.html$/, _constants.NEXT_META_SUFFIX), JSON.stringify(meta, null, 2));
return {
// Only include the metadata if the environment has next support.
metadata: _ciinfo.hasNextSupport ? meta : undefined,
hasEmptyPrelude: Boolean(postponed) && html === "",
hasPostponed: Boolean(postponed),
revalidate
};
} catch (err) {
if (!(0, _isdynamicusageerror.isDynamicUsageError)(err)) {
throw err;
}
// If enabled, we should fail rendering if a client side rendering bailout
// occurred at the page level.
if (renderOpts.experimental.missingSuspenseWithCSRBailout && (0, _bailouttocsr.isBailoutToCSRError)(err)) {
throw err;
}
if (debugOutput) {
const { dynamicUsageDescription, dynamicUsageStack } = renderOpts.store;
logDynamicUsageWarning({
path,
description: dynamicUsageDescription,
stack: dynamicUsageStack
});
}
return {
revalidate: 0
};
}
}
function logDynamicUsageWarning({ path, description, stack }) {
const errMessage = new Error(`Static generation failed due to dynamic usage on ${path}, reason: ${description}`);
if (stack) {
errMessage.stack = errMessage.message + stack.substring(stack.indexOf("\n"));
}
console.warn(errMessage);
}
//# sourceMappingURL=app-page.js.map

1
node_modules/next/dist/export/routes/app-page.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/export/routes/app-page.ts"],"names":["exportAppPage","ExportedAppPageFiles","req","res","page","path","pathname","query","renderOpts","htmlFilepath","debugOutput","isDynamicError","fileWriter","isDefaultNotFound","result","lazyRenderAppPage","html","toUnchunkedString","metadata","flightData","revalidate","postponed","fetchTags","experimental","ppr","Error","staticBailoutInfo","description","logDynamicUsageWarning","stack","replace","RSC_PREFETCH_SUFFIX","RSC_SUFFIX","headers","Object","assign","getHeaders","NEXT_CACHE_TAGS_HEADER","isParallelRoute","test","isNonSuccessfulStatusCode","statusCode","status","undefined","meta","NEXT_META_SUFFIX","JSON","stringify","hasNextSupport","hasEmptyPrelude","Boolean","hasPostponed","err","isDynamicUsageError","missingSuspenseWithCSRBailout","isBailoutToCSRError","dynamicUsageDescription","dynamicUsageStack","store","errMessage","message","substring","indexOf","console","warn"],"mappings":";;;;;;;;;;;;;;;;;;IA6BsBA,aAAa;eAAbA;;;qCAnBc;2BAM7B;wBACwB;8BACG;8BACE;;UAElBC;;;;;;GAAAA,yBAAAA;AAQX,eAAeD,cACpBE,GAAkB,EAClBC,GAAmB,EACnBC,IAAY,EACZC,IAAY,EACZC,QAAgB,EAChBC,KAAyB,EACzBC,UAAsB,EACtBC,YAAoB,EACpBC,WAAoB,EACpBC,cAAuB,EACvBC,UAAsB;IAEtB,IAAIC,oBAAoB;IACxB,6EAA6E;IAC7E,qJAAqJ;IACrJ,IAAIT,SAAS,oBAAoB;QAC/BS,oBAAoB;QACpBP,WAAW;IACb;IAEA,IAAI;QACF,MAAMQ,SAAS,MAAMC,IAAAA,+BAAiB,EACpCb,KACAC,KACAG,UACAC,OACAC;QAGF,MAAMQ,OAAOF,OAAOG,iBAAiB;QAErC,MAAM,EAAEC,QAAQ,EAAE,GAAGJ;QACrB,MAAM,EAAEK,UAAU,EAAEC,aAAa,KAAK,EAAEC,SAAS,EAAEC,SAAS,EAAE,GAAGJ;QAEjE,uDAAuD;QACvD,IAAIG,aAAa,CAACb,WAAWe,YAAY,CAACC,GAAG,EAAE;YAC7C,MAAM,IAAIC,MAAM;QAClB;QAEA,IAAIL,eAAe,GAAG;YACpB,IAAIT,gBAAgB;gBAClB,MAAM,IAAIc,MACR,CAAC,+DAA+D,EAAEpB,KAAK,CAAC,CAAC;YAE7E;YACA,MAAM,EAAEqB,oBAAoB,CAAC,CAAC,EAAE,GAA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C1BF;YACAT;YACAZ;QACF;QAEA,MAAMT,mBAEJH,aAAaqB,OAAO,CAAC,WAAWe,2BAAgB,GAChDC,KAAKC,SAAS,CAACH,MAAM,MAAM;QAG7B,OAAO;YACL,iEAAiE;YACjE1B,UAAU8B,sBAAc,GAAGJ,OAAOD;YAClCM,iBAAiBC,QAAQ7B,cAAcL,SAAS;YAChDmC,cAAcD,QAAQ7B;YACtBD;QACF;IACF,EAAE,OAAOgC,KAAK;QACZ,IAAI,CAACC,IAAAA,wCAAmB,EAACD,MAAM;YAC7B,MAAMA;QACR;QAEA,0EAA0E;QAC1E,8BAA8B;QAC9B,IACE5C,WAAWe,YAAY,CAAC+B,6BAA6B,IACrDC,IAAAA,iCAAmB,EAACH,MACpB;YACA,MAAMA;QACR;QAEA,IAAI1C,aAAa;YACf,MAAM,EAAE8C,uBAAuB,EAAEC,iBAAiB,EAAE,GAAG,AAACjD,WACrDkD,KAAK;YAER9B,uBAAuB;gBACrBvB;gBACAsB,aAAa6B;gBACb3B,OAAO4B;YACT;QACF;QAEA,OAAO;YAAErC,YAAY;QAAE;IACzB;AACF;AAEA,SAASQ,uBAAuB,EAC9BvB,IAAI,EACJsB,WAAW,EACXE,KAAK,EAKN;IACC,MAAM8B,aAAa,IAAIlC,MACrB,CAAC,iDAAiD,EAAEpB,KAAK,UAAU,EAAEsB,YAAY,CAAC;IAGpF,IAAIE,OAAO;QACT8B,WAAW9B,KAAK,GAAG8B,WAAWC,OAAO,GAAG/B,MAAMgC,SAAS,CAAChC,MAAMiC,OAAO,CAAC;IACxE;IAEAC,QAAQC,IAAI,CAACL;AACf"}

10
node_modules/next/dist/export/routes/app-route.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
import type { ExportRouteResult, FileWriter } from '../types';
import type { IncrementalCache } from '../../server/lib/incremental-cache';
import type { MockedRequest, MockedResponse } from '../../server/lib/mock-request';
export declare const enum ExportedAppRouteFiles {
BODY = "BODY",
META = "META"
}
export declare function exportAppRoute(req: MockedRequest, res: MockedResponse, params: {
[key: string]: string | string[];
} | undefined, page: string, incrementalCache: IncrementalCache | undefined, distDir: string, htmlFilepath: string, fileWriter: FileWriter): Promise<ExportRouteResult>;

117
node_modules/next/dist/export/routes/app-route.js generated vendored Normal file
View File

@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ExportedAppRouteFiles: null,
exportAppRoute: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ExportedAppRouteFiles: function() {
return ExportedAppRouteFiles;
},
exportAppRoute: function() {
return exportAppRoute;
}
});
const _path = require("path");
const _constants = require("../../lib/constants");
const _node = require("../../server/base-http/node");
const _routemoduleloader = require("../../server/future/helpers/module-loader/route-module-loader");
const _nextrequest = require("../../server/web/spec-extension/adapters/next-request");
const _utils = require("../../server/web/utils");
const _isdynamicusageerror = require("../helpers/is-dynamic-usage-error");
const _constants1 = require("../../shared/lib/constants");
const _ciinfo = require("../../telemetry/ci-info");
var ExportedAppRouteFiles;
(function(ExportedAppRouteFiles) {
ExportedAppRouteFiles["BODY"] = "BODY";
ExportedAppRouteFiles["META"] = "META";
})(ExportedAppRouteFiles || (ExportedAppRouteFiles = {}));
async function exportAppRoute(req, res, params, page, incrementalCache, distDir, htmlFilepath, fileWriter) {
// Ensure that the URL is absolute.
req.url = `http://localhost:3000${req.url}`;
// Adapt the request and response to the Next.js request and response.
const request = _nextrequest.NextRequestAdapter.fromNodeNextRequest(new _node.NodeNextRequest(req), (0, _nextrequest.signalFromNodeResponse)(res));
// Create the context for the handler. This contains the params from
// the route and the context for the request.
const context = {
params,
prerenderManifest: {
version: 4,
routes: {},
dynamicRoutes: {},
preview: {
previewModeEncryptionKey: "",
previewModeId: "",
previewModeSigningKey: ""
},
notFoundRoutes: []
},
renderOpts: {
experimental: {
ppr: false
},
originalPathname: page,
nextExport: true,
supportsDynamicResponse: false,
incrementalCache
}
};
if (_ciinfo.hasNextSupport) {
context.renderOpts.isRevalidate = true;
}
// This is a route handler, which means it has it's handler in the
// bundled file already, we should just use that.
const filename = (0, _path.join)(distDir, _constants1.SERVER_DIRECTORY, "app", page);
try {
var _context_renderOpts_store;
// Route module loading and handling.
const module1 = await _routemoduleloader.RouteModuleLoader.load(filename);
const response = await module1.handle(request, context);
const isValidStatus = response.status < 400 || response.status === 404;
if (!isValidStatus) {
return {
revalidate: 0
};
}
const blob = await response.blob();
const revalidate = typeof ((_context_renderOpts_store = context.renderOpts.store) == null ? void 0 : _context_renderOpts_store.revalidate) === "undefined" ? false : context.renderOpts.store.revalidate;
const headers = (0, _utils.toNodeOutgoingHttpHeaders)(response.headers);
const cacheTags = context.renderOpts.fetchTags;
if (cacheTags) {
headers[_constants.NEXT_CACHE_TAGS_HEADER] = cacheTags;
}
if (!headers["content-type"] && blob.type) {
headers["content-type"] = blob.type;
}
// Writing response body to a file.
const body = Buffer.from(await blob.arrayBuffer());
await fileWriter("BODY", htmlFilepath.replace(/\.html$/, _constants.NEXT_BODY_SUFFIX), body, "utf8");
// Write the request metadata to a file.
const meta = {
status: response.status,
headers
};
await fileWriter("META", htmlFilepath.replace(/\.html$/, _constants.NEXT_META_SUFFIX), JSON.stringify(meta));
return {
revalidate: revalidate,
metadata: meta
};
} catch (err) {
if (!(0, _isdynamicusageerror.isDynamicUsageError)(err)) {
throw err;
}
return {
revalidate: 0
};
}
}
//# sourceMappingURL=app-route.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/export/routes/app-route.ts"],"names":["exportAppRoute","ExportedAppRouteFiles","req","res","params","page","incrementalCache","distDir","htmlFilepath","fileWriter","url","request","NextRequestAdapter","fromNodeNextRequest","NodeNextRequest","signalFromNodeResponse","context","prerenderManifest","version","routes","dynamicRoutes","preview","previewModeEncryptionKey","previewModeId","previewModeSigningKey","notFoundRoutes","renderOpts","experimental","ppr","originalPathname","nextExport","supportsDynamicResponse","hasNextSupport","isRevalidate","filename","join","SERVER_DIRECTORY","module","RouteModuleLoader","load","response","handle","isValidStatus","status","revalidate","blob","store","headers","toNodeOutgoingHttpHeaders","cacheTags","fetchTags","NEXT_CACHE_TAGS_HEADER","type","body","Buffer","from","arrayBuffer","replace","NEXT_BODY_SUFFIX","meta","NEXT_META_SUFFIX","JSON","stringify","metadata","err","isDynamicUsageError"],"mappings":";;;;;;;;;;;;;;;;;;IA+BsBA,cAAc;eAAdA;;;sBA1BD;2BAKd;sBACyB;mCACE;6BAI3B;uBACmC;qCAKN;4BACH;wBACF;;UAEbC;;;GAAAA,0BAAAA;AAKX,eAAeD,eACpBE,GAAkB,EAClBC,GAAmB,EACnBC,MAAwD,EACxDC,IAAY,EACZC,gBAA8C,EAC9CC,OAAe,EACfC,YAAoB,EACpBC,UAAsB;IAEtB,mCAAmC;IACnCP,IAAIQ,GAAG,GAAG,CAAC,qBAAqB,EAAER,IAAIQ,GAAG,CAAC,CAAC;IAE3C,sEAAsE;IACtE,MAAMC,UAAUC,+BAAkB,CAACC,mBAAmB,CACpD,IAAIC,qBAAe,CAACZ,MACpBa,IAAAA,mCAAsB,EAACZ;IAGzB,oEAAoE;IACpE,6CAA6C;IAC7C,MAAMa,UAAuC;QAC3CZ;QACAa,mBAAmB;YACjBC,SAAS;YACTC,QAAQ,CAAC;YACTC,eAAe,CAAC;YAChBC,SAAS;gBACPC,0BAA0B;gBAC1BC,eAAe;gBACfC,uBAAuB;YACzB;YACAC,gBAAgB,EAAE;QACpB;QACAC,YAAY;YACVC,cAAc;gBAAEC,KAAK;YAAM;YAC3BC,kBAAkBxB;YAClByB,YAAY;YACZC,yBAAyB;YACzBzB;QACF;IACF;IAEA,IAAI0B,sBAAc,EAAE;QAClBhB,QAAQU,UAAU,CAACO,YAAY,GAAG;IACpC;IAEA,kEAAkE;IAClE,iDAAiD;IACjD,MAAMC,WAAWC,IAAAA,UAAI,EAAC5B,SAAS6B,4BAAgB,EAAE,OAAO/B;IAExD,IAAI;YAYOW;QAXT,qCAAqC;QACrC,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vendored Normal file
View File

@ -0,0 +1,12 @@
import type { ExportRouteResult, FileWriter } from '../types';
import type { RenderOpts } from '../../server/render';
import type { LoadComponentsReturnType } from '../../server/load-components';
import type { NextParsedUrlQuery } from '../../server/request-meta';
import type { MockedRequest, MockedResponse } from '../../server/lib/mock-request';
export declare const enum ExportedPagesFiles {
HTML = "HTML",
DATA = "DATA",
AMP_HTML = "AMP_HTML",
AMP_DATA = "AMP_PAGE_DATA"
}
export declare function exportPages(req: MockedRequest, res: MockedResponse, path: string, page: string, query: NextParsedUrlQuery, htmlFilepath: string, htmlFilename: string, ampPath: string, subFolders: boolean, outDir: string, ampValidatorPath: string | undefined, pagesDataDir: string, buildExport: boolean, isDynamic: boolean, hasOrigQueryValues: boolean, renderOpts: RenderOpts, components: LoadComponentsReturnType, fileWriter: FileWriter): Promise<ExportRouteResult | undefined>;

151
node_modules/next/dist/export/routes/pages.js generated vendored Normal file
View File

@ -0,0 +1,151 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ExportedPagesFiles: null,
exportPages: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ExportedPagesFiles: function() {
return ExportedPagesFiles;
},
exportPages: function() {
return exportPages;
}
});
const _renderresult = /*#__PURE__*/ _interop_require_default(require("../../server/render-result"));
const _path = require("path");
const _ampmode = require("../../shared/lib/amp-mode");
const _constants = require("../../lib/constants");
const _bailouttocsr = require("../../shared/lib/lazy-dynamic/bailout-to-csr");
const _amphtmlvalidator = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/amphtml-validator"));
const _fileexists = require("../../lib/file-exists");
const _modulerender = require("../../server/future/route-modules/pages/module.render");
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
var ExportedPagesFiles;
(function(ExportedPagesFiles) {
ExportedPagesFiles["HTML"] = "HTML";
ExportedPagesFiles["DATA"] = "DATA";
ExportedPagesFiles["AMP_HTML"] = "AMP_HTML";
ExportedPagesFiles["AMP_DATA"] = "AMP_PAGE_DATA";
})(ExportedPagesFiles || (ExportedPagesFiles = {}));
async function exportPages(req, res, path, page, query, htmlFilepath, htmlFilename, ampPath, subFolders, outDir, ampValidatorPath, pagesDataDir, buildExport, isDynamic, hasOrigQueryValues, renderOpts, components, fileWriter) {
var _components_pageConfig, _components_pageConfig1;
const ampState = {
ampFirst: ((_components_pageConfig = components.pageConfig) == null ? void 0 : _components_pageConfig.amp) === true,
hasQuery: Boolean(query.amp),
hybrid: ((_components_pageConfig1 = components.pageConfig) == null ? void 0 : _components_pageConfig1.amp) === "hybrid"
};
const inAmpMode = (0, _ampmode.isInAmpMode)(ampState);
const hybridAmp = ampState.hybrid;
if (components.getServerSideProps) {
throw new Error(`Error for page ${page}: ${_constants.SERVER_PROPS_EXPORT_ERROR}`);
}
// for non-dynamic SSG pages we should have already
// prerendered the file
if (!buildExport && components.getStaticProps && !isDynamic) {
return;
}
if (components.getStaticProps && !htmlFilepath.endsWith(".html")) {
// make sure it ends with .html if the name contains a dot
htmlFilepath += ".html";
htmlFilename += ".html";
}
let renderResult;
if (typeof components.Component === "string") {
renderResult = _renderresult.default.fromStatic(components.Component);
if (hasOrigQueryValues) {
throw new Error(`\nError: you provided query values for ${path} which is an auto-exported page. These can not be applied since the page can no longer be re-rendered on the server. To disable auto-export for this page add \`getInitialProps\`\n`);
}
} else {
/**
* This sets environment variable to be used at the time of static export by head.tsx.
* Using this from process.env allows targeting SSR by calling
* `process.env.__NEXT_OPTIMIZE_FONTS`.
* TODO(prateekbh@): Remove this when experimental.optimizeFonts are being cleaned up.
*/ if (renderOpts.optimizeFonts) {
process.env.__NEXT_OPTIMIZE_FONTS = JSON.stringify(renderOpts.optimizeFonts);
}
if (renderOpts.optimizeCss) {
process.env.__NEXT_OPTIMIZE_CSS = JSON.stringify(true);
}
try {
renderResult = await (0, _modulerender.lazyRenderPagesPage)(req, res, page, query, renderOpts);
} catch (err) {
if (!(0, _bailouttocsr.isBailoutToCSRError)(err)) throw err;
}
}
const ssgNotFound = renderResult == null ? void 0 : renderResult.metadata.isNotFound;
const ampValidations = [];
const validateAmp = async (rawAmpHtml, ampPageName, validatorPath)=>{
const validator = await _amphtmlvalidator.default.getInstance(validatorPath);
const result = validator.validateString(rawAmpHtml);
const errors = result.errors.filter((e)=>e.severity === "ERROR");
const warnings = result.errors.filter((e)=>e.severity !== "ERROR");
if (warnings.length || errors.length) {
ampValidations.push({
page: ampPageName,
result: {
errors,
warnings
}
});
}
};
const html = renderResult && !renderResult.isNull ? renderResult.toUnchunkedString() : "";
let ampRenderResult;
if (inAmpMode && !renderOpts.ampSkipValidation) {
if (!ssgNotFound) {
await validateAmp(html, path, ampValidatorPath);
}
} else if (hybridAmp) {
const ampHtmlFilename = subFolders ? (0, _path.join)(ampPath, "index.html") : `${ampPath}.html`;
const ampHtmlFilepath = (0, _path.join)(outDir, ampHtmlFilename);
const exists = await (0, _fileexists.fileExists)(ampHtmlFilepath, _fileexists.FileType.File);
if (!exists) {
try {
ampRenderResult = await (0, _modulerender.lazyRenderPagesPage)(req, res, page, {
...query,
amp: "1"
}, renderOpts);
} catch (err) {
if (!(0, _bailouttocsr.isBailoutToCSRError)(err)) throw err;
}
const ampHtml = ampRenderResult && !ampRenderResult.isNull ? ampRenderResult.toUnchunkedString() : "";
if (!renderOpts.ampSkipValidation) {
await validateAmp(ampHtml, page + "?amp=1", ampValidatorPath);
}
await fileWriter("AMP_HTML", ampHtmlFilepath, ampHtml, "utf8");
}
}
const metadata = (renderResult == null ? void 0 : renderResult.metadata) || (ampRenderResult == null ? void 0 : ampRenderResult.metadata) || {};
if (metadata.pageData) {
const dataFile = (0, _path.join)(pagesDataDir, htmlFilename.replace(/\.html$/, _constants.NEXT_DATA_SUFFIX));
await fileWriter("DATA", dataFile, JSON.stringify(metadata.pageData), "utf8");
if (hybridAmp) {
await fileWriter("AMP_PAGE_DATA", dataFile.replace(/\.json$/, ".amp.json"), JSON.stringify(metadata.pageData), "utf8");
}
}
if (!ssgNotFound) {
// don't attempt writing to disk if getStaticProps returned not found
await fileWriter("HTML", htmlFilepath, html, "utf8");
}
return {
ampValidations,
revalidate: metadata.revalidate ?? false,
ssgNotFound
};
}
//# sourceMappingURL=pages.js.map

1
node_modules/next/dist/export/routes/pages.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/export/routes/pages.ts"],"names":["exportPages","ExportedPagesFiles","req","res","path","page","query","htmlFilepath","htmlFilename","ampPath","subFolders","outDir","ampValidatorPath","pagesDataDir","buildExport","isDynamic","hasOrigQueryValues","renderOpts","components","fileWriter","ampState","ampFirst","pageConfig","amp","hasQuery","Boolean","hybrid","inAmpMode","isInAmpMode","hybridAmp","getServerSideProps","Error","SERVER_PROPS_EXPORT_ERROR","getStaticProps","endsWith","renderResult","Component","RenderResult","fromStatic","optimizeFonts","process","env","__NEXT_OPTIMIZE_FONTS","JSON","stringify","optimizeCss","__NEXT_OPTIMIZE_CSS","lazyRenderPagesPage","err","isBailoutToCSRError","ssgNotFound","metadata","isNotFound","ampValidations","validateAmp","rawAmpHtml","ampPageName","validatorPath","validator","AmpHtmlValidator","getInstance","result","validateString","errors","filter","e","severity","warnings","length","push","html","isNull","toUnchunkedString","ampRenderResult","ampSkipValidation","ampHtmlFilename","join","ampHtmlFilepath","exists","fileExists","FileType","File","ampHtml","pageData","dataFile","replace","NEXT_DATA_SUFFIX","revalidate"],"mappings":";;;;;;;;;;;;;;;;;;IA6BsBA,WAAW;eAAXA;;;qEAvBG;sBACJ;yBAKO;2BAIrB;8BAC6B;yEACP;4BACQ;8BACD;;;;;;;UAElBC;;;;;GAAAA,uBAAAA;AAOX,eAAeD,YACpBE,GAAkB,EAClBC,GAAmB,EACnBC,IAAY,EACZC,IAAY,EACZC,KAAyB,EACzBC,YAAoB,EACpBC,YAAoB,EACpBC,OAAe,EACfC,UAAmB,EACnBC,MAAc,EACdC,gBAAoC,EACpCC,YAAoB,EACpBC,WA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E,MACA;oBAAE,GAAGC,KAAK;oBAAEiB,KAAK;gBAAI,GACrBN;YAEJ,EAAE,OAAO+B,KAAK;gBACZ,IAAI,CAACC,IAAAA,iCAAmB,EAACD,MAAM,MAAMA;YACvC;YAEA,MAAMkC,UACJT,mBAAmB,CAACA,gBAAgBF,MAAM,GACtCE,gBAAgBD,iBAAiB,KACjC;YACN,IAAI,CAACvD,WAAWyD,iBAAiB,EAAE;gBACjC,MAAMpB,YAAY4B,SAAS7E,OAAO,UAAUO;YAC9C;YAEA,MAAMO,uBAEJ0D,iBACAK,SACA;QAEJ;IACF;IAEA,MAAM/B,WAAWhB,CAAAA,gCAAAA,aAAcgB,QAAQ,MAAIsB,mCAAAA,gBAAiBtB,QAAQ,KAAI,CAAC;IACzE,IAAIA,SAASgC,QAAQ,EAAE;QACrB,MAAMC,WAAWR,IAAAA,UAAI,EACnB/D,cACAL,aAAa6E,OAAO,CAAC,WAAWC,2BAAgB;QAGlD,MAAMnE,mBAEJiE,UACAzC,KAAKC,SAAS,CAACO,SAASgC,QAAQ,GAChC;QAGF,IAAItD,WAAW;YACb,MAAMV,4BAEJiE,SAASC,OAAO,CAAC,WAAW,cAC5B1C,KAAKC,SAAS,CAACO,SAASgC,QAAQ,GAChC;QAEJ;IACF;IAEA,IAAI,CAACjC,aAAa;QAChB,qEAAqE;QACrE,MAAM/B,mBAAoCZ,cAAc+D,MAAM;IAChE;IAEA,OAAO;QACLjB;QACAkC,YAAYpC,SAASoC,UAAU,IAAI;QACnCrC;IACF;AACF"}

7
node_modules/next/dist/export/routes/types.d.ts generated vendored Normal file
View File

@ -0,0 +1,7 @@
/// <reference types="node" />
import type { OutgoingHttpHeaders } from 'node:http';
export type RouteMetadata = {
status: number | undefined;
headers: OutgoingHttpHeaders | undefined;
postponed: string | undefined;
};

6
node_modules/next/dist/export/routes/types.js generated vendored Normal file
View File

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

1
node_modules/next/dist/export/routes/types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}