{"version":3,"sources":["../../../src/server/app-render/work-async-storage.external.ts"],"sourcesContent":["import type { AsyncLocalStorage } from 'async_hooks'\nimport type { IncrementalCache } from '../lib/incremental-cache'\nimport type { FetchMetrics } from '../base-http'\nimport type { DeepReadonly } from '../../shared/lib/deep-readonly'\nimport type { AppSegmentConfig } from '../../build/segment-config/app/app-segment-config'\nimport type { AfterContext } from '../after/after-context'\nimport type { ResolvedCacheLifeProfiles } from '../config-shared'\nimport type { SharedCacheResult } from '../use-cache/use-cache-wrapper'\nimport type { ValidationLevel } from '../config-shared'\n\n// Share the instance module in the next-shared layer\nimport { workAsyncStorageInstance } from './work-async-storage-instance' with { 'turbopack-transition': 'next-shared' }\nimport type { LazyResult } from '../lib/lazy-result'\nimport type { DigestedError } from './create-error-handler'\nimport type { ActionRevalidationKind } from '../../shared/lib/action-revalidation-kind'\n\nexport interface WorkStore {\n  readonly isStaticGeneration: boolean\n\n  /**\n   * The page that is being rendered. This relates to the path to the page file.\n   */\n  readonly page: string\n\n  /**\n   * The route that is being rendered. This is the page property without the\n   * trailing `/page` or `/route` suffix.\n   */\n  readonly route: string\n\n  readonly incrementalCache?: IncrementalCache\n  readonly cacheLifeProfiles: ResolvedCacheLifeProfiles\n  readonly useCacheTimeout: number\n  readonly staticPageGenerationTimeout: number\n\n  readonly isOnDemandRevalidate?: boolean\n  readonly isBuildTimePrerendering?: boolean\n\n  forceDynamic?: boolean\n  fetchCache?: AppSegmentConfig['fetchCache']\n\n  forceStatic?: boolean\n  dynamicShouldError?: boolean\n  pendingRevalidates?: Record<string, Promise<any>>\n  pendingRevalidateWrites?: Array<Promise<void>> // This is like pendingRevalidates but isn't used for deduping.\n  readonly afterContext: AfterContext\n\n  dynamicUsageDescription?: string\n  dynamicUsageStack?: string\n\n  /**\n   * Invalid dynamic usage errors might be caught in userland. We attach them to\n   * the work store to ensure we can still fail the build, or show en error in\n   * dev mode.\n   */\n  // TODO: Collect an array of errors, and throw as AggregateError when\n  // `serializeError` and the Dev Overlay support it.\n  invalidDynamicUsageError?: Error\n\n  nextFetchId?: number\n  pathWasRevalidated?: ActionRevalidationKind\n\n  /**\n   * Tags that were revalidated during the current request. They need to be sent\n   * to cache handlers to propagate their revalidation.\n   */\n  pendingRevalidatedTags?: Array<{\n    tag: string\n    profile?: string | { stale?: number; revalidate?: number; expire?: number }\n    /**\n     * When the tag was revalidated, on the same clock as `CacheEntry.timestamp`\n     * (`performance.timeOrigin + performance.now()`). A cache entry created\n     * before this is stale; one created after it already reflects the\n     * revalidation and can still be served. Re-revalidating a tag moves this\n     * forward.\n     */\n    revalidatedAt: number\n  }>\n\n  /**\n   * Tags that were previously revalidated (e.g. by a redirecting server action)\n   * and have already been sent to cache handlers. Retrieved cache entries that\n   * include any of these tags must be discarded.\n   */\n  readonly previouslyRevalidatedTags: readonly string[]\n\n  /**\n   * When this request started, on the same clock as `CacheEntry.timestamp`.\n   * `previouslyRevalidatedTags` carry no timestamp of their own, having been\n   * revalidated by an earlier request, so they are treated as revalidated at\n   * this instant: entries predating the request are discarded, while entries\n   * generated during it are not.\n   */\n  readonly requestStartTime: number\n\n  /**\n   * This map contains lazy results so that we can evaluate them when the first\n   * cache entry is read. It allows us to skip refreshing tags if no caches are\n   * read at all.\n   */\n  readonly refreshTagsByCacheKind: Map<string, LazyResult<void>>\n\n  fetchMetrics?: FetchMetrics\n  shouldTrackFetchMetrics: boolean\n\n  /**\n   * Tracks pending `\"use cache\"` invocations within the current request scope,\n   * keyed by the serialized cache key (coarse key). Used for intra-request\n   * deduplication: when multiple components call the same cache function within\n   * a single request, only the first one runs (cache handler lookup +\n   * generation), and joiners tee its result stream.\n   * Root params are identical within a request, so the coarse key is sufficient.\n   */\n  pendingCacheInvocations?: Map<string, Promise<SharedCacheResult>>\n\n  /**\n   * Invocations from this request that have already completed, keyed the same\n   * way as `pendingCacheInvocations`. Entries move here when their fill\n   * finishes rather than being dropped, so a later invocation of the same cache\n   * function reuses the entry instead of repeating the cache handler lookup\n   * and, on a miss, the work.\n   *\n   * Only populated for kinds where that saves something real: private caches,\n   * which have no cache handler in production, and kinds whose handler was\n   * supplied by the platform or by `cacheHandlers` config, whose reads may be\n   * remote. A built-in handler read is a map lookup, so retaining its entries\n   * would cost memory for nothing.\n   */\n  completedCacheInvocations?: Map<string, Promise<SharedCacheResult>>\n\n  /**\n   * Set by the dev-server's hang-detection probe worker (see\n   * `use-cache-probe-worker.ts`) to switch `cache()` into a one-shot fill\n   * path: run `generateCacheEntry` as for a cold fill, drain the resulting\n   * stream, return. No cache-handler or resume-data-cache I/O, no\n   * intra-request leader election — the probe just needs to learn whether\n   * the body completes in module-scope isolation.\n   */\n  readonly useCacheProbeMode?: {\n    /**\n     * Max wall time the probe fill may take. `cache()` enforces this with\n     * `UseCacheTimeoutError`, which the probe worker translates to\n     * `{ outcome: 'hung' }` for the parent process.\n     */\n    readonly timeoutMs: number\n  }\n\n  isDraftMode?: boolean\n  isUnstableNoStore?: boolean\n  isPrefetchRequest?: boolean\n\n  /**\n   * Dev-only request identity used by local request insights. requestId\n   * identifies one server request, while htmlRequestId groups requests that\n   * originated from the same browser page.\n   */\n  requestId?: string\n  htmlRequestId?: string\n\n  /**\n   * This only exists because it's needed in use-cache-wrapper\n   */\n  deploymentId: string\n  /**\n   * Prefer `sharedContext.buildId` instead. This only exists because it's needed in use-cache-wrapper\n   */\n  buildId: string\n\n  readonly reactLoadableManifest?: DeepReadonly<\n    Record<string, { files: string[] }>\n  >\n  readonly assetPrefix?: string\n  readonly nonce?: string\n\n  cacheComponentsEnabled: boolean\n  validationLevel: ValidationLevel\n\n  /**\n   * Pages, other than the one being rendered, whose client reference manifest\n   * supplied a client reference for this render. Only populated by the dev\n   * server, where React's I/O tracking can carry a reference from another page\n   * into this render, which `createProxiedClientReferenceManifest` resolves by\n   * searching the other pages' manifests. The dev validation worker rebuilds\n   * that registry in its own thread from the route it validates, so it relies\n   * on this to know which other manifests to register.\n   */\n  additionalClientReferenceManifestPages?: Set<string>\n\n  /**\n   * Run the given function inside a clean AsyncLocalStorage snapshot. This is\n   * useful when generating cache entries, to ensure that the cache generation\n   * cannot read anything from the context we're currently executing in, which\n   * might include request-specific things like `cookies()` inside a\n   * `React.cache()`.\n   */\n  runInCleanSnapshot: <R, TArgs extends any[]>(\n    fn: (...args: TArgs) => R,\n    ...args: TArgs\n  ) => R\n\n  reactServerErrorsByDigest: Map<string, DigestedError>\n}\n\nexport type WorkAsyncStorage = AsyncLocalStorage<WorkStore>\n\nexport { workAsyncStorageInstance as workAsyncStorage }\n"],"names":["workAsyncStorage","workAsyncStorageInstance"],"mappings":";;;;+BA6MqCA;;;eAA5BC,kDAAwB;;;0CAlMQ","ignoreList":[0]}