{"version":3,"sources":["../../../src/server/dev/static-paths-worker.ts"],"sourcesContent":["import type { NextConfigComplete } from '../config-shared'\nimport type {\n  AppPageModule,\n  AppPageRouteModule,\n} from '../route-modules/app-page/module'\nimport type {\n  AppRouteModule,\n  AppRouteRouteModule,\n} from '../route-modules/app-route/module.compiled'\n\nimport '../require-hook'\nimport '../node-environment'\n\nimport { collectSegments } from '../../build/segment-config/app/app-segments'\nimport type { StaticPathsResult } from '../../build/static-paths/types'\nimport { loadComponents } from '../load-components'\nimport { setHttpClientAndAgentOptions } from '../setup-http-agent-env'\nimport type { IncrementalCache } from '../lib/incremental-cache'\nimport { isAppPageRouteModule } from '../route-modules/checks'\nimport {\n  checkIsRoutePPREnabled,\n  type ExperimentalPPRConfig,\n} from '../lib/experimental/ppr'\nimport { InvariantError } from '../../shared/lib/invariant-error'\nimport { collectRootParamKeys } from '../../build/segment-config/app/collect-root-param-keys'\nimport { buildAppStaticPaths } from '../../build/static-paths/app'\nimport { buildPagesStaticPaths } from '../../build/static-paths/pages'\nimport { createIncrementalCache } from '../../export/helpers/create-incremental-cache'\nimport { parseAppRoute } from '../../shared/lib/router/routes/app'\n\ntype RuntimeConfig = {\n  pprConfig: ExperimentalPPRConfig | undefined\n  partialFallbacks: boolean\n  configFileName: string\n  cacheComponents: boolean\n}\n\n// we call getStaticPaths in a separate process to ensure\n// side-effects aren't relied on in dev that will break\n// during a production build\nexport async function loadStaticPaths({\n  dir,\n  distDir,\n  pathname,\n  config,\n  httpAgentOptions,\n  locales,\n  defaultLocale,\n  isAppPath,\n  page,\n  isrFlushToDisk,\n  fetchCacheKeyPrefix,\n  cacheMaxMemorySize,\n  requestHeaders,\n  cacheHandler,\n  cacheHandlers,\n  cacheLifeProfiles,\n  nextConfigOutput,\n  buildId,\n  deploymentId,\n  authInterrupts,\n  sriEnabled,\n}: {\n  dir: string\n  distDir: string\n  pathname: string\n  config: RuntimeConfig\n  httpAgentOptions: NextConfigComplete['httpAgentOptions']\n  locales?: readonly string[]\n  defaultLocale?: string\n  isAppPath: boolean\n  page: string\n  isrFlushToDisk?: boolean\n  fetchCacheKeyPrefix?: string\n  cacheMaxMemorySize: number\n  requestHeaders: IncrementalCache['requestHeaders']\n  cacheHandler?: string\n  cacheHandlers?: NextConfigComplete['cacheHandlers']\n  cacheLifeProfiles?: {\n    [profile: string]: import('../../server/use-cache/cache-life').CacheLife\n  }\n  nextConfigOutput: 'standalone' | 'export' | undefined\n  buildId: string\n  deploymentId: string\n  authInterrupts: boolean\n  sriEnabled: boolean\n}): Promise<StaticPathsResult> {\n  // this needs to be initialized before loadComponents otherwise\n  // \"use cache\" could be missing it's cache handlers\n  await createIncrementalCache({\n    dir,\n    distDir,\n    cacheHandler,\n    cacheHandlers,\n    requestHeaders,\n    fetchCacheKeyPrefix,\n    flushToDisk: isrFlushToDisk,\n    cacheMaxMemorySize,\n  })\n\n  // update work memory runtime-config\n  setHttpClientAndAgentOptions({\n    httpAgentOptions,\n  })\n\n  const components = await loadComponents<AppPageModule | AppRouteModule>({\n    distDir,\n    // In `pages/`, the page is the same as the pathname.\n    page: page || pathname,\n    isAppPath,\n    isDev: true,\n    sriEnabled,\n    needsManifestsForLegacyReasons: true,\n  })\n\n  if (isAppPath) {\n    const routeModule = components.routeModule\n    const segments = await collectSegments(\n      // We know this is an app page or app route module because we checked\n      // above that the page type is 'app'.\n      routeModule as AppPageRouteModule | AppRouteRouteModule\n    )\n\n    const route = parseAppRoute(pathname, true)\n    if (route.dynamicSegments.length === 0) {\n      throw new InvariantError(\n        `Expected a dynamic route, but got a static route: ${pathname}`\n      )\n    }\n\n    const isRoutePPREnabled =\n      isAppPageRouteModule(routeModule) &&\n      checkIsRoutePPREnabled(config.pprConfig)\n\n    const rootParamKeys = collectRootParamKeys(routeModule)\n\n    return buildAppStaticPaths({\n      dir,\n      page: pathname,\n      route,\n      cacheComponents: config.cacheComponents,\n      segments,\n      distDir,\n      requestHeaders,\n      cacheHandler,\n      cacheLifeProfiles,\n      isrFlushToDisk,\n      fetchCacheKeyPrefix,\n      cacheMaxMemorySize,\n      ComponentMod: components.ComponentMod,\n      nextConfigOutput,\n      isRoutePPREnabled,\n      partialFallbacksEnabled: config.partialFallbacks,\n      buildId,\n      deploymentId,\n      authInterrupts,\n      rootParamKeys,\n    })\n  } else if (!components.getStaticPaths) {\n    // We shouldn't get to this point since the worker should only be called for\n    // SSG pages with getStaticPaths.\n    throw new InvariantError(\n      `Failed to load page with getStaticPaths for ${pathname}`\n    )\n  }\n\n  return buildPagesStaticPaths({\n    page: pathname,\n    getStaticPaths: components.getStaticPaths,\n    configFileName: config.configFileName,\n    locales,\n    defaultLocale,\n  })\n}\n"],"names":["loadStaticPaths","dir","distDir","pathname","config","httpAgentOptions","locales","defaultLocale","isAppPath","page","isrFlushToDisk","fetchCacheKeyPrefix","cacheMaxMemorySize","requestHeaders","cacheHandler","cacheHandlers","cacheLifeProfiles","nextConfigOutput","buildId","deploymentId","authInterrupts","sriEnabled","createIncrementalCache","flushToDisk","setHttpClientAndAgentOptions","components","loadComponents","isDev","needsManifestsForLegacyReasons","routeModule","segments","collectSegments","route","parseAppRoute","dynamicSegments","length","InvariantError","isRoutePPREnabled","isAppPageRouteModule","checkIsRoutePPREnabled","pprConfig","rootParamKeys","collectRootParamKeys","buildAppStaticPaths","cacheComponents","ComponentMod","partialFallbacksEnabled","partialFallbacks","getStaticPaths","buildPagesStaticPaths","configFileName"],"mappings":";;;;+BAwCsBA;;;eAAAA;;;QA9Bf;QACA;6BAEyB;gCAED;mCACc;wBAER;qBAI9B;gCACwB;sCACM;qBACD;uBACE;wCACC;sBACT;AAYvB,eAAeA,gBAAgB,EACpCC,GAAG,EACHC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,gBAAgB,EAChBC,OAAO,EACPC,aAAa,EACbC,SAAS,EACTC,IAAI,EACJC,cAAc,EACdC,mBAAmB,EACnBC,kBAAkB,EAClBC,cAAc,EACdC,YAAY,EACZC,aAAa,EACbC,iBAAiB,EACjBC,gBA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