better-effect 0.9.31 → 0.11.0
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/LICENSE +21 -0
- package/README.md +277 -16
- package/dist/adapters/iti.d.mts +10 -5
- package/dist/adapters/iti.d.mts.map +1 -1
- package/dist/adapters/iti.mjs +30 -5
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/context-BUEf1qjL.mjs +152 -0
- package/dist/context-BUEf1qjL.mjs.map +1 -0
- package/dist/effect-2ZcGZI8A.mjs +513 -0
- package/dist/effect-2ZcGZI8A.mjs.map +1 -0
- package/dist/errors-BKcsQ0ip.d.mts +12 -0
- package/dist/errors-BKcsQ0ip.d.mts.map +1 -0
- package/dist/hono.d.mts +39 -21
- package/dist/hono.d.mts.map +1 -1
- package/dist/hono.mjs +25 -20
- package/dist/hono.mjs.map +1 -1
- package/dist/{index-BsPr7qHf.d.mts → index-C7Qild0_.d.mts} +158 -28
- package/dist/index-C7Qild0_.d.mts.map +1 -0
- package/dist/{index-CITM15SE.d.mts → index-DStz0JMN.d.mts} +4 -4
- package/dist/{index-CITM15SE.d.mts.map → index-DStz0JMN.d.mts.map} +1 -1
- package/dist/{index-1NLNdkJy.d.mts → index-heuaRmXR.d.mts} +8 -8
- package/dist/{index-1NLNdkJy.d.mts.map → index-heuaRmXR.d.mts.map} +1 -1
- package/dist/{index-EJlskfAW.d.mts → index-rQhZk3Nt.d.mts} +130 -23
- package/dist/index-rQhZk3Nt.d.mts.map +1 -0
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +6 -540
- package/dist/index.mjs.map +1 -1
- package/dist/runtime/explicit.d.mts +11 -7
- package/dist/runtime/explicit.d.mts.map +1 -1
- package/dist/runtime/explicit.mjs +96 -23
- package/dist/runtime/explicit.mjs.map +1 -1
- package/dist/runtime/node.d.mts +2 -2
- package/dist/runtime/node.d.mts.map +1 -1
- package/dist/runtime/node.mjs +10 -6
- package/dist/runtime/node.mjs.map +1 -1
- package/dist/runtime-DnMn0X0X.mjs +613 -0
- package/dist/runtime-DnMn0X0X.mjs.map +1 -0
- package/dist/scope-GGnmTQck.mjs +245 -0
- package/dist/scope-GGnmTQck.mjs.map +1 -0
- package/dist/{signal-Cl9tqGyX.mjs → signal-B97cs85Z.mjs} +86 -6
- package/dist/signal-B97cs85Z.mjs.map +1 -0
- package/dist/{standard-services-QseopL9g.mjs → standard-services-BFBq-4lo.mjs} +2 -2
- package/dist/{standard-services-QseopL9g.mjs.map → standard-services-BFBq-4lo.mjs.map} +1 -1
- package/dist/standard-services.d.mts +2 -2
- package/dist/standard-services.mjs +2 -2
- package/dist/testing.d.mts +198 -2
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +976 -2
- package/dist/testing.mjs.map +1 -0
- package/package.json +6 -3
- package/dist/context-B4yO5LaH.mjs +0 -80
- package/dist/context-B4yO5LaH.mjs.map +0 -1
- package/dist/effect-CZdZCZLW.mjs +0 -522
- package/dist/effect-CZdZCZLW.mjs.map +0 -1
- package/dist/errors-BXKc7juX.d.mts +0 -8
- package/dist/errors-BXKc7juX.d.mts.map +0 -1
- package/dist/index-BsPr7qHf.d.mts.map +0 -1
- package/dist/index-EJlskfAW.d.mts.map +0 -1
- package/dist/map-layer-backend-DMJauecV.d.mts +0 -42
- package/dist/map-layer-backend-DMJauecV.d.mts.map +0 -1
- package/dist/map-layer-backend-gal-mcRv.mjs +0 -53
- package/dist/map-layer-backend-gal-mcRv.mjs.map +0 -1
- package/dist/signal-Cl9tqGyX.mjs.map +0 -1
package/dist/effect-CZdZCZLW.mjs
DELETED
|
@@ -1,522 +0,0 @@
|
|
|
1
|
-
import { a as runRuntimeContext, i as makeRuntimeContext, n as currentRuntimeContext, r as getRuntimeContext, t as activeRuntimeContextStorage } from "./context-B4yO5LaH.mjs";
|
|
2
|
-
import { t as isPromiseLike } from "./runtime-CDcCF5cb.mjs";
|
|
3
|
-
import { Result } from "better-result";
|
|
4
|
-
//#region src/scope/errors.ts
|
|
5
|
-
/** Thrown when Scope context is accessed outside an active Scope execution. */
|
|
6
|
-
var ScopeRuntimeNotConfiguredError = class extends Error {
|
|
7
|
-
constructor() {
|
|
8
|
-
super("No Scope is available in the current execution context");
|
|
9
|
-
this.name = "ScopeRuntimeNotConfiguredError";
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
/** Thrown when a resource or finalizer is added after Scope closure begins. */
|
|
13
|
-
var ScopeClosedError = class extends Error {
|
|
14
|
-
constructor() {
|
|
15
|
-
super("Cannot add resources or finalizers to a closed Scope");
|
|
16
|
-
this.name = "ScopeClosedError";
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
/** Aggregates finalizer failures encountered while closing a Scope. */
|
|
20
|
-
var ScopeCloseError = class extends Error {
|
|
21
|
-
causes;
|
|
22
|
-
constructor(causes) {
|
|
23
|
-
super(`Failed to close Scope (${causes.length} finalizer${causes.length === 1 ? "" : "s"} failed)`);
|
|
24
|
-
this.causes = causes;
|
|
25
|
-
this.name = "ScopeCloseError";
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */
|
|
29
|
-
var ResourceNotDisposableError = class extends Error {
|
|
30
|
-
constructor() {
|
|
31
|
-
super("Resource does not implement Symbol.dispose or Symbol.asyncDispose");
|
|
32
|
-
this.name = "ResourceNotDisposableError";
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/scope/disposable.ts
|
|
37
|
-
const SCOPE_SUCCESS$1 = { status: "success" };
|
|
38
|
-
/** Return a Scope finalizer for a value's async or sync disposal protocol. */
|
|
39
|
-
const getDisposeFinalizer = (resource) => {
|
|
40
|
-
const candidate = Object(resource);
|
|
41
|
-
const asyncDispose = candidate[Symbol.asyncDispose];
|
|
42
|
-
if (asyncDispose instanceof Function) return () => asyncDispose.call(resource);
|
|
43
|
-
const dispose = candidate[Symbol.dispose];
|
|
44
|
-
if (dispose instanceof Function) return () => dispose.call(resource);
|
|
45
|
-
};
|
|
46
|
-
/** Dispose a value immediately when it implements a disposal protocol. */
|
|
47
|
-
const disposeResource = (resource) => {
|
|
48
|
-
return getDisposeFinalizer(resource)?.(SCOPE_SUCCESS$1);
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/scope/runtime.ts
|
|
52
|
-
const scopeStorages = /* @__PURE__ */ new WeakMap();
|
|
53
|
-
/** Bridges the current Scope through async execution context. */
|
|
54
|
-
var ScopeRuntime = class {
|
|
55
|
-
/** Supply a Scope while invoking a callback. */
|
|
56
|
-
static run(scope, program, storage = scopeStorages.get(scope) ?? activeRuntimeContextStorage()) {
|
|
57
|
-
scopeStorages.set(scope, storage);
|
|
58
|
-
const current = getRuntimeContext(storage);
|
|
59
|
-
const context = makeRuntimeContext(current?.resolver, scope, current?.resolutionPath ?? [], current?.signal);
|
|
60
|
-
return runRuntimeContext(storage, context, program);
|
|
61
|
-
}
|
|
62
|
-
/** Return the Scope active in the current execution context. */
|
|
63
|
-
static current() {
|
|
64
|
-
let context;
|
|
65
|
-
try {
|
|
66
|
-
context = currentRuntimeContext();
|
|
67
|
-
} catch {
|
|
68
|
-
throw new ScopeRuntimeNotConfiguredError();
|
|
69
|
-
}
|
|
70
|
-
if (!context.scope) throw new ScopeRuntimeNotConfiguredError();
|
|
71
|
-
return context.scope;
|
|
72
|
-
}
|
|
73
|
-
/** Associate a Runtime-owned Scope with its context storage. */
|
|
74
|
-
static bind(scope, storage) {
|
|
75
|
-
scopeStorages.set(scope, storage);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/scope/internal.ts
|
|
80
|
-
const notifyCleanupFailure = async (observer, diagnostic) => {
|
|
81
|
-
if (!observer) return;
|
|
82
|
-
try {
|
|
83
|
-
await observer(diagnostic);
|
|
84
|
-
} catch {}
|
|
85
|
-
};
|
|
86
|
-
const runScoped = async (scope, program, options) => {
|
|
87
|
-
let value;
|
|
88
|
-
let programFailed = false;
|
|
89
|
-
let programFailure;
|
|
90
|
-
try {
|
|
91
|
-
const run = () => ScopeRuntime.run(scope, program, options.contextStorage);
|
|
92
|
-
value = await (options.context && options.contextStorage ? runRuntimeContext(options.contextStorage, options.context, run) : run());
|
|
93
|
-
} catch (cause) {
|
|
94
|
-
programFailed = true;
|
|
95
|
-
programFailure = cause;
|
|
96
|
-
}
|
|
97
|
-
const outcome = programFailed ? {
|
|
98
|
-
status: "failure",
|
|
99
|
-
cause: programFailure
|
|
100
|
-
} : options.classify(value);
|
|
101
|
-
let cleanupFailed = false;
|
|
102
|
-
let cleanupFailure;
|
|
103
|
-
try {
|
|
104
|
-
await scope.close(outcome);
|
|
105
|
-
} catch (cause) {
|
|
106
|
-
cleanupFailed = true;
|
|
107
|
-
cleanupFailure = cause;
|
|
108
|
-
}
|
|
109
|
-
if (cleanupFailed) {
|
|
110
|
-
const error = cleanupFailure instanceof ScopeCloseError ? cleanupFailure : new ScopeCloseError([cleanupFailure]);
|
|
111
|
-
await notifyCleanupFailure(options.onCleanupFailure, {
|
|
112
|
-
outcome,
|
|
113
|
-
error
|
|
114
|
-
});
|
|
115
|
-
cleanupFailure = error;
|
|
116
|
-
}
|
|
117
|
-
if (programFailed) throw programFailure;
|
|
118
|
-
if (outcome.status === "failure") return value;
|
|
119
|
-
if (cleanupFailed) throw cleanupFailure;
|
|
120
|
-
return value;
|
|
121
|
-
};
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/scope/scope.ts
|
|
124
|
-
const SCOPE_SUCCESS = Object.freeze({ status: "success" });
|
|
125
|
-
var ScopeImpl = class ScopeImpl {
|
|
126
|
-
parent;
|
|
127
|
-
children = /* @__PURE__ */ new Set();
|
|
128
|
-
finalizers = [];
|
|
129
|
-
closePromise;
|
|
130
|
-
closeOutcome;
|
|
131
|
-
constructor(parent) {
|
|
132
|
-
this.parent = parent;
|
|
133
|
-
}
|
|
134
|
-
fork() {
|
|
135
|
-
this.assertOpen();
|
|
136
|
-
const child = new ScopeImpl(this);
|
|
137
|
-
this.children.add(child);
|
|
138
|
-
return child;
|
|
139
|
-
}
|
|
140
|
-
addFinalizer(finalizer) {
|
|
141
|
-
this.assertOpen();
|
|
142
|
-
this.finalizers.push(finalizer);
|
|
143
|
-
}
|
|
144
|
-
async acquire(acquire, release) {
|
|
145
|
-
this.assertOpen();
|
|
146
|
-
const resource = await acquire();
|
|
147
|
-
try {
|
|
148
|
-
this.addFinalizer((outcome) => release(resource, outcome));
|
|
149
|
-
return resource;
|
|
150
|
-
} catch (scopeFailure) {
|
|
151
|
-
try {
|
|
152
|
-
await release(resource, this.closeOutcome ?? SCOPE_SUCCESS);
|
|
153
|
-
} catch (releaseFailure) {
|
|
154
|
-
throw new AggregateError([scopeFailure, releaseFailure], "Scope closed while acquiring a resource and immediate cleanup also failed");
|
|
155
|
-
}
|
|
156
|
-
throw scopeFailure;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
async add(resource) {
|
|
160
|
-
const finalizer = getDisposeFinalizer(resource);
|
|
161
|
-
if (!finalizer) throw new ResourceNotDisposableError();
|
|
162
|
-
try {
|
|
163
|
-
this.addFinalizer(finalizer);
|
|
164
|
-
return resource;
|
|
165
|
-
} catch (scopeFailure) {
|
|
166
|
-
try {
|
|
167
|
-
await finalizer(this.closeOutcome ?? SCOPE_SUCCESS);
|
|
168
|
-
} catch (releaseFailure) {
|
|
169
|
-
throw new AggregateError([scopeFailure, releaseFailure], "Scope closed while adding a disposable resource and cleanup also failed");
|
|
170
|
-
}
|
|
171
|
-
throw scopeFailure;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
close(outcome = SCOPE_SUCCESS) {
|
|
175
|
-
if (this.closePromise) return this.closePromise;
|
|
176
|
-
this.closeOutcome = outcome;
|
|
177
|
-
this.closePromise = ScopeRuntime.run(this, () => this.closeInternal(outcome));
|
|
178
|
-
return this.closePromise;
|
|
179
|
-
}
|
|
180
|
-
async closeInternal(outcome) {
|
|
181
|
-
const failures = [];
|
|
182
|
-
const children = [...this.children];
|
|
183
|
-
this.children.clear();
|
|
184
|
-
for (let index = children.length - 1; index >= 0; index--) {
|
|
185
|
-
const child = children[index];
|
|
186
|
-
if (!child) continue;
|
|
187
|
-
try {
|
|
188
|
-
await child.close(outcome);
|
|
189
|
-
} catch (cause) {
|
|
190
|
-
if (cause instanceof ScopeCloseError) failures.push(...cause.causes);
|
|
191
|
-
else failures.push(cause);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
for (let index = this.finalizers.length - 1; index >= 0; index--) {
|
|
195
|
-
const finalizer = this.finalizers[index];
|
|
196
|
-
if (!finalizer) continue;
|
|
197
|
-
try {
|
|
198
|
-
await finalizer(outcome);
|
|
199
|
-
} catch (cause) {
|
|
200
|
-
failures.push(cause);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
this.finalizers.length = 0;
|
|
204
|
-
this.detach();
|
|
205
|
-
if (failures.length > 0) throw new ScopeCloseError(failures);
|
|
206
|
-
}
|
|
207
|
-
detach() {
|
|
208
|
-
const parent = this.parent;
|
|
209
|
-
if (!parent) return;
|
|
210
|
-
parent.children.delete(this);
|
|
211
|
-
this.parent = void 0;
|
|
212
|
-
}
|
|
213
|
-
assertOpen() {
|
|
214
|
-
if (this.closePromise) throw new ScopeClosedError();
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
const Scope = {
|
|
218
|
-
/** Create an owned, initially open Scope. */
|
|
219
|
-
make() {
|
|
220
|
-
return new ScopeImpl();
|
|
221
|
-
},
|
|
222
|
-
/** Return the non-owning Scope available in the current execution context. */
|
|
223
|
-
current() {
|
|
224
|
-
return ScopeRuntime.current();
|
|
225
|
-
},
|
|
226
|
-
/** Run a callback with an existing Scope supplied as the current context. */
|
|
227
|
-
provide(scope, program) {
|
|
228
|
-
return ScopeRuntime.run(scope, program);
|
|
229
|
-
},
|
|
230
|
-
/** Resolve the current Scope through `yield* Scope` inside an Effect. */
|
|
231
|
-
*[Symbol.iterator]() {
|
|
232
|
-
return ScopeRuntime.current();
|
|
233
|
-
},
|
|
234
|
-
/**
|
|
235
|
-
* Run a program in a newly owned Scope.
|
|
236
|
-
*
|
|
237
|
-
* Scope is independent from `better-result`, so returned values—including
|
|
238
|
-
* `Result.err`—close this Scope with a successful outcome. Result-aware
|
|
239
|
-
* outcome classification belongs to `Runtime.run`.
|
|
240
|
-
*
|
|
241
|
-
* @example
|
|
242
|
-
* ```ts
|
|
243
|
-
* await Scope.run(async (scope) => {
|
|
244
|
-
* const connection = await scope.acquire(connect, (connection) => connection.close())
|
|
245
|
-
* return connection.query()
|
|
246
|
-
* })
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
run(program) {
|
|
250
|
-
const scope = new ScopeImpl();
|
|
251
|
-
return runScoped(scope, () => program(scope), { classify: () => SCOPE_SUCCESS });
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/effect/combinators.ts
|
|
256
|
-
const asResult = (value) => {
|
|
257
|
-
return value;
|
|
258
|
-
};
|
|
259
|
-
const mapResult = (result, fn) => {
|
|
260
|
-
return Result.map(result, fn);
|
|
261
|
-
};
|
|
262
|
-
const mapErrorResult = (result, fn) => {
|
|
263
|
-
return Result.mapError(result, fn);
|
|
264
|
-
};
|
|
265
|
-
const andThenResult = (result, next) => {
|
|
266
|
-
const resultNext = next;
|
|
267
|
-
return Result.andThen(result, resultNext);
|
|
268
|
-
};
|
|
269
|
-
const andThenAsyncResult = (result, next) => {
|
|
270
|
-
const resultNext = (value) => {
|
|
271
|
-
return Promise.resolve(next(value));
|
|
272
|
-
};
|
|
273
|
-
return Result.andThenAsync(result, resultNext);
|
|
274
|
-
};
|
|
275
|
-
function map(first, second) {
|
|
276
|
-
if (first instanceof Function && second === void 0) {
|
|
277
|
-
const callback = first;
|
|
278
|
-
return (effect) => {
|
|
279
|
-
return map(effect, callback);
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
const fn = second;
|
|
283
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => {
|
|
284
|
-
return mapResult(result, fn);
|
|
285
|
-
});
|
|
286
|
-
return mapResult(first, fn);
|
|
287
|
-
}
|
|
288
|
-
function mapError(first, second) {
|
|
289
|
-
if (first instanceof Function && second === void 0) {
|
|
290
|
-
const callback = first;
|
|
291
|
-
return (effect) => {
|
|
292
|
-
return mapError(effect, callback);
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
const fn = second;
|
|
296
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => {
|
|
297
|
-
return mapErrorResult(result, fn);
|
|
298
|
-
});
|
|
299
|
-
return mapErrorResult(first, fn);
|
|
300
|
-
}
|
|
301
|
-
function andThen(first, second) {
|
|
302
|
-
if (first instanceof Function && second === void 0) {
|
|
303
|
-
const callback = first;
|
|
304
|
-
return (effect) => {
|
|
305
|
-
return andThen(effect, callback);
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
return andThenResult(first, second);
|
|
309
|
-
}
|
|
310
|
-
function andThenAsync(first, second) {
|
|
311
|
-
if (first instanceof Function && second === void 0) {
|
|
312
|
-
const callback = first;
|
|
313
|
-
return (effect) => {
|
|
314
|
-
return andThenAsync(effect, callback);
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
const next = second;
|
|
318
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => {
|
|
319
|
-
return andThenAsyncResult(result, next);
|
|
320
|
-
});
|
|
321
|
-
return andThenAsyncResult(first, next);
|
|
322
|
-
}
|
|
323
|
-
const tapResult = (result, fn) => Result.tap(result, fn);
|
|
324
|
-
const tapErrorResult = (result, fn) => Result.tapError(result, fn);
|
|
325
|
-
const tapBothResult = (result, handlers) => Result.tapBoth(result, handlers);
|
|
326
|
-
const recoverResult = (result, fn) => Result.tryRecover(result, fn);
|
|
327
|
-
const recoverAsyncResult = (result, fn) => Result.tryRecoverAsync(result, (error) => Promise.resolve(fn(error)));
|
|
328
|
-
const flattenResult = (result) => Result.flatten(result);
|
|
329
|
-
const matchResult = (result, handlers) => Result.match(result, handlers);
|
|
330
|
-
const allResult = (results) => Result.all(results);
|
|
331
|
-
function tap(first, second) {
|
|
332
|
-
if (first instanceof Function && second === void 0) {
|
|
333
|
-
const callback = first;
|
|
334
|
-
return (effect) => tap(effect, callback);
|
|
335
|
-
}
|
|
336
|
-
if (second === void 0) throw new TypeError("Effect.tap requires a callback");
|
|
337
|
-
const fn = second;
|
|
338
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => tapResult(asResult(result), fn));
|
|
339
|
-
return tapResult(asResult(first), fn);
|
|
340
|
-
}
|
|
341
|
-
function tapError(first, second) {
|
|
342
|
-
if (first instanceof Function && second === void 0) {
|
|
343
|
-
const callback = first;
|
|
344
|
-
return (effect) => tapError(effect, callback);
|
|
345
|
-
}
|
|
346
|
-
if (second === void 0) throw new TypeError("Effect.tapError requires a callback");
|
|
347
|
-
const fn = second;
|
|
348
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => tapErrorResult(asResult(result), fn));
|
|
349
|
-
return tapErrorResult(asResult(first), fn);
|
|
350
|
-
}
|
|
351
|
-
function tapBoth(first, second) {
|
|
352
|
-
if (second === void 0) return (effect) => tapBoth(effect, first);
|
|
353
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => tapBothResult(result, second));
|
|
354
|
-
return tapBothResult(asResult(first), second);
|
|
355
|
-
}
|
|
356
|
-
function recover(first, second) {
|
|
357
|
-
if (first instanceof Function && second === void 0) {
|
|
358
|
-
const callback = first;
|
|
359
|
-
return (effect) => recover(effect, callback);
|
|
360
|
-
}
|
|
361
|
-
if (second === void 0) throw new TypeError("Effect.recover requires a callback");
|
|
362
|
-
const fn = second;
|
|
363
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => recoverResult(asResult(result), fn));
|
|
364
|
-
return recoverResult(asResult(first), fn);
|
|
365
|
-
}
|
|
366
|
-
function recoverAsync(first, second) {
|
|
367
|
-
if (first instanceof Function && second === void 0) {
|
|
368
|
-
const callback = first;
|
|
369
|
-
return (effect) => recoverAsync(effect, callback);
|
|
370
|
-
}
|
|
371
|
-
if (second === void 0) throw new TypeError("Effect.recoverAsync requires a callback");
|
|
372
|
-
const fn = second;
|
|
373
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => recoverAsyncResult(asResult(result), fn));
|
|
374
|
-
return recoverAsyncResult(asResult(first), fn);
|
|
375
|
-
}
|
|
376
|
-
/** Remove one nested Result/Effect layer. */
|
|
377
|
-
function flatten(effect) {
|
|
378
|
-
return flattenResult(asResult(effect));
|
|
379
|
-
}
|
|
380
|
-
function as(first, second) {
|
|
381
|
-
if (arguments.length < 2) return (effect) => as(effect, first);
|
|
382
|
-
return mapResult(asResult(first), () => second);
|
|
383
|
-
}
|
|
384
|
-
/** Replace a successful value with void. */
|
|
385
|
-
function asVoid(effect) {
|
|
386
|
-
return mapResult(asResult(effect), () => void 0);
|
|
387
|
-
}
|
|
388
|
-
function match(first, second) {
|
|
389
|
-
if (isPromiseLike(first)) return Promise.resolve(first).then((result) => match(asResult(result), second));
|
|
390
|
-
return matchResult(asResult(first), second);
|
|
391
|
-
}
|
|
392
|
-
/** Collect already-created Effects in input order. */
|
|
393
|
-
function all(results) {
|
|
394
|
-
return allResult(results);
|
|
395
|
-
}
|
|
396
|
-
/** Combine two already-created Effects in input order. */
|
|
397
|
-
function zip(left, right) {
|
|
398
|
-
return Result.all([left, right]);
|
|
399
|
-
}
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region src/effect/effect.ts
|
|
402
|
-
const runResultGenerator = Result.gen;
|
|
403
|
-
function gen(body) {
|
|
404
|
-
return runResultGenerator(body);
|
|
405
|
-
}
|
|
406
|
-
function fn(body) {
|
|
407
|
-
const program = () => runResultGenerator(body);
|
|
408
|
-
return program;
|
|
409
|
-
}
|
|
410
|
-
const validateProgramConcurrency = (concurrency) => {
|
|
411
|
-
if (concurrency !== void 0 && (!Number.isFinite(concurrency) || !Number.isInteger(concurrency) || concurrency <= 0)) throw new RangeError("Program.all concurrency must be a positive integer");
|
|
412
|
-
};
|
|
413
|
-
/** Build a lazy Program collection with optional bounded concurrency. */
|
|
414
|
-
function programAll(programs, options = {}) {
|
|
415
|
-
validateProgramConcurrency(options.concurrency);
|
|
416
|
-
const concurrency = options.concurrency;
|
|
417
|
-
const program = async () => {
|
|
418
|
-
const results = Array.from({ length: programs.length });
|
|
419
|
-
const failures = Array.from({ length: programs.length }, () => false);
|
|
420
|
-
const causes = Array.from({ length: programs.length });
|
|
421
|
-
let nextIndex = 0;
|
|
422
|
-
const worker = async () => {
|
|
423
|
-
while (true) {
|
|
424
|
-
const index = nextIndex++;
|
|
425
|
-
if (index >= programs.length) return;
|
|
426
|
-
try {
|
|
427
|
-
results[index] = await programs[index]();
|
|
428
|
-
} catch (cause) {
|
|
429
|
-
failures[index] = true;
|
|
430
|
-
causes[index] = cause;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
const workers = Math.min(concurrency ?? programs.length, programs.length);
|
|
435
|
-
await Promise.all(Array.from({ length: workers }, () => worker()));
|
|
436
|
-
const failureIndex = failures.findIndex(Boolean);
|
|
437
|
-
if (failureIndex >= 0) throw causes[failureIndex];
|
|
438
|
-
return Result.all(results);
|
|
439
|
-
};
|
|
440
|
-
return program;
|
|
441
|
-
}
|
|
442
|
-
/** Value-level namespace for lazy Program combinators. */
|
|
443
|
-
const Program = { all: programAll };
|
|
444
|
-
/**
|
|
445
|
-
* Acquire a resource in the current Scope and register its release callback.
|
|
446
|
-
*
|
|
447
|
-
* Acquisition failures are represented in the Effect Result error channel;
|
|
448
|
-
* release failures remain owned by Scope cleanup. The release callback
|
|
449
|
-
* receives the final outcome chosen by the enclosing execution boundary.
|
|
450
|
-
*
|
|
451
|
-
* @example
|
|
452
|
-
* ```ts
|
|
453
|
-
* const connection = yield* Effect.acquireRelease(
|
|
454
|
-
* () => pool.connect(),
|
|
455
|
-
* (connection, outcome) => connection.close(outcome)
|
|
456
|
-
* )
|
|
457
|
-
* ```
|
|
458
|
-
*/
|
|
459
|
-
function acquireRelease(acquire, release) {
|
|
460
|
-
const scope = Scope.current();
|
|
461
|
-
return Result.await(Result.tryPromise(() => scope.acquire(acquire, release)));
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Register an already-acquired disposable resource in the current Scope.
|
|
465
|
-
*
|
|
466
|
-
* The resource is not acquired by this helper. Registration failures are
|
|
467
|
-
* represented in the Effect Result error channel; disposal failures remain
|
|
468
|
-
* owned by Scope cleanup.
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```ts
|
|
472
|
-
* const file = yield* Effect.add(await openFile('notes.txt'))
|
|
473
|
-
* ```
|
|
474
|
-
*/
|
|
475
|
-
function add(resource) {
|
|
476
|
-
const scope = Scope.current();
|
|
477
|
-
return Result.await(Result.tryPromise(() => scope.add(resource)));
|
|
478
|
-
}
|
|
479
|
-
const Effect = {
|
|
480
|
-
/** Compose a generator-based Effect program. */
|
|
481
|
-
gen,
|
|
482
|
-
/** Build a lazy Program from a generator. */
|
|
483
|
-
fn,
|
|
484
|
-
/** Acquire and register a resource in the current Scope. */
|
|
485
|
-
acquireRelease,
|
|
486
|
-
/** Register an already-acquired disposable in the current Scope. */
|
|
487
|
-
add,
|
|
488
|
-
/** Map a successful Effect result. */
|
|
489
|
-
map,
|
|
490
|
-
/** Map an Effect error. */
|
|
491
|
-
mapError,
|
|
492
|
-
/** Chain a synchronous Effect result. */
|
|
493
|
-
andThen,
|
|
494
|
-
/** Chain an asynchronous Effect result. */
|
|
495
|
-
andThenAsync,
|
|
496
|
-
/** Observe successful values without changing the Result. */
|
|
497
|
-
tap,
|
|
498
|
-
/** Observe error values without changing the Result. */
|
|
499
|
-
tapError,
|
|
500
|
-
/** Observe the active Result branch without changing the Result. */
|
|
501
|
-
tapBoth,
|
|
502
|
-
/** Recover an error with another Effect. */
|
|
503
|
-
recover,
|
|
504
|
-
/** Recover an error asynchronously with another Effect. */
|
|
505
|
-
recoverAsync,
|
|
506
|
-
/** Remove one nested Effect layer. */
|
|
507
|
-
flatten,
|
|
508
|
-
/** Replace a successful value. */
|
|
509
|
-
as,
|
|
510
|
-
/** Replace a successful value with void. */
|
|
511
|
-
asVoid,
|
|
512
|
-
/** Match either Result branch. */
|
|
513
|
-
match,
|
|
514
|
-
/** Collect Effects in input order. */
|
|
515
|
-
all,
|
|
516
|
-
/** Zip two Effects in input order. */
|
|
517
|
-
zip
|
|
518
|
-
};
|
|
519
|
-
//#endregion
|
|
520
|
-
export { ScopeRuntime as a, ScopeCloseError as c, runScoped as i, ScopeClosedError as l, Program as n, disposeResource as o, Scope as r, ResourceNotDisposableError as s, Effect as t, ScopeRuntimeNotConfiguredError as u };
|
|
521
|
-
|
|
522
|
-
//# sourceMappingURL=effect-CZdZCZLW.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effect-CZdZCZLW.mjs","names":["SCOPE_SUCCESS","next"],"sources":["../src/scope/errors.ts","../src/scope/disposable.ts","../src/scope/runtime.ts","../src/scope/internal.ts","../src/scope/scope.ts","../src/effect/combinators.ts","../src/effect/effect.ts"],"sourcesContent":["/** Thrown when Scope context is accessed outside an active Scope execution. */\nexport class ScopeRuntimeNotConfiguredError extends Error {\n constructor() {\n super('No Scope is available in the current execution context')\n\n this.name = 'ScopeRuntimeNotConfiguredError'\n }\n}\n\n/** Thrown when a resource or finalizer is added after Scope closure begins. */\nexport class ScopeClosedError extends Error {\n constructor() {\n super('Cannot add resources or finalizers to a closed Scope')\n\n this.name = 'ScopeClosedError'\n }\n}\n\n/** Aggregates finalizer failures encountered while closing a Scope. */\nexport class ScopeCloseError extends Error {\n constructor(readonly causes: readonly unknown[]) {\n super(\n `Failed to close Scope (${causes.length} finalizer${causes.length === 1 ? '' : 's'} failed)`\n )\n\n this.name = 'ScopeCloseError'\n }\n}\n\n/** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */\nexport class ResourceNotDisposableError extends Error {\n constructor() {\n super('Resource does not implement Symbol.dispose or Symbol.asyncDispose')\n\n this.name = 'ResourceNotDisposableError'\n }\n}\n","import type { ScopeFinalizer } from './types'\n\nconst SCOPE_SUCCESS = { status: 'success' } as const\n\ntype Disposer = (...args: never[]) => void | PromiseLike<void>\n\ntype DisposableCandidate = {\n [Symbol.dispose]?: Disposer\n\n [Symbol.asyncDispose]?: Disposer\n}\n\n/** Return a Scope finalizer for a value's async or sync disposal protocol. */\nexport const getDisposeFinalizer = <Resource>(resource: Resource): ScopeFinalizer | undefined => {\n // SAFETY: Object() provides a property-bearing view for protocol lookup; each method is checked for callability before invocation.\n const candidate = Object(resource) as DisposableCandidate\n const asyncDispose = candidate[Symbol.asyncDispose]\n\n if (asyncDispose instanceof Function) {\n return () => asyncDispose.call(resource)\n }\n\n const dispose = candidate[Symbol.dispose]\n\n if (dispose instanceof Function) {\n return () => dispose.call(resource)\n }\n\n return undefined\n}\n\n/** Dispose a value immediately when it implements a disposal protocol. */\nexport const disposeResource = <Resource>(resource: Resource): void | PromiseLike<void> => {\n const finalizer = getDisposeFinalizer(resource)\n\n return finalizer?.(SCOPE_SUCCESS)\n}\n","import { ScopeRuntimeNotConfiguredError } from './errors'\n\nimport type { Scope } from './scope'\n\nimport {\n activeRuntimeContextStorage,\n currentRuntimeContext,\n getRuntimeContext,\n makeRuntimeContext,\n runRuntimeContext\n} from '../runtime/context'\n\nimport type { RuntimeContextStorage } from '../runtime/context'\n\nconst scopeStorages = new WeakMap<object, RuntimeContextStorage>()\n\n/** Bridges the current Scope through async execution context. */\nexport class ScopeRuntime {\n /** Supply a Scope while invoking a callback. */\n static run<A>(\n scope: Scope,\n program: () => A,\n storage: RuntimeContextStorage = scopeStorages.get(scope) ?? activeRuntimeContextStorage()\n ): A {\n scopeStorages.set(scope, storage)\n\n const current = getRuntimeContext(storage)\n const context = makeRuntimeContext(\n current?.resolver,\n scope,\n current?.resolutionPath ?? [],\n current?.signal\n )\n\n return runRuntimeContext(storage, context, program)\n }\n\n /** Return the Scope active in the current execution context. */\n static current(): Scope {\n let context\n\n try {\n context = currentRuntimeContext()\n } catch {\n throw new ScopeRuntimeNotConfiguredError()\n }\n\n if (!context.scope) {\n throw new ScopeRuntimeNotConfiguredError()\n }\n\n return context.scope\n }\n\n /** Associate a Runtime-owned Scope with its context storage. */\n static bind(scope: Scope, storage: RuntimeContextStorage): void {\n scopeStorages.set(scope, storage)\n }\n}\n","import { ScopeCloseError } from './errors'\n\nimport { ScopeRuntime } from './runtime'\n\nimport type { CloseableScope } from './scope'\n\nimport {\n runRuntimeContext,\n type RuntimeContext,\n type RuntimeContextStorage\n} from '../runtime/context'\n\nimport type { CleanupFailureDiagnostic, MaybePromise, ScopeOutcome } from './types'\n\nexport type OutcomeClassifier<A> = (value: A) => ScopeOutcome\n\nexport type RunScopedOptions<A> = {\n readonly classify: OutcomeClassifier<A>\n readonly onCleanupFailure?: (diagnostic: CleanupFailureDiagnostic) => MaybePromise<void>\n readonly contextStorage?: RuntimeContextStorage\n readonly context?: RuntimeContext\n}\n\nconst notifyCleanupFailure = async (\n observer: ((diagnostic: CleanupFailureDiagnostic) => MaybePromise<void>) | undefined,\n diagnostic: CleanupFailureDiagnostic\n): Promise<void> => {\n if (!observer) {\n return\n }\n\n try {\n await observer(diagnostic)\n } catch {\n // Cleanup diagnostics are best effort and never affect the primary result.\n }\n}\n\nexport const runScoped = async <A>(\n scope: CloseableScope,\n program: () => A | PromiseLike<A>,\n options: RunScopedOptions<Awaited<A>>\n): Promise<Awaited<A>> => {\n let value!: Awaited<A>\n\n let programFailed = false\n let programFailure: unknown\n\n try {\n const run = () => ScopeRuntime.run(scope, program, options.contextStorage)\n\n value = await (options.context && options.contextStorage\n ? runRuntimeContext(options.contextStorage, options.context, run)\n : run())\n } catch (cause) {\n programFailed = true\n programFailure = cause\n }\n\n const outcome: ScopeOutcome = programFailed\n ? {\n status: 'failure',\n cause: programFailure\n }\n : options.classify(value)\n\n let cleanupFailed = false\n let cleanupFailure: unknown\n\n try {\n await scope.close(outcome)\n } catch (cause) {\n cleanupFailed = true\n cleanupFailure = cause\n }\n\n if (cleanupFailed) {\n const error =\n cleanupFailure instanceof ScopeCloseError\n ? cleanupFailure\n : new ScopeCloseError([cleanupFailure])\n\n await notifyCleanupFailure(options.onCleanupFailure, {\n outcome,\n error\n })\n\n cleanupFailure = error\n }\n\n if (programFailed) {\n throw programFailure\n }\n\n if (outcome.status === 'failure') {\n return value\n }\n\n if (cleanupFailed) {\n throw cleanupFailure\n }\n\n return value\n}\n","import { ResourceNotDisposableError, ScopeCloseError, ScopeClosedError } from './errors'\n\nimport { getDisposeFinalizer } from './disposable'\n\nimport { runScoped } from './internal'\n\nimport { ScopeRuntime } from './runtime'\n\nimport type { DisposableResource, MaybePromise, ScopeFinalizer, ScopeOutcome } from './types'\n\n/**\n * Non-owning lifecycle context for finalizers and child Scopes.\n *\n * A Scope can register cleanup and create children, but it cannot close\n * itself. Use `Scope.make()` or `Scope.run()` when your code owns the Scope.\n */\nexport interface Scope {\n /** Register a finalizer that runs when the owning Scope closes. */\n addFinalizer(finalizer: ScopeFinalizer): void\n\n /** Acquire a resource and register its outcome-aware release callback. */\n acquire<R>(\n acquire: () => MaybePromise<R>,\n release: (resource: R, outcome: ScopeOutcome) => MaybePromise<void>\n ): Promise<R>\n\n /** Register an already-acquired disposable resource. */\n add<R extends DisposableResource>(resource: R): Promise<R>\n\n /** Create a child Scope owned by this Scope. */\n fork(): CloseableScope\n}\n\n/** A Scope whose owner is responsible for calling `close()`. */\nexport interface CloseableScope extends Scope {\n /** Close the Scope and run children and finalizers in child-first LIFO order. */\n close(outcome?: ScopeOutcome): Promise<void>\n}\n\nconst SCOPE_SUCCESS: ScopeOutcome = Object.freeze({ status: 'success' })\n\nclass ScopeImpl implements CloseableScope {\n private readonly children = new Set<ScopeImpl>()\n\n private readonly finalizers: ScopeFinalizer[] = []\n\n private closePromise: Promise<void> | undefined\n\n private closeOutcome: ScopeOutcome | undefined\n\n constructor(private parent?: ScopeImpl) {}\n\n fork(): CloseableScope {\n this.assertOpen()\n\n const child = new ScopeImpl(this)\n\n this.children.add(child)\n\n return child\n }\n\n addFinalizer(finalizer: ScopeFinalizer): void {\n this.assertOpen()\n\n this.finalizers.push(finalizer)\n }\n\n async acquire<R>(\n acquire: () => MaybePromise<R>,\n release: (resource: R, outcome: ScopeOutcome) => MaybePromise<void>\n ): Promise<R> {\n this.assertOpen()\n\n const resource = await acquire()\n\n try {\n this.addFinalizer((outcome) => release(resource, outcome))\n\n return resource\n } catch (scopeFailure) {\n try {\n await release(resource, this.closeOutcome ?? SCOPE_SUCCESS)\n } catch (releaseFailure) {\n throw new AggregateError(\n [scopeFailure, releaseFailure],\n 'Scope closed while acquiring a resource and immediate cleanup also failed'\n )\n }\n\n throw scopeFailure\n }\n }\n\n async add<R extends DisposableResource>(resource: R): Promise<R> {\n const finalizer = getDisposeFinalizer(resource)\n\n if (!finalizer) {\n throw new ResourceNotDisposableError()\n }\n\n try {\n this.addFinalizer(finalizer)\n\n return resource\n } catch (scopeFailure) {\n try {\n await finalizer(this.closeOutcome ?? SCOPE_SUCCESS)\n } catch (releaseFailure) {\n throw new AggregateError(\n [scopeFailure, releaseFailure],\n 'Scope closed while adding a disposable resource and cleanup also failed'\n )\n }\n\n throw scopeFailure\n }\n }\n\n close(outcome: ScopeOutcome = SCOPE_SUCCESS): Promise<void> {\n if (this.closePromise) {\n return this.closePromise\n }\n\n this.closeOutcome = outcome\n this.closePromise = ScopeRuntime.run(this, () => this.closeInternal(outcome))\n\n return this.closePromise\n }\n\n private async closeInternal(outcome: ScopeOutcome): Promise<void> {\n const failures: unknown[] = []\n\n const children = [...this.children]\n\n this.children.clear()\n\n for (let index = children.length - 1; index >= 0; index--) {\n const child = children[index]\n\n if (!child) {\n continue\n }\n\n try {\n await child.close(outcome)\n } catch (cause) {\n if (cause instanceof ScopeCloseError) {\n failures.push(...cause.causes)\n } else {\n failures.push(cause)\n }\n }\n }\n\n for (let index = this.finalizers.length - 1; index >= 0; index--) {\n const finalizer = this.finalizers[index]\n\n if (!finalizer) {\n continue\n }\n\n try {\n await finalizer(outcome)\n } catch (cause) {\n failures.push(cause)\n }\n }\n\n this.finalizers.length = 0\n\n this.detach()\n\n if (failures.length > 0) {\n throw new ScopeCloseError(failures)\n }\n }\n\n private detach(): void {\n const parent = this.parent\n\n if (!parent) {\n return\n }\n\n parent.children.delete(this)\n this.parent = undefined\n }\n\n private assertOpen(): void {\n if (this.closePromise) {\n throw new ScopeClosedError()\n }\n }\n}\n\nexport const Scope = {\n /** Create an owned, initially open Scope. */\n make(): CloseableScope {\n return new ScopeImpl()\n },\n\n /** Return the non-owning Scope available in the current execution context. */\n current(): Scope {\n return ScopeRuntime.current()\n },\n\n /** Run a callback with an existing Scope supplied as the current context. */\n provide<A>(scope: Scope, program: () => A): A {\n return ScopeRuntime.run(scope, program)\n },\n\n /** Resolve the current Scope through `yield* Scope` inside an Effect. */\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<never, Scope, unknown> {\n return ScopeRuntime.current()\n },\n\n /**\n * Run a program in a newly owned Scope.\n *\n * Scope is independent from `better-result`, so returned values—including\n * `Result.err`—close this Scope with a successful outcome. Result-aware\n * outcome classification belongs to `Runtime.run`.\n *\n * @example\n * ```ts\n * await Scope.run(async (scope) => {\n * const connection = await scope.acquire(connect, (connection) => connection.close())\n * return connection.query()\n * })\n * ```\n */\n run<A>(program: (scope: Scope) => A | PromiseLike<A>): Promise<Awaited<A>> {\n const scope = new ScopeImpl()\n\n return runScoped(scope, () => program(scope), {\n classify: () => SCOPE_SUCCESS\n })\n }\n} as const\n\n/** Type-level aliases for Scope ownership, outcomes, and cleanup contracts. */\nexport declare namespace Scope {\n /** A Scope whose owner is responsible for calling `close()`. */\n export type Closeable = CloseableScope\n\n /** The outcome supplied to Scope finalizers and resource releases. */\n export type Outcome = ScopeOutcome\n\n /** A cleanup callback registered with a Scope. */\n export type Finalizer = ScopeFinalizer\n\n /** A value implementing a JavaScript disposal protocol. */\n export type Disposable = DisposableResource\n}\n","import { Result } from 'better-result'\n\nimport type { Result as ResultType } from 'better-result'\n\nimport type { AnyService } from '../service'\nimport { isPromiseLike } from '../utils/runtime'\nimport type { Effect, EffectError, EffectRequirements, EffectSuccess } from './types'\n\ntype EffectInput<A, E> = ResultType<A, E> | PromiseLike<ResultType<A, E>>\n\ntype AnyEffectInput = EffectInput<any, any>\ntype AnyEffectValue = ResultType<any, any>\ntype AnyAsyncEffectInput = PromiseLike<ResultType<any, any>>\ntype CombinatorCallback = (value: any) => any\ntype CombinatorInput = AnyEffectInput | CombinatorCallback\n\ntype PreserveAsync<Input, Output> = Input extends PromiseLike<unknown> ? Promise<Output> : Output\n\ntype MappedResult<Input, B> = Effect<B, EffectError<Input>, EffectRequirements<Input>>\n\ntype ErrorMappedResult<Input, E2> = Effect<EffectSuccess<Input>, E2, EffectRequirements<Input>>\n\ntype ChainedResult<First, Next> = Effect<\n EffectSuccess<Next>,\n EffectError<First> | EffectError<Next>,\n EffectRequirements<First> | EffectRequirements<Next>\n>\n\ntype ChainedOutput<First, Next> = ChainedResult<First, Next>\n\ntype AsyncChainedOutput<First, Next> = Promise<ChainedResult<First, Next>>\n\ntype MapOperation<A, B> = {\n <Input>(effect: Input & EffectInput<A, any>): PreserveAsync<Input, MappedResult<Input, B>>\n}\n\ntype MapErrorOperation<E1, E2> = {\n <Input>(effect: Input & EffectInput<any, E1>): PreserveAsync<Input, ErrorMappedResult<Input, E2>>\n}\n\ntype AndThenOperation<Next> = {\n <Input>(effect: Input & AnyEffectValue): ChainedOutput<Input, Next>\n}\n\ntype AndThenAsyncOperation<A, Next> = {\n <Input>(effect: Input & EffectInput<A, any>): AsyncChainedOutput<Input, Next>\n}\n\ntype TappedResult<Input> = Effect<\n EffectSuccess<Input>,\n EffectError<Input>,\n EffectRequirements<Input>\n>\n\ntype RecoveredResult<Input, Next> = Effect<\n EffectSuccess<Input> | EffectSuccess<Next>,\n EffectError<Next>,\n EffectRequirements<Input> | EffectRequirements<Next>\n>\n\ntype FlattenedResult<Input> = Effect<\n EffectSuccess<EffectSuccess<Input>>,\n EffectError<Input> | EffectError<EffectSuccess<Input>>,\n EffectRequirements<Input> | EffectRequirements<EffectSuccess<Input>>\n>\n\ntype AsResult<Input, Value> = Effect<Value, EffectError<Input>, EffectRequirements<Input>>\n\ntype MatchedResult<Input, OkResult, ErrResult> = Effect<\n EffectSuccess<OkResult> | EffectSuccess<ErrResult>,\n EffectError<OkResult> | EffectError<ErrResult>,\n EffectRequirements<Input> | EffectRequirements<OkResult> | EffectRequirements<ErrResult>\n>\n\ntype AllResult<Results extends readonly AnyEffectValue[]> = Effect<\n { -readonly [Index in keyof Results]: EffectSuccess<Results[Index]> },\n EffectError<Results[number]>,\n EffectRequirements<Results[number]>\n>\n\ntype ZipResult<Left, Right> = Effect<\n [EffectSuccess<Left>, EffectSuccess<Right>],\n EffectError<Left> | EffectError<Right>,\n EffectRequirements<Left> | EffectRequirements<Right>\n>\n\ntype TapOperation = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => void\n ): PreserveAsync<Input, TappedResult<Input>>\n}\n\ntype TapErrorOperation = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => void\n ): PreserveAsync<Input, TappedResult<Input>>\n}\n\ntype TapBothOperation = {\n <Input>(\n effect: Input & AnyEffectInput,\n handlers: {\n ok: (value: EffectSuccess<Input>) => void\n err: (error: EffectError<Input>) => void\n }\n ): PreserveAsync<Input, TappedResult<Input>>\n}\n\ntype RecoverOperation<Next> = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n ): PreserveAsync<Input, RecoveredResult<Input, Next>>\n}\n\ntype RecoverAsyncOperation<Next> = {\n <Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n ): Promise<RecoveredResult<Input, Next>>\n}\n\nconst asResult = <Value>(value: Value): ResultType<any, any> => {\n // SAFETY: Effect is the declaration-only Result facade, so every runtime value is a Result.\n return value as ResultType<any, any>\n}\n\nconst mapResult = <A, B, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (value: A) => B\n): Effect<B, E, Requirements> => {\n // SAFETY: Result.map changes only the success channel; the declaration-only Effect marker is restored by this adapter.\n return Result.map(result, fn) as Effect<B, E, Requirements>\n}\n\nconst mapErrorResult = <A, E1, E2, Requirements extends AnyService>(\n result: ResultType<A, E1>,\n fn: (error: E1) => E2\n): Effect<A, E2, Requirements> => {\n // SAFETY: Result.mapError changes only the error channel; the declaration-only Effect marker is restored by this adapter.\n return Result.mapError(result, fn) as Effect<A, E2, Requirements>\n}\n\nconst andThenResult = <\n A,\n B,\n E1,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E1>,\n next: (value: A) => ResultType<B, E2>\n): Effect<B, E1 | E2, Requirements1 | Requirements2> => {\n // SAFETY: The public callback returns an Effect, whose only runtime contract is the underlying Result.\n const resultNext = next as (value: A) => ResultType<B, E2>\n\n // SAFETY: Result.andThen unions Result errors; the declaration-only Effect marker is restored by this adapter.\n return Result.andThen(result, resultNext) as Effect<B, E1 | E2, Requirements1 | Requirements2>\n}\n\nconst andThenAsyncResult = <\n A,\n B,\n E1,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E1>,\n next: (value: A) => PromiseLike<ResultType<B, E2>>\n): Promise<Effect<B, E1 | E2, Requirements1 | Requirements2>> => {\n // SAFETY: The public callback returns an Effect, whose only runtime contract is the underlying Result.\n const resultNext = (value: A) => {\n // SAFETY: Promise resolution preserves the callback's Result value; only declaration-only Effect metadata is erased.\n return Promise.resolve(next(value)) as Promise<ResultType<B, E2>>\n }\n\n // SAFETY: Result.andThenAsync unions Result errors; the declaration-only Effect marker is restored by this adapter.\n return Result.andThenAsync(result, resultNext) as Promise<\n Effect<B, E1 | E2, Requirements1 | Requirements2>\n >\n}\n\n/**\n * Map the successful value of a Result or Effect result.\n *\n * Supports both data-first and data-last forms and preserves asynchronous\n * results and declaration-only Service requirements.\n *\n * @example\n * ```ts\n * const doubled = Effect.map(Result.ok(2), (value) => value * 2)\n * const toLabel = Effect.map((value: number) => `#${value}`)\n * ```\n */\nexport function map<A, B>(fn: (value: A) => B): MapOperation<A, B>\nexport function map<Input, B>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => B\n): PreserveAsync<Input, MappedResult<Input, B>>\nexport function map(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary mapping callback in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return map(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to be a unary mapping callback.\n const fn = second as CombinatorCallback\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => {\n // SAFETY: Result is the runtime representation shared by Effect and better-result.\n return mapResult(result as ResultType<any, any>, fn)\n })\n }\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return mapResult(first as ResultType<any, any>, fn)\n}\n\n/**\n * Map the error value of a Result or Effect result while preserving its\n * successful value, asynchronous shape, and declaration-only Service requirements.\n *\n * @example\n * ```ts\n * const labelled = Effect.mapError(Result.err('missing'), (error) => ({ error }))\n * ```\n */\nexport function mapError<E1, E2>(fn: (error: E1) => E2): MapErrorOperation<E1, E2>\nexport function mapError<Input, E2>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => E2\n): PreserveAsync<Input, ErrorMappedResult<Input, E2>>\nexport function mapError(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary error-mapping callback in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return mapError(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to be a unary error-mapping callback.\n const fn = second as CombinatorCallback\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => {\n // SAFETY: Result is the runtime representation shared by Effect and better-result.\n return mapErrorResult(result as ResultType<any, any>, fn)\n })\n }\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return mapErrorResult(first as ResultType<any, any>, fn)\n}\n\n/**\n * Chain a synchronous Result-producing operation after a successful result.\n *\n * The next operation is skipped when the input is an error. Both error types\n * and both sets of Service requirements are preserved in the output.\n *\n * @example\n * ```ts\n * const user = Effect.andThen(Result.ok('u1'), (id) => repository.find(id))\n * ```\n */\nexport function andThen<A, Next extends AnyEffectValue>(\n next: (value: A) => Next\n): AndThenOperation<Next>\nexport function andThen<Input, Next extends AnyEffectValue>(\n effect: Input & AnyEffectValue,\n next: (value: EffectSuccess<Input>) => Next\n): ChainedOutput<Input, Next>\nexport function andThen(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary continuation in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return andThen(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to return a Result.\n const next = second as CombinatorCallback\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return andThenResult(first as ResultType<any, any>, next)\n}\n\n/**\n * Chain an asynchronous Result-producing operation after a successful result.\n *\n * The returned value is always a Promise and retains both operations' error\n * and Service-requirement metadata.\n *\n * @example\n * ```ts\n * const user = Effect.andThenAsync(loadUser(), (user) => fetchProfile(user.id))\n * ```\n */\nexport function andThenAsync<A, Next extends AnyAsyncEffectInput>(\n next: (value: A) => Next\n): AndThenAsyncOperation<A, Next>\nexport function andThenAsync<Input, Next extends AnyAsyncEffectInput>(\n effect: Input & AnyEffectInput,\n next: (value: EffectSuccess<Input>) => Next\n): AsyncChainedOutput<Input, Next>\nexport function andThenAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n // SAFETY: The curried overload accepts a unary asynchronous continuation in this branch.\n const callback = first as CombinatorCallback\n\n return (effect: AnyEffectInput) => {\n // SAFETY: The overload implementation has already established the callback and Effect input positions.\n return andThenAsync(effect as never, callback as never)\n }\n }\n\n // SAFETY: The data-first overload requires the second argument to return a PromiseLike Effect.\n const next = second as CombinatorCallback\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => {\n // SAFETY: Result is the runtime representation shared by Effect and better-result.\n return andThenAsyncResult(result as ResultType<any, any>, next)\n })\n }\n\n // SAFETY: The data-first overload supplies a Result-compatible Effect value.\n return andThenAsyncResult(first as ResultType<any, any>, next)\n}\n\nconst tapResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (value: A) => void\n): Effect<A, E, Requirements> =>\n // SAFETY: Result.tap preserves the Result value; the declaration-only Effect marker is restored here.\n Result.tap(result, fn) as Effect<A, E, Requirements>\n\nconst tapErrorResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (error: E) => void\n): Effect<A, E, Requirements> =>\n // SAFETY: Result.tapError preserves the Result value; the declaration-only Effect marker is restored here.\n Result.tapError(result, fn) as Effect<A, E, Requirements>\n\nconst tapBothResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n handlers: { ok: (value: A) => void; err: (error: E) => void }\n): Effect<A, E, Requirements> =>\n // SAFETY: Result.tapBoth preserves the Result value; the declaration-only Effect marker is restored here.\n Result.tapBoth(result, handlers) as Effect<A, E, Requirements>\n\nconst recoverResult = <\n A,\n E,\n B,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E>,\n fn: (error: E) => ResultType<B, E2>\n): Effect<A | B, E2, Requirements1 | Requirements2> =>\n // SAFETY: Result.tryRecover owns recovery and short-circuiting; only Effect metadata is restored here.\n Result.tryRecover(result, fn) as Effect<A | B, E2, Requirements1 | Requirements2>\n\nconst recoverAsyncResult = <\n A,\n E,\n B,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<A, E>,\n fn: (error: E) => PromiseLike<ResultType<B, E2>>\n): Promise<Effect<A | B, E2, Requirements1 | Requirements2>> =>\n // SAFETY: Result.tryRecoverAsync owns asynchronous recovery; only Effect metadata is restored here.\n Result.tryRecoverAsync(result, (error) => Promise.resolve(fn(error))) as Promise<\n Effect<A | B, E2, Requirements1 | Requirements2>\n >\n\nconst flattenResult = <\n A,\n E1,\n E2,\n Requirements1 extends AnyService,\n Requirements2 extends AnyService\n>(\n result: ResultType<ResultType<A, E2>, E1>\n): Effect<A, E1 | E2, Requirements1 | Requirements2> =>\n // SAFETY: Result.flatten removes one Result layer; the outer and inner Effect markers are restored here.\n Result.flatten(result) as Effect<A, E1 | E2, Requirements1 | Requirements2>\n\nconst matchResult = <A, E, OkResult, ErrResult>(\n result: ResultType<A, E>,\n handlers: { ok: (value: A) => OkResult; err: (error: E) => ErrResult }\n): OkResult | ErrResult =>\n // SAFETY: Result.match invokes only the selected branch; handler Results remain ordinary runtime values.\n Result.match(result, handlers as never) as OkResult | ErrResult\n\nconst allResult = <const Results extends readonly AnyEffectValue[]>(\n results: Results\n): AllResult<Results> =>\n // SAFETY: Result.all preserves tuple order and short-circuiting; the declaration-only channels are restored here.\n Result.all(results as readonly ResultType<any, any>[]) as AllResult<Results>\n\n/** Observe a successful value without changing the Result. */\nexport function tap(fn: (value: any) => void): TapOperation\nexport function tap<Input>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => void\n): PreserveAsync<Input, TappedResult<Input>>\nexport function tap(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tap(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tap requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapResult(asResult(result), fn))\n }\n\n return tapResult(asResult(first), fn)\n}\n\n/** Observe an error value without changing the Result. */\nexport function tapError(fn: (error: any) => void): TapErrorOperation\nexport function tapError<Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => void\n): PreserveAsync<Input, TappedResult<Input>>\nexport function tapError(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tapError(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tapError requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapErrorResult(asResult(result), fn))\n }\n\n return tapErrorResult(asResult(first), fn)\n}\n\n/** Observe whichever Result branch is active without changing the Result. */\nexport function tapBoth(handlers: {\n ok: (value: any) => void\n err: (error: any) => void\n}): TapBothOperation\nexport function tapBoth<Input>(\n effect: Input & AnyEffectInput,\n handlers: {\n ok: (value: EffectSuccess<Input>) => void\n err: (error: EffectError<Input>) => void\n }\n): PreserveAsync<Input, TappedResult<Input>>\nexport function tapBoth(first: any, second?: any): any {\n if (second === undefined) {\n return (effect: AnyEffectInput) => tapBoth(effect, first)\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapBothResult(result, second))\n }\n\n return tapBothResult(asResult(first), second)\n}\n\n/** Recover an Err with a synchronous Result-producing callback. */\nexport function recover<Next extends AnyEffectValue>(\n fn: (error: any) => Next\n): RecoverOperation<Next>\nexport function recover<Input, Next extends AnyEffectValue>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n): PreserveAsync<Input, RecoveredResult<Input, Next>>\nexport function recover(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => recover(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.recover requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => recoverResult(asResult(result), fn))\n }\n\n return recoverResult(asResult(first), fn)\n}\n\n/** Recover an Err with an asynchronous Result-producing callback. */\nexport function recoverAsync<Next extends AnyAsyncEffectInput>(\n fn: (error: any) => Next\n): RecoverAsyncOperation<Next>\nexport function recoverAsync<Input, Next extends AnyAsyncEffectInput>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => Next\n): Promise<RecoveredResult<Input, Next>>\nexport function recoverAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => recoverAsync(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.recoverAsync requires a callback')\n }\n\n const fn = second\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => recoverAsyncResult(asResult(result), fn))\n }\n\n return recoverAsyncResult(asResult(first), fn)\n}\n\n/** Remove one nested Result/Effect layer. */\nexport function flatten<Input>(effect: Input & AnyEffectValue): FlattenedResult<Input> {\n // SAFETY: flattenResult restores the nested Effect channels after Result.flatten removes one runtime layer.\n return flattenResult(asResult(effect)) as FlattenedResult<Input>\n}\n\n/** Replace a successful value while preserving errors and requirements. */\nexport function as<Value>(\n value: Value\n): <Input>(effect: Input & AnyEffectValue) => AsResult<Input, Value>\nexport function as<Input, Value>(\n effect: Input & AnyEffectValue,\n value: Value\n): AsResult<Input, Value>\nexport function as(first: any, second?: any): any {\n if (arguments.length < 2) {\n return (effect: AnyEffectValue) => as(effect, first)\n }\n\n return mapResult(asResult(first), () => second)\n}\n\n/** Replace a successful value with void. */\nexport function asVoid<Input>(effect: Input & AnyEffectValue): AsResult<Input, void> {\n return mapResult(asResult(effect), () => undefined)\n}\n\n/** Match an Effect and return branch Effects with their channels unioned. */\nexport function match<Input, OkResult extends AnyEffectValue, ErrResult extends AnyEffectValue>(\n effect: Input & AnyEffectValue,\n handlers: {\n ok: (value: EffectSuccess<Input>) => OkResult\n err: (error: EffectError<Input>) => ErrResult\n }\n): PreserveAsync<Input, MatchedResult<Input, OkResult, ErrResult>>\nexport function match<Input, OkValue, ErrValue>(\n effect: Input & AnyEffectValue,\n handlers: {\n ok: (value: EffectSuccess<Input>) => OkValue\n err: (error: EffectError<Input>) => ErrValue\n }\n): PreserveAsync<Input, OkValue | ErrValue>\nexport function match(first: AnyEffectInput, second?: any): any {\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => match(asResult(result), second))\n }\n\n return matchResult(asResult(first), second)\n}\n\n/** Collect already-created Effects in input order. */\nexport function all<const Results extends readonly AnyEffectValue[]>(\n results: Results\n): AllResult<Results> {\n return allResult(results)\n}\n\n/** Combine two already-created Effects in input order. */\nexport function zip<Left, Right>(\n left: Left & AnyEffectValue,\n right: Right & AnyEffectValue\n): ZipResult<Left, Right> {\n // SAFETY: Result.all returns the ordered pair; ZipResult restores only the declaration-only Effect channels.\n return Result.all([left, right]) as ZipResult<Left, Right>\n}\n","import { Result } from 'better-result'\n\nimport type { Err, Result as ResultType, UnhandledException } from 'better-result'\n\nimport { Scope } from '../scope'\n\nimport type { DisposableResource, MaybePromise, ScopeOutcome } from '../scope'\nimport type { AnyService } from '../service'\n\nimport type {\n AnyEffect,\n Effect as EffectType,\n EffectError,\n EffectFromGenerator,\n EffectRequirements,\n EffectSuccess,\n EffectYield,\n Program as ProgramType,\n ProgramFromGenerator\n} from './types'\n\nimport {\n all,\n andThen,\n andThenAsync,\n as,\n asVoid,\n flatten,\n map,\n mapError,\n match,\n recover,\n recoverAsync,\n tap,\n tapBoth,\n tapError,\n zip\n} from './combinators'\n\nexport type Effect<A, E, R extends AnyService = never> = EffectType<A, E, R>\n\ntype LazyProgram<A, E, R extends AnyService = never> = ProgramType<A, E, R>\n\n/** A nominal lazy computation that produces an Effect when invoked. */\nexport type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>\n\ntype AnyResult = ResultType<any, any>\n\ntype AnyProgram = ProgramType<any, any, AnyService>\n\ntype ProgramAllSuccess<Programs extends readonly AnyProgram[]> = {\n -readonly [Index in keyof Programs]: EffectSuccess<Programs[Index]>\n}\n\ntype ProgramAllError<Programs extends readonly AnyProgram[]> = EffectError<Programs[number]>\n\ntype ProgramAllRequirements<Programs extends readonly AnyProgram[]> = EffectRequirements<\n Programs[number]\n>\n\ntype ProgramAllResult<Programs extends readonly AnyProgram[]> = ProgramType<\n ProgramAllSuccess<Programs>,\n ProgramAllError<Programs>,\n ProgramAllRequirements<Programs>\n>\n\nexport type ProgramAllOptions = {\n readonly concurrency?: number\n}\n\ntype EffectGenerator =\n | (() => Generator<EffectYield, AnyResult, unknown>)\n | (() => AsyncGenerator<EffectYield, AnyResult, unknown>)\n\ntype RuntimeResultGenerator = (body: EffectGenerator) => AnyResult | Promise<AnyResult>\n\n// SAFETY: Service iterators yield no runtime markers, so Result.gen receives only the Err values that exist at runtime.\nconst runResultGenerator = Result.gen as RuntimeResultGenerator\n\n/**\n * Compose `better-result` operations while preserving Service requirements in\n * a declaration-only type channel.\n *\n * A generator may yield Service tokens and Result operations. It must return a\n * `Result` as its final value; Service yields are resolved by the active\n * Runtime and do not add runtime values to the Result stream.\n * Use `fn` when generator execution should wait for a Runtime boundary.\n *\n * @example\n * ```ts\n * const loadUser = Effect.gen(async function* () {\n * const database = yield* Database\n * const user = yield* Result.await(database.findUser('u1'))\n *\n * return Result.ok(user)\n * })\n * ```\n */\nexport function gen<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => Generator<Yield, Returned, unknown>\n): EffectFromGenerator<Yield, Returned>\n\nexport function gen<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => AsyncGenerator<Yield, Returned, unknown>\n): Promise<EffectFromGenerator<Yield, Returned>>\n\nexport function gen(body: EffectGenerator): AnyResult | Promise<AnyResult> {\n return runResultGenerator(body)\n}\n\n/** Build a lazy Program without running its generator. */\nexport function fn<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => Generator<Yield, Returned, unknown>\n): ProgramFromGenerator<Yield, Returned>\n\nexport function fn<Yield extends EffectYield, Returned extends AnyResult>(\n body: () => AsyncGenerator<Yield, Returned, unknown>\n): ProgramFromGenerator<Yield, Returned>\n\nexport function fn(body: EffectGenerator): Program<any, any, AnyService> {\n const program = () => runResultGenerator(body)\n\n // SAFETY: The generator overloads derive the Program channels; this cast only adds the declaration-only nominal marker.\n return program as Program<any, any, AnyService>\n}\n\nconst validateProgramConcurrency = (concurrency: number | undefined): void => {\n if (\n concurrency !== undefined &&\n (!Number.isFinite(concurrency) || !Number.isInteger(concurrency) || concurrency <= 0)\n ) {\n throw new RangeError('Program.all concurrency must be a positive integer')\n }\n}\n\n/** Build a lazy Program collection with optional bounded concurrency. */\nexport function programAll<const Programs extends readonly AnyProgram[]>(\n programs: Programs,\n options: ProgramAllOptions = {}\n): ProgramAllResult<Programs> {\n validateProgramConcurrency(options.concurrency)\n\n const concurrency = options.concurrency\n const program = async (): Promise<AnyResult> => {\n const results: Array<AnyResult | undefined> = Array.from({ length: programs.length })\n const failures: boolean[] = Array.from({ length: programs.length }, () => false)\n const causes: unknown[] = Array.from({ length: programs.length })\n let nextIndex = 0\n\n const worker = async (): Promise<void> => {\n while (true) {\n const index = nextIndex++\n\n if (index >= programs.length) {\n return\n }\n\n try {\n results[index] = await programs[index]!()\n } catch (cause) {\n failures[index] = true\n causes[index] = cause\n }\n }\n }\n\n const workers = Math.min(concurrency ?? programs.length, programs.length)\n await Promise.all(Array.from({ length: workers }, () => worker()))\n\n const failureIndex = failures.findIndex(Boolean)\n\n if (failureIndex >= 0) {\n throw causes[failureIndex]\n }\n\n // SAFETY: Program's callable contract produces Result values; the array is erased only at this collection boundary.\n return Result.all(results as AnyResult[])\n }\n\n // SAFETY: Program channels are declaration-only and are restored from the input tuple here.\n return program as ProgramAllResult<Programs>\n}\n\n/** Value-level namespace for lazy Program combinators. */\nexport const Program = {\n all: programAll\n} as const\n\n/**\n * Acquire a resource in the current Scope and register its release callback.\n *\n * Acquisition failures are represented in the Effect Result error channel;\n * release failures remain owned by Scope cleanup. The release callback\n * receives the final outcome chosen by the enclosing execution boundary.\n *\n * @example\n * ```ts\n * const connection = yield* Effect.acquireRelease(\n * () => pool.connect(),\n * (connection, outcome) => connection.close(outcome)\n * )\n * ```\n */\nexport function acquireRelease<R>(\n acquire: () => MaybePromise<R>,\n release: (resource: R, outcome: ScopeOutcome) => MaybePromise<void>\n): AsyncGenerator<Err<never, UnhandledException>, R, unknown> {\n const scope = Scope.current()\n\n return Result.await(Result.tryPromise(() => scope.acquire(acquire, release)))\n}\n\n/**\n * Register an already-acquired disposable resource in the current Scope.\n *\n * The resource is not acquired by this helper. Registration failures are\n * represented in the Effect Result error channel; disposal failures remain\n * owned by Scope cleanup.\n *\n * @example\n * ```ts\n * const file = yield* Effect.add(await openFile('notes.txt'))\n * ```\n */\nexport function add<R extends DisposableResource>(\n resource: R\n): AsyncGenerator<Err<never, UnhandledException>, R, unknown> {\n const scope = Scope.current()\n\n return Result.await(Result.tryPromise(() => scope.add(resource)))\n}\n\n/**\n * Effect namespace containing generator, resource, and Result combinators.\n *\n * Prefer these helpers when a program needs typed Service requirements or\n * Scope-aware acquisition and cleanup.\n */\ntype EffectNamespace = {\n readonly gen: typeof gen\n readonly fn: typeof fn\n readonly acquireRelease: typeof acquireRelease\n readonly add: typeof add\n readonly map: typeof map\n readonly mapError: typeof mapError\n readonly andThen: typeof andThen\n readonly andThenAsync: typeof andThenAsync\n readonly tap: typeof tap\n readonly tapError: typeof tapError\n readonly tapBoth: typeof tapBoth\n readonly recover: typeof recover\n readonly recoverAsync: typeof recoverAsync\n readonly flatten: typeof flatten\n readonly as: typeof as\n readonly asVoid: typeof asVoid\n readonly match: typeof match\n readonly all: typeof all\n readonly zip: typeof zip\n}\n\nexport const Effect: EffectNamespace = {\n /** Compose a generator-based Effect program. */\n gen,\n /** Build a lazy Program from a generator. */\n fn,\n /** Acquire and register a resource in the current Scope. */\n acquireRelease,\n /** Register an already-acquired disposable in the current Scope. */\n add,\n /** Map a successful Effect result. */\n map,\n /** Map an Effect error. */\n mapError,\n /** Chain a synchronous Effect result. */\n andThen,\n /** Chain an asynchronous Effect result. */\n andThenAsync,\n /** Observe successful values without changing the Result. */\n tap,\n /** Observe error values without changing the Result. */\n tapError,\n /** Observe the active Result branch without changing the Result. */\n tapBoth,\n /** Recover an error with another Effect. */\n recover,\n /** Recover an error asynchronously with another Effect. */\n recoverAsync,\n /** Remove one nested Effect layer. */\n flatten,\n /** Replace a successful value. */\n as,\n /** Replace a successful value with void. */\n asVoid,\n /** Match either Result branch. */\n match,\n /** Collect Effects in input order. */\n all,\n /** Zip two Effects in input order. */\n zip\n} as const\n\n/** Type-level aliases for inspecting Effect result channels and requirements. */\nexport declare namespace Effect {\n /** A nominal lazy computation that produces an Effect when invoked. */\n export type Program<A, E, R extends AnyService = never> = LazyProgram<A, E, R>\n\n /** Extract the success channel from an Effect result or Promise. */\n export type Success<T> = EffectSuccess<T>\n\n /** Extract the error channel from an Effect result or Promise. */\n export type Error<T> = EffectError<T>\n\n /** Extract the Service requirements from an Effect result or Promise. */\n export type Requirements<T> = EffectRequirements<T>\n\n /** An Effect with erased success, error, and requirements. */\n export type Any = AnyEffect\n}\n"],"mappings":";;;;;AACA,IAAa,iCAAb,cAAoD,MAAM;CACxD,cAAc;EACZ,MAAM,wDAAwD;EAE9D,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,cAAc;EACZ,MAAM,sDAAsD;EAE5D,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,kBAAb,cAAqC,MAAM;CACpB;CAArB,YAAY,QAAqC;EAC/C,MACE,0BAA0B,OAAO,OAAO,YAAY,OAAO,WAAW,IAAI,KAAK,IAAI,SACrF;EAHmB,KAAA,SAAA;EAKnB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,6BAAb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,MAAM,CAAE;IAC1C,SAAS,OAAO;KACd,SAAS,SAAS;KAClB,OAAO,SAAS;IAClB;GACF;EACF;EAEA,MAAM,UAAU,KAAK,IAAI,eAAe,SAAS,QAAQ,SAAS,MAAM;EACxE,MAAM,QAAQ,IAAI,MAAM,KAAK,EAAE,QAAQ,QAAQ,SAAS,OAAO,CAAC,CAAC;EAEjE,MAAM,eAAe,SAAS,UAAU,OAAO;EAE/C,IAAI,gBAAgB,GAClB,MAAM,OAAO;EAIf,OAAO,OAAO,IAAI,OAAsB;CAC1C;CAGA,OAAO;AACT;;AAGA,MAAa,UAAU,EACrB,KAAK,WACP;;;;;;;;;;;;;;;;AAiBA,SAAgB,eACd,SACA,SAC4D;CAC5D,MAAM,QAAQ,MAAM,QAAQ;CAE5B,OAAO,OAAO,MAAM,OAAO,iBAAiB,MAAM,QAAQ,SAAS,OAAO,CAAC,CAAC;AAC9E;;;;;;;;;;;;;AAcA,SAAgB,IACd,UAC4D;CAC5D,MAAM,QAAQ,MAAM,QAAQ;CAE5B,OAAO,OAAO,MAAM,OAAO,iBAAiB,MAAM,IAAI,QAAQ,CAAC,CAAC;AAClE;AA8BA,MAAa,SAA0B;;CAErC;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;AACF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region src/runtime/errors.d.ts
|
|
2
|
-
/** Thrown when no RuntimeContext is active in the selected storage. */
|
|
3
|
-
declare class RuntimeContextNotConfiguredError extends Error {
|
|
4
|
-
constructor();
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { RuntimeContextNotConfiguredError as t };
|
|
8
|
-
//# sourceMappingURL=errors-BXKc7juX.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-BXKc7juX.d.mts","names":[],"sources":["../src/runtime/errors.ts"],"mappings":";;cACa,yCAAyC;EAAA"}
|