import { t as DiError } from "./error-B_g1YEwt.mjs"; import { l as Provider, t as Container } from "./types-DHrRUW_I.mjs"; //#region src/adapters/node/types.d.ts /** * Options for `createNodeDi`. */ type CreateNodeDiOptions = { /** * Providers registered once in the root container. */ readonly providers?: readonly Provider[]; /** * Providers registered in each async request-scoped child container. */ readonly requestProviders?: () => readonly Provider[]; }; /** * Options for running work inside an AsyncLocalStorage-backed child container. */ type RunWithRequestContainerOptions = { /** * Extra providers registered only for this request container. */ readonly providers?: readonly Provider[]; /** * Work that runs inside the current async request scope. */ readonly run: (container: Container) => TResult | Promise; }; /** * Node.js AsyncLocalStorage adapter instance created by `createNodeDi`. */ type NodeDiAdapter = { /** * Returns the long-lived root container. */ readonly getRootContainer: () => Container; /** * Returns the container bound to the current async request scope. */ readonly getRequestContainer: () => Container; /** * Creates a fresh child container without binding it to async context. */ readonly createRequestContainer: (extraProviders?: readonly Provider[]) => Container; /** * Runs work inside a fresh child container, binds it to AsyncLocalStorage, * and disposes it after the callback settles. */ readonly runWithRequestContainer: (options: RunWithRequestContainerOptions) => Promise>; /** * Disposes cached instances owned by the root container. */ readonly disposeRootContainer: () => Promise; }; //#endregion //#region src/adapters/node/errors.d.ts /** * Error thrown when reading a Node async request container outside its scope. */ declare class NodeRequestScopeError extends DiError { constructor(); } //#endregion //#region src/adapters/node/server.d.ts /** * Creates a Node.js adapter backed by `AsyncLocalStorage`. * * Use this for explicit async scopes such as route handlers, server actions, * jobs, and plain server code. React Server Components should keep using the * Next adapter with React's `cache` primitive. * * Await all async work that reads the request container before the callback * passed to `runWithRequestContainer` settles. The request container is disposed * immediately after that callback settles. */ declare const createNodeDi: ({ providers: rootProviders, requestProviders }?: CreateNodeDiOptions) => NodeDiAdapter; //#endregion export { type CreateNodeDiOptions, type NodeDiAdapter, NodeRequestScopeError, type RunWithRequestContainerOptions, createNodeDi }; //# sourceMappingURL=node.d.mts.map