/opt/canhelp/node_modules/next/dist/server
Edit: /opt/canhelp/node_modules/next/dist/server/load-components.js.map (13170B)
{"version":3,"sources":["../../src/server/load-components.ts"],"sourcesContent":["import type {\n AppType,\n DocumentType,\n NextComponentType,\n} from '../shared/lib/utils'\nimport type { ClientReferenceManifest } from '../build/webpack/plugins/flight-manifest-plugin'\nimport type {\n PageConfig,\n GetStaticPaths,\n GetServerSideProps,\n GetStaticProps,\n} from '../types'\nimport type { RouteModule } from './route-modules/route-module'\nimport type { BuildManifest } from './get-page-files'\nimport type { ActionManifest } from '../build/webpack/plugins/flight-client-entry-plugin'\n\nimport {\n BUILD_MANIFEST,\n REACT_LOADABLE_MANIFEST,\n CLIENT_REFERENCE_MANIFEST,\n SERVER_REFERENCE_MANIFEST,\n DYNAMIC_CSS_MANIFEST,\n SUBRESOURCE_INTEGRITY_MANIFEST,\n} from '../shared/lib/constants'\nimport { join } from 'path'\nimport { requirePage } from './require'\nimport { interopDefault } from '../lib/interop-default'\nimport { getTracer } from './lib/trace/tracer'\nimport { LoadComponentsSpan } from './lib/trace/constants'\nimport { evalManifest, loadManifest } from './load-manifest.external'\nimport { wait } from '../lib/wait'\nimport { setReferenceManifestsSingleton } from './app-render/encryption-utils'\nimport { createServerModuleMap } from './app-render/action-utils'\nimport type { DeepReadonly } from '../shared/lib/deep-readonly'\nimport { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'\nimport { isStaticMetadataRoute } from '../lib/metadata/is-metadata-route'\n\nexport type ManifestItem = {\n id: number | string\n files: string[]\n}\n\nexport type ReactLoadableManifest = { [moduleId: string]: ManifestItem }\n/**\n * This manifest prevents removing server rendered
tags after client\n * navigation. This is only needed under `Pages dir && Production && Webpack`.\n * @see https://github.com/vercel/next.js/pull/72959\n */\nexport type DynamicCssManifest = string[]\n\n/**\n * A manifest entry type for the react-loadable-manifest.json.\n *\n * The whole manifest.json is a type of `Record
`\n * where pathname is a string-based key points to the path of the page contains\n * each dynamic imports.\n */\nexport interface LoadableManifest {\n [k: string]: { id: string | number; files: string[] }\n}\n\nexport type LoadComponentsReturnType = {\n Component: NextComponentType\n pageConfig: PageConfig\n buildManifest: DeepReadonly\n subresourceIntegrityManifest?: DeepReadonly>\n reactLoadableManifest: DeepReadonly\n dynamicCssManifest?: DeepReadonly\n clientReferenceManifest?: DeepReadonly\n serverActionsManifest?: any\n Document: DocumentType\n App: AppType\n getStaticProps?: GetStaticProps\n getStaticPaths?: GetStaticPaths\n getServerSideProps?: GetServerSideProps\n ComponentMod: NextModule\n routeModule: RouteModule\n isAppPath?: boolean\n page: string\n multiZoneDraftMode?: boolean\n}\n\n/**\n * Load manifest file with retries, defaults to 3 attempts.\n */\nexport async function loadManifestWithRetries(\n manifestPath: string,\n attempts = 3\n) {\n while (true) {\n try {\n return loadManifest(manifestPath)\n } catch (err) {\n attempts--\n if (attempts <= 0) throw err\n\n await wait(100)\n }\n }\n}\n\n/**\n * Load manifest file with retries, defaults to 3 attempts, or return undefined.\n */\nexport async function tryLoadManifestWithRetries(\n manifestPath: string,\n attempts = 3\n) {\n try {\n return await loadManifestWithRetries(manifestPath, attempts)\n } catch (err) {\n return undefined\n }\n}\n\n/**\n * Load manifest file with retries, defaults to 3 attempts.\n */\nexport async function evalManifestWithRetries(\n manifestPath: string,\n attempts = 3\n) {\n while (true) {\n try {\n return evalManifest(manifestPath)\n } catch (err) {\n attempts--\n if (attempts <= 0) throw err\n\n await wait(100)\n }\n }\n}\n\nasync function tryLoadClientReferenceManifest(\n manifestPath: string,\n entryName: string,\n attempts?: number\n) {\n try {\n const context = await evalManifestWithRetries<{\n __RSC_MANIFEST: { [key: string]: ClientReferenceManifest }\n }>(manifestPath, attempts)\n return context.__RSC_MANIFEST[entryName]\n } catch (err) {\n return undefined\n }\n}\n\nasync function loadComponentsImpl({\n distDir,\n page,\n isAppPath,\n isDev,\n sriEnabled,\n}: {\n distDir: string\n page: string\n isAppPath: boolean\n isDev: boolean\n sriEnabled: boolean\n}): Promise> {\n let DocumentMod = {}\n let AppMod = {}\n if (!isAppPath) {\n ;[DocumentMod, AppMod] = await Promise.all([\n requirePage('/_document', distDir, false),\n requirePage('/_app', distDir, false),\n ])\n }\n\n // In dev mode we retry loading a manifest file to handle a race condition\n // that can occur while app and pages are compiling at the same time, and the\n // build-manifest is still being written to disk while an app path is\n // attempting to load.\n const manifestLoadAttempts = isDev ? 3 : 1\n\n let reactLoadableManifestPath\n if (!process.env.TURBOPACK) {\n reactLoadableManifestPath = join(distDir, REACT_LOADABLE_MANIFEST)\n } else if (isAppPath) {\n reactLoadableManifestPath = join(\n distDir,\n 'server',\n 'app',\n page,\n REACT_LOADABLE_MANIFEST\n )\n } else {\n reactLoadableManifestPath = join(\n distDir,\n 'server',\n 'pages',\n normalizePagePath(page),\n REACT_LOADABLE_MANIFEST\n )\n }\n\n // Make sure to avoid loading the manifest for static metadata routes for better performance.\n const hasClientManifest = !isStaticMetadataRoute(page)\n\n // Load the manifest files first\n //\n // Loading page-specific manifests shouldn't throw an error if the manifest couldn't be found, so\n // that the `requirePage` call below will throw the correct error in that case\n // (a `PageNotFoundError`).\n const [\n buildManifest,\n reactLoadableManifest,\n dynamicCssManifest,\n clientReferenceManifest,\n serverActionsManifest,\n subresourceIntegrityManifest,\n ] = await Promise.all([\n loadManifestWithRetries(\n join(distDir, BUILD_MANIFEST),\n manifestLoadAttempts\n ),\n tryLoadManifestWithRetries(\n reactLoadableManifestPath,\n manifestLoadAttempts\n ),\n // This manifest will only exist in Pages dir && Production && Webpack.\n isAppPath || process.env.TURBOPACK\n ? undefined\n : loadManifestWithRetries(\n join(distDir, `${DYNAMIC_CSS_MANIFEST}.json`),\n manifestLoadAttempts\n ).catch(() => undefined),\n isAppPath && hasClientManifest\n ? tryLoadClientReferenceManifest(\n join(\n distDir,\n 'server',\n 'app',\n page.replace(/%5F/g, '_') + '_' + CLIENT_REFERENCE_MANIFEST + '.js'\n ),\n page.replace(/%5F/g, '_'),\n manifestLoadAttempts\n )\n : undefined,\n isAppPath\n ? loadManifestWithRetries(\n join(distDir, 'server', SERVER_REFERENCE_MANIFEST + '.json'),\n manifestLoadAttempts\n ).catch(() => null)\n : null,\n sriEnabled\n ? loadManifestWithRetries>>(\n join(distDir, 'server', SUBRESOURCE_INTEGRITY_MANIFEST + '.json')\n ).catch(() => undefined)\n : undefined,\n ])\n\n // Before requiring the actual page module, we have to set the reference\n // manifests to our global store so Server Action's encryption util can access\n // to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setReferenceManifestsSingleton({\n page,\n clientReferenceManifest,\n serverActionsManifest,\n serverModuleMap: createServerModuleMap({\n serverActionsManifest,\n }),\n })\n }\n\n const ComponentMod = await requirePage(page, distDir, isAppPath)\n\n const Component = interopDefault(ComponentMod)\n const Document = interopDefault(DocumentMod)\n const App = interopDefault(AppMod)\n\n const { getServerSideProps, getStaticProps, getStaticPaths, routeModule } =\n ComponentMod\n\n return {\n App,\n Document,\n Component,\n buildManifest,\n subresourceIntegrityManifest,\n reactLoadableManifest: reactLoadableManifest || {},\n dynamicCssManifest,\n pageConfig: ComponentMod.config || {},\n ComponentMod,\n getServerSideProps,\n getStaticProps,\n getStaticPaths,\n clientReferenceManifest,\n serverActionsManifest,\n isAppPath,\n page,\n routeModule,\n }\n}\n\nexport const loadComponents = getTracer().wrap(\n LoadComponentsSpan.loadComponents,\n loadComponentsImpl\n)\n"],"names":["evalManifestWithRetries","loadComponents","loadManifestWithRetries","tryLoadManifestWithRetries","manifestPath","attempts","loadManifest","err","wait","undefined","evalManifest","tryLoadClientReferenceManifest","entryName","context","__RSC_MANIFEST","loadComponentsImpl","distDir","page","isAppPath","isDev","sriEnabled","DocumentMod","AppMod","Promise","all","requirePage","manifestLoadAttempts","reactLoadableManifestPath","process","env","TURBOPACK","join","REACT_LOADABLE_MANIFEST","normalizePagePath","hasClientManifest","isStaticMetadataRoute","buildManifest","reactLoadableManifest","dynamicCssManifest","clientReferenceManifest","serverActionsManifest","subresourceIntegrityManifest","BUILD_MANIFEST","DYNAMIC_CSS_MANIFEST","catch","replace","CLIENT_REFERENCE_MANIFEST","SERVER_REFERENCE_MANIFEST","SUBRESOURCE_INTEGRITY_MANIFEST","setReferenceManifestsSingleton","serverModuleMap","createServerModuleMap","ComponentMod","Component","interopDefault","Document","App","getServerSideProps","getStaticProps","getStaticPaths","routeModule","pageConfig","config","getTracer","wrap","LoadComponentsSpan"],"mappings":";;;;;;;;;;;;;;;;;IAsHsBA,uBAAuB;eAAvBA;;IAoLTC,cAAc;eAAdA;;IArNSC,uBAAuB;eAAvBA;;IAmBAC,0BAA0B;eAA1BA;;;2BAjFf;sBACc;yBACO;gCACG;wBACL;4BACS;sCACQ;sBACtB;iCAC0B;6BACT;mCAEJ;iCACI;AAkD/B,eAAeD,wBACpBE,YAAoB,EACpBC,WAAW,CAAC;IAEZ,MAAO,KAAM;QACX,IAAI;YACF,OAAOC,IAAAA,kCAAY,EAAIF;QACzB,EAAE,OAAOG,KAAK;YACZF;YACA,IAAIA,YAAY,GAAG,MAAME;YAEzB,MAAMC,IAAAA,UAAI,EAAC;QACb;IACF;AACF;AAKO,eAAeL,2BACpBC,YAAoB,EACpBC,WAAW,CAAC;IAEZ,IAAI;QACF,OAAO,MAAMH,wBAA2BE,cAAcC;IACxD,EAAE,OAAOE,KAAK;QACZ,OAAOE;IACT;AACF;AAKO,eAAeT,wBACpBI,YAAoB,EACpBC,WAAW,CAAC;IAEZ,MAAO,KAAM;QACX,IAAI;YACF,OAAOK,IAAAA,kCAAY,EAAIN;QACzB,EAAE,OAAOG,KAAK;YACZF;YACA,IAAIA,YAAY,GAAG,MAAME;YAEzB,MAAMC,IAAAA,UAAI,EAAC;QACb;IACF;AACF;AAEA,eAAeG,+BACbP,YAAoB,EACpBQ,SAAiB,EACjBP,QAAiB;IAEjB,IAAI;QACF,MAAMQ,UAAU,MAAMb,wBAEnBI,cAAcC;QACjB,OAAOQ,QAAQC,cAAc,CAACF,UAAU;IAC1C,EAAE,OAAOL,KAAK;QACZ,OAAOE;IACT;A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