rsnext/packages/next/client/components/static-generation-async-storage.ts

21 lines
555 B
TypeScript
Raw Normal View History

import type { AsyncLocalStorage } from 'async_hooks'
export interface StaticGenerationStore {
inUse?: boolean
pathname?: string
revalidate?: number
fetchRevalidate?: number
isStaticGeneration?: boolean
forceStatic?: boolean
}
export let staticGenerationAsyncStorage:
| AsyncLocalStorage<StaticGenerationStore>
| StaticGenerationStore = {}
// @ts-expect-error we provide this on globalThis in
// the edge and node runtime
if (globalThis.AsyncLocalStorage) {
staticGenerationAsyncStorage = new (globalThis as any).AsyncLocalStorage()
}