better-effect 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Type your errors with `better-result`. Typecheck the rest of your application wiring with `better-effect`.
6
6
 
7
- Use Services directly inside `Effect.gen`, compose implementations into application environments, and let TypeScript catch missing dependencies before your application starts — while keeping Promises, `better-result`, and your DI backend.
7
+ Use Services directly inside `Effect.fn` Programs (or eager `Effect.gen` workflows), compose implementations into application environments, and let TypeScript catch missing dependencies before your application starts — while keeping Promises, `better-result`, and your DI backend.
8
8
 
9
9
  ```bash
10
10
  bun add better-effect better-result
@@ -34,7 +34,7 @@ class UserRepository extends Service<UserRepository>()('UserRepository') {
34
34
 
35
35
  const UserRepositoryLive = Layer.make(UserRepository)
36
36
 
37
- await Runtime.make(UserRepositoryLive, backend)
37
+ await Runtime.make(UserRepositoryLive)
38
38
  // ^^^^^^^^^^^^^^^^^^
39
39
  // Type error: Database is required but not provided
40
40
  ```
@@ -44,9 +44,17 @@ literal is the Service's stable logical identity. Services with identical
44
44
  methods but different tags are different dependencies; use a namespaced tag
45
45
  such as `@acme/Database` when identities must be shared across packages.
46
46
 
47
- `UserRepository` used `Database`, so `Database` became part of its environment requirements.
47
+ `UserRepository` used `Database`, so `Database` became part of its environment requirements:
48
48
 
49
- No dependency list was written manually.
49
+ ```ts
50
+ type FindUser = Awaited<ReturnType<UserRepository['findUser']>>
51
+ // Effect<User, never, Database>
52
+ ```
53
+
54
+ `Effect<A, E, R>` is a type-only facade over a `better-result` Result, not an Effect TS
55
+ instruction tree. Constructors remain the handles used by `yield*`, Layers and resolver backends;
56
+ the public requirement `R` is a union of tagged Service instances. No dependency list was written
57
+ manually.
50
58
 
51
59
  Services can also describe a contract without requiring a class instance. Use the
52
60
  static `of` helper to type-check a structural implementation; it returns the same
@@ -68,6 +76,15 @@ const AuthorizationLive = Layer.succeed(Authorization, authorization)
68
76
  `instanceof Authorization`. For services with constructors, private fields or
69
77
  other runtime invariants, use `new Authorization(...)` instead.
70
78
 
79
+ Service tokens themselves are always declared through `Service<Self>()(tag)`.
80
+ Every instance carries a required, declaration-only `ServiceIdentity<Tag>`; no
81
+ identity property exists at runtime. `Service.Contract<Authorization>` projects
82
+ the marker-free implementation shape accepted by `Service.of` and all Layer
83
+ provider APIs. Those boundaries return or provide the branded Service type
84
+ without modifying the implementation object. `Service.of(...)` does not create
85
+ an alternate token, so the instance contract stays tied to the constructor used
86
+ by Layers and resolver backends.
87
+
71
88
  Provide it and the environment becomes complete:
72
89
 
73
90
  ```ts
@@ -75,7 +92,7 @@ const DatabaseLive = Layer.make(Database)
75
92
 
76
93
  const AppLive = Layer.merge(DatabaseLive, UserRepositoryLive)
77
94
 
78
- const runtime = await Runtime.make(AppLive, backend)
95
+ const runtime = await Runtime.make(AppLive)
79
96
  ```
80
97
 
81
98
  And the contract does not disappear after startup.
@@ -83,15 +100,24 @@ And the contract does not disappear after startup.
83
100
  A Runtime also knows which Services exist in its environment:
84
101
 
85
102
  ```ts
86
- await runtime.run(() =>
87
- Effect.gen(async function* () {
88
- const database = yield* Database
103
+ const inspectDatabase = Effect.fn(async function* () {
104
+ const database = yield* Database
89
105
 
90
- return Result.ok(database)
91
- })
92
- )
106
+ return Result.ok(database)
107
+ })
108
+
109
+ await runtime.run(inspectDatabase)
93
110
  ```
94
111
 
112
+ `Effect.gen` remains eager for code that already runs inside a resolver and
113
+ Scope. `Effect.fn` captures the generator as a lazy `Program` for Runtime
114
+ boundaries; the callback form remains supported for compatibility.
115
+
116
+ `Runtime.make(AppLive)` and `Runtime.run(AppLive, program)` use the built-in
117
+ `MapLayerBackend`. Pass `{ backend: new ItiLayerBackend() }` when an external
118
+ container is needed; `MemoryLayerBackend` remains its compatibility alias from
119
+ `better-effect/testing`.
120
+
95
121
  If a program asks that Runtime for a Service its environment does not provide, TypeScript rejects the call.
96
122
 
97
123
  ```text
@@ -114,6 +140,40 @@ We call this **typechecked wiring**.
114
140
 
115
141
  The Services your code uses, the implementations your Layers provide, and the programs your Runtime executes participate in the same type-level contract.
116
142
 
143
+ A Layer's public type is `Layer<Provided, Required>`. `Provided` is the Service
144
+ instance union produced by the Layer and `Required` is only the external
145
+ requirement union left after composition. Preserve inferred Layers when possible;
146
+ use `satisfies Layer<Provided, Required>` when checking an application boundary
147
+ without erasing provider provenance.
148
+
149
+ Generic infrastructure that intentionally erases this metadata can use the
150
+ explicit `Layer.Any` sentinel, including for an empty Layer. Bare Layers,
151
+ partial-`any` shapes and concrete unions such as `Layer<A> | Layer<B>` are not
152
+ implicit unchecked boundaries.
153
+
154
+ ### Discover type helpers from their API
155
+
156
+ Public type helpers are also grouped under the runtime API they describe:
157
+
158
+ ```ts
159
+ import type { Effect, Layer, Runtime, Scope, Service } from 'better-effect'
160
+
161
+ type Program = ReturnType<UserRepository['findUser']>
162
+ type Success = Effect.Success<Program>
163
+ type Failure = Effect.Error<Program>
164
+ type Dependencies = Effect.Requirements<Program>
165
+ type Services = Layer.Provided<typeof AppLive>
166
+ type AppRuntime = Runtime.For<typeof AppLive>
167
+ type DatabaseTag = Service.Tag<Database> // 'Database'
168
+ type DatabaseToken = Service.TokenOf<Database> // Service.Token<'Database', Database>
169
+ type Outcome = Scope.Outcome
170
+ ```
171
+
172
+ These are declaration-only aliases and add nothing to the JavaScript bundle.
173
+ The associated `Layer` helpers are intentionally namespaced; use
174
+ `Layer.Provided`, `Layer.Required`, `Layer.Complete` and `Layer.Any` rather than
175
+ low-level provider metadata names.
176
+
117
177
  ---
118
178
 
119
179
  ## Why better-effect?
@@ -181,7 +241,7 @@ Others own connections, sessions, files or other resources.
181
241
  const DatabaseLive = Layer.scoped(
182
242
  Database,
183
243
  () => Database.connect(),
184
- (database) => database.close()
244
+ (database, outcome) => database.close(outcome)
185
245
  )
186
246
  ```
187
247
 
@@ -193,9 +253,11 @@ Resources acquired during an individual execution belong to that execution inste
193
253
 
194
254
  `better-effect` is not a replacement implementation of Effect.
195
255
 
196
- It does not introduce a fiber runtime, scheduler, streams, queues or a public `Effect<A, E, R>` abstraction.
256
+ It does not introduce a fiber runtime, scheduler, streams, queues or a lazy runtime instruction tree.
197
257
 
198
- `Effect.gen` builds on `better-result` generator composition while carrying Service requirements through the TypeScript type system.
258
+ Its public `Effect<A, E, R>` is only a type-level Result facade. `Effect.gen` builds on
259
+ `better-result` generator composition while carrying Service instance requirements through the
260
+ TypeScript type system.
199
261
 
200
262
  Dependency resolution stays behind a pluggable backend.
201
263
 
@@ -265,13 +327,14 @@ Application resources live with the Runtime. Execution resources live with the e
265
327
 
266
328
  ### better-result underneath
267
329
 
268
- **Result → Result.gen → Effect.gen → pipe**
330
+ **Result → Result.gen → Effect.gen / Effect.fn → pipe**
269
331
 
270
332
  Keep `better-result` as the source of truth for typed successes, failures, short-circuiting
271
333
  and generator control flow. `Effect.gen` delegates to `Result.gen`; it adds only the
272
- phantom Service requirements that TypeScript needs to check the application environment.
273
- At runtime, an `EffectResult` is still a `better-result` Result; the requirements exist
274
- only in the type.
334
+ declaration-only Service requirements that TypeScript needs to check the application environment.
335
+ At runtime, an `Effect<A, E, R>` is still a `better-result` Result; the requirements exist
336
+ only in the type. `Effect.Requirements`, `Layer.Provided`, `Layer.Required` and
337
+ `Runtime.For` expose tagged Service instance unions.
275
338
 
276
339
  For a linear workflow, `pipe` composes the same kind of program without introducing a
277
340
  second Result model or a lazy Effect runtime:
@@ -295,5 +358,6 @@ or already an `Err`. The pipeline carries the requirements of every step, so Run
295
358
  still rejects it when its Layer does not provide every required Service.
296
359
 
297
360
  Use `Effect.gen` for larger workflows with several intermediate values, branches or
298
- procedural logic. Use `pipe` for concise, linear composition; both are ways to compose
299
- `better-result` programs while keeping dependency checking in the `better-effect` layer.
361
+ procedural logic that already has a resolver. Use `Effect.fn` when the workflow should
362
+ start at a Runtime boundary. Use `pipe` for concise, linear composition; all three
363
+ keep dependency checking in the `better-effect` layer.
@@ -1,4 +1,5 @@
1
- import { V as AnyServiceToken, t as LayerBackend, v as LayerRegistration } from "../index-D77AvuBl.mjs";
1
+ import { T as AnyServiceToken, a as LayerRegistration, n as LayerBackend } from "../map-layer-backend-7hQkf_QP.mjs";
2
+ import "../index-R3FdVmdr.mjs";
2
3
  //#region src/adapters/iti.d.ts
3
4
  /**
4
5
  * ITI-backed Layer backend.
@@ -1 +1 @@
1
- {"version":3,"file":"iti.d.mts","names":[],"sources":["../../src/adapters/iti.ts"],"mappings":";;;;;;;;cAmBa,2BAA2B;UAC9B;mBAES;mBAEA;UAET;;EAgBR,SAAS,cAAc;;EAuBvB,QAAQ,UAAU,iBAAiB,OAAO,IAAI,aAAa,KAAK,YAAY,aAAa;;EAuBnF,cAAc"}
1
+ {"version":3,"file":"iti.d.mts","names":[],"sources":["../../src/adapters/iti.ts"],"mappings":";;;;;;;;;cAsBa,2BAA2B;UAC9B;mBAES;mBAEA;UAET;;EAgBR,SAAS,cAAc;;EAuBvB,QAAQ,UAAU,iBAAiB,OAAO,IAAI,aAAa,KAAK,YAAY,aAAa;;EAyBnF,cAAc"}
@@ -1,5 +1,5 @@
1
- import { a as ServiceTagCollisionError, o as ServiceNotFoundError, t as DuplicateServiceError } from "../errors-GR3K_nRu.mjs";
2
- import { t as assertServiceCompatibility } from "../internal-identity-BnZC3Au-.mjs";
1
+ import { l as ServiceNotFoundError, n as DuplicateServiceError, o as ServiceTagCollisionError, t as assertServiceCompatibility } from "../internal-identity-Cm4-KIUj.mjs";
2
+ import { t as isPromiseLike } from "../runtime-CDcCF5cb.mjs";
3
3
  import { createContainer } from "iti";
4
4
  //#region src/adapters/iti.ts
5
5
  /**
@@ -33,15 +33,15 @@ var ItiLayerBackend = class {
33
33
  }
34
34
  /** Resolve a registered Service through the ITI container. */
35
35
  resolve(token) {
36
- if (!this.registered.has(token.serviceTag)) throw new ServiceNotFoundError(token);
37
36
  const registered = this.registered.get(token.serviceTag);
37
+ if (registered === void 0) throw new ServiceNotFoundError(token);
38
38
  const key = this.keyFor(token);
39
39
  const resolved = this.container.get(key);
40
40
  const validate = (instance) => {
41
41
  assertServiceCompatibility(token, registered, instance);
42
42
  return instance;
43
43
  };
44
- if (resolved && typeof resolved.then === "function") return Promise.resolve(resolved).then(validate);
44
+ if (isPromiseLike(resolved)) return Promise.resolve(resolved).then(validate);
45
45
  return validate(resolved);
46
46
  }
47
47
  /** Dispose all ITI-managed provider instances. */
@@ -1 +1 @@
1
- {"version":3,"file":"iti.mjs","names":[],"sources":["../../src/adapters/iti.ts"],"sourcesContent":["import { createContainer } from 'iti'\n\nimport {\n DuplicateServiceError,\n ServiceTagCollisionError,\n type LayerBackend,\n type LayerRegistration\n} from '../layer'\n\nimport { ServiceNotFoundError, type AnyServiceToken } from '../service'\n\nimport { assertServiceCompatibility } from '../layer/internal-identity'\n\n/**\n * ITI-backed Layer backend.\n *\n * Install `iti` as the optional peer dependency and pass an instance to\n * `Runtime.make` when using ITI's container implementation.\n */\nexport class ItiLayerBackend implements LayerBackend {\n private container: any = createContainer()\n\n private readonly keys = new Map<string, string>()\n\n private readonly registered = new Map<string, AnyServiceToken>()\n\n private keyFor(token: AnyServiceToken): string {\n const tag = token.serviceTag\n const existing = this.keys.get(tag)\n\n if (existing) {\n return existing\n }\n\n const key = `better-effect:${tag}`\n\n this.keys.set(tag, key)\n\n return key\n }\n\n /** Register a Layer provider under its deterministic Service-tag key. */\n register(registration: LayerRegistration): void {\n const token = registration.service\n const tag = token.serviceTag\n const existing = this.registered.get(tag)\n\n if (existing === token) {\n throw new DuplicateServiceError(token)\n }\n\n if (existing) {\n throw new ServiceTagCollisionError(existing, token)\n }\n\n const key = this.keyFor(token)\n\n this.container = this.container.add({\n [key]: registration.acquire\n })\n\n this.registered.set(tag, token)\n }\n\n /** Resolve a registered Service through the ITI container. */\n resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>> {\n if (!this.registered.has(token.serviceTag)) {\n throw new ServiceNotFoundError(token)\n }\n\n const registered = this.registered.get(token.serviceTag)\n const key = this.keyFor(token)\n const resolved = this.container.get(key) as unknown\n\n const validate = (instance: unknown): InstanceType<T> => {\n assertServiceCompatibility(token, registered!, instance)\n\n return instance as InstanceType<T>\n }\n\n if (resolved && typeof (resolved as PromiseLike<unknown>).then === 'function') {\n return Promise.resolve(resolved).then(validate)\n }\n\n return validate(resolved)\n }\n\n /** Dispose all ITI-managed provider instances. */\n async disposeAll(): Promise<void> {\n await this.container.disposeAll()\n }\n}\n"],"mappings":";;;;;;;;;;AAmBA,IAAa,kBAAb,MAAqD;CACnD,YAAyB,gBAAgB;CAEzC,uBAAwB,IAAI,IAAoB;CAEhD,6BAA8B,IAAI,IAA6B;CAE/D,OAAe,OAAgC;EAC7C,MAAM,MAAM,MAAM;EAClB,MAAM,WAAW,KAAK,KAAK,IAAI,GAAG;EAElC,IAAI,UACF,OAAO;EAGT,MAAM,MAAM,iBAAiB;EAE7B,KAAK,KAAK,IAAI,KAAK,GAAG;EAEtB,OAAO;CACT;;CAGA,SAAS,cAAuC;EAC9C,MAAM,QAAQ,aAAa;EAC3B,MAAM,MAAM,MAAM;EAClB,MAAM,WAAW,KAAK,WAAW,IAAI,GAAG;EAExC,IAAI,aAAa,OACf,MAAM,IAAI,sBAAsB,KAAK;EAGvC,IAAI,UACF,MAAM,IAAI,yBAAyB,UAAU,KAAK;EAGpD,MAAM,MAAM,KAAK,OAAO,KAAK;EAE7B,KAAK,YAAY,KAAK,UAAU,IAAI,GACjC,MAAM,aAAa,QACtB,CAAC;EAED,KAAK,WAAW,IAAI,KAAK,KAAK;CAChC;;CAGA,QAAmC,OAA0D;EAC3F,IAAI,CAAC,KAAK,WAAW,IAAI,MAAM,UAAU,GACvC,MAAM,IAAI,qBAAqB,KAAK;EAGtC,MAAM,aAAa,KAAK,WAAW,IAAI,MAAM,UAAU;EACvD,MAAM,MAAM,KAAK,OAAO,KAAK;EAC7B,MAAM,WAAW,KAAK,UAAU,IAAI,GAAG;EAEvC,MAAM,YAAY,aAAuC;GACvD,2BAA2B,OAAO,YAAa,QAAQ;GAEvD,OAAO;EACT;EAEA,IAAI,YAAY,OAAQ,SAAkC,SAAS,YACjE,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KAAK,QAAQ;EAGhD,OAAO,SAAS,QAAQ;CAC1B;;CAGA,MAAM,aAA4B;EAChC,MAAM,KAAK,UAAU,WAAW;CAClC;AACF"}
1
+ {"version":3,"file":"iti.mjs","names":[],"sources":["../../src/adapters/iti.ts"],"sourcesContent":["import { createContainer } from 'iti'\n\nimport {\n DuplicateServiceError,\n ServiceTagCollisionError,\n type LayerBackend,\n type LayerRegistration\n} from '../layer'\n\nimport { ServiceNotFoundError, type AnyServiceToken } from '../service'\n\nimport { assertServiceCompatibility } from '../layer/internal-identity'\nimport { isPromiseLike } from '../utils/runtime'\n\ntype LayerAcquiredValue = Awaited<ReturnType<LayerRegistration['acquire']>>\n\n/**\n * ITI-backed Layer backend.\n *\n * Install `iti` as the optional peer dependency and pass an instance to\n * `Runtime.make` when using ITI's container implementation.\n */\nexport class ItiLayerBackend implements LayerBackend {\n private container: any = createContainer()\n\n private readonly keys = new Map<string, string>()\n\n private readonly registered = new Map<string, AnyServiceToken>()\n\n private keyFor(token: AnyServiceToken): string {\n const tag = token.serviceTag\n const existing = this.keys.get(tag)\n\n if (existing) {\n return existing\n }\n\n const key = `better-effect:${tag}`\n\n this.keys.set(tag, key)\n\n return key\n }\n\n /** Register a Layer provider under its deterministic Service-tag key. */\n register(registration: LayerRegistration): void {\n const token = registration.service\n const tag = token.serviceTag\n const existing = this.registered.get(tag)\n\n if (existing === token) {\n throw new DuplicateServiceError(token)\n }\n\n if (existing) {\n throw new ServiceTagCollisionError(existing, token)\n }\n\n const key = this.keyFor(token)\n\n this.container = this.container.add({\n [key]: registration.acquire\n })\n\n this.registered.set(tag, token)\n }\n\n /** Resolve a registered Service through the ITI container. */\n resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>> {\n const registered = this.registered.get(token.serviceTag)\n\n if (registered === undefined) {\n throw new ServiceNotFoundError(token)\n }\n\n const key = this.keyFor(token)\n const resolved = this.container.get(key)\n\n const validate = (instance: LayerAcquiredValue): InstanceType<T> => {\n assertServiceCompatibility(token, registered, instance)\n\n // SAFETY: The registered tag and compatibility check establish the constructor-to-instance relationship after ITI erases it.\n return instance as InstanceType<T>\n }\n\n if (isPromiseLike(resolved)) {\n return Promise.resolve(resolved).then(validate)\n }\n\n return validate(resolved)\n }\n\n /** Dispose all ITI-managed provider instances. */\n async disposeAll(): Promise<void> {\n await this.container.disposeAll()\n }\n}\n"],"mappings":";;;;;;;;;;AAsBA,IAAa,kBAAb,MAAqD;CACnD,YAAyB,gBAAgB;CAEzC,uBAAwB,IAAI,IAAoB;CAEhD,6BAA8B,IAAI,IAA6B;CAE/D,OAAe,OAAgC;EAC7C,MAAM,MAAM,MAAM;EAClB,MAAM,WAAW,KAAK,KAAK,IAAI,GAAG;EAElC,IAAI,UACF,OAAO;EAGT,MAAM,MAAM,iBAAiB;EAE7B,KAAK,KAAK,IAAI,KAAK,GAAG;EAEtB,OAAO;CACT;;CAGA,SAAS,cAAuC;EAC9C,MAAM,QAAQ,aAAa;EAC3B,MAAM,MAAM,MAAM;EAClB,MAAM,WAAW,KAAK,WAAW,IAAI,GAAG;EAExC,IAAI,aAAa,OACf,MAAM,IAAI,sBAAsB,KAAK;EAGvC,IAAI,UACF,MAAM,IAAI,yBAAyB,UAAU,KAAK;EAGpD,MAAM,MAAM,KAAK,OAAO,KAAK;EAE7B,KAAK,YAAY,KAAK,UAAU,IAAI,GACjC,MAAM,aAAa,QACtB,CAAC;EAED,KAAK,WAAW,IAAI,KAAK,KAAK;CAChC;;CAGA,QAAmC,OAA0D;EAC3F,MAAM,aAAa,KAAK,WAAW,IAAI,MAAM,UAAU;EAEvD,IAAI,eAAe,KAAA,GACjB,MAAM,IAAI,qBAAqB,KAAK;EAGtC,MAAM,MAAM,KAAK,OAAO,KAAK;EAC7B,MAAM,WAAW,KAAK,UAAU,IAAI,GAAG;EAEvC,MAAM,YAAY,aAAkD;GAClE,2BAA2B,OAAO,YAAY,QAAQ;GAGtD,OAAO;EACT;EAEA,IAAI,cAAc,QAAQ,GACxB,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KAAK,QAAQ;EAGhD,OAAO,SAAS,QAAQ;CAC1B;;CAGA,MAAM,aAA4B;EAChC,MAAM,KAAK,UAAU,WAAW;CAClC;AACF"}
@@ -0,0 +1,297 @@
1
+ import { A as ServiceRequirements, C as ServiceRequirement, D as ServiceContract, E as ServiceClass, M as ServiceTagOf, N as ServiceToken, P as ServiceTokenOf, T as AnyServiceToken, a as LayerRegistration, i as LayerGeneratorRequirements, n as LayerBackend, o as MaybePromise$1, r as LayerGenerator, v as EffectRequirements, w as AnyService } from "./map-layer-backend-7hQkf_QP.mjs";
2
+ //#region src/scope/errors.d.ts
3
+ /** Thrown when Scope context is accessed outside an active Scope execution. */
4
+ declare class ScopeRuntimeNotConfiguredError extends Error {
5
+ constructor();
6
+ }
7
+ /** Thrown when a resource or finalizer is added after Scope closure begins. */
8
+ declare class ScopeClosedError extends Error {
9
+ constructor();
10
+ }
11
+ /** Aggregates finalizer failures encountered while closing a Scope. */
12
+ declare class ScopeCloseError extends Error {
13
+ readonly causes: readonly unknown[];
14
+ constructor(causes: readonly unknown[]);
15
+ }
16
+ /** Thrown when a value has neither Symbol.dispose nor Symbol.asyncDispose. */
17
+ declare class ResourceNotDisposableError extends Error {
18
+ constructor();
19
+ }
20
+ //#endregion
21
+ //#region src/scope/types.d.ts
22
+ /** A value that may be returned synchronously or asynchronously. */
23
+ type MaybePromise<T> = T | PromiseLike<T>;
24
+ /** Final outcome supplied to Scope finalizers and resource releases. */
25
+ type ScopeOutcome = {
26
+ /** Indicates that the owning program completed successfully. */
27
+ readonly status: 'success';
28
+ } | {
29
+ /** Indicates that the owning program failed or was interrupted. */
30
+ readonly status: 'failure';
31
+ /** The original program or execution failure. */
32
+ readonly cause: unknown;
33
+ };
34
+ /** Cleanup callback registered with a Scope. */
35
+ type ScopeFinalizer = (outcome: ScopeOutcome) => MaybePromise<void>;
36
+ /** Aggregated cleanup information reported at an execution boundary. */
37
+ type CleanupFailureDiagnostic = {
38
+ /** Outcome used for the Scope close that triggered cleanup. */
39
+ readonly outcome: ScopeOutcome;
40
+ /** Aggregated finalizer failure. */
41
+ readonly error: ScopeCloseError;
42
+ };
43
+ type SyncDisposableResource = {
44
+ [Symbol.dispose]: () => void;
45
+ [Symbol.asyncDispose]?: () => MaybePromise<void>;
46
+ };
47
+ type AsyncDisposableResource = {
48
+ [Symbol.dispose]?: () => void;
49
+ [Symbol.asyncDispose]: () => MaybePromise<void>;
50
+ };
51
+ /** A value implementing at least one JavaScript disposal protocol. */
52
+ type DisposableResource = SyncDisposableResource | AsyncDisposableResource;
53
+ //#endregion
54
+ //#region src/internal/variance.d.ts
55
+ /** Type-level marker for a value produced by `A`. */
56
+ type Covariant<A> = () => A;
57
+ /** Type-level marker that both consumes and produces `A`. */
58
+ type Invariant<A> = (value: A) => A;
59
+ //#endregion
60
+ //#region src/internal/missing-dependencies.d.ts
61
+ declare const MissingDependenciesTypeId: unique symbol;
62
+ type MissingDependencies<Missing extends AnyService> = {
63
+ readonly [MissingDependenciesTypeId]: Missing;
64
+ };
65
+ //#endregion
66
+ //#region src/layer/metadata.d.ts
67
+ /** Package-private declaration-only carrier for inferred Layer provenance. */
68
+ declare const LayerProvenanceTypeId: unique symbol;
69
+ interface ProviderEntry<out Provided extends AnyService, out RawRequired extends AnyService = never> {
70
+ readonly provided: Provided;
71
+ readonly required: RawRequired;
72
+ }
73
+ interface ErasedProvenance<out Provided extends AnyService, out StickyRequired extends AnyService> {
74
+ readonly provided: Provided;
75
+ readonly stickyRequired: StickyRequired;
76
+ }
77
+ interface LayerProvenance<out Entries extends ProviderEntry<AnyService, AnyService> = never, out Erased extends ErasedProvenance<AnyService, AnyService> = never> {
78
+ readonly [LayerProvenanceTypeId]: {
79
+ readonly entries: Entries;
80
+ readonly erased: Erased;
81
+ };
82
+ }
83
+ //#endregion
84
+ //#region src/layer/inference.d.ts
85
+ type IsAny<T> = 0 extends 1 & T ? true : false;
86
+ type IsNever<T> = [T] extends [never] ? true : false;
87
+ type IsUnion<T, Candidate = T> = T extends unknown ? [Candidate] extends [T] ? false : true : never;
88
+ /** Any Layer shape accepted by type-level inference helpers. */
89
+ type LayerInput = Layer<any, any> | Layer<never, any>;
90
+ /** Extract the public Service environment channels from a Layer. */
91
+ type ProvidedEnvironment<L extends LayerInput> = L extends Layer<infer Provided, infer _Required> ? Provided : never;
92
+ type RequiredEnvironment<L extends LayerInput> = L extends Layer<infer _Provided, infer Required> ? Required : never;
93
+ type HasWidenedTag<Services> = IsAny<Services> extends true ? false : Services extends AnyService ? string extends ServiceTagOf<Services> ? true : false : false;
94
+ type SameServiceTag<Left extends AnyService, Right extends AnyService> = [ServiceTagOf<Left>] extends [ServiceTagOf<Right>] ? [ServiceTagOf<Right>] extends [ServiceTagOf<Left>] ? true : false : false;
95
+ type SameServiceContract<Left extends AnyService, Right extends AnyService> = [ServiceContract<Left>] extends [ServiceContract<Right>] ? [ServiceContract<Right>] extends [ServiceContract<Left>] ? true : false : false;
96
+ type SameService<Left extends AnyService, Right extends AnyService> = SameServiceTag<Left, Right> extends true ? SameServiceContract<Left, Right> : false;
97
+ type RequirementProvided<Requirement extends AnyService, Provided extends AnyService> = Provided extends AnyService ? SameService<Requirement, Provided> : false;
98
+ type MissingRequirement<Requirement extends AnyService, Provided> = true extends RequirementProvided<Requirement, Extract<Provided, AnyService>> ? never : Requirement;
99
+ /**
100
+ * Existing Runtime matching semantics. Widened Service environments are an
101
+ * explicit execution erasure and therefore satisfy every concrete requirement.
102
+ */
103
+ type MissingServices<Required extends AnyService, Provided extends AnyService> = ServiceToken<string, Required> extends ServiceToken<string, Provided> ? never : IsAny<Required> extends true ? never : IsAny<Provided> extends true ? never : true extends HasWidenedTag<Required | Provided> ? never : Required extends AnyService ? MissingRequirement<Required, Provided> : never;
104
+ /** Layer matching that keeps widened Service.Any as an external requirement. */
105
+ type LayerExternalRequirements<RawRequired extends AnyService, Provided extends AnyService> = true extends HasWidenedTag<Extract<RawRequired | Provided, AnyService>> ? Extract<RawRequired, AnyService> : MissingServices<RawRequired, Provided>;
106
+ type AnyProviderEntry = ProviderEntry<AnyService, AnyService>;
107
+ type AnyErasedProvenance = ErasedProvenance<AnyService, AnyService>;
108
+ type EntryProvided<Entries> = Entries extends ProviderEntry<infer Provided, any> ? Provided : never;
109
+ type EntryRequired<Entries> = Entries extends ProviderEntry<any, infer Required> ? Required : never;
110
+ type ErasedProvided<Erased> = Erased extends ErasedProvenance<infer Provided, any> ? Provided : never;
111
+ type ErasedRequired<Erased> = Erased extends ErasedProvenance<any, infer Required> ? Required : never;
112
+ /** Extract precise provider entries carried by an inferred Layer. */
113
+ type PreciseEntries<L extends LayerInput> = L extends LayerProvenance<infer Entries, any> ? Entries : never;
114
+ /**
115
+ * Extract erased provenance, falling back to the public channels for an
116
+ * explicitly annotated Layer.
117
+ */
118
+ type ErasedEntries<L extends LayerInput> = L extends LayerProvenance<any, infer Erased> ? Erased : [ProvidedEnvironment<L> | RequiredEnvironment<L>] extends [never] ? never : ErasedProvenance<ProvidedEnvironment<L>, RequiredEnvironment<L>>;
119
+ type LayerMetadata<Entries extends AnyProviderEntry, Erased extends AnyErasedProvenance> = [Entries | Erased] extends [never] ? unknown : LayerProvenance<Entries, Erased>;
120
+ /** Opaque internal result type used by Layer constructors and combinators. */
121
+ type LayerResult<Entries extends AnyProviderEntry, Erased extends AnyErasedProvenance = never> = Layer<EntryProvided<Entries> | ErasedProvided<Erased>, LayerExternalRequirements<EntryRequired<Entries> | ErasedRequired<Erased>, EntryProvided<Entries> | ErasedProvided<Erased>>> & LayerMetadata<Entries, Erased>;
122
+ type LayerChannelPair<L> = L extends Layer<infer Provided, infer Required> ? [Provided, Required] : never;
123
+ type ExactUncheckedArm<L> = LayerChannelPair<L> extends [infer Provided extends AnyService, infer Required extends AnyService] ? IsAny<Provided> extends true ? IsAny<Required> extends true ? true : false : IsNever<Provided> extends true ? IsAny<Required> extends true ? true : false : false : false;
124
+ type HasUncheckedProvidedArm<L> = L extends unknown ? LayerChannelPair<L> extends [infer Provided, infer Required] ? IsAny<Provided> extends true ? IsAny<Required> extends true ? true : false : false : false : never;
125
+ type HasUncheckedEmptyArm<L> = L extends unknown ? LayerChannelPair<L> extends [infer Provided, infer Required] ? IsNever<Provided> extends true ? IsAny<Required> extends true ? true : false : false : false : never;
126
+ type HasNonUncheckedArm<L> = L extends unknown ? ExactUncheckedArm<L> extends true ? false : true : never;
127
+ /** Recognize only the documented exact unchecked Layer sentinels. */
128
+ type IsExactUncheckedLayer<L> = IsUnion<L> extends false ? ExactUncheckedArm<L> : true extends HasNonUncheckedArm<L> ? false : true extends HasUncheckedProvidedArm<L> ? true extends HasUncheckedEmptyArm<L> ? true : false : false;
129
+ type PartialAnyArm<L> = LayerChannelPair<L> extends [infer Provided extends AnyService, infer Required extends AnyService] ? IsAny<Provided> extends true ? IsAny<Required> extends true ? false : true : IsAny<Required> extends true ? IsNever<Provided> extends true ? false : true : false : false;
130
+ /** Detect any Layer constituent with only one erased generic channel. */
131
+ type HasPartialAnyChannel<L> = true extends (L extends unknown ? PartialAnyArm<L> : never) ? true : false;
132
+ /** Detect a concrete union of Layer values, preserving the original shape. */
133
+ type IsConcreteUnion<L> = IsAny<L> extends true ? false : IsUnion<L> extends true ? IsExactUncheckedLayer<L> extends true ? false : true : false;
134
+ type LayerInputState<L> = IsExactUncheckedLayer<L> extends true ? 'unchecked' : HasPartialAnyChannel<L> extends true ? 'invalid-partial-any' : IsConcreteUnion<L> extends true ? 'invalid-union' : 'typed';
135
+ type InvalidLayerErasure = {
136
+ readonly __betterEffectInvalidLayerErasure: unique symbol;
137
+ };
138
+ type AmbiguousLayerUnion = {
139
+ readonly __betterEffectAmbiguousLayerUnion: unique symbol;
140
+ };
141
+ /** Validate an original Layer argument without widening it to Layer.Any. */
142
+ type ValidateLayerInput<L extends LayerInput> = LayerInputState<L> extends 'invalid-partial-any' ? InvalidLayerErasure : LayerInputState<L> extends 'invalid-union' ? AmbiguousLayerUnion : unknown;
143
+ /** Validate every original element of a merge tuple. */
144
+ type ValidateLayerTuple<Layers extends readonly LayerInput[]> = { [Index in keyof Layers]: ValidateLayerInput<Layers[Index]>; };
145
+ /** Remove compatible Services from a union while retaining all other identities. */
146
+ type RemoveCompatibleServices<Provided extends AnyService, Replacements extends AnyService> = Provided extends AnyService ? true extends (Replacements extends AnyService ? SameService<Provided, Replacements> : false) ? never : Provided : never;
147
+ type HasCompatibleService<Provided extends AnyService, Replacements extends AnyService> = true extends (Replacements extends AnyService ? SameService<Provided, Replacements> : false) ? true : false;
148
+ type RemoveCompatibleEntries<Entries extends AnyProviderEntry, Replacements extends AnyService> = Entries extends ProviderEntry<infer Provided, any> ? HasCompatibleService<Provided, Replacements> extends true ? never : Entries : never;
149
+ type ReplacePreciseOne<Entries extends AnyProviderEntry, Replacement extends LayerInput> = RemoveCompatibleEntries<Entries, Extract<ProvidedEnvironment<Replacement>, AnyService>> | PreciseEntries<Replacement>;
150
+ type ReplaceErasedOne<Erased extends AnyErasedProvenance, Replacement extends LayerInput> = Erased extends ErasedProvenance<infer Provided, infer StickyRequired> ? ErasedProvenance<RemoveCompatibleServices<Provided, Extract<ProvidedEnvironment<Replacement>, AnyService>>, StickyRequired> : never;
151
+ type ApplyPreciseOverrides<Entries extends AnyProviderEntry, Overrides extends readonly LayerInput[]> = Overrides extends readonly [infer Head extends LayerInput, ...infer Tail extends readonly LayerInput[]] ? ApplyPreciseOverrides<ReplacePreciseOne<Entries, Head>, Tail> : Entries;
152
+ type ApplyErasedOverrides<Erased extends AnyErasedProvenance, Overrides extends readonly LayerInput[]> = Overrides extends readonly [infer Head extends LayerInput, ...infer Tail extends readonly LayerInput[]] ? ApplyErasedOverrides<ReplaceErasedOne<Erased, Head> | Extract<ErasedEntries<Head>, AnyErasedProvenance>, Tail> : Erased;
153
+ type HasUncheckedLayerInTuple<Layers extends readonly LayerInput[]> = true extends (Layers[number] extends unknown ? IsExactUncheckedLayer<Layers[number]> : never) ? true : false;
154
+ type MergeLayerResult<Layers extends readonly LayerInput[]> = HasUncheckedLayerInTuple<Layers> extends true ? Layer<any, any> : LayerResult<PreciseEntries<Layers[number]>, ErasedEntries<Layers[number]>>;
155
+ /** Internal result type for Layer.merge. */
156
+ type MergeResult<Layers extends readonly LayerInput[]> = MergeLayerResult<Layers>;
157
+ type OverrideLayerResultUnchecked<Base extends LayerInput, Overrides extends readonly LayerInput[]> = HasUncheckedLayerInTuple<[Base, ...Overrides]> extends true ? Layer<any, any> : LayerResult<ApplyPreciseOverrides<PreciseEntries<Base>, Overrides>, ApplyErasedOverrides<ErasedEntries<Base>, Overrides>>;
158
+ /** Internal result type for Layer.override. */
159
+ type OverrideResult<Base extends LayerInput, Replacement extends LayerInput> = OverrideLayerResultUnchecked<Base, readonly [Replacement]>;
160
+ /** Internal result type for an ordered override tuple. */
161
+ type OverrideLayerResult<Base extends LayerInput, Overrides extends readonly LayerInput[]> = OverrideLayerResultUnchecked<Base, Overrides>;
162
+ type IncompatibleOverridePair<Current extends AnyService, Replacement extends AnyService> = SameServiceTag<Current, Replacement> extends true ? SameServiceContract<Current, Replacement> extends true ? never : ServiceTokenOf<Replacement> : never;
163
+ /** Fully distributive same-tag incompatible override comparison. */
164
+ type IncompatibleOverridePairs<CurrentProvided extends AnyService, ReplacementProvided extends AnyService> = CurrentProvided extends AnyService ? ReplacementProvided extends AnyService ? IncompatibleOverridePair<CurrentProvided, ReplacementProvided> : never : never;
165
+ type IncompatibleLayerOverride<Tokens extends AnyServiceToken> = {
166
+ readonly __betterEffectIncompatibleLayerOverride: Tokens;
167
+ };
168
+ type InvalidWidenedProvidedEnvironment = {
169
+ readonly __betterEffectWidenedProvidedEnvironment: unique symbol;
170
+ };
171
+ type ValidateOverrideLayerInput<L extends LayerInput> = IsExactUncheckedLayer<L> extends true ? unknown : ValidateLayerInput<L> & (true extends HasWidenedTag<Extract<ProvidedEnvironment<L>, AnyService>> ? InvalidWidenedProvidedEnvironment : unknown);
172
+ /** Validate one override against the currently accumulated Layer state. */
173
+ type ValidateOneOverride<Current extends LayerInput, Replacement extends LayerInput> = ValidateOverrideLayerInput<Current> & ValidateOverrideLayerInput<Replacement> & (IsExactUncheckedLayer<Current> extends true ? unknown : IsExactUncheckedLayer<Replacement> extends true ? unknown : [IncompatibleOverridePairs<Extract<ProvidedEnvironment<Current>, AnyService>, Extract<ProvidedEnvironment<Replacement>, AnyService>>] extends [never] ? unknown : IncompatibleLayerOverride<IncompatibleOverridePairs<Extract<ProvidedEnvironment<Current>, AnyService>, Extract<ProvidedEnvironment<Replacement>, AnyService>>>);
174
+ /** Validate ordered overrides against the state produced by earlier overrides. */
175
+ type ValidateOverrides<Base extends LayerInput, Overrides extends readonly LayerInput[]> = Overrides extends readonly [infer Head extends LayerInput, ...infer Tail extends readonly LayerInput[]] ? ValidateOneOverride<Base, Head> & ValidateOverrides<OverrideResult<Base, Head>, Tail> : unknown;
176
+ /** A Layer accepted by Runtime boundaries after completeness validation. */
177
+ type CompleteInput<L extends LayerInput> = ValidateLayerInput<L> & (LayerInputState<L> extends 'unchecked' ? L : LayerInputState<L> extends 'typed' ? [RequiredEnvironment<L>] extends [never] ? L : L & MissingDependencies<Extract<RequiredEnvironment<L>, AnyService>> : L);
178
+ type ExecutionProgram<A> = () => A | PromiseLike<A>;
179
+ type CompleteExecutionWithRequirements<Provided extends AnyService, A, Required extends AnyService> = [MissingServices<Required, Provided>] extends [never] ? ExecutionProgram<A> : ExecutionProgram<A> & MissingDependencies<MissingServices<Required, Provided>>;
180
+ /** Keep execution callbacks unchanged when their Effect requirements are met. */
181
+ type CompleteExecution<Provided extends AnyService, A> = CompleteExecutionWithRequirements<Provided, A, EffectRequirements<A>>;
182
+ //#endregion
183
+ //#region src/layer/layer.d.ts
184
+ declare const LayerTypeId: unique symbol;
185
+ interface LayerVariance<in out Provided, out Required> {
186
+ readonly _Provided: Invariant<Provided>;
187
+ readonly _Required: Covariant<Required>;
188
+ }
189
+ interface LayerProvider extends LayerRegistration {
190
+ /** Provider storage deliberately erases the concrete instance type. */
191
+ readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise$1<void>;
192
+ }
193
+ /** A Service class whose constructor can be called without arguments. */
194
+ type DefaultConstructibleServiceClass<Tag extends string = string, Instance extends AnyService = AnyService> = ServiceClass<Tag, Instance> & (new () => Instance);
195
+ /**
196
+ * Declarative collection of Service providers.
197
+ *
198
+ * A Layer describes how to acquire implementations; it does not execute
199
+ * providers until a `Runtime` is created. Use `merge` to compose distinct
200
+ * providers and `override` when replacing an existing provider intentionally.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const AppLive = Layer.merge(
205
+ * Layer.succeed(Database, database),
206
+ * Layer.make(UserRepository)
207
+ * )
208
+ *
209
+ * const runtime = await Runtime.make(AppLive, backend)
210
+ * ```
211
+ */
212
+ declare class Layer<in out Provided extends AnyService = AnyService, out Required extends AnyService = AnyService> {
213
+ readonly [LayerTypeId]: LayerVariance<Provided, Required>;
214
+ /** The provider registrations retained by this Layer. */
215
+ readonly providers: readonly LayerProvider[];
216
+ private constructor();
217
+ /** Create a Layer that lazily acquires a Service instance. */
218
+ static make<S extends DefaultConstructibleServiceClass<any, any>>(service: S): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
219
+ static make<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise$1<ServiceContract<InstanceType<S>>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
220
+ /** Create a Layer from an already-constructed Service instance. */
221
+ static succeed<S extends ServiceClass<any, any>>(service: S, instance: ServiceContract<InstanceType<S>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
222
+ /** Define a provider with Runtime-root cleanup. */
223
+ static scoped<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise$1<ServiceContract<InstanceType<S>>>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise$1<void>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
224
+ /** Define a provider whose acquisition can yield contextual Services. */
225
+ static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise$1<void>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
226
+ /** Define a provider whose acquisition can yield contextual Services. */
227
+ static gen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
228
+ /** Compose Layers without replacing providers. */
229
+ static merge<const Layers extends readonly LayerInput[]>(...layers: Layers & ValidateLayerTuple<Layers>): MergeResult<Layers>;
230
+ /** Replace providers in a base Layer, using tag identity and compatible contracts. */
231
+ static override<Base extends LayerInput, const Overrides extends readonly LayerInput[]>(base: Base & ValidateLayerInput<Base>, ...overrides: Overrides & ValidateOverrides<Base, Overrides>): OverrideLayerResult<Base, Overrides>;
232
+ }
233
+ /** Type-level aliases for inspecting Layer environments and completeness. */
234
+ declare namespace Layer {
235
+ /** The widened Layer shape accepted by generic Layer infrastructure. */
236
+ type Any = LayerInput;
237
+ /** Extract the branded Service instances provided by a Layer. */
238
+ type Provided<L extends LayerInput> = ProvidedEnvironment<L>;
239
+ /** Extract the external Service requirements of a Layer. */
240
+ type Required<L extends LayerInput> = RequiredEnvironment<L>;
241
+ /** Validate a Layer's requirements and input shape. */
242
+ type Complete<L extends LayerInput> = CompleteInput<L>;
243
+ }
244
+ //#endregion
245
+ //#region src/layer/errors.d.ts
246
+ type LayerCause = Extract<ScopeOutcome, {
247
+ readonly status: 'failure';
248
+ }>['cause'];
249
+ /** Thrown when a Layer registers the same Service tag more than once. */
250
+ declare class DuplicateServiceError extends Error {
251
+ readonly service: ServiceClass<any>;
252
+ constructor(service: ServiceClass<any>);
253
+ }
254
+ /** Thrown when one Service tag is associated with incompatible constructors. */
255
+ declare class ServiceTagCollisionError extends Error {
256
+ readonly existing: AnyServiceToken;
257
+ readonly incoming: AnyServiceToken;
258
+ constructor(existing: AnyServiceToken, incoming: AnyServiceToken);
259
+ }
260
+ /** Thrown when a backend fails while registering a Layer provider. */
261
+ declare class LayerRegistrationError extends Error {
262
+ readonly service: ServiceClass<any> | undefined;
263
+ readonly registrationCause: LayerCause;
264
+ readonly cleanupCause?: LayerCause | undefined;
265
+ constructor(service: ServiceClass<any> | undefined, registrationCause: LayerCause, cleanupCause?: LayerCause | undefined);
266
+ }
267
+ /** Thrown when one or more Layer-owned resources fail during disposal. */
268
+ declare class LayerDisposeError extends Error {
269
+ readonly causes: readonly unknown[];
270
+ constructor(causes: readonly unknown[]);
271
+ }
272
+ /** Thrown when a Layer generator yields a value other than a Service requirement. */
273
+ declare class LayerGeneratorYieldError extends Error {
274
+ readonly service: ServiceClass<any>;
275
+ constructor(service: ServiceClass<any>);
276
+ }
277
+ //#endregion
278
+ //#region src/runtime/outcome.d.ts
279
+ /** Aggregated cleanup information reported during Runtime shutdown. */
280
+ type RuntimeShutdownDiagnostic = {
281
+ /** Final outcome supplied to the Runtime root Scope. */
282
+ readonly outcome: ScopeOutcome;
283
+ /** Aggregated root-Scope and backend cleanup failure. */
284
+ readonly error: LayerDisposeError;
285
+ };
286
+ /** Observer notified about cleanup failures without changing primary results. */
287
+ type CleanupFailureObserver = (diagnostic: CleanupFailureDiagnostic | RuntimeShutdownDiagnostic) => MaybePromise<void>;
288
+ /** Optional Runtime configuration for cleanup diagnostics. */
289
+ type RuntimeOptions = {
290
+ /** Backend used to register and resolve the Layer. Defaults to MapLayerBackend. */
291
+ readonly backend?: LayerBackend;
292
+ /** Optional observer for best-effort cleanup diagnostics. */
293
+ readonly onCleanupFailure?: CleanupFailureObserver;
294
+ };
295
+ //#endregion
296
+ export { ScopeRuntimeNotConfiguredError as S, ScopeFinalizer as _, LayerDisposeError as a, ScopeCloseError as b, ServiceTagCollisionError as c, CompleteInput as d, LayerInput as f, MaybePromise as g, DisposableResource as h, DuplicateServiceError as i, Layer as l, CleanupFailureDiagnostic as m, RuntimeOptions as n, LayerGeneratorYieldError as o, ProvidedEnvironment as p, RuntimeShutdownDiagnostic as r, LayerRegistrationError as s, CleanupFailureObserver as t, CompleteExecution as u, ScopeOutcome as v, ScopeClosedError as x, ResourceNotDisposableError as y };
297
+ //# sourceMappingURL=index-R3FdVmdr.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-R3FdVmdr.d.mts","names":[],"sources":["../src/scope/errors.ts","../src/scope/types.ts","../src/internal/variance.ts","../src/internal/missing-dependencies.ts","../src/layer/metadata.ts","../src/layer/inference.ts","../src/layer/layer.ts","../src/layer/errors.ts","../src/runtime/outcome.ts"],"mappings":";;;cACa,uCAAuC;EAAA;;;cASvC,yBAAyB;EAAA;;;cASzB,wBAAwB;WACd;EAAA,YAAA;;;cAUV,mCAAmC;EAAA;;;;;KC3BpC,aAAa,KAAK,IAAI,YAAY;;KAGlC;;WAGG;;;WAIA;;WAEA;;;KAIH,kBAAkB,SAAS,iBAAiB;;KAG5C;;WAED,SAAS;;WAET,OAAO;;KAGb;GACF,OAAO;GAEP,OAAO,sBAAsB;;KAG3B;GACF,OAAO;GAEP,OAAO,qBAAqB;;;KAInB,qBAAqB,yBAAyB;;;;KCzC9C,UAAU,WAAW;;KAGrB,UAAU,MAAM,OAAO,MAAM;;;cCF3B;KAEF,oBAAoB,gBAAgB;YACpC,4BAA4B;;;;;cCAnB;UAEJ,kBACX,iBAAiB,gBACjB,oBAAoB;WAEf,UAAU;WACV,UAAU;;UAGJ,qBACX,iBAAiB,gBACjB,uBAAuB;WAElB,UAAU;WACV,gBAAgB;;UAGV,oBACX,g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