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

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

@ -0,0 +1,126 @@
import { isDynamicUsageError } from "../helpers/is-dynamic-usage-error";
import { NEXT_CACHE_TAGS_HEADER, NEXT_META_SUFFIX, RSC_PREFETCH_SUFFIX, RSC_SUFFIX } from "../../lib/constants";
import { hasNextSupport } from "../../telemetry/ci-info";
import { lazyRenderAppPage } from "../../server/future/route-modules/app-page/module.render";
import { isBailoutToCSRError } from "../../shared/lib/lazy-dynamic/bailout-to-csr";
export var ExportedAppPageFiles;
(function(ExportedAppPageFiles) {
ExportedAppPageFiles["HTML"] = "HTML";
ExportedAppPageFiles["FLIGHT"] = "FLIGHT";
ExportedAppPageFiles["PREFETCH_FLIGHT"] = "PREFETCH_FLIGHT";
ExportedAppPageFiles["META"] = "META";
ExportedAppPageFiles["POSTPONED"] = "POSTPONED";
})(ExportedAppPageFiles || (ExportedAppPageFiles = {}));
export 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 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$/, 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$/, 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[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$/, NEXT_META_SUFFIX), JSON.stringify(meta, null, 2));
return {
// Only include the metadata if the environment has next support.
metadata: hasNextSupport ? meta : undefined,
hasEmptyPrelude: Boolean(postponed) && html === "",
hasPostponed: Boolean(postponed),
revalidate
};
} catch (err) {
if (!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 && 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

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/export/routes/app-page.ts"],"names":["isDynamicUsageError","NEXT_CACHE_TAGS_HEADER","NEXT_META_SUFFIX","RSC_PREFETCH_SUFFIX","RSC_SUFFIX","hasNextSupport","lazyRenderAppPage","isBailoutToCSRError","ExportedAppPageFiles","exportAppPage","req","res","page","path","pathname","query","renderOpts","htmlFilepath","debugOutput","isDynamicError","fileWriter","isDefaultNotFound","result","html","toUnchunkedString","metadata","flightData","revalidate","postponed","fetchTags","experimental","ppr","Error","staticBailoutInfo","description","logDynamicUsageWarning","stack","replace","headers","Object","assign","getHeaders","isParallelRoute","test","isNonSuccessfulStatusCode","statusCode","status","undefined","meta","JSON","stringify","hasEmptyPrelude","Boolean","hasPostponed","err","missingSuspenseWithCSRBailout","dynamicUsageDescription","dynamicUsageStack","store","errMessage","message","substring","indexOf","console","warn"],"mappings":"AAUA,SAASA,mBAAmB,QAAQ,oCAAmC;AACvE,SACEC,sBAAsB,EACtBC,gBAAgB,EAChBC,mBAAmB,EACnBC,UAAU,QACL,sBAAqB;AAC5B,SAASC,cAAc,QAAQ,0BAAyB;AACxD,SAASC,iBAAiB,QAAQ,2DAA0D;AAC5F,SAASC,mBAAmB,QAAQ,+CAA8C;;UAEhEC;;;;;;GAAAA,yBAAAA;AAQlB,OAAO,eAAeC,cACpBC,GAAkB,EAClBC,GAAmB,EACnBC,IAAY,EACZC,IAAY,EACZC,QAAgB,EAChBC,KAAyB,EACzBC,UAAsB,EACtBC,YAAoB,EACpBC,WAAo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pB,OAAOqB;YACT;QACF;QAEA,OAAO;YAAE9B,YAAY;QAAE;IACzB;AACF;AAEA,SAASQ,uBAAuB,EAC9BtB,IAAI,EACJqB,WAAW,EACXE,KAAK,EAKN;IACC,MAAMuB,aAAa,IAAI3B,MACrB,CAAC,iDAAiD,EAAEnB,KAAK,UAAU,EAAEqB,YAAY,CAAC;IAGpF,IAAIE,OAAO;QACTuB,WAAWvB,KAAK,GAAGuB,WAAWC,OAAO,GAAGxB,MAAMyB,SAAS,CAACzB,MAAM0B,OAAO,CAAC;IACxE;IAEAC,QAAQC,IAAI,CAACL;AACf"}

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

@ -0,0 +1,95 @@
import { join } from "path";
import { NEXT_BODY_SUFFIX, NEXT_CACHE_TAGS_HEADER, NEXT_META_SUFFIX } from "../../lib/constants";
import { NodeNextRequest } from "../../server/base-http/node";
import { RouteModuleLoader } from "../../server/future/helpers/module-loader/route-module-loader";
import { NextRequestAdapter, signalFromNodeResponse } from "../../server/web/spec-extension/adapters/next-request";
import { toNodeOutgoingHttpHeaders } from "../../server/web/utils";
import { isDynamicUsageError } from "../helpers/is-dynamic-usage-error";
import { SERVER_DIRECTORY } from "../../shared/lib/constants";
import { hasNextSupport } from "../../telemetry/ci-info";
export var ExportedAppRouteFiles;
(function(ExportedAppRouteFiles) {
ExportedAppRouteFiles["BODY"] = "BODY";
ExportedAppRouteFiles["META"] = "META";
})(ExportedAppRouteFiles || (ExportedAppRouteFiles = {}));
export 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 = NextRequestAdapter.fromNodeNextRequest(new NodeNextRequest(req), 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 (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 = join(distDir, SERVER_DIRECTORY, "app", page);
try {
var _context_renderOpts_store;
// Route module loading and handling.
const module = await RouteModuleLoader.load(filename);
const response = await module.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 = toNodeOutgoingHttpHeaders(response.headers);
const cacheTags = context.renderOpts.fetchTags;
if (cacheTags) {
headers[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$/, NEXT_BODY_SUFFIX), body, "utf8");
// Write the request metadata to a file.
const meta = {
status: response.status,
headers
};
await fileWriter("META", htmlFilepath.replace(/\.html$/, NEXT_META_SUFFIX), JSON.stringify(meta));
return {
revalidate: revalidate,
metadata: meta
};
} catch (err) {
if (!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":["join","NEXT_BODY_SUFFIX","NEXT_CACHE_TAGS_HEADER","NEXT_META_SUFFIX","NodeNextRequest","RouteModuleLoader","NextRequestAdapter","signalFromNodeResponse","toNodeOutgoingHttpHeaders","isDynamicUsageError","SERVER_DIRECTORY","hasNextSupport","ExportedAppRouteFiles","exportAppRoute","req","res","params","page","incrementalCache","distDir","htmlFilepath","fileWriter","url","request","fromNodeNextRequest","context","prerenderManifest","version","routes","dynamicRoutes","preview","previewModeEncryptionKey","previewModeId","previewModeSigningKey","notFoundRoutes","renderOpts","experimental","ppr","originalPathname","nextExport","supportsDynamicResponse","isRevalidate","filename","module","load","response","handle","isValidStatus","status","revalidate","blob","store","headers","cacheTags","fetchTags","type","body","Buffer","from","arrayBuffer","replace","meta","JSON","stringify","metadata","err"],"mappings":"AAKA,SAASA,IAAI,QAAQ,OAAM;AAC3B,SACEC,gBAAgB,EAChBC,sBAAsB,EACtBC,gBAAgB,QACX,sBAAqB;AAC5B,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,iBAAiB,QAAQ,gEAA+D;AACjG,SACEC,kBAAkB,EAClBC,sBAAsB,QACjB,wDAAuD;AAC9D,SAASC,yBAAyB,QAAQ,yBAAwB;AAKlE,SAASC,mBAAmB,QAAQ,oCAAmC;AACvE,SAASC,gBAAgB,QAAQ,6BAA4B;AAC7D,SAASC,cAAc,QAAQ,0BAAyB;;UAEtCC;;;GAAAA,0BAAAA;AAKlB,OAAO,eAAeC,eACpBC,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,UAAUjB,mBAAmBkB,mBAAmB,CACpD,IAAIpB,gBAAgBU,MACpBP,uBAAuBQ;IAGzB,oEAAoE;IACpE,6CAA6C;IAC7C,MAAMU,UAAuC;QAC3CT;QACAU,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,KAA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,KAAKC,SAAS,CAACF;QAGjB,OAAO;YACLZ,YAAYA;YACZe,UAAUH;QACZ;IACF,EAAE,OAAOI,KAAK;QACZ,IAAI,CAACxD,oBAAoBwD,MAAM;YAC7B,MAAMA;QACR;QAEA,OAAO;YAAEhB,YAAY;QAAE;IACzB;AACF"}

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

@ -0,0 +1,124 @@
import RenderResult from "../../server/render-result";
import { join } from "path";
import { isInAmpMode } from "../../shared/lib/amp-mode";
import { NEXT_DATA_SUFFIX, SERVER_PROPS_EXPORT_ERROR } from "../../lib/constants";
import { isBailoutToCSRError } from "../../shared/lib/lazy-dynamic/bailout-to-csr";
import AmpHtmlValidator from "next/dist/compiled/amphtml-validator";
import { FileType, fileExists } from "../../lib/file-exists";
import { lazyRenderPagesPage } from "../../server/future/route-modules/pages/module.render";
export var ExportedPagesFiles;
(function(ExportedPagesFiles) {
ExportedPagesFiles["HTML"] = "HTML";
ExportedPagesFiles["DATA"] = "DATA";
ExportedPagesFiles["AMP_HTML"] = "AMP_HTML";
ExportedPagesFiles["AMP_DATA"] = "AMP_PAGE_DATA";
})(ExportedPagesFiles || (ExportedPagesFiles = {}));
export 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 = isInAmpMode(ampState);
const hybridAmp = ampState.hybrid;
if (components.getServerSideProps) {
throw new Error(`Error for page ${page}: ${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.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 lazyRenderPagesPage(req, res, page, query, renderOpts);
} catch (err) {
if (!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.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 ? join(ampPath, "index.html") : `${ampPath}.html`;
const ampHtmlFilepath = join(outDir, ampHtmlFilename);
const exists = await fileExists(ampHtmlFilepath, FileType.File);
if (!exists) {
try {
ampRenderResult = await lazyRenderPagesPage(req, res, page, {
...query,
amp: "1"
}, renderOpts);
} catch (err) {
if (!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 = join(pagesDataDir, htmlFilename.replace(/\.html$/, 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

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/export/routes/pages.ts"],"names":["RenderResult","join","isInAmpMode","NEXT_DATA_SUFFIX","SERVER_PROPS_EXPORT_ERROR","isBailoutToCSRError","AmpHtmlValidator","FileType","fileExists","lazyRenderPagesPage","ExportedPagesFiles","exportPages","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","hybridAmp","getServerSideProps","Error","getStaticProps","endsWith","renderResult","Component","fromStatic","optimizeFonts","process","env","__NEXT_OPTIMIZE_FONTS","JSON","stringify","optimizeCss","__NEXT_OPTIMIZE_CSS","err","ssgNotFound","metadata","isNotFound","ampValidations","validateAmp","rawAmpHtml","ampPageName","validatorPath","validator","getInstance","result","validateString","errors","filter","e","severity","warnings","length","push","html","isNull","toUnchunkedString","ampRenderResult","ampSkipValidation","ampHtmlFilename","ampHtmlFilepath","exists","File","ampHtml","pageData","dataFile","replace","revalidate"],"mappings":"AAMA,OAAOA,kBAAkB,6BAA4B;AACrD,SAASC,IAAI,QAAQ,OAAM;AAK3B,SAASC,WAAW,QAAQ,4BAA2B;AACvD,SACEC,gBAAgB,EAChBC,yBAAyB,QACpB,sBAAqB;AAC5B,SAASC,mBAAmB,QAAQ,+CAA8C;AAClF,OAAOC,sBAAsB,uCAAsC;AACnE,SAASC,QAAQ,EAAEC,UAAU,QAAQ,wBAAuB;AAC5D,SAASC,mBAAmB,QAAQ,wDAAuD;;UAEzEC;;;;;GAAAA,uBAAAA;AAOlB,OAAO,eAAeC,YACpBC,GAAkB,EAClBC,GAAmB,EACnBC,IAAY,EACZC,IAAY,EACZC,KAAyB,EACzBC,YAAoB,EACpBC,YAAoB,EACpBC,OAAe,EACfC,UAAmB,EACnBC,MAAc,EACdC,gBAAoC,EACpCC,YAAoB,EACpBC,WAAoB,EACpBC,SAAkB,EAClBC,kBAA2B,EAC3BC,UAAsB,EACtBC,UAAoC,EACpCC,UAAsB;QAGVD,wBAEFA;IAHV,MAAME,WAAW;QACfC,UAAUH,EAAAA,yBAAAA,WAAWI,UAAU,qBAArBJ,uBAAuBK,GAAG,MAAK;QACzCC,UAAUC,QAAQnB,MAAMiB,GAAG;QAC3BG,QAAQR,EAAAA,0BAAAA,WAAWI,UAAU,qBAArBJ,wBAAuBK,GAAG,MAAK;IACzC;IAEA,MAAMI,YAAYnC,YAAY4B;IAC9B,MAAMQ,YAAYR,SAASM,MAAM;IAEjC,IAAIR,WAAWW,kBAAkB,EAAE;QACjC,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAEzB,KAAK,EAAE,EAAEX,0BAA0B,CAAC;IACxE;IAEA,mDAAmD;IACnD,uBAAuB;IACvB,IAAI,CAACoB,eAAeI,WAA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,4BAEJwD,SAASC,OAAO,CAAC,WAAW,cAC5BpC,KAAKC,SAAS,CAACK,SAAS4B,QAAQ,GAChC;QAEJ;IACF;IAEA,IAAI,CAAC7B,aAAa;QAChB,qEAAqE;QACrE,MAAM1B,mBAAoCZ,cAAcyD,MAAM;IAChE;IAEA,OAAO;QACLhB;QACA6B,YAAY/B,SAAS+B,UAAU,IAAI;QACnChC;IACF;AACF"}

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

@ -0,0 +1,3 @@
export { };
//# sourceMappingURL=types.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/export/routes/types.ts"],"names":[],"mappings":"AAEA,WAIC"}