better-effect 0.8.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/adapters/iti.d.mts +3 -3
- package/dist/adapters/iti.mjs +2 -1
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/{internal-identity-Cm4-KIUj.mjs → errors-Dnjhzbt0.mjs} +2 -25
- package/dist/errors-Dnjhzbt0.mjs.map +1 -0
- package/dist/{index-BFgG9zZC.d.mts → index-1NLNdkJy.d.mts} +2 -2
- package/dist/{index-BFgG9zZC.d.mts.map → index-1NLNdkJy.d.mts.map} +1 -1
- package/dist/index-BJFBEsm5.d.mts +406 -0
- package/dist/index-BJFBEsm5.d.mts.map +1 -0
- package/dist/{index-fUyY0eNJ.d.mts → index-CYAgpM_5.d.mts} +28 -14
- package/dist/index-CYAgpM_5.d.mts.map +1 -0
- package/dist/index.d.mts +5 -320
- package/dist/index.mjs +142 -277
- package/dist/index.mjs.map +1 -1
- package/dist/internal-identity-DmUpBeeL.mjs +27 -0
- package/dist/internal-identity-DmUpBeeL.mjs.map +1 -0
- package/dist/{map-layer-backend-CGibcwkc.d.mts → map-layer-backend-DMJauecV.d.mts} +2 -2
- package/dist/{map-layer-backend-CGibcwkc.d.mts.map → map-layer-backend-DMJauecV.d.mts.map} +1 -1
- package/dist/{map-layer-backend-BodcEeNA.mjs → map-layer-backend-gal-mcRv.mjs} +3 -2
- package/dist/{map-layer-backend-BodcEeNA.mjs.map → map-layer-backend-gal-mcRv.mjs.map} +1 -1
- package/dist/runtime/explicit.d.mts +1 -1
- package/dist/runtime/node.d.mts +1 -1
- package/dist/signal-Cl9tqGyX.mjs +270 -0
- package/dist/signal-Cl9tqGyX.mjs.map +1 -0
- package/dist/standard-services.d.mts +116 -0
- package/dist/standard-services.d.mts.map +1 -0
- package/dist/standard-services.mjs +180 -0
- package/dist/standard-services.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +6 -2
- package/dist/index-fUyY0eNJ.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/internal-identity-Cm4-KIUj.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as LayerRegistration, i as LayerGeneratorRequirements, n as LayerBackend, o as MaybePromise$1, r as LayerGenerator } from "./map-layer-backend-
|
|
1
|
+
import { F as ServiceContract, H as ServiceToken, L as ServiceIdentityTypeId, M as AnyService, N as AnyServiceToken, P as ServiceClass, T as EffectRequirements, U as ServiceTokenOf, V as ServiceTagOf, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, h as ScopeOutcome, j as ServiceRequirement, p as MaybePromise, u as Scope, z as ServiceRequirements } from "./index-1NLNdkJy.mjs";
|
|
2
|
+
import { a as LayerRegistration, i as LayerGeneratorRequirements, n as LayerBackend, o as MaybePromise$1, r as LayerGenerator } from "./map-layer-backend-DMJauecV.mjs";
|
|
3
3
|
//#region src/internal/variance.d.ts
|
|
4
4
|
/** Type-level marker for a value produced by `A`. */
|
|
5
5
|
type Covariant<A> = () => A;
|
|
@@ -91,9 +91,10 @@ type AmbiguousLayerUnion = {
|
|
|
91
91
|
type ValidateLayerInput<L extends LayerInput> = LayerInputState<L> extends 'invalid-partial-any' ? InvalidLayerErasure : LayerInputState<L> extends 'invalid-union' ? AmbiguousLayerUnion : unknown;
|
|
92
92
|
/** Validate every original element of a merge tuple. */
|
|
93
93
|
type ValidateLayerTuple<Layers extends readonly LayerInput[]> = { [Index in keyof Layers]: ValidateLayerInput<Layers[Index]>; };
|
|
94
|
+
type HasMatchingServiceTag<Left extends AnyService, Right extends AnyService> = [Extract<ServiceTagOf<Left>, ServiceTagOf<Right>>] extends [never] ? false : true;
|
|
94
95
|
/** Remove compatible Services from a union while retaining all other identities. */
|
|
95
|
-
type RemoveCompatibleServices<Provided extends AnyService, Replacements extends AnyService> = Provided extends AnyService ? true extends (Replacements extends AnyService ? SameService<Provided, Replacements> : false) ? never : Provided : never;
|
|
96
|
-
type HasCompatibleService<Provided extends AnyService, Replacements extends AnyService> = true extends (Replacements extends AnyService ? SameService<Provided, Replacements> : false) ? true : false;
|
|
96
|
+
type RemoveCompatibleServices<Provided extends AnyService, Replacements extends AnyService> = Provided extends AnyService ? HasMatchingServiceTag<Provided, Replacements> extends true ? true extends (Replacements extends AnyService ? SameService<Provided, Replacements> : false) ? never : Provided : Provided : never;
|
|
97
|
+
type HasCompatibleService<Provided extends AnyService, Replacements extends AnyService> = HasMatchingServiceTag<Provided, Replacements> extends true ? true extends (Replacements extends AnyService ? SameService<Provided, Replacements> : false) ? true : false : false;
|
|
97
98
|
type RemoveCompatibleEntries<Entries extends AnyProviderEntry, Replacements extends AnyService> = Entries extends ProviderEntry<infer Provided, any> ? HasCompatibleService<Provided, Replacements> extends true ? never : Entries : never;
|
|
98
99
|
type ReplacePreciseOne<Entries extends AnyProviderEntry, Replacement extends LayerInput> = RemoveCompatibleEntries<Entries, Extract<ProvidedEnvironment<Replacement>, AnyService>> | PreciseEntries<Replacement>;
|
|
99
100
|
type ReplaceErasedOne<Erased extends AnyErasedProvenance, Replacement extends LayerInput> = Erased extends ErasedProvenance<infer Provided, infer StickyRequired> ? ErasedProvenance<RemoveCompatibleServices<Provided, Extract<ProvidedEnvironment<Replacement>, AnyService>>, StickyRequired> : never;
|
|
@@ -104,13 +105,9 @@ type MergeLayerResult<Layers extends readonly LayerInput[]> = HasUncheckedLayerI
|
|
|
104
105
|
/** Internal result type for Layer.merge. */
|
|
105
106
|
type MergeResult<Layers extends readonly LayerInput[]> = MergeLayerResult<Layers>;
|
|
106
107
|
type OverrideLayerResultUnchecked<Base extends LayerInput, Overrides extends readonly LayerInput[]> = HasUncheckedLayerInTuple<[Base, ...Overrides]> extends true ? Layer<any, any> : LayerResult<ApplyPreciseOverrides<PreciseEntries<Base>, Overrides>, ApplyErasedOverrides<ErasedEntries<Base>, Overrides>>;
|
|
107
|
-
/** Internal result type for Layer.override. */
|
|
108
|
-
type OverrideResult<Base extends LayerInput, Replacement extends LayerInput> = OverrideLayerResultUnchecked<Base, readonly [Replacement]>;
|
|
109
108
|
/** Internal result type for an ordered override tuple. */
|
|
110
109
|
type OverrideLayerResult<Base extends LayerInput, Overrides extends readonly LayerInput[]> = OverrideLayerResultUnchecked<Base, Overrides>;
|
|
111
110
|
type IncompatibleOverridePair<Current extends AnyService, Replacement extends AnyService> = SameServiceTag<Current, Replacement> extends true ? SameServiceContract<Current, Replacement> extends true ? never : ServiceTokenOf<Replacement> : never;
|
|
112
|
-
/** Fully distributive same-tag incompatible override comparison. */
|
|
113
|
-
type IncompatibleOverridePairs<CurrentProvided extends AnyService, ReplacementProvided extends AnyService> = CurrentProvided extends AnyService ? ReplacementProvided extends AnyService ? IncompatibleOverridePair<CurrentProvided, ReplacementProvided> : never : never;
|
|
114
111
|
type IncompatibleLayerOverride<Tokens extends AnyServiceToken> = {
|
|
115
112
|
readonly __betterEffectIncompatibleLayerOverride: Tokens;
|
|
116
113
|
};
|
|
@@ -118,10 +115,25 @@ type InvalidWidenedProvidedEnvironment = {
|
|
|
118
115
|
readonly __betterEffectWidenedProvidedEnvironment: unique symbol;
|
|
119
116
|
};
|
|
120
117
|
type ValidateOverrideLayerInput<L extends LayerInput> = IsExactUncheckedLayer<L> extends true ? unknown : ValidateLayerInput<L> & (true extends HasWidenedTag<Extract<ProvidedEnvironment<L>, AnyService>> ? InvalidWidenedProvidedEnvironment : unknown);
|
|
121
|
-
|
|
122
|
-
type
|
|
118
|
+
type ValidateOverrideTuple<Overrides extends readonly LayerInput[]> = { [Index in keyof Overrides]: ValidateOverrideLayerInput<Overrides[Index]>; };
|
|
119
|
+
type ServiceAtTag<Services, Tag extends string> = Tag extends keyof Services ? Extract<Services[Tag], AnyService> : never;
|
|
120
|
+
type ServiceTagMap<Services extends AnyService> = { [Tag in ServiceTagOf<Services>]: Extract<Services, {
|
|
121
|
+
readonly [ServiceIdentityTypeId]: Tag;
|
|
122
|
+
}>; };
|
|
123
|
+
type ExactMapOverrideMatch<Current, Replacement extends AnyService> = [MapServicesAtTag<Current, ServiceTagOf<Replacement>>] extends [never] ? true : [MapServicesAtTag<Current, ServiceTagOf<Replacement>>] extends [Replacement] ? [Replacement] extends [MapServicesAtTag<Current, ServiceTagOf<Replacement>>] ? true : false : false;
|
|
124
|
+
type CanSkipBaseOverride<Current, Replacement extends AnyService> = false extends (Replacement extends AnyService ? [MapServicesAtTag<Current, ServiceTagOf<Replacement>>] extends [never] ? false : ExactMapOverrideMatch<Current, Replacement> : never) ? false : true;
|
|
125
|
+
type MapServicesAtTag<Maps, Tag extends string> = Maps extends unknown ? ServiceAtTag<Maps, Tag> : never;
|
|
126
|
+
type IncompatibleOverridePairsForValidation<CurrentProvided extends AnyService, Replacement extends AnyService> = CurrentProvided extends AnyService ? Replacement extends AnyService ? IncompatibleOverridePair<CurrentProvided, Replacement> : never : never;
|
|
127
|
+
type ApplyValidationOverride<CurrentProvided extends AnyService, ReplacementProvided extends AnyService> = RemoveCompatibleServices<CurrentProvided, ReplacementProvided> | ReplacementProvided;
|
|
128
|
+
type ValidateOverridePair<CurrentProvided extends AnyService, ReplacementProvided extends AnyService> = IncompatibleOverridePairsForValidation<CurrentProvided, ReplacementProvided> extends (infer Incompatible) ? [Incompatible] extends [never] ? unknown : IncompatibleLayerOverride<Extract<Incompatible, AnyServiceToken>> : never;
|
|
129
|
+
/**
|
|
130
|
+
* Validate overrides while carrying only the current provided union.
|
|
131
|
+
* Rebuilding the full Layer provenance for every step is quadratic and can
|
|
132
|
+
* exhaust TypeScript's instantiation depth on otherwise simple override lists.
|
|
133
|
+
*/
|
|
134
|
+
type ValidateOverridesFromState<Overrides extends readonly LayerInput[], BaseMap, CurrentProvided extends AnyService, CurrentChanged extends boolean, CurrentUnchecked extends boolean> = Overrides extends readonly [infer Head extends LayerInput, ...infer Tail extends readonly LayerInput[]] ? CurrentUnchecked extends true ? ValidateOverridesFromState<Tail, BaseMap, AnyService, true, true> : IsExactUncheckedLayer<Head> extends true ? ValidateOverridesFromState<Tail, BaseMap, AnyService, true, true> : CurrentChanged extends false ? CanSkipBaseOverride<BaseMap, Extract<ProvidedEnvironment<Head>, AnyService>> extends true ? ValidateOverridesFromState<Tail, BaseMap, CurrentProvided, false, false> : ValidateOverridePair<CurrentProvided, Extract<ProvidedEnvironment<Head>, AnyService>> & ValidateOverridesFromState<Tail, BaseMap, ApplyValidationOverride<CurrentProvided, Extract<ProvidedEnvironment<Head>, AnyService>>, true, false> : ValidateOverridePair<CurrentProvided, Extract<ProvidedEnvironment<Head>, AnyService>> & ValidateOverridesFromState<Tail, BaseMap, ApplyValidationOverride<CurrentProvided, Extract<ProvidedEnvironment<Head>, AnyService>>, true, false> : unknown;
|
|
123
135
|
/** Validate ordered overrides against the state produced by earlier overrides. */
|
|
124
|
-
type ValidateOverrides<Base extends LayerInput, Overrides extends readonly LayerInput[]> = Overrides extends readonly [
|
|
136
|
+
type ValidateOverrides<Base extends LayerInput, Overrides extends readonly LayerInput[]> = Overrides extends readonly [] ? unknown : ValidateOverrideLayerInput<Base> & ValidateOverrideTuple<Overrides> & ValidateOverridesFromState<Overrides, ServiceTagMap<Extract<ProvidedEnvironment<Base>, AnyService>>, Extract<ProvidedEnvironment<Base>, AnyService>, false, IsExactUncheckedLayer<Base>>;
|
|
125
137
|
/** A Layer accepted by Runtime boundaries after completeness validation. */
|
|
126
138
|
type CompleteInput<L extends LayerInput> = ValidateLayerInput<L> & (LayerInputState<L> extends 'unchecked' ? L : LayerInputState<L> extends 'typed' ? [RequiredEnvironment<L>] extends [never] ? L : L & MissingDependencies<Extract<RequiredEnvironment<L>, AnyService>> : L);
|
|
127
139
|
type ExecutionRequirementsMissing<RootProvided extends AnyService, Request extends LayerInput> = MissingServices<Extract<RequiredEnvironment<Request>, AnyService>, Extract<RootProvided, AnyService>>;
|
|
@@ -182,7 +194,9 @@ declare class Layer<in out Provided extends AnyService = AnyService, out Require
|
|
|
182
194
|
/** Mark a Layer composition root as complete without changing its runtime value. */
|
|
183
195
|
static complete<L extends LayerInput>(layer: L & CompleteInput<L>): L;
|
|
184
196
|
/** Replace providers in a base Layer, using tag identity and compatible contracts. */
|
|
185
|
-
static override<Base extends LayerInput
|
|
197
|
+
static override<Base extends LayerInput>(base: Base & ValidateLayerInput<Base>): OverrideLayerResult<Base, readonly []>;
|
|
198
|
+
static override<Base extends LayerInput, const Overrides extends readonly [LayerInput, ...LayerInput[]]>(base: Base & ValidateLayerInput<Base>, ...overrides: Overrides & ValidateOverrides<Base, Overrides>): OverrideLayerResult<Base, Overrides>;
|
|
199
|
+
static override<Base extends LayerInput, const Overrides extends readonly LayerInput[]>(base: Base & ValidateLayerInput<Base>, ...overrides: Overrides extends readonly [LayerInput, ...LayerInput[]] ? never : Overrides & ValidateOverrides<Base, Overrides>): OverrideLayerResult<Base, Overrides>;
|
|
186
200
|
}
|
|
187
201
|
/** Type-level aliases for inspecting Layer environments and completeness. */
|
|
188
202
|
declare namespace Layer {
|
|
@@ -305,5 +319,5 @@ type RuntimeDisposeOptions = {
|
|
|
305
319
|
readonly abortAfterGracePeriod?: boolean;
|
|
306
320
|
};
|
|
307
321
|
//#endregion
|
|
308
|
-
export { ProvidedEnvironment as S, Layer as _, RuntimeShutdownDiagnostic as a, CompleteInput as b, RuntimeObserver as c, RuntimeServiceResolveEvent as d, DuplicateServiceError as f, ServiceTagCollisionError as g, LayerRegistrationError as h, RuntimeRunOptions as i, RuntimeResourceReleaseEvent as l, LayerGeneratorYieldError as m, RuntimeDisposeOptions as n, RuntimeExecutionEndEvent as o, LayerDisposeError as p, RuntimeOptions as r, RuntimeExecutionStartEvent as s, CleanupFailureObserver as t, RuntimeServiceAcquireEvent as u, CompleteExecution as v, LayerInput as x, CompleteExecutionLayer as y };
|
|
309
|
-
//# sourceMappingURL=index-
|
|
322
|
+
export { ProvidedEnvironment as C, LayerResult as S, Layer as _, RuntimeShutdownDiagnostic as a, CompleteInput as b, RuntimeObserver as c, RuntimeServiceResolveEvent as d, DuplicateServiceError as f, ServiceTagCollisionError as g, LayerRegistrationError as h, RuntimeRunOptions as i, RuntimeResourceReleaseEvent as l, LayerGeneratorYieldError as m, RuntimeDisposeOptions as n, RuntimeExecutionEndEvent as o, LayerDisposeError as p, RuntimeOptions as r, RuntimeExecutionStartEvent as s, CleanupFailureObserver as t, RuntimeServiceAcquireEvent as u, CompleteExecution as v, ProviderEntry as w, LayerInput as x, CompleteExecutionLayer as y };
|
|
323
|
+
//# sourceMappingURL=index-CYAgpM_5.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CYAgpM_5.d.mts","names":[],"sources":["../src/internal/variance.ts","../src/internal/missing-dependencies.ts","../src/layer/metadata.ts","../src/layer/inference.ts","../src/layer/layer.ts","../src/layer/errors.ts","../src/runtime/observer.ts","../src/runtime/outcome.ts"],"mappings":";;;;KACY,UAAU,WAAW;;KAGrB,UAAU,MAAM,OAAO,MAAM;;;KCF7B,oBAAoB,gBAAgB;;WAErC,iBAAiB;;;;;cCCP;UAEJ,kBACX,iBAAiB,gBACjB,oBAAoB;WAEf,UAAU;WACV,UAAU;;UAGJ,qBACX,iBAAiB,gBACjB,uBAAuB;WAElB,UAAU;WACV,gBAAgB;;UAGV,oBACX,gBAAgB,cAAc,YAAY,yBAC1C,eAAe,iBAAiB,YAAY;YAEtC;aACC,SAAS;aACT,QAAQ;;;;;KCfhB,MAAM,mBAAmB;KACzB,QAAQ,MAAM;KAEd,QAAQ,GAAG,YAAY,KAAK,qBAC5B,oBAAoB;;KAMb,aAAa,kBAAkB;;KAG/B,oBAAoB,UAAU,cACxC,UAAU,YAAY,gBAAgB,aAAa;KAEzC,oBAAoB,UAAU,cACxC,UAAU,YAAY,iBAAiB,YAAY;KAEhD,cAAc,YACjB,MAAM,iCAEF,iBAAiB,4BACA,aAAa;KAK/B,eAAe,aAAa,YAAY,cAAc,eACzD,aAAa,gBACJ,aAAa,WACnB,aAAa,iB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,SAAS;WACT,yBAAyB;WACzB,SAAS;;;KAIR;WACD,SAAS;WACT,yBAAyB;WACzB,SAAS;;;KAIR;WACD,OAAO;;;KAIN;WACD,OAAO;WACP,SAAS;;;KAIR;WACD,SAAS;WACT,SAAS;WACT;;;KAIC;WACD,oBAAoB,OAAO,+BAA+B;WAC1D,oBAAoB,OAAO,+BAA+B;WAC1D,oBAAoB,OAAO,+BAA+B;WAC1D,kBAAkB,OAAO,6BAA6B;WACtD,qBAAqB,OAAO,gCAAgC;;;;;KC5B3D;;WAED,SAAS;;WAET,OAAO;;;KAIN,0BACV,YAAY,2BAA2B,8BACpC;;KAGO;;WAED,UAAU;;WAEV;;WAEA,qBAAqB;;WAErB,mBAAmB;;WAEnB,iBAAiB;;WAEjB,SAAS;;;KAIR;WACD,SAAS;;;KAIR;;WAED;;WAEA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,321 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as LayerRegistration, n as LayerBackend, t as MapLayerBackend } from "./map-layer-backend-
|
|
1
|
+
import { B as ServiceTag, C as EffectError, D as EffectYield, E as EffectSuccess, F as ServiceContract, H as ServiceToken, I as ServiceIdentity, M as AnyService, N as AnyServiceToken, P as ServiceClass, R as ServiceInstance, T as EffectRequirements, U as ServiceTokenOf, _ as ScopeCloseError, a as ServiceResolver, b as Service, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, f as DisposableResource, g as ResourceNotDisposableError, h as ScopeOutcome, i as ServiceRuntimeNotConfiguredError, j as ServiceRequirement, l as CloseableScope, m as ScopeFinalizer, n as ServiceAcquisitionError, o as ServiceRuntime, r as ServiceNotFoundError, s as RuntimeContext, t as CircularDependencyError, u as Scope, v as ScopeClosedError, x as AnyEffect, y as ScopeRuntimeNotConfiguredError, z as ServiceRequirements } from "./index-1NLNdkJy.mjs";
|
|
2
|
+
import { _ as Layer, a as RuntimeShutdownDiagnostic, c as RuntimeObserver, d as RuntimeServiceResolveEvent, f as DuplicateServiceError, g as ServiceTagCollisionError, h as LayerRegistrationError, i as RuntimeRunOptions, l as RuntimeResourceReleaseEvent, m as LayerGeneratorYieldError, n as RuntimeDisposeOptions, o as RuntimeExecutionEndEvent, p as LayerDisposeError, r as RuntimeOptions, s as RuntimeExecutionStartEvent, t as CleanupFailureObserver, u as RuntimeServiceAcquireEvent } from "./index-CYAgpM_5.mjs";
|
|
3
|
+
import { a as LayerRegistration, n as LayerBackend, t as MapLayerBackend } from "./map-layer-backend-DMJauecV.mjs";
|
|
4
|
+
import { a as AcquireUseReleaseOptions, c as ReleaseOutcome, d as Effect, f as Program, i as Resource, l as ResourceReleaseFailure, n as Runtime, o as AsyncResult, p as ProgramAllOptions, r as RuntimeFor, s as ReleaseFailureObserver, t as CurrentAbortSignal, u as pipe } from "./index-BJFBEsm5.mjs";
|
|
4
5
|
import { t as RuntimeContextNotConfiguredError } from "./errors-BXKc7juX.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/effect/combinators.d.ts
|
|
7
|
-
type EffectInput<A, E> = Result<A, E> | PromiseLike<Result<A, E>>;
|
|
8
|
-
type AnyEffectInput = EffectInput<any, any>;
|
|
9
|
-
type AnyEffectValue = Result<any, any>;
|
|
10
|
-
type AnyAsyncEffectInput = PromiseLike<Result<any, any>>;
|
|
11
|
-
type PreserveAsync<Input, Output> = Input extends PromiseLike<unknown> ? Promise<Output> : Output;
|
|
12
|
-
type MappedResult<Input, B> = Effect$1<B, EffectError<Input>, EffectRequirements<Input>>;
|
|
13
|
-
type ErrorMappedResult<Input, E2> = Effect$1<EffectSuccess<Input>, E2, EffectRequirements<Input>>;
|
|
14
|
-
type ChainedResult<First, Next> = Effect$1<EffectSuccess<Next>, EffectError<First> | EffectError<Next>, EffectRequirements<First> | EffectRequirements<Next>>;
|
|
15
|
-
type ChainedOutput<First, Next> = ChainedResult<First, Next>;
|
|
16
|
-
type AsyncChainedOutput<First, Next> = Promise<ChainedResult<First, Next>>;
|
|
17
|
-
type MapOperation<A, B> = {
|
|
18
|
-
<Input>(effect: Input & EffectInput<A, any>): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
19
|
-
};
|
|
20
|
-
type MapErrorOperation<E1, E2> = {
|
|
21
|
-
<Input>(effect: Input & EffectInput<any, E1>): PreserveAsync<Input, ErrorMappedResult<Input, E2>>;
|
|
22
|
-
};
|
|
23
|
-
type AndThenOperation<Next> = {
|
|
24
|
-
<Input>(effect: Input & AnyEffectValue): ChainedOutput<Input, Next>;
|
|
25
|
-
};
|
|
26
|
-
type AndThenAsyncOperation<A, Next> = {
|
|
27
|
-
<Input>(effect: Input & EffectInput<A, any>): AsyncChainedOutput<Input, Next>;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Map the successful value of a Result or Effect result.
|
|
31
|
-
*
|
|
32
|
-
* Supports both data-first and data-last forms and preserves asynchronous
|
|
33
|
-
* results and declaration-only Service requirements.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* const doubled = Effect.map(Result.ok(2), (value) => value * 2)
|
|
38
|
-
* const toLabel = Effect.map((value: number) => `#${value}`)
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
declare function map<A, B>(fn: (value: A) => B): MapOperation<A, B>;
|
|
42
|
-
declare function map<Input, B>(effect: Input & AnyEffectInput, fn: (value: EffectSuccess<Input>) => B): PreserveAsync<Input, MappedResult<Input, B>>;
|
|
43
|
-
/**
|
|
44
|
-
* Map the error value of a Result or Effect result while preserving its
|
|
45
|
-
* successful value, asynchronous shape, and declaration-only Service requirements.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* const labelled = Effect.mapError(Result.err('missing'), (error) => ({ error }))
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
declare function mapError<E1, E2>(fn: (error: E1) => E2): MapErrorOperation<E1, E2>;
|
|
53
|
-
declare function mapError<Input, E2>(effect: Input & AnyEffectInput, fn: (error: EffectError<Input>) => E2): PreserveAsync<Input, ErrorMappedResult<Input, E2>>;
|
|
54
|
-
/**
|
|
55
|
-
* Chain a synchronous Result-producing operation after a successful result.
|
|
56
|
-
*
|
|
57
|
-
* The next operation is skipped when the input is an error. Both error types
|
|
58
|
-
* and both sets of Service requirements are preserved in the output.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* const user = Effect.andThen(Result.ok('u1'), (id) => repository.find(id))
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
declare function andThen<A, Next extends AnyEffectValue>(next: (value: A) => Next): AndThenOperation<Next>;
|
|
66
|
-
declare function andThen<Input, Next extends AnyEffectValue>(effect: Input & AnyEffectValue, next: (value: EffectSuccess<Input>) => Next): ChainedOutput<Input, Next>;
|
|
67
|
-
/**
|
|
68
|
-
* Chain an asynchronous Result-producing operation after a successful result.
|
|
69
|
-
*
|
|
70
|
-
* The returned value is always a Promise and retains both operations' error
|
|
71
|
-
* and Service-requirement metadata.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const user = Effect.andThenAsync(loadUser(), (user) => fetchProfile(user.id))
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
declare function andThenAsync<A, Next extends AnyAsyncEffectInput>(next: (value: A) => Next): AndThenAsyncOperation<A, Next>;
|
|
79
|
-
declare function andThenAsync<Input, Next extends AnyAsyncEffectInput>(effect: Input & AnyEffectInput, next: (value: EffectSuccess<Input>) => Next): AsyncChainedOutput<Input, Next>;
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/effect/effect.d.ts
|
|
82
|
-
type Effect<A, E, R extends AnyService = never> = Effect$1<A, E, R>;
|
|
83
|
-
type LazyProgram<A, E, R extends AnyService = never> = Program<A, E, R>;
|
|
84
|
-
type AnyResult = Result<any, any>;
|
|
85
|
-
/**
|
|
86
|
-
* Compose `better-result` operations while preserving Service requirements in
|
|
87
|
-
* a declaration-only type channel.
|
|
88
|
-
*
|
|
89
|
-
* A generator may yield Service tokens and Result operations. It must return a
|
|
90
|
-
* `Result` as its final value; Service yields are resolved by the active
|
|
91
|
-
* Runtime and do not add runtime values to the Result stream.
|
|
92
|
-
* Use `fn` when generator execution should wait for a Runtime boundary.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* const loadUser = Effect.gen(async function* () {
|
|
97
|
-
* const database = yield* Database
|
|
98
|
-
* const user = yield* Result.await(database.findUser('u1'))
|
|
99
|
-
*
|
|
100
|
-
* return Result.ok(user)
|
|
101
|
-
* })
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => Generator<Yield, Returned, unknown>): EffectFromGenerator<Yield, Returned>;
|
|
105
|
-
declare function gen<Yield extends EffectYield, Returned extends AnyResult>(body: () => AsyncGenerator<Yield, Returned, unknown>): Promise<EffectFromGenerator<Yield, Returned>>;
|
|
106
|
-
/** Build a lazy Program without running its generator. */
|
|
107
|
-
declare function fn<Yield extends EffectYield, Returned extends AnyResult>(body: () => Generator<Yield, Returned, unknown>): ProgramFromGenerator<Yield, Returned>;
|
|
108
|
-
declare function fn<Yield extends EffectYield, Returned extends AnyResult>(body: () => AsyncGenerator<Yield, Returned, unknown>): ProgramFromGenerator<Yield, Returned>;
|
|
109
|
-
/**
|
|
110
|
-
* Acquire a resource in the current Scope and register its release callback.
|
|
111
|
-
*
|
|
112
|
-
* Acquisition failures are represented in the Effect Result error channel;
|
|
113
|
-
* release failures remain owned by Scope cleanup. The release callback
|
|
114
|
-
* receives the final outcome chosen by the enclosing execution boundary.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* const connection = yield* Effect.acquireRelease(
|
|
119
|
-
* () => pool.connect(),
|
|
120
|
-
* (connection, outcome) => connection.close(outcome)
|
|
121
|
-
* )
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
declare function acquireRelease<R>(acquire: () => MaybePromise$1<R>, release: (resource: R, outcome: ScopeOutcome) => MaybePromise$1<void>): AsyncGenerator<Err<never, UnhandledException>, R, unknown>;
|
|
125
|
-
/**
|
|
126
|
-
* Register an already-acquired disposable resource in the current Scope.
|
|
127
|
-
*
|
|
128
|
-
* The resource is not acquired by this helper. Registration failures are
|
|
129
|
-
* represented in the Effect Result error channel; disposal failures remain
|
|
130
|
-
* owned by Scope cleanup.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```ts
|
|
134
|
-
* const file = yield* Effect.add(await openFile('notes.txt'))
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
declare function add<R extends DisposableResource>(resource: R): AsyncGenerator<Err<never, UnhandledException>, R, unknown>;
|
|
138
|
-
/**
|
|
139
|
-
* Effect namespace containing generator, resource, and Result combinators.
|
|
140
|
-
*
|
|
141
|
-
* Prefer these helpers when a program needs typed Service requirements or
|
|
142
|
-
* Scope-aware acquisition and cleanup.
|
|
143
|
-
*/
|
|
144
|
-
declare const Effect: {
|
|
145
|
-
/** Compose a generator-based Effect program. */
|
|
146
|
-
readonly gen: typeof gen;
|
|
147
|
-
/** Build a lazy Program from a generator. */
|
|
148
|
-
readonly fn: typeof fn;
|
|
149
|
-
/** Acquire and register a resource in the current Scope. */
|
|
150
|
-
readonly acquireRelease: typeof acquireRelease;
|
|
151
|
-
/** Register an already-acquired disposable in the current Scope. */
|
|
152
|
-
readonly add: typeof add;
|
|
153
|
-
/** Map a successful Effect result. */
|
|
154
|
-
readonly map: typeof map;
|
|
155
|
-
/** Map an Effect error. */
|
|
156
|
-
readonly mapError: typeof mapError;
|
|
157
|
-
/** Chain a synchronous Effect result. */
|
|
158
|
-
readonly andThen: typeof andThen;
|
|
159
|
-
/** Chain an asynchronous Effect result. */
|
|
160
|
-
readonly andThenAsync: typeof andThenAsync;
|
|
161
|
-
};
|
|
162
|
-
/** Type-level aliases for inspecting Effect result channels and requirements. */
|
|
163
|
-
declare namespace Effect {
|
|
164
|
-
/** A nominal lazy computation that produces an Effect when invoked. */
|
|
165
|
-
type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>;
|
|
166
|
-
/** Extract the success channel from an Effect result or Promise. */
|
|
167
|
-
type Success<T> = EffectSuccess<T>;
|
|
168
|
-
/** Extract the error channel from an Effect result or Promise. */
|
|
169
|
-
type Error<T> = EffectError<T>;
|
|
170
|
-
/** Extract the Service requirements from an Effect result or Promise. */
|
|
171
|
-
type Requirements<T> = EffectRequirements<T>;
|
|
172
|
-
/** An Effect with erased success, error, and requirements. */
|
|
173
|
-
type Any = AnyEffect;
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/function/pipe.d.ts
|
|
177
|
-
type Unary<A, B> = (value: A) => B;
|
|
178
|
-
declare function pipe<A>(value: A): A;
|
|
179
|
-
declare function pipe<A, B>(value: A, ab: Unary<A, B>): B;
|
|
180
|
-
declare function pipe<A, B, C>(value: A, ab: Unary<A, B>, bc: Unary<B, C>): C;
|
|
181
|
-
declare function pipe<A, B, C, D>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>): D;
|
|
182
|
-
declare function pipe<A, B, C, D, E>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>): E;
|
|
183
|
-
declare function pipe<A, B, C, D, E, F>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>): F;
|
|
184
|
-
declare function pipe<A, B, C, D, E, F, G>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>): G;
|
|
185
|
-
declare function pipe<A, B, C, D, E, F, G, H>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>): H;
|
|
186
|
-
declare function pipe<A, B, C, D, E, F, G, H, I>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>, hi: Unary<H, I>): I;
|
|
187
|
-
declare function pipe<A, B, C, D, E, F, G, H, I, J>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>, hi: Unary<H, I>, ij: Unary<I, J>): J;
|
|
188
|
-
declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(value: A, ab: Unary<A, B>, bc: Unary<B, C>, cd: Unary<C, D>, de: Unary<D, E>, ef: Unary<E, F>, fg: Unary<F, G>, gh: Unary<G, H>, hi: Unary<H, I>, ij: Unary<I, J>, jk: Unary<J, K>): K;
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region src/resource/errors.d.ts
|
|
191
|
-
declare const ResourceReleaseFailure_base: import("better-result").TaggedErrorClass<"ResourceReleaseFailure">;
|
|
192
|
-
/** Describes a failure encountered while releasing a Resource. */
|
|
193
|
-
declare class ResourceReleaseFailure extends ResourceReleaseFailure_base<{
|
|
194
|
-
readonly resource: string;
|
|
195
|
-
readonly cause: unknown;
|
|
196
|
-
readonly message: string;
|
|
197
|
-
}> {}
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region src/resource/types.d.ts
|
|
200
|
-
/** A value that may be delivered synchronously or through a thenable. */
|
|
201
|
-
type MaybePromise<T> = T | PromiseLike<T>;
|
|
202
|
-
/** A synchronous or asynchronous better-result Result operation. */
|
|
203
|
-
type AsyncResult<T, E> = MaybePromise<Result<T, E>>;
|
|
204
|
-
/** The allowed return value of a custom Resource release callback. */
|
|
205
|
-
type ReleaseOutcome = void | Result<void, unknown>;
|
|
206
|
-
/** Receives release failures for diagnostics without changing error precedence. */
|
|
207
|
-
type ReleaseFailureObserver = (failure: ResourceReleaseFailure) => MaybePromise<void>;
|
|
208
|
-
/** Options controlling `Resource.acquireUseRelease`. */
|
|
209
|
-
type AcquireUseReleaseOptions<R, A, AcquireError, UseError> = {
|
|
210
|
-
/** Human-readable name included in release failures. */
|
|
211
|
-
readonly name: string;
|
|
212
|
-
/** Acquire the resource. A failure skips use and release. */
|
|
213
|
-
readonly acquire: () => AsyncResult<R, AcquireError>;
|
|
214
|
-
/** Use the acquired resource. Release is attempted afterward. */
|
|
215
|
-
readonly use: (resource: R) => AsyncResult<A, UseError>;
|
|
216
|
-
/** Release the resource, or omit it to use its disposal protocol. */
|
|
217
|
-
readonly release?: (resource: R) => MaybePromise<ReleaseOutcome>;
|
|
218
|
-
/**
|
|
219
|
-
* Observe cleanup failures without changing error precedence. This is most
|
|
220
|
-
* useful when both `use` and `release` can fail.
|
|
221
|
-
*/
|
|
222
|
-
readonly onReleaseFailure?: ReleaseFailureObserver;
|
|
223
|
-
};
|
|
224
|
-
//#endregion
|
|
225
|
-
//#region src/resource/resource.d.ts
|
|
226
|
-
declare const Resource: {
|
|
227
|
-
/** Acquire, use, and release a resource with deterministic error precedence. */
|
|
228
|
-
readonly acquireUseRelease: <R, A, AcquireError, UseError>({ name, acquire, use, release, onReleaseFailure }: AcquireUseReleaseOptions<R, A, AcquireError, UseError>) => Promise<Result<A, AcquireError | UseError | UnhandledException | ResourceReleaseFailure>>;
|
|
229
|
-
};
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/runtime/types.d.ts
|
|
232
|
-
/**
|
|
233
|
-
* Name a Runtime type from a concrete Layer without repeating its provided
|
|
234
|
-
* branded Service instance union.
|
|
235
|
-
*
|
|
236
|
-
* @example
|
|
237
|
-
* ```ts
|
|
238
|
-
* type AppRuntime = RuntimeFor<typeof AppLive>
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
type RuntimeFor<L extends LayerInput> = Runtime<Layer.Provided<L>>;
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/runtime/runtime.d.ts
|
|
244
|
-
/**
|
|
245
|
-
* Long-lived execution environment backed by a complete Layer.
|
|
246
|
-
*
|
|
247
|
-
* A Runtime owns Layer resources until `dispose()` is called. Each `run()` is
|
|
248
|
-
* isolated in a child Scope, while Layer-scoped resources remain shared.
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* ```ts
|
|
252
|
-
* const runtime = await Runtime.make(AppLive)
|
|
253
|
-
* const result = await runtime.run(loadUser('u1'))
|
|
254
|
-
* await runtime.dispose()
|
|
255
|
-
* ```
|
|
256
|
-
*
|
|
257
|
-
* @typeParam Provided The branded Service instances supplied by the Layer.
|
|
258
|
-
*/
|
|
259
|
-
declare class Runtime<Provided extends AnyService = any> {
|
|
260
|
-
private readonly handle;
|
|
261
|
-
private constructor();
|
|
262
|
-
/**
|
|
263
|
-
* Create a long-lived Runtime that owns its Layer resources.
|
|
264
|
-
*
|
|
265
|
-
* @example
|
|
266
|
-
* ```ts
|
|
267
|
-
* const runtime = await Runtime.make(AppLive)
|
|
268
|
-
* const result = await runtime.run(program)
|
|
269
|
-
* await runtime.dispose()
|
|
270
|
-
* ```
|
|
271
|
-
*/
|
|
272
|
-
static make<L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
273
|
-
static make<L extends LayerInput>(layer: L & CompleteInput<L>, options?: RuntimeOptions): Promise<Runtime<ProvidedEnvironment<L>>>;
|
|
274
|
-
/**
|
|
275
|
-
* Run one program and dispose its Layer resources before resolving.
|
|
276
|
-
*
|
|
277
|
-
* This is convenient for request-style or command-style execution where a
|
|
278
|
-
* Runtime should not outlive the operation.
|
|
279
|
-
*/
|
|
280
|
-
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, backend: LayerBackend, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
281
|
-
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, program: CompleteExecution<ProvidedEnvironment<L>, A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
282
|
-
static run<A, L extends LayerInput>(layer: L & CompleteInput<L>, options: RuntimeOptions, program: CompleteExecution<ProvidedEnvironment<L>, A>): Promise<Awaited<A>>;
|
|
283
|
-
/** Run a callback with a managed Runtime and always dispose it afterward. */
|
|
284
|
-
static use<A, L extends LayerInput>(layer: L & CompleteInput<L>, use: (runtime: Runtime<ProvidedEnvironment<L>>) => A | PromiseLike<A>, options?: RuntimeOptions): Promise<Awaited<A>>;
|
|
285
|
-
/** Resolve every Layer provider and dispose the Runtime if warmup fails. */
|
|
286
|
-
warmup(): Promise<void>;
|
|
287
|
-
/** Run one execution in this Runtime's child Scope. */
|
|
288
|
-
run<A>(program: CompleteExecution<Provided, A>, options?: RuntimeRunOptions): Promise<Awaited<A>>;
|
|
289
|
-
/** Run one execution with a Layer owned by that execution's child Scope. */
|
|
290
|
-
runWith<Request extends LayerInput, A>(layer: Request & CompleteExecutionLayer<Provided, Request>, program: CompleteExecution<Provided | ProvidedEnvironment<Request>, A>, options?: RuntimeRunOptions): Promise<Awaited<A>>;
|
|
291
|
-
private runUnchecked;
|
|
292
|
-
/** Stop new executions and release the Runtime's Layer resources. */
|
|
293
|
-
dispose(options?: RuntimeDisposeOptions): Promise<void>;
|
|
294
|
-
/** @deprecated Scope outcomes are kept for internal compatibility. */
|
|
295
|
-
dispose(outcome: ScopeOutcome): Promise<void>;
|
|
296
|
-
/** Release Runtime-owned resources through JavaScript's async disposal protocol. */
|
|
297
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
298
|
-
private disposeWithOutcome;
|
|
299
|
-
}
|
|
300
|
-
/** Type-level aliases for naming Runtime handles and shutdown options. */
|
|
301
|
-
declare namespace Runtime {
|
|
302
|
-
/** Name a Runtime type from a concrete Layer. */
|
|
303
|
-
type For<L extends LayerInput> = RuntimeFor<L>;
|
|
304
|
-
/** Optional Runtime shutdown configuration. */
|
|
305
|
-
type Options = RuntimeOptions;
|
|
306
|
-
/** Optional signal supplied to one managed Runtime execution. */
|
|
307
|
-
type RunOptions = RuntimeRunOptions;
|
|
308
|
-
/** Cooperative shutdown policy for a managed Runtime. */
|
|
309
|
-
type DisposeOptions = RuntimeDisposeOptions;
|
|
310
|
-
/** Diagnostic reported for aggregated Runtime shutdown cleanup failures. */
|
|
311
|
-
type ShutdownDiagnostic = RuntimeShutdownDiagnostic;
|
|
312
|
-
}
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region src/runtime/signal.d.ts
|
|
315
|
-
/** Yieldable access to the signal of the current Runtime execution. */
|
|
316
|
-
declare const CurrentAbortSignal: {
|
|
317
|
-
readonly [Symbol.iterator]: () => Generator<never, AbortSignal, unknown>;
|
|
318
|
-
};
|
|
319
|
-
//#endregion
|
|
320
|
-
export { type AcquireUseReleaseOptions, type AnyEffect, type AnyService, type AnyServiceToken, type AsyncResult, CircularDependencyError, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, CurrentAbortSignal, type DisposableResource, DuplicateServiceError, Effect, type EffectError, type EffectRequirements, type EffectSuccess, type EffectYield, Layer, type LayerBackend, LayerDisposeError, LayerGeneratorYieldError, type LayerRegistration, LayerRegistrationError, MapLayerBackend, type Program, type ReleaseFailureObserver, type ReleaseOutcome, Resource, ResourceNotDisposableError, ResourceReleaseFailure, Runtime, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, type RuntimeDisposeOptions, type RuntimeExecutionEndEvent, type RuntimeExecutionStartEvent, type RuntimeFor, type RuntimeObserver, type RuntimeOptions, type RuntimeResourceReleaseEvent, type RuntimeRunOptions, type RuntimeServiceAcquireEvent, type RuntimeServiceResolveEvent, type RuntimeShutdownDiagnostic, Scope, ScopeCloseError, ScopeClosedError, type ScopeFinalizer, type ScopeOutcome, ScopeRuntimeNotConfiguredError, Service, ServiceAcquisitionError, type ServiceClass, type ServiceContract, type ServiceIdentity, type ServiceInstance, ServiceNotFoundError, type ServiceRequirement, type ServiceRequirements, type ServiceResolver, ServiceRuntime, ServiceRuntimeNotConfiguredError, type ServiceTag, ServiceTagCollisionError, type ServiceToken, type ServiceTokenOf, pipe };
|
|
321
|
-
//# sourceMappingURL=index.d.mts.map
|
|
6
|
+
export { type AcquireUseReleaseOptions, type AnyEffect, type AnyService, type AnyServiceToken, type AsyncResult, CircularDependencyError, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, CurrentAbortSignal, type DisposableResource, DuplicateServiceError, Effect, type EffectError, type EffectRequirements, type EffectSuccess, type EffectYield, Layer, type LayerBackend, LayerDisposeError, LayerGeneratorYieldError, type LayerRegistration, LayerRegistrationError, MapLayerBackend, Program, type ProgramAllOptions, type ReleaseFailureObserver, type ReleaseOutcome, Resource, ResourceNotDisposableError, ResourceReleaseFailure, Runtime, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, type RuntimeDisposeOptions, type RuntimeExecutionEndEvent, type RuntimeExecutionStartEvent, type RuntimeFor, type RuntimeObserver, type RuntimeOptions, type RuntimeResourceReleaseEvent, type RuntimeRunOptions, type RuntimeServiceAcquireEvent, type RuntimeServiceResolveEvent, type RuntimeShutdownDiagnostic, Scope, ScopeCloseError, ScopeClosedError, type ScopeFinalizer, type ScopeOutcome, ScopeRuntimeNotConfiguredError, Service, ServiceAcquisitionError, type ServiceClass, type ServiceContract, type ServiceIdentity, type ServiceInstance, ServiceNotFoundError, type ServiceRequirement, type ServiceRequirements, type ServiceResolver, ServiceRuntime, ServiceRuntimeNotConfiguredError, type ServiceTag, ServiceTagCollisionError, type ServiceToken, type ServiceTokenOf, pipe };
|