better-effect 0.12.0 → 0.14.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.
Files changed (101) hide show
  1. package/README.md +599 -30
  2. package/dist/adapters/iti.d.mts +2 -3
  3. package/dist/adapters/iti.d.mts.map +1 -1
  4. package/dist/adapters/iti.mjs +2 -2
  5. package/dist/bun.d.mts +95 -0
  6. package/dist/bun.d.mts.map +1 -0
  7. package/dist/bun.mjs +177 -0
  8. package/dist/bun.mjs.map +1 -0
  9. package/dist/{context-BUEf1qjL.mjs → context-DSGSqcJj.mjs} +14 -3
  10. package/dist/context-DSGSqcJj.mjs.map +1 -0
  11. package/dist/current-request-Bc1YHL0w.mjs +21 -0
  12. package/dist/current-request-Bc1YHL0w.mjs.map +1 -0
  13. package/dist/current-request-Dm-QQ3Xr.d.mts +22 -0
  14. package/dist/current-request-Dm-QQ3Xr.d.mts.map +1 -0
  15. package/dist/{effect-CK4YZaX0.mjs → effect-W0IQXY8P.mjs} +21 -2
  16. package/dist/effect-W0IQXY8P.mjs.map +1 -0
  17. package/dist/{errors-BKcsQ0ip.d.mts → errors-CpHMzPiP.d.mts} +6 -2
  18. package/dist/errors-CpHMzPiP.d.mts.map +1 -0
  19. package/dist/hono.d.mts +65 -27
  20. package/dist/hono.d.mts.map +1 -1
  21. package/dist/hono.mjs +177 -53
  22. package/dist/hono.mjs.map +1 -1
  23. package/dist/{index-CX6iAoCB.d.mts → index-3Bkl-sxS.d.mts} +7 -2
  24. package/dist/{index-CX6iAoCB.d.mts.map → index-3Bkl-sxS.d.mts.map} +1 -1
  25. package/dist/{index-B1nH4luq.d.mts → index-C2ed9Ilq.d.mts} +32 -21
  26. package/dist/index-C2ed9Ilq.d.mts.map +1 -0
  27. package/dist/{index-GYJ4qm9K.d.mts → index-ClNndn2-.d.mts} +93 -62
  28. package/dist/index-ClNndn2-.d.mts.map +1 -0
  29. package/dist/{index-BMdU_Z72.d.mts → index-Cy1VsU-u.d.mts} +2 -3
  30. package/dist/index-Cy1VsU-u.d.mts.map +1 -0
  31. package/dist/index.d.mts +6 -7
  32. package/dist/index.mjs +8 -8
  33. package/dist/{internal-identity-CbXoZIfw.mjs → internal-identity-BuHBtP0k.mjs} +2 -2
  34. package/dist/{internal-identity-CbXoZIfw.mjs.map → internal-identity-BuHBtP0k.mjs.map} +1 -1
  35. package/dist/layer-2kjHVv4N.mjs +343 -0
  36. package/dist/layer-2kjHVv4N.mjs.map +1 -0
  37. package/dist/{outcome-CB43bnFW.d.mts → layer-C2OaqTmB.d.mts} +683 -138
  38. package/dist/layer-C2OaqTmB.d.mts.map +1 -0
  39. package/dist/next.d.mts +192 -0
  40. package/dist/next.d.mts.map +1 -0
  41. package/dist/next.mjs +185 -0
  42. package/dist/next.mjs.map +1 -0
  43. package/dist/{node-context-DWsCUBRa.d.mts → node-context-1YEjrU9g.d.mts} +2 -2
  44. package/dist/{node-context-DWsCUBRa.d.mts.map → node-context-1YEjrU9g.d.mts.map} +1 -1
  45. package/dist/{node-context-lggRF4bR.mjs → node-context-g3bCcY9t.mjs} +2 -2
  46. package/dist/{node-context-lggRF4bR.mjs.map → node-context-g3bCcY9t.mjs.map} +1 -1
  47. package/dist/node.d.mts +11 -6
  48. package/dist/node.d.mts.map +1 -1
  49. package/dist/node.mjs +156 -10
  50. package/dist/node.mjs.map +1 -1
  51. package/dist/opentelemetry.d.mts +112 -0
  52. package/dist/opentelemetry.d.mts.map +1 -0
  53. package/dist/opentelemetry.mjs +871 -0
  54. package/dist/opentelemetry.mjs.map +1 -0
  55. package/dist/{registration-drnZk0SY.mjs → registration-Bwe2GbVu.mjs} +8 -2
  56. package/dist/registration-Bwe2GbVu.mjs.map +1 -0
  57. package/dist/runtime/explicit.d.mts +2 -2
  58. package/dist/runtime/explicit.mjs +1 -1
  59. package/dist/runtime/node.d.mts +3 -3
  60. package/dist/runtime/node.mjs +2 -2
  61. package/dist/runtime-qpcVwaz_.mjs +1680 -0
  62. package/dist/runtime-qpcVwaz_.mjs.map +1 -0
  63. package/dist/service-CO9VJQYa.mjs +74 -0
  64. package/dist/service-CO9VJQYa.mjs.map +1 -0
  65. package/dist/signal-5Rg9bUUe.mjs +52 -0
  66. package/dist/signal-5Rg9bUUe.mjs.map +1 -0
  67. package/dist/{standard-services-GBZ32tll.mjs → standard-services-B-iMM_W7.mjs} +39 -19
  68. package/dist/standard-services-B-iMM_W7.mjs.map +1 -0
  69. package/dist/standard-services.d.mts +4 -3
  70. package/dist/standard-services.mjs +3 -2
  71. package/dist/testing.d.mts +25 -6
  72. package/dist/testing.d.mts.map +1 -1
  73. package/dist/testing.mjs +51 -7
  74. package/dist/testing.mjs.map +1 -1
  75. package/dist/types-BFTqCCcw.d.mts +81 -0
  76. package/dist/types-BFTqCCcw.d.mts.map +1 -0
  77. package/dist/web-effect-B9hp9jIe.mjs +380 -0
  78. package/dist/web-effect-B9hp9jIe.mjs.map +1 -0
  79. package/dist/web.d.mts +56 -0
  80. package/dist/web.d.mts.map +1 -0
  81. package/dist/web.mjs +2 -0
  82. package/package.json +36 -11
  83. package/dist/context-BUEf1qjL.mjs.map +0 -1
  84. package/dist/effect-CK4YZaX0.mjs.map +0 -1
  85. package/dist/errors-BKcsQ0ip.d.mts.map +0 -1
  86. package/dist/index-B1nH4luq.d.mts.map +0 -1
  87. package/dist/index-BMdU_Z72.d.mts.map +0 -1
  88. package/dist/index-GYJ4qm9K.d.mts.map +0 -1
  89. package/dist/index-heuaRmXR.d.mts +0 -374
  90. package/dist/index-heuaRmXR.d.mts.map +0 -1
  91. package/dist/layer-D56fRdLt.mjs +0 -269
  92. package/dist/layer-D56fRdLt.mjs.map +0 -1
  93. package/dist/outcome-CB43bnFW.d.mts.map +0 -1
  94. package/dist/program-metadata-DhQCCirO.mjs +0 -260
  95. package/dist/program-metadata-DhQCCirO.mjs.map +0 -1
  96. package/dist/registration-drnZk0SY.mjs.map +0 -1
  97. package/dist/runtime-CBMrX8Wl.mjs +0 -776
  98. package/dist/runtime-CBMrX8Wl.mjs.map +0 -1
  99. package/dist/signal-D2UTcaaG.mjs +0 -105
  100. package/dist/signal-D2UTcaaG.mjs.map +0 -1
  101. package/dist/standard-services-GBZ32tll.mjs.map +0 -1
@@ -1,374 +0,0 @@
1
- import { Err, InferErr, InferOk, Result } from "better-result";
2
- //#region src/service/types.d.ts
3
- /** Internal type-only identity for the branded Service instance. */
4
- declare const ServiceIdentityTypeId: unique symbol;
5
- /** A branded Service instance identity carried by the literal Service tag. */
6
- interface ServiceIdentity<out Tag extends string = string> {
7
- readonly [ServiceIdentityTypeId]: Tag;
8
- }
9
- /** The widened Service instance constraint used by contextual APIs. */
10
- type AnyService = ServiceIdentity<string>;
11
- /** Remove the internal Service identity marker from an implementation contract. */
12
- type ServiceContract<S> = S extends unknown ? Omit<S, typeof ServiceIdentityTypeId> : never;
13
- type ServiceStatics<out Tag extends string, in out Instance extends AnyService> = {
14
- readonly name: string;
15
- readonly serviceTag: Tag;
16
- /** Type-check a structural implementation and return it unchanged. */
17
- readonly of: (this: void, implementation: ServiceContract<Instance>) => Instance;
18
- };
19
- type AbstractServiceConstructor<out Instance> = abstract new (...args: any[]) => Instance;
20
- /** A class constructor carrying a Service tag and its instance contract. */
21
- interface ServiceToken<out Tag extends string = string, in out Instance extends AnyService = any> extends AbstractServiceConstructor<Instance>, ServiceStatics<Tag, Instance> {}
22
- /** The widened token constraint used by generic Service infrastructure. */
23
- type AnyServiceToken = ServiceToken<string, any>;
24
- /** A concrete, constructible Service class accepted by a Layer provider. */
25
- type ServiceClass<Tag extends string = string, Instance extends AnyService = AnyService> = (new (...args: any[]) => Instance) & ServiceStatics<Tag, Instance>;
26
- /** Extract the instance type represented by a Service token. */
27
- type ServiceInstance<T extends AnyServiceToken> = InstanceType<T>;
28
- /** Extract the literal identity tag represented by a branded Service instance. */
29
- type ServiceTagOf<S extends AnyService> = S[typeof ServiceIdentityTypeId];
30
- /** Extract the Service token represented by a branded Service instance. */
31
- type ServiceTokenOf<S extends AnyService> = S extends AnyService ? ServiceToken<ServiceTagOf<S>, S> : never;
32
- /** Extract the literal identity tag represented by a Service instance or token. */
33
- type ServiceTag<T extends AnyService | AnyServiceToken> = T extends AnyService ? ServiceTagOf<T> : T extends AnyServiceToken ? T['serviceTag'] : never;
34
- type MethodRequirements<T> = { [K in keyof T]: T[K] extends ((...args: any[]) => infer Return) ? EffectRequirements<Return> : never; }[keyof T];
35
- /**
36
- * Services required by the Effect-returning methods of a Service class.
37
- *
38
- * This type is used automatically by `Layer.make`, `Layer.gen`, and the other
39
- * provider constructors.
40
- */
41
- type ServiceRequirements<S extends AnyService> = MethodRequirements<S>;
42
- //#endregion
43
- //#region src/effect/types.d.ts
44
- type ResultValue = Result<any, any>;
45
- /** Keep nested Effect errors and Service requirements in one inferred yield. */
46
- type EffectIterator<A, E, R extends AnyService> = {
47
- [Symbol.iterator](): Generator<Err<never, E> & ServiceRequirement<R>, A, unknown>;
48
- };
49
- type EffectMethods<A, E, R extends AnyService> = {
50
- map<B>(fn: (value: A) => B): Effect<B, E, R>;
51
- mapError<E2>(fn: (error: E) => E2): Effect<A, E2, R>;
52
- tryRecover<Next extends ResultValue>(fn: (error: E) => Next): Effect<A | EffectSuccess<Next>, EffectError<Next>, R | EffectRequirements<Next>>;
53
- tryRecoverAsync<Next extends ResultValue>(fn: (error: E) => Promise<Next>): Promise<Effect<A | EffectSuccess<Next>, EffectError<Next>, R | EffectRequirements<Next>>>;
54
- andThen<Next extends ResultValue>(fn: (value: A) => Next): Effect<EffectSuccess<Next>, E | EffectError<Next>, R | EffectRequirements<Next>>;
55
- andThenAsync<Next extends ResultValue>(fn: (value: A) => Promise<Next>): Promise<Effect<EffectSuccess<Next>, E | EffectError<Next>, R | EffectRequirements<Next>>>;
56
- tap(fn: (value: A) => void): Effect<A, E, R>;
57
- tapAsync(fn: (value: A) => PromiseLike<void>): Promise<Effect<A, E, R>>;
58
- tapError(fn: (error: E) => void): Effect<A, E, R>;
59
- tapErrorAsync(fn: (error: E) => PromiseLike<void>): Promise<Effect<A, E, R>>;
60
- tapBoth(handlers: {
61
- ok: (value: A) => void;
62
- err: (error: E) => void;
63
- }): Effect<A, E, R>;
64
- tapBothAsync(handlers: {
65
- ok: (value: A) => PromiseLike<void>;
66
- err: (error: E) => PromiseLike<void>;
67
- }): Promise<Effect<A, E, R>>;
68
- };
69
- /**
70
- * Type-only identity for a Service requirement yielded by a generator.
71
- *
72
- * The declaration has no runtime value. Service iterators return their
73
- * resolved instances without yielding a marker at runtime.
74
- */
75
- declare const ServiceRequirementTypeId: unique symbol;
76
- /** Type-only identity for requirement metadata attached to Effect results. */
77
- declare const EffectRequirementsTypeId: unique symbol;
78
- /** Type-only identity for lazy Effect programs. */
79
- declare const ProgramTypeId: unique symbol;
80
- /** Required declaration-only variance carrier for Effect Service requirements. */
81
- interface EffectVariance<out R extends AnyService> {
82
- readonly requirements: R;
83
- }
84
- /** Required declaration-only variance carrier for a lazy Program. */
85
- interface ProgramVariance<out A, out E, out R extends AnyService> {
86
- readonly success: A;
87
- readonly error: E;
88
- readonly requirements: R;
89
- }
90
- /**
91
- * Metadata carried by the yield type of a Service token.
92
- *
93
- * This interface is intentionally phantom: it is used only while TypeScript
94
- * infers a generator's yielded values.
95
- */
96
- interface ServiceRequirement<out T> {
97
- readonly [ServiceRequirementTypeId]: T;
98
- }
99
- /** A `better-result` Result with required declaration-only metadata for Services. */
100
- type Effect<A, E, R extends AnyService = never> = EffectMethods<A, E, R> & Result<A, E> & EffectIterator<A, E, R> & {
101
- readonly [EffectRequirementsTypeId]: EffectVariance<R>;
102
- };
103
- /** A nominal lazy computation that produces an Effect when invoked. */
104
- type Program<A, E, R extends AnyService = never> = {
105
- (): Effect<A, E, R> | Promise<Effect<A, E, R>>;
106
- readonly [ProgramTypeId]: ProgramVariance<A, E, R>;
107
- };
108
- /** An Effect with erased success, error, and Service requirements. */
109
- type AnyEffect = Effect<unknown, unknown, AnyService>;
110
- /** Values that an Effect generator may yield. */
111
- type EffectYield = Err<never, unknown> | ServiceRequirement<unknown>;
112
- /** Extract the error channel from Result values yielded by a generator. */
113
- type InferYieldError<Y> = Y extends Err<never, infer E> ? E : never;
114
- /** Extract branded Service instances carried by yielded Service requirements. */
115
- type InferYieldRequirements<Y> = Y extends ServiceRequirement<infer Requirement> ? Requirement extends AnyService ? Requirement : never : never;
116
- type InferEffectRequirements<T> = T extends unknown ? typeof EffectRequirementsTypeId extends keyof T ? T extends {
117
- readonly [EffectRequirementsTypeId]: EffectVariance<infer Requirements extends AnyService>;
118
- } ? Requirements : never : never : never;
119
- type InferProgramSuccess<T> = T extends {
120
- readonly [ProgramTypeId]: ProgramVariance<infer Success, any, any>;
121
- } ? Success : never;
122
- type InferProgramError<T> = T extends {
123
- readonly [ProgramTypeId]: ProgramVariance<any, infer Error, any>;
124
- } ? Error : never;
125
- type InferProgramRequirements<T> = T extends {
126
- readonly [ProgramTypeId]: ProgramVariance<any, any, infer Requirements>;
127
- } ? Requirements : never;
128
- /** Extract declaration-only Service requirements from an Effect or Promise. */
129
- type EffectRequirements<T> = T extends unknown ? InferProgramRequirements<T> extends never ? InferEffectRequirements<Awaited<T>> : InferProgramRequirements<T> : never;
130
- /** Extract the success value from an Effect or Promise. */
131
- type EffectSuccess<T> = T extends unknown ? InferProgramSuccess<T> extends never ? Awaited<T> extends Result<infer A, unknown> ? A : never : InferProgramSuccess<T> : never;
132
- /** Extract the error value from an Effect or Promise. */
133
- type EffectError<T> = T extends unknown ? InferProgramError<T> extends never ? Awaited<T> extends Result<unknown, infer E> ? E : never : InferProgramError<T> : never;
134
- /** Build the public Effect type produced from a generator. */
135
- type EffectFromGenerator<Yield, Returned extends Result<any, any>> = Effect<InferOk<Returned>, InferYieldError<Yield> | InferErr<Returned>, InferYieldRequirements<Yield> | EffectRequirements<Returned>>;
136
- /** Build the nominal lazy Program produced from a generator. */
137
- type ProgramFromGenerator<Yield, Returned extends Result<any, any>> = Program<InferOk<Returned>, InferYieldError<Yield> | InferErr<Returned>, InferYieldRequirements<Yield> | EffectRequirements<Returned>>;
138
- //#endregion
139
- //#region src/service/service.d.ts
140
- type ServiceTagLiteral<Tag extends string> = string extends Tag ? never : Tag extends '' ? never : Tag;
141
- interface ServiceFactory<Self> {
142
- <const Tag extends string>(tag: ServiceTagLiteral<Tag>): (abstract new () => ServiceIdentity<Tag>) & {
143
- readonly name: string;
144
- readonly serviceTag: Tag;
145
- } & {
146
- readonly of: Service.FactoryOf<Self, Tag>;
147
- readonly [Symbol.asyncIterator]: (this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>) => AsyncGenerator<ServiceRequirement<Self>, Self, unknown>;
148
- };
149
- }
150
- /**
151
- * Declare a class-backed Service with a stable string-literal identity.
152
- *
153
- * The returned class is simultaneously the implementation type, the runtime
154
- * dependency token, and the value yielded by `yield*` in an Effect generator.
155
- * The explicit self type preserves exact instance inference, while the second
156
- * call captures the tag as a literal for Layer composition and diagnostics.
157
- *
158
- * @example
159
- * ```ts
160
- * class Database extends Service<Database>()('Database') {
161
- * query(): string {
162
- * return 'ok'
163
- * }
164
- * }
165
- *
166
- * const database = yield* Database
167
- * database.query()
168
- * ```
169
- *
170
- * @typeParam Self The instance type implemented by the declared Service.
171
- */
172
- declare function Service<Self>(): ServiceFactory<Self>;
173
- /** Type-level aliases for Service tokens and their instance contracts. */
174
- declare namespace Service {
175
- /** The widened Service instance constraint. */
176
- type Any = AnyService;
177
- /** A class-backed Service token with a stable tag and instance contract. */
178
- type Token<Tag extends string = string, Instance extends AnyService = any> = ServiceToken<Tag, Instance>;
179
- /** A constructible Service class with a stable tag and instance contract. */
180
- type Class<Tag extends string = string, Instance extends AnyService = AnyService> = ServiceClass<Tag, Instance>;
181
- /** Extract the instance represented by a Service token. */
182
- type Instance<T extends AnyServiceToken> = ServiceInstance<T>;
183
- /** Extract the stable tag represented by a Service instance. */
184
- type Tag<S extends AnyService> = ServiceTag<S>;
185
- /** A branded Service instance identity with a stable tag. */
186
- type Identity<Tag extends string = string> = ServiceIdentity<Tag>;
187
- /** Remove the internal identity marker from a Service implementation contract. */
188
- type Contract<S extends AnyService> = ServiceContract<S>;
189
- /** Extract the Service token represented by a branded Service instance. */
190
- type TokenOf<S extends AnyService> = ServiceTokenOf<S>;
191
- /** Declaration bridge for the recursive structural `Service.of` signature. */
192
- type FactoryOf<Self, Tag extends string> = (this: void, implementation: ServiceContract<Self & ServiceIdentity<Tag>>) => Self;
193
- /** Extract Effect Service requirements from a Service instance. */
194
- type Requirements<S extends AnyService> = ServiceRequirements<S>;
195
- }
196
- //#endregion
197
- //#region src/scope/errors.d.ts
198
- /** Thrown when Scope context is accessed outside an active Scope execution. */
199
- declare class ScopeRuntimeNotConfiguredError extends Error {
200
- constructor();
201
- }
202
- /** Thrown when a resource or finalizer is added after Scope closure begins. */
203
- declare class ScopeClosedError extends Error {
204
- constructor();
205
- }
206
- /** Aggregates finalizer failures encountered while closing a Scope. */
207
- declare class ScopeCloseError extends Error {
208
- readonly causes: readonly unknown[];
209
- constructor(causes: readonly unknown[]);
210
- }
211
- /** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */
212
- declare class ResourceNotDisposableError extends Error {
213
- constructor();
214
- }
215
- //#endregion
216
- //#region src/scope/types.d.ts
217
- /** A value that may be returned synchronously or asynchronously. */
218
- type MaybePromise<T> = T | PromiseLike<T>;
219
- /** Final outcome supplied to Scope finalizers and resource releases. */
220
- type ScopeOutcome = {
221
- /** Indicates that the owning program completed successfully. */
222
- readonly status: 'success';
223
- } | {
224
- /** Indicates that the owning program failed or was interrupted. */
225
- readonly status: 'failure';
226
- /** The original program or execution failure. */
227
- readonly cause: unknown;
228
- };
229
- /** Cleanup callback registered with a Scope. */
230
- type ScopeFinalizer = (outcome: ScopeOutcome) => MaybePromise<void>;
231
- /** Aggregated cleanup information reported at an execution boundary. */
232
- type CleanupFailureDiagnostic = {
233
- /** Outcome used for the Scope close that triggered cleanup. */
234
- readonly outcome: ScopeOutcome;
235
- /** Aggregated finalizer failure. */
236
- readonly error: ScopeCloseError;
237
- };
238
- type SyncDisposableResource = {
239
- [Symbol.dispose]: () => void;
240
- [Symbol.asyncDispose]?: () => MaybePromise<void>;
241
- };
242
- type AsyncDisposableResource = {
243
- [Symbol.dispose]?: () => void;
244
- [Symbol.asyncDispose]: () => MaybePromise<void>;
245
- };
246
- /** A value implementing at least one JavaScript disposal protocol. */
247
- type DisposableResource = SyncDisposableResource | AsyncDisposableResource;
248
- //#endregion
249
- //#region src/scope/scope.d.ts
250
- /**
251
- * Non-owning lifecycle context for finalizers and child Scopes.
252
- *
253
- * A Scope can register cleanup and create children, but it cannot close
254
- * itself. Use `Scope.make()` or `Scope.run()` when your code owns the Scope.
255
- */
256
- interface Scope {
257
- /** Register a finalizer that runs when the owning Scope closes. */
258
- addFinalizer(finalizer: ScopeFinalizer): void;
259
- /** Acquire a resource and register its outcome-aware release callback. */
260
- acquire<R>(acquire: () => MaybePromise<R>, release: (resource: R, outcome: ScopeOutcome) => MaybePromise<void>): Promise<R>;
261
- /** Register an already-acquired disposable resource. */
262
- add<R extends DisposableResource>(resource: R): Promise<R>;
263
- /** Create a child Scope owned by this Scope. */
264
- fork(): CloseableScope;
265
- }
266
- /** A Scope whose owner is responsible for calling `close()`. */
267
- interface CloseableScope extends Scope {
268
- /** Close the Scope and run children and finalizers in child-first LIFO order. */
269
- close(outcome?: ScopeOutcome): Promise<void>;
270
- }
271
- declare const Scope: {
272
- /** Create an owned, initially open Scope. */
273
- readonly make: () => CloseableScope;
274
- /** Return the non-owning Scope available in the current execution context. */
275
- readonly current: () => Scope;
276
- /** Run a callback with an existing Scope supplied as the current context. */
277
- readonly provide: <A>(scope: Scope, program: () => A) => A;
278
- /** Resolve the current Scope through `yield* Scope` inside an Effect. */
279
- readonly [Symbol.iterator]: () => Generator<never, Scope, unknown>;
280
- /**
281
- * Run a program in a newly owned Scope.
282
- *
283
- * Scope is independent from `better-result`, so returned values—including
284
- * `Result.err`—close this Scope with a successful outcome. Result-aware
285
- * outcome classification belongs to `Runtime.run`.
286
- *
287
- * @example
288
- * ```ts
289
- * await Scope.run(async (scope) => {
290
- * const connection = await scope.acquire(connect, (connection) => connection.close())
291
- * return connection.query()
292
- * })
293
- * ```
294
- */
295
- readonly run: <A>(program: (scope: Scope) => A | PromiseLike<A>) => Promise<Awaited<A>>;
296
- };
297
- /** Type-level aliases for Scope ownership, outcomes, and cleanup contracts. */
298
- declare namespace Scope {
299
- /** A Scope whose owner is responsible for calling `close()`. */
300
- type Closeable = CloseableScope;
301
- /** The outcome supplied to Scope finalizers and resource releases. */
302
- type Outcome = ScopeOutcome;
303
- /** A cleanup callback registered with a Scope. */
304
- type Finalizer = ScopeFinalizer;
305
- /** A value implementing a JavaScript disposal protocol. */
306
- type Disposable = DisposableResource;
307
- }
308
- //#endregion
309
- //#region src/runtime/context.d.ts
310
- /** Contextual state shared by Service, Scope and Layer resolution. */
311
- interface RuntimeContext {
312
- readonly resolver?: ServiceResolver;
313
- readonly scope?: Scope;
314
- readonly signal?: AbortSignal;
315
- readonly resolutionPath: readonly AnyServiceToken[];
316
- }
317
- /** Host-specific storage for the current RuntimeContext. */
318
- interface RuntimeContextStorage {
319
- run<A>(context: RuntimeContext, program: () => A): A;
320
- current(): RuntimeContext;
321
- }
322
- //#endregion
323
- //#region src/service/runtime.d.ts
324
- /** Resolves class-backed Service tokens for a runtime execution. */
325
- interface ServiceResolver {
326
- /** Resolve a token to its corresponding Service instance. */
327
- resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>>;
328
- }
329
- /** Provides the resolver context used by Service tokens during execution. */
330
- declare class ServiceRuntime {
331
- /**
332
- * Run a callback with a resolver available to `yield* Service` expressions.
333
- *
334
- * The context is scoped to the callback and is restored afterward.
335
- *
336
- * @example
337
- * ```ts
338
- * const value = ServiceRuntime.run(resolver, () => {
339
- * return ServiceRuntime.resolve(Database)
340
- * })
341
- * ```
342
- */
343
- static run<A>(resolver: ServiceResolver, program: () => A, storage?: RuntimeContextStorage): A;
344
- /** Return the resolver active in the current execution context. */
345
- static current(): ServiceResolver;
346
- /** Resolve a Service token using the active resolver. */
347
- static resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>>;
348
- }
349
- //#endregion
350
- //#region src/service/errors.d.ts
351
- /** Thrown when a Service is accessed without an active runtime resolver. */
352
- declare class ServiceRuntimeNotConfiguredError extends Error {
353
- constructor();
354
- }
355
- /** Thrown when a runtime has no provider for the requested Service tag. */
356
- declare class ServiceNotFoundError extends Error {
357
- readonly service: AnyServiceToken;
358
- constructor(service: AnyServiceToken);
359
- }
360
- /** Thrown when resolving a Service re-enters a Service already in its path. */
361
- declare class CircularDependencyError extends Error {
362
- readonly path: readonly AnyServiceToken[];
363
- constructor(path: readonly AnyServiceToken[]);
364
- }
365
- /** Thrown when a registered Service provider fails during lazy acquisition. */
366
- declare class ServiceAcquisitionError extends Error {
367
- readonly service: AnyServiceToken;
368
- readonly cause: unknown;
369
- constructor(service: AnyServiceToken, resolutionPath: readonly AnyServiceToken[], cause: unknown);
370
- readonly resolutionPath: readonly AnyServiceToken[];
371
- }
372
- //#endregion
373
- export { ProgramFromGenerator as A, ServiceTag as B, EffectError as C, EffectYield as D, EffectSuccess as E, ServiceContract as F, ServiceToken as H, ServiceIdentity as I, ServiceIdentityTypeId as L, AnyService as M, AnyServiceToken as N, InferYieldRequirements as O, ServiceClass as P, ServiceInstance as R, Effect as S, EffectRequirements as T, ServiceTokenOf as U, ServiceTagOf as V, ScopeCloseError as _, ServiceResolver as a, Service as b, RuntimeContextStorage as c, CleanupFailureDiagnostic as d, DisposableResource as f, ResourceNotDisposableError as g, ScopeOutcome as h, ServiceRuntimeNotConfiguredError as i, ServiceRequirement as j, Program as k, CloseableScope as l, ScopeFinalizer as m, ServiceAcquisitionError as n, ServiceRuntime as o, MaybePromise as p, ServiceNotFoundError as r, RuntimeContext as s, CircularDependencyError as t, Scope as u, ScopeClosedError as v, EffectFromGenerator as w, AnyEffect as x, ScopeRuntimeNotConfiguredError as y, ServiceRequirements as z };
374
- //# sourceMappingURL=index-heuaRmXR.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-heuaRmXR.d.mts","names":[],"sources":["../src/service/types.ts","../src/effect/types.ts","../src/service/service.ts","../src/scope/errors.ts","../src/scope/types.ts","../src/scope/scope.ts","../src/runtime/context.ts","../src/service/runtime.ts","../src/service/errors.ts"],"mappings":";;;cAGqB;;UAGJ,oBAAoB;YACzB,wBAAwB;;;KAIxB,aAAa;;KAGb,gBAAgB,KAAK,oBAAoB,KAAK,UAAU;KAExD,mBAAmB,2BAA2B,iBAAiB;WAChE;WACA,YAAY;;WAGZ,KAAK,YAAY,gBAAgB,gBAAgB,cAAc;;KAGrE,+BAA+B,6BAA6B,gBAAgB;;UAGhE,iBACX,oCACG,iBAAiB,0BAEhB,2BAA2B,WAAW,eAAe,KAAK;;KAGxD,kBAAkB;;KAGlB,aACV,6BACA,iBAAiB,aAAa,uBACnB,gBAAgB,YAAY,eAAe,KAAK;;KAGjD,gBAAgB,UAAU,mBAAmB,aAAa;;KAG1D,aAAa,UAAU,cAAc,SAAS;;KAG9C,eAAe,UAAU,cAAc,UAAU,aACzD,aAAa,aAAa,IAAI;;KAItB,WAAW,UAAU,aAAa,mBAAmB,UAAU,aACvE,aAAa,KACb,UAAU,kBACR;KAGD,mBAAmB,QACrB,WAAW,IAAI,EAAE,gBAAe,sBAAsB,UAAS,mBAAmB,yBAC7E;;;;;;;KAQI,oBAAoB,UAAU,cAAc,mBAAmB;;;KClEtE,cAAc;;KAGd,eAAe,GAAG,GAAG,UAAU;GACjC,OAAO,aAAa,UAAU,WAAW,KAAK,mBAAmB,IAAI;;KAGnE,cAAc,GAAG,GAAG,UAAU;EACjC,IAAI,GAAG,KAAK,OAAO,MAAM,IAAI,OAAO,GAAG,GAAG;EAC1C,SAAS,IAAI,KAAK,OAAO,MAAM,KAAK,OAAO,GAAG,IAAI;EAElD,WAAW,aAAa,aACtB,KAAK,OAAO,MAAM,OACjB,OAAO,IAAI,c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B,OAAO,IAAI,aAAa,KAAK,YAAY,aAAa;;;cAI9E;;;;;;;;;;;;;SAaJ,IAAI,GACT,UAAU,iBACV,eAAe,GACf,UAAS,wBACR;;SAcI,WAAW;;SAqBL,QAAQ,UAAU,iBAAiB,OAAO,IAAI,QAAQ,aAAa;;;;;cCtErE,yCAAyC;EAAA;;;cASzC,6BAA6B;WACnB,SAAS;EAAT,YAAA,SAAS;;;cAQnB,gCAAgC;WAClC,eAAe;EAEZ,YAAA,eAAe;;;cAWhB,gCAAgC;WAIhC,SAAS;WAHF;EAGP,YAAA,SAAS,iBAClB,yBAAyB,mBACzB;WAgBO,yBAAyB"}
@@ -1,269 +0,0 @@
1
- import { a as LayerGeneratorYieldError, d as ServiceRuntimeNotConfiguredError, f as captureServiceTag, m as validateServiceTag, p as registerServiceTag, r as DuplicateServiceError, s as ServiceTagCollisionError, t as captureLayerRegistrationTag } from "./registration-drnZk0SY.mjs";
2
- import { h as RuntimeContextNotConfiguredError, i as getRuntimeContext, l as makeRuntimeContext, n as currentRuntimeContext, u as runRuntimeContext } from "./context-BUEf1qjL.mjs";
3
- import { a as ResourceNotDisposableError, i as getDisposeFinalizer, l as defaultRuntimeContextStorage } from "./signal-D2UTcaaG.mjs";
4
- //#region src/service/runtime.ts
5
- /** Provides the resolver context used by Service tokens during execution. */
6
- var ServiceRuntime = class ServiceRuntime {
7
- /**
8
- * Run a callback with a resolver available to `yield* Service` expressions.
9
- *
10
- * The context is scoped to the callback and is restored afterward.
11
- *
12
- * @example
13
- * ```ts
14
- * const value = ServiceRuntime.run(resolver, () => {
15
- * return ServiceRuntime.resolve(Database)
16
- * })
17
- * ```
18
- */
19
- static run(resolver, program, storage = defaultRuntimeContextStorage) {
20
- const current = getRuntimeContext(storage);
21
- const context = makeRuntimeContext(resolver, current?.scope, current?.resolver === resolver ? current.resolutionPath : [], current?.signal, current?.resolver === resolver ? current : void 0);
22
- return runRuntimeContext(storage, context, program);
23
- }
24
- /** Return the resolver active in the current execution context. */
25
- static current() {
26
- let context;
27
- try {
28
- context = currentRuntimeContext();
29
- } catch (cause) {
30
- if (cause instanceof RuntimeContextNotConfiguredError) throw new ServiceRuntimeNotConfiguredError();
31
- throw cause;
32
- }
33
- if (!context.resolver) throw new ServiceRuntimeNotConfiguredError();
34
- return context.resolver;
35
- }
36
- /** Resolve a Service token using the active resolver. */
37
- static async resolve(token) {
38
- captureServiceTag(token);
39
- return await ServiceRuntime.current().resolve(token);
40
- }
41
- };
42
- //#endregion
43
- //#region src/service/service.ts
44
- /**
45
- * Declare a class-backed Service with a stable string-literal identity.
46
- *
47
- * The returned class is simultaneously the implementation type, the runtime
48
- * dependency token, and the value yielded by `yield*` in an Effect generator.
49
- * The explicit self type preserves exact instance inference, while the second
50
- * call captures the tag as a literal for Layer composition and diagnostics.
51
- *
52
- * @example
53
- * ```ts
54
- * class Database extends Service<Database>()('Database') {
55
- * query(): string {
56
- * return 'ok'
57
- * }
58
- * }
59
- *
60
- * const database = yield* Database
61
- * database.query()
62
- * ```
63
- *
64
- * @typeParam Self The instance type implemented by the declared Service.
65
- */
66
- function Service() {
67
- return function(tag) {
68
- validateServiceTag(tag);
69
- class BaseService {
70
- /** The stable logical identity used by Layers and resolver backends. */
71
- static serviceTag = tag;
72
- /**
73
- * Type-check a structural implementation of this Service.
74
- *
75
- * This is an identity helper. It returns the supplied value unchanged
76
- * and does not invoke a constructor or modify its prototype.
77
- *
78
- * @example
79
- * ```ts
80
- * class Database extends Service<Database>()('Database') {
81
- * query(sql: string): string {
82
- * return sql
83
- * }
84
- * }
85
- *
86
- * const database = Database.of({
87
- * query: (sql) => `Result: ${sql}`
88
- * })
89
- *
90
- * database.query('SELECT 1')
91
- * // 'Result: SELECT 1'
92
- * // database is the original object, not an instance of Database
93
- * ```
94
- */
95
- static of(implementation) {
96
- return implementation;
97
- }
98
- /** Resolve this Service from the resolver active in the current runtime. */
99
- static async *[Symbol.asyncIterator]() {
100
- return await ServiceRuntime.resolve(this);
101
- }
102
- }
103
- registerServiceTag(BaseService, tag);
104
- return BaseService;
105
- };
106
- }
107
- //#endregion
108
- //#region src/layer/internal.ts
109
- const runLayerGenerator = async (service, factory) => {
110
- const iterator = factory();
111
- const state = await iterator.next();
112
- if (!state.done) try {
113
- await iterator.return(void 0);
114
- } finally {
115
- throw new LayerGeneratorYieldError(service);
116
- }
117
- return state.value;
118
- };
119
- //#endregion
120
- //#region src/layer/layer.ts
121
- /**
122
- * Declarative collection of Service providers.
123
- *
124
- * A Layer describes how to acquire implementations; it does not execute
125
- * providers until a `Runtime` is created. Use `merge` to compose distinct
126
- * providers and `override` when replacing an existing provider intentionally.
127
- *
128
- * @example
129
- * ```ts
130
- * const AppLive = Layer.merge(
131
- * Layer.succeed(Database, database),
132
- * Layer.make(UserRepository)
133
- * )
134
- *
135
- * const runtime = await Runtime.make(AppLive, backend)
136
- * ```
137
- */
138
- var Layer = class Layer {
139
- /** The provider registrations retained by this Layer. */
140
- providers;
141
- constructor(providers) {
142
- this.providers = Object.freeze(providers.map((provider) => Object.freeze({
143
- ...provider,
144
- serviceTag: captureLayerRegistrationTag(provider)
145
- })));
146
- }
147
- /** A stable provider-free Layer for composition roots with no Services. */
148
- static empty = Object.freeze(new Layer([]));
149
- static make(service, acquire) {
150
- const serviceTag = captureServiceTag(service);
151
- const defaultAcquire = () => {
152
- return new service();
153
- };
154
- const normalizedAcquire = normalizeAcquire(acquire ?? defaultAcquire);
155
- return new Layer([{
156
- service,
157
- serviceTag,
158
- acquire: normalizedAcquire
159
- }]);
160
- }
161
- /** Create a Layer from an already-constructed Service instance. */
162
- static succeed(service, instance) {
163
- const serviceTag = captureServiceTag(service);
164
- const normalizedAcquire = normalizeAcquire(() => instance);
165
- return new Layer([{
166
- service,
167
- serviceTag,
168
- acquire: normalizedAcquire
169
- }]);
170
- }
171
- /** Alias a source Service under a compatible target contract. */
172
- static alias(options) {
173
- const { from, to } = options;
174
- captureServiceTag(from);
175
- return Layer.gen(to, async function* () {
176
- return await ServiceRuntime.resolve(from);
177
- });
178
- }
179
- /** Define a provider with Runtime-root cleanup. */
180
- static scoped(service, acquire, release) {
181
- const serviceTag = captureServiceTag(service);
182
- return new Layer([{
183
- service,
184
- serviceTag,
185
- acquire: normalizeAcquire(acquire),
186
- release: (instance, outcome) => {
187
- return release(instance, outcome);
188
- }
189
- }]);
190
- }
191
- /** Define a provider with Runtime-root cleanup through its disposal protocol. */
192
- static scopedDisposable(service, acquire) {
193
- const acquireWithRelease = async () => {
194
- const instance = await acquire();
195
- const finalizer = getDisposeFinalizer(instance);
196
- if (!finalizer) throw new ResourceNotDisposableError();
197
- return {
198
- instance,
199
- release: finalizer
200
- };
201
- };
202
- const serviceTag = captureServiceTag(service);
203
- return new Layer([{
204
- service,
205
- serviceTag,
206
- acquire: async () => (await acquireWithRelease()).instance,
207
- acquireWithRelease
208
- }]);
209
- }
210
- /** Define a provider whose acquisition can yield contextual Services. */
211
- static scopedGen(service, factory, release) {
212
- const serviceTag = captureServiceTag(service);
213
- return new Layer([{
214
- service,
215
- serviceTag,
216
- acquire: () => runLayerGenerator(service, factory),
217
- release: (instance, outcome) => {
218
- return release(instance, outcome);
219
- }
220
- }]);
221
- }
222
- /** Define a provider whose acquisition can yield contextual Services. */
223
- static gen(service, factory) {
224
- const serviceTag = captureServiceTag(service);
225
- return new Layer([{
226
- service,
227
- serviceTag,
228
- acquire: () => runLayerGenerator(service, factory)
229
- }]);
230
- }
231
- /** Compose Layers without replacing providers. */
232
- static merge(...layers) {
233
- const providers = /* @__PURE__ */ new Map();
234
- for (const layer of layers) for (const provider of layer.providers) {
235
- const service = provider.service;
236
- const serviceTag = captureLayerRegistrationTag(provider);
237
- const existing = providers.get(serviceTag);
238
- if (existing) {
239
- if (existing.service !== service) throw new ServiceTagCollisionError(existing.service, service);
240
- throw new DuplicateServiceError(service);
241
- }
242
- providers.set(serviceTag, provider);
243
- }
244
- return new Layer([...providers.values()]);
245
- }
246
- /** Mark a Layer composition root as complete without changing its runtime value. */
247
- static complete(layer) {
248
- return layer;
249
- }
250
- static override(base, ...overrides) {
251
- const providers = /* @__PURE__ */ new Map();
252
- for (const provider of base.providers) providers.set(captureLayerRegistrationTag(provider), provider);
253
- for (const layer of overrides) for (const provider of layer.providers) providers.set(captureLayerRegistrationTag(provider), provider);
254
- return new Layer([...providers.values()]);
255
- }
256
- };
257
- Object.defineProperty(Layer, "empty", {
258
- value: Layer.empty,
259
- writable: false,
260
- enumerable: true,
261
- configurable: false
262
- });
263
- const normalizeAcquire = (acquire) => () => {
264
- return acquire();
265
- };
266
- //#endregion
267
- export { Service as n, ServiceRuntime as r, Layer as t };
268
-
269
- //# sourceMappingURL=layer-D56fRdLt.mjs.map