/opt/canhelp/node_modules/next/dist/esm/server/lib
NameSizeModeActions
cache-handlers/-0755rm
experimental/-0755rm
incremental-cache/-0755rm
module-loader/-0755rm
router-utils/-0755rm
server-ipc/-0755rm
trace/-0755rm
app-dir-module.js11640644editdlrm
app-dir-module.js.map25980644editdlrm
app-info-log.js27230644editdlrm
app-info-log.js.map58270644editdlrm
async-callback-set.js5190644editdlrm
async-callback-set.js.map10970644editdlrm
cache-control.js5830644editdlrm
cache-control.js.map16220644editdlrm
chrome-devtools-workspace.js22970644editdlrm
chrome-devtools-workspace.js.map41450644editdlrm
clone-response.js28830644editdlrm
clone-response.js.map44410644editdlrm
cpu-profile.js10200644editdlrm
cpu-profile.js.map20610644editdlrm
decode-query-path-parameter.js4580644editdlrm
decode-query-path-parameter.js.map7400644editdlrm
dedupe-fetch.js50850644editdlrm
dedupe-fetch.js.map73740644editdlrm
dev-bundler-service.js31100644editdlrm
dev-bundler-service.js.map58380644editdlrm
disk-lru-cache.external.js18570644editdlrm
disk-lru-cache.external.js.map31490644editdlrm
etag.js11480644editdlrm
etag.js.map21650644editdlrm
find-page-file.js54450644editdlrm
find-page-file.js.map94800644editdlrm
fix-mojibake.js5230644editdlrm
fix-mojibake.js.map10260644editdlrm
format-hostname.js3320644editdlrm
format-hostname.js.map6160644editdlrm
i18n-provider.js55310644editdlrm
i18n-provider.js.map90410644editdlrm
implicit-tags.js24500644editdlrm
implicit-tags.js.map52380644editdlrm
is-ipv6.js20900644editdlrm
is-ipv6.js.map33880644editdlrm
lazy-result.js9390644editdlrm
lazy-result.js.map18690644editdlrm
lru-cache.js71480644editdlrm
lru-cache.js.map113740644editdlrm
match-next-data-pathname.js3120644editdlrm
match-next-data-pathname.js.map6290644editdlrm
mock-request.js137530644editdlrm
mock-request.js.map212240644editdlrm
node-fs-methods.js3640644editdlrm
node-fs-methods.js.map9460644editdlrm
parse-stack.js15610644editdlrm
parse-stack.js.map29830644editdlrm
patch-fetch.js449390644editdlrm
patch-fetch.js.map647210644editdlrm
patch-set-header.js13680644editdlrm
patch-set-header.js.map24710644editdlrm
render-server.js29880644editdlrm
render-server.js.map62760644editdlrm
router-server.js300290644editdlrm
router-server.js.map467520644editdlrm
server-action-request-meta.js15300644editdlrm
server-action-request-meta.js.map30300644editdlrm
source-maps.js81720644editdlrm
source-maps.js.map148120644editdlrm
start-server.js167970644editdlrm
start-server.js.map277270644editdlrm
streaming-metadata.js7620644editdlrm
streaming-metadata.js.map15820644editdlrm
to-route.js5820644editdlrm
to-route.js.map8480644editdlrm
types.js460644editdlrm
types.js.map4510644editdlrm
utils.js85160644editdlrm
utils.js.map136270644editdlrm
worker-utils.js7550644editdlrm
worker-utils.js.map11200644editdlrm
Edit: /opt/canhelp/node_modules/next/dist/esm/server/lib/find-page-file.js (5445B)
import { fileExists } from '../../lib/file-exists'; import { getPagePaths } from '../../shared/lib/page-path/get-page-paths'; import { nonNullable } from '../../lib/non-nullable'; import { join, sep, normalize } from 'path'; import { promises as fsPromises } from 'fs'; import { warn } from '../../build/output/log'; import { cyan } from '../../lib/picocolors'; import { isMetadataRouteFile } from '../../lib/metadata/is-metadata-route'; async function isTrueCasePagePath(pagePath, pagesDir) { const pageSegments = normalize(pagePath).split(sep).filter(Boolean); const segmentExistsPromises = pageSegments.map(async (segment, i)=>{ const segmentParentDir = join(pagesDir, ...pageSegments.slice(0, i)); const parentDirEntries = await fsPromises.readdir(segmentParentDir); return parentDirEntries.includes(segment); }); return (await Promise.all(segmentExistsPromises)).every(Boolean); } /** * Finds a page file with the given parameters. If the page is duplicated with * multiple extensions it will throw, otherwise it will return the *relative* * path to the page file or null if it is not found. * * @param pagesDir Absolute path to the pages folder with trailing `/pages`. * @param normalizedPagePath The page normalized (it will be denormalized). * @param pageExtensions Array of page extensions. */ export async function findPageFile(pagesDir, normalizedPagePath, pageExtensions, isAppDir) { const pagePaths = getPagePaths(normalizedPagePath, pageExtensions, isAppDir); const [existingPath, ...others] = (await Promise.all(pagePaths.map(async (path)=>{ const filePath = join(pagesDir, path); try { return await fileExists(filePath) ? path : null; } catch (err) { var _err_code; if (!(err == null ? void 0 : (_err_code = err.code) == null ? void 0 : _err_code.includes('ENOTDIR'))) throw err; } return null; }))).filter(nonNullable); if (!existingPath) { return null; } if (!await isTrueCasePagePath(existingPath, pagesDir)) { return null; } if (others.length > 0) { warn(`Duplicate page detected. ${cyan(join('pages', existingPath))} and ${cyan(join('pages', others[0]))} both resolve to ${cyan(normalizedPagePath)}.`); } return existingPath; } /** * * createValidFileMatcher receives configured page extensions and return helpers to determine: * `isLayoutsLeafPage`: if a file is a valid page file or routes file under app directory * `isTrackedFiles`: if it's a tracked file for webpack watcher * */ export function createValidFileMatcher(pageExtensions, appDirPath) { const getExtensionRegexString = (extensions)=>`(?:${extensions.join('|')})`; const validExtensionFileRegex = new RegExp('\\.' + getExtensionRegexString(pageExtensions) + '$'); const leafOnlyPageFileRegex = new RegExp(`(^(page|route)|[\\\\/](page|route))\\.${getExtensionRegexString(pageExtensions)}$`); const leafOnlyRouteFileRegex = new RegExp(`(^route|[\\\\/]route)\\.${getExtensionRegexString(pageExtensions)}$`); const leafOnlyLayoutFileRegex = new RegExp(`(^(layout)|[\\\\/](layout))\\.${getExtensionRegexString(pageExtensions)}$`); const rootNotFoundFileRegex = new RegExp(`^not-found\\.${getExtensionRegexString(pageExtensions)}$`); const leafOnlyDefaultFileRegex = new RegExp(`(^(default)|[\\\\/](default))\\.${getExtensionRegexString(pageExtensions)}$`); /** TODO-METADATA: support other metadata routes * regex for: * * /robots.txt| * /sitemap.xml| * /favicon.ico * /manifest.json| * /icon.png|jpg| * /apple-touch-icon.png|jpg| * */ /** * Match the file if it's a metadata route file, static: if the file is a static metadata file. * It needs to be a file which doesn't match the custom metadata routes e.g. `app/robots.txt/route.js` */ function isMetadataFile(filePath) { const appDirRelativePath = appDirPath ? filePath.replace(appDirPath, '') : filePath; return isMetadataRouteFile(appDirRelativePath, pageExtensions, true); } // Determine if the file is leaf node page file or route file under layouts, // 'page.' | 'route.' function isAppRouterPage(filePath) { return leafOnlyPageFileRegex.test(filePath) || isMetadataFile(filePath); } // Determine if the file is leaf node route file under app directory function isAppRouterRoute(filePath) { return leafOnlyRouteFileRegex.test(filePath); } function isAppLayoutPage(filePath) { return leafOnlyLayoutFileRegex.test(filePath); } function isAppDefaultPage(filePath) { return leafOnlyDefaultFileRegex.test(filePath); } function isPageFile(filePath) { return validExtensionFileRegex.test(filePath) || isMetadataFile(filePath); } function isRootNotFound(filePath) { if (!appDirPath) { return false; } if (!filePath.startsWith(appDirPath + sep)) { return false; } const rest = filePath.slice(appDirPath.length + 1); return rootNotFoundFileRegex.test(rest); } return { isPageFile, isAppRouterPage, isAppRouterRoute, isAppLayoutPage, isAppDefaultPage, isMetadataFile, isRootNotFound }; } //# sourceMappingURL=find-page-file.js.map