import { AsyncLocalStorage } from "node:async_hooks";
//#region src/shims/internal/als-registry.d.ts
/**
 * Get (or lazily create) the AsyncLocalStorage registered on `globalThis`
 * under `Symbol.for(key)`. Multiple callers — including callers in different
 * module instances — that pass the same `key` receive the same ALS instance.
 *
 * @param key - String key fed to `Symbol.for(...)`. By convention vinext
 *   shims use a dotted namespace such as `"vinext.cache.als"`.
 */
declare function getOrCreateAls<T>(key: string): AsyncLocalStorage<T>;
/**
 * Enrol an ALS that is *not* created through `getOrCreateAls` into the
 * scope-exit set. For stores that must stay module-local for identity reasons
 * (`workUnitAsyncStorage` is a Next.js-compat external module third parties
 * resolve by specifier) but still hold per-request state.
 *
 * Callers register themselves rather than being imported here, so this module
 * keeps importing nothing but `node:async_hooks` and stays safe to evaluate in
 * client bundles where that resolves to a constructor-less stub.
 */
declare function registerAlsForScopeExit(als: AsyncLocalStorage<never>): void;
/**
 * Run `fn` — and every async continuation it starts — outside every
 * request-scoped AsyncLocalStorage vinext installs, so the callback observes no
 * request at all.
 *
 * For one-time module evaluation whose result is cached for the isolate's
 * lifetime: a dynamic `import()` propagates ALS into the imported module's
 * top-level evaluation, so without this the first request to reach a route
 * leaks into module scope and stays there for every request after it.
 *
 * Exiting a single store is not enough. The stores are entered at different
 * depths — the Cloudflare entry enters the standalone execution-context ALS
 * *outside* the unified request context, and prerendering enters the work-unit
 * store *inside* it — so anything left entered stays visible. `after()` in
 * particular takes its `getRequestExecutionContext()` fallback precisely when
 * the unified store is absent, so a partial exit would enable that path rather
 * than close it.
 */
declare function runOutsideRequestScopes<T>(fn: () => T): T;
//#endregion
export { getOrCreateAls, registerAlsForScopeExit, runOutsideRequestScopes };