better-effect 0.7.0 → 0.9.1
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 +96 -1
- package/dist/adapters/iti.d.mts +1 -1
- 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-BddlcJK6.d.mts → index-BSRPIYII.d.mts} +58 -3
- package/dist/index-BSRPIYII.d.mts.map +1 -0
- package/dist/index-yOfq7LKL.d.mts +406 -0
- package/dist/index-yOfq7LKL.d.mts.map +1 -0
- package/dist/index.d.mts +4 -303
- package/dist/index.mjs +382 -262
- 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-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/signal-BgUtPQj5.mjs +271 -0
- package/dist/signal-BgUtPQj5.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.mjs +1 -1
- package/package.json +6 -2
- package/dist/index-BddlcJK6.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/internal-identity-Cm4-KIUj.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,305 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { C as EffectError, D as EffectYield, E as EffectSuccess, F as ServiceContract, H as ServiceTokenOf, I as ServiceIdentity, L as ServiceInstance, M as AnyService, N as AnyServiceToken, P as ServiceClass, R as ServiceRequirements, T as EffectRequirements, V as ServiceToken, _ 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 ServiceTag } from "./index-BFgG9zZC.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-BSRPIYII.mjs";
|
|
3
3
|
import { a as LayerRegistration, n as LayerBackend, t as MapLayerBackend } from "./map-layer-backend-CGibcwkc.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-yOfq7LKL.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
|
-
/** Run one execution in this Runtime's child Scope. */
|
|
286
|
-
run<A>(program: CompleteExecution<Provided, A>): Promise<Awaited<A>>;
|
|
287
|
-
private runUnchecked;
|
|
288
|
-
/** Stop new executions and release the Runtime's Layer resources. */
|
|
289
|
-
dispose(): Promise<void>;
|
|
290
|
-
/** Release Runtime-owned resources through JavaScript's async disposal protocol. */
|
|
291
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
292
|
-
private disposeWithOutcome;
|
|
293
|
-
}
|
|
294
|
-
/** Type-level aliases for naming Runtime handles and shutdown options. */
|
|
295
|
-
declare namespace Runtime {
|
|
296
|
-
/** Name a Runtime type from a concrete Layer. */
|
|
297
|
-
type For<L extends LayerInput> = RuntimeFor<L>;
|
|
298
|
-
/** Optional Runtime shutdown configuration. */
|
|
299
|
-
type Options = RuntimeOptions;
|
|
300
|
-
/** Diagnostic reported for aggregated Runtime shutdown cleanup failures. */
|
|
301
|
-
type ShutdownDiagnostic = RuntimeShutdownDiagnostic;
|
|
302
|
-
}
|
|
303
|
-
//#endregion
|
|
304
|
-
export { type AcquireUseReleaseOptions, type AnyEffect, type AnyService, type AnyServiceToken, type AsyncResult, CircularDependencyError, type CleanupFailureDiagnostic, type CleanupFailureObserver, type CloseableScope, 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 RuntimeFor, type RuntimeOptions, 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 };
|
|
305
|
-
//# 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 };
|