/** @effect-diagnostics anyUnknownInErrorContext:off */ import * as Layer from "effect/Layer"; import { AlchemyContext } from "../AlchemyContext.ts"; import type { Platform } from "../Platform.ts"; import type { ResourceClassLike, ResourceLike } from "../Resource.ts"; /** * Registers a resource provider with both a **live** and a **local** * implementation, making provider mode a first-class, per-run *and* * per-resource concern: * * - The `Provider(type)` service placed in context is the variant for the * run's default mode (`AlchemyContext.dev ? "local" : "live"`), so * existing lookups keep working unchanged. * - Both variants are additionally exposed via * {@link ProviderService.modes} as lazy, memoized builders. The * non-default variant (and its mode-specific dependency layers, composed * inside the thunk) is only constructed when something actually demands * it — e.g. deleting a `providerMode: "local"` state row during a live * deploy. * * Laziness mechanics: the layer is a {@link Layer.fromBuildMemo}, so the * build itself is memoized by layer identity (one provider instance — and * one instance registry for local providers — per memo-map ancestry, i.e. * shared across every stack build that forks the same root, exactly like * ordinary layers). The build receives its `MemoMap` and `Scope`; variant * layers are built with `Layer.buildWithMemoMap` against that same memo * map and scope, which means: * * - dependency layers shared between different providers' local variants * (e.g. Cloudflare's `localRuntimeServices()`) are constructed exactly * once, provided the thunks share the layer *reference*; * - lazily-built services live until the memoized entry's scope closes * (when every borrowing scope has closed), like any eagerly-built * provider. * * @example * ```ts * export const WorkerProvider = () => * ProviderLayer.dual(Worker, { * live: () => LiveWorkerProvider(), * local: () => * LocalWorkerProvider().pipe(Layer.provide(localRuntimeServices())), * }); * ``` */ export declare const dual: , LayerLocal extends Layer.Layer>(cls: ResourceClassLike | Platform | { Type: R["Type"]; }, input: { live: () => LayerLive; local: () => LayerLocal; }) => Layer.Layer, Layer.Error, Layer.Services | AlchemyContext>; //# sourceMappingURL=ProviderLayer.d.ts.map