better-effect 0.11.0 → 0.12.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/README.md +220 -6
- package/dist/adapters/iti.d.mts +2 -1
- package/dist/adapters/iti.d.mts.map +1 -1
- package/dist/adapters/iti.mjs +11 -10
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/{effect-2ZcGZI8A.mjs → effect-CK4YZaX0.mjs} +56 -10
- package/dist/effect-CK4YZaX0.mjs.map +1 -0
- package/dist/hono.d.mts +3 -3
- package/dist/hono.mjs +3 -3
- package/dist/{index-DStz0JMN.d.mts → index-B1nH4luq.d.mts} +73 -6
- package/dist/index-B1nH4luq.d.mts.map +1 -0
- package/dist/index-BMdU_Z72.d.mts +18 -0
- package/dist/index-BMdU_Z72.d.mts.map +1 -0
- package/dist/{index-C7Qild0_.d.mts → index-CX6iAoCB.d.mts} +15 -151
- package/dist/index-CX6iAoCB.d.mts.map +1 -0
- package/dist/index-GYJ4qm9K.d.mts +179 -0
- package/dist/index-GYJ4qm9K.d.mts.map +1 -0
- package/dist/index-heuaRmXR.d.mts.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{internal-identity-DmUpBeeL.mjs → internal-identity-CbXoZIfw.mjs} +3 -3
- package/dist/internal-identity-CbXoZIfw.mjs.map +1 -0
- package/dist/{signal-B97cs85Z.mjs → layer-D56fRdLt.mjs} +30 -111
- package/dist/layer-D56fRdLt.mjs.map +1 -0
- package/dist/node-context-DWsCUBRa.d.mts +12 -0
- package/dist/node-context-DWsCUBRa.d.mts.map +1 -0
- package/dist/node-context-lggRF4bR.mjs +25 -0
- package/dist/node-context-lggRF4bR.mjs.map +1 -0
- package/dist/node.d.mts +51 -0
- package/dist/node.d.mts.map +1 -0
- package/dist/node.mjs +233 -0
- package/dist/node.mjs.map +1 -0
- package/dist/{index-rQhZk3Nt.d.mts → outcome-CB43bnFW.d.mts} +29 -19
- package/dist/outcome-CB43bnFW.d.mts.map +1 -0
- package/dist/{scope-GGnmTQck.mjs → program-metadata-DhQCCirO.mjs} +18 -3
- package/dist/program-metadata-DhQCCirO.mjs.map +1 -0
- package/dist/registration-drnZk0SY.mjs +182 -0
- package/dist/registration-drnZk0SY.mjs.map +1 -0
- package/dist/runtime/node.d.mts +2 -11
- package/dist/runtime/node.mjs +2 -24
- package/dist/{runtime-DnMn0X0X.mjs → runtime-CBMrX8Wl.mjs} +210 -47
- package/dist/runtime-CBMrX8Wl.mjs.map +1 -0
- package/dist/signal-D2UTcaaG.mjs +105 -0
- package/dist/signal-D2UTcaaG.mjs.map +1 -0
- package/dist/{standard-services-BFBq-4lo.mjs → standard-services-GBZ32tll.mjs} +200 -16
- package/dist/standard-services-GBZ32tll.mjs.map +1 -0
- package/dist/standard-services.d.mts +3 -3
- package/dist/standard-services.mjs +3 -3
- package/dist/testing.d.mts +65 -6
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +191 -8
- package/dist/testing.mjs.map +1 -1
- package/package.json +8 -3
- package/dist/effect-2ZcGZI8A.mjs.map +0 -1
- package/dist/errors-Dnjhzbt0.mjs +0 -99
- package/dist/errors-Dnjhzbt0.mjs.map +0 -1
- package/dist/index-C7Qild0_.d.mts.map +0 -1
- package/dist/index-DStz0JMN.d.mts.map +0 -1
- package/dist/index-rQhZk3Nt.d.mts.map +0 -1
- package/dist/internal-identity-DmUpBeeL.mjs.map +0 -1
- package/dist/runtime/node.d.mts.map +0 -1
- package/dist/runtime/node.mjs.map +0 -1
- package/dist/runtime-DnMn0X0X.mjs.map +0 -1
- package/dist/scope-GGnmTQck.mjs.map +0 -1
- package/dist/signal-B97cs85Z.mjs.map +0 -1
- package/dist/standard-services-BFBq-4lo.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effect-2ZcGZI8A.mjs","names":["map","mapError","andThen","next","resultMatchError","resultMatchErrorPartial","tap","tapError","matchError","matchErrorPartial","recover","programMap","programMapError","programAndThen","programTap","programTapError","programRecover"],"sources":["../src/effect/combinators.ts","../src/effect/program-combinators.ts","../src/effect/program-scheduler.ts","../src/effect/effect.ts"],"sourcesContent":["import {\n matchError as resultMatchError,\n matchErrorPartial as resultMatchErrorPartial,\n Result\n} 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 TapAsyncOperation = {\n <Input>(effect: Input & AnyEffectInput): Promise<TappedResult<Input>>\n}\n\ntype TapErrorAsyncOperation = {\n <Input>(effect: Input & AnyEffectInput): Promise<TappedResult<Input>>\n}\n\ntype TapBothAsyncOperation = {\n <Input>(effect: Input & AnyEffectInput): Promise<TappedResult<Input>>\n}\n\ntype TaggedErrorLike = Error & { readonly _tag: string }\n\ntype TaggedErrorHandlers<ErrorValue extends TaggedErrorLike> = {\n // oxlint-disable-next-line anti-slop/no-unknown-returns -- better-result matchers allow arbitrary handler results.\n [Tag in ErrorValue['_tag']]: (error: Extract<ErrorValue, { readonly _tag: Tag }>) => unknown\n}\n\ntype TaggedErrorOf<Input> = Extract<EffectError<Input>, TaggedErrorLike>\n\ntype TaggedErrorHandlersFor<Input> = [EffectError<Input>] extends [TaggedErrorLike]\n ? TaggedErrorHandlers<TaggedErrorOf<Input>>\n : never\n\ntype HandlerReturn<Handlers> = {\n [Key in keyof Handlers]-?: NonNullable<Handlers[Key]> extends (error: never) => infer Return\n ? Return\n : never\n}[keyof Handlers]\n\ntype RequiredHandlerKeys<Handlers> = {\n [Key in keyof Handlers]-?: {} extends Pick<Handlers, Key>\n ? never\n : undefined extends Handlers[Key]\n ? never\n : Key\n}[keyof Handlers]\n\ntype UnhandledTaggedErrors<ErrorValue extends TaggedErrorLike, Handlers> = Exclude<\n ErrorValue,\n { readonly _tag: Extract<RequiredHandlerKeys<Handlers>, ErrorValue['_tag']> }\n>\n\ntype MatchErrorResult<Input, Handlers> = Effect<\n EffectSuccess<Input>,\n HandlerReturn<Handlers>,\n EffectRequirements<Input>\n>\n\ntype MatchErrorPartialResult<Input, Handlers> = Effect<\n EffectSuccess<Input>,\n HandlerReturn<Handlers> | UnhandledTaggedErrors<TaggedErrorOf<Input>, Handlers>,\n EffectRequirements<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 tapAsyncResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (value: A) => PromiseLike<void>\n): Promise<Effect<A, E, Requirements>> =>\n // SAFETY: Result.tapAsync preserves the Result value and owns observer defect behavior; only the Effect marker is restored here.\n Result.tapAsync(result, (value) => Promise.resolve(fn(value))) as Promise<\n Effect<A, E, Requirements>\n >\n\nconst tapErrorAsyncResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n fn: (error: E) => PromiseLike<void>\n): Promise<Effect<A, E, Requirements>> =>\n // SAFETY: Result.tapErrorAsync preserves the Result value and owns observer defect behavior; only the Effect marker is restored here.\n Result.tapErrorAsync(result, (error) => Promise.resolve(fn(error))) as Promise<\n Effect<A, E, Requirements>\n >\n\nconst tapBothAsyncResult = <A, E, Requirements extends AnyService>(\n result: ResultType<A, E>,\n handlers: { ok: (value: A) => PromiseLike<void>; err: (error: E) => PromiseLike<void> }\n): Promise<Effect<A, E, Requirements>> =>\n // SAFETY: Result.tapBothAsync selects one branch and preserves the Result; only the Effect marker is restored here.\n Result.tapBothAsync(result, {\n ok: (value) => Promise.resolve(handlers.ok(value)),\n err: (error) => Promise.resolve(handlers.err(error))\n }) as Promise<Effect<A, E, Requirements>>\n\nconst asTaggedResult = (\n result: ResultType<unknown, unknown>\n): ResultType<unknown, TaggedErrorLike> => {\n // SAFETY: The public matcher overload restricts error values to TaggedErrorLike before reaching this runtime boundary.\n return result as ResultType<unknown, TaggedErrorLike>\n}\n\nconst matchErrorResult = <\n A,\n E extends TaggedErrorLike,\n Requirements extends AnyService,\n Handlers extends TaggedErrorHandlers<E>\n>(\n result: ResultType<A, E>,\n handlers: Handlers\n): Effect<A, HandlerReturn<Handlers>, Requirements> => {\n // SAFETY: Result.mapError selects Err and preserves Ok; the declaration-only Effect marker is restored here.\n return Result.mapError(result, (error) => resultMatchError(error, handlers)) as Effect<\n A,\n HandlerReturn<Handlers>,\n Requirements\n >\n}\n\nconst matchErrorPartialResult = <\n A,\n E extends TaggedErrorLike,\n Requirements extends AnyService,\n Handlers extends Partial<TaggedErrorHandlers<E>>\n>(\n result: ResultType<A, E>,\n handlers: Handlers\n): Effect<A, HandlerReturn<Handlers> | UnhandledTaggedErrors<E, Handlers>, Requirements> => {\n // SAFETY: Result.mapError selects Err and preserves Ok; the declaration-only Effect marker is restored here.\n return Result.mapError(result, (error) => resultMatchErrorPartial(error, handlers)) as Effect<\n A,\n HandlerReturn<Handlers> | UnhandledTaggedErrors<E, Handlers>,\n Requirements\n >\n}\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/** Observe a successful value asynchronously without changing the Result. */\nexport function tapAsync(fn: (value: any) => PromiseLike<void>): TapAsyncOperation\nexport function tapAsync<Input>(\n effect: Input & AnyEffectInput,\n fn: (value: EffectSuccess<Input>) => PromiseLike<void>\n): Promise<TappedResult<Input>>\nexport function tapAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tapAsync(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tapAsync requires a callback')\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapAsyncResult(asResult(result), second))\n }\n\n return tapAsyncResult(asResult(first), second)\n}\n\n/** Observe an error value asynchronously without changing the Result. */\nexport function tapErrorAsync(fn: (error: any) => PromiseLike<void>): TapErrorAsyncOperation\nexport function tapErrorAsync<Input>(\n effect: Input & AnyEffectInput,\n fn: (error: EffectError<Input>) => PromiseLike<void>\n): Promise<TappedResult<Input>>\nexport function tapErrorAsync(first: CombinatorInput, second?: CombinatorCallback): any {\n if (first instanceof Function && second === undefined) {\n const callback = first\n return (effect: AnyEffectInput) => tapErrorAsync(effect, callback)\n }\n\n if (second === undefined) {\n throw new TypeError('Effect.tapErrorAsync requires a callback')\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapErrorAsyncResult(asResult(result), second))\n }\n\n return tapErrorAsyncResult(asResult(first), second)\n}\n\n/** Observe the active Result branch asynchronously without changing the Result. */\nexport function tapBothAsync(handlers: {\n ok: (value: any) => PromiseLike<void>\n err: (error: any) => PromiseLike<void>\n}): TapBothAsyncOperation\nexport function tapBothAsync<Input>(\n effect: Input & AnyEffectInput,\n handlers: {\n ok: (value: EffectSuccess<Input>) => PromiseLike<void>\n err: (error: EffectError<Input>) => PromiseLike<void>\n }\n): Promise<TappedResult<Input>>\nexport function tapBothAsync(first: any, second?: any): any {\n if (second === undefined) {\n return (effect: AnyEffectInput) => tapBothAsync(effect, first)\n }\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) => tapBothAsyncResult(result, second))\n }\n\n return tapBothAsyncResult(asResult(first), second)\n}\n\n/** Match every tagged error variant and map it to a new error value. */\nexport function matchError<Input, Handlers extends TaggedErrorHandlersFor<Input>>(\n effect: Input & AnyEffectInput,\n handlers: Handlers\n): PreserveAsync<Input, MatchErrorResult<Input, Handlers>>\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- overload implementation is narrowed by the typed public signature.\nexport function matchError(first: AnyEffectInput, second?: unknown): any {\n if (second === undefined) {\n throw new TypeError('Effect.matchError requires handlers')\n }\n\n // SAFETY: The public matcher overload checks the handler map against the source tagged-error union.\n const handlers = second as TaggedErrorHandlers<TaggedErrorLike>\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) =>\n matchErrorResult(asTaggedResult(asResult(result)), handlers)\n )\n }\n\n return matchErrorResult(asTaggedResult(asResult(first)), handlers)\n}\n\n/** Match selected tagged errors and retain unhandled variants unchanged. */\nexport function matchErrorPartial<Input, Handlers extends Partial<TaggedErrorHandlersFor<Input>>>(\n effect: Input & AnyEffectInput,\n handlers: Handlers\n): PreserveAsync<Input, MatchErrorPartialResult<Input, Handlers>>\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- overload implementation is narrowed by the typed public signature.\nexport function matchErrorPartial(first: AnyEffectInput, second?: unknown): any {\n if (second === undefined) {\n throw new TypeError('Effect.matchErrorPartial requires handlers')\n }\n\n // SAFETY: The public matcher overload checks the handler map against the source tagged-error union.\n const handlers = second as Partial<TaggedErrorHandlers<TaggedErrorLike>>\n\n if (isPromiseLike(first)) {\n return Promise.resolve(first).then((result) =>\n matchErrorPartialResult(asTaggedResult(asResult(result)), handlers)\n )\n }\n\n return matchErrorPartialResult(asTaggedResult(asResult(first)), handlers)\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 { Result as ResultType } from 'better-result'\n\nimport type { AnyService } from '../service'\nimport { isPromiseLike } from '../utils/runtime'\n\nimport type { EffectError, EffectRequirements, EffectSuccess, Program } from './types'\n\ntype AnyResult = ResultType<any, any>\ntype RuntimeEffect = AnyResult | PromiseLike<AnyResult>\ntype RuntimeProgram = () => RuntimeEffect\ntype RuntimeProgramOutput = RuntimeEffect | RuntimeProgram\ntype RuntimeCallback = (value: any) => any\ntype RuntimeContinuation = (value: any) => RuntimeProgramOutput\ntype AnyProgram = Program<any, any, AnyService>\n\ntype ProgramInput<Input extends RuntimeProgram> = Input &\n Program<EffectSuccess<Input>, EffectError<Input>, EffectRequirements<Input>>\n\ntype CompatibleSuccess<Input, A> = EffectSuccess<Input> extends A ? unknown : never\ntype CompatibleError<Input, E> = EffectError<Input> extends E ? unknown : never\n\ntype ProgramOutput<Output> =\n Output extends Program<infer _Success, infer _Error, infer _Requirements extends AnyService>\n ? Output\n : Output extends PromiseLike<infer AsyncOutput>\n ? AsyncOutput extends ResultType<infer _Success, infer _Error>\n ? Output\n : never\n : Output extends ResultType<infer _Success, infer _Error>\n ? Output\n : never\n\ntype MappedProgram<Input, B> = Program<B, EffectError<Input>, EffectRequirements<Input>>\n\ntype ErrorMappedProgram<Input, E2> = Program<EffectSuccess<Input>, E2, EffectRequirements<Input>>\n\ntype ChainedProgram<Input, Next> = Program<\n EffectSuccess<Next>,\n EffectError<Input> | EffectError<Next>,\n EffectRequirements<Input> | EffectRequirements<Next>\n>\n\ntype TappedProgram<Input> = Program<\n EffectSuccess<Input>,\n EffectError<Input>,\n EffectRequirements<Input>\n>\n\ntype RecoveredProgram<Input, Next> = Program<\n EffectSuccess<Input> | EffectSuccess<Next>,\n EffectError<Next>,\n EffectRequirements<Input> | EffectRequirements<Next>\n>\n\ntype MapOperation<A, B> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleSuccess<Input, A>\n ): MappedProgram<Input, B>\n}\n\ntype MapErrorOperation<E1, E2> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleError<Input, E1>\n ): ErrorMappedProgram<Input, E2>\n}\n\ntype AndThenOperation<A, Next> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleSuccess<Input, A>\n ): ChainedProgram<Input, Next>\n}\n\ntype TapOperation<A> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleSuccess<Input, A>\n ): TappedProgram<Input>\n}\n\ntype TapErrorOperation<E> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleError<Input, E>\n ): TappedProgram<Input>\n}\n\ntype RecoverOperation<E, Next> = {\n <Input extends RuntimeProgram>(\n program: ProgramInput<Input> & CompatibleError<Input, E>\n ): RecoveredProgram<Input, Next>\n}\n\nconst asProgram = <Output extends AnyProgram>(program: RuntimeProgram): Output =>\n // SAFETY: Program's channels and nominal marker are declaration-only; callers derive them from typed inputs.\n program as Output\n\nconst isAsyncEffect = (effect: RuntimeEffect): effect is PromiseLike<AnyResult> =>\n isPromiseLike(effect)\n\nconst mapRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.map(result, fn))\n }\n\n return Result.map(effect, fn)\n}\n\nconst mapErrorRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.mapError(result, fn))\n }\n\n return Result.mapError(effect, fn)\n}\n\nconst tapRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.tap(result, fn))\n }\n\n return Result.tap(effect, fn)\n}\n\nconst tapErrorRuntime = (effect: RuntimeEffect, fn: RuntimeCallback): RuntimeEffect => {\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.tapError(result, fn))\n }\n\n return Result.tapError(effect, fn)\n}\n\nconst invoke = (output: RuntimeProgramOutput): RuntimeEffect =>\n output instanceof Function ? output() : output\n\nconst andThenRuntime = (effect: RuntimeEffect, next: RuntimeContinuation): Promise<AnyResult> => {\n const continueWith = (value: any) => Promise.resolve(invoke(next(value)))\n\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.andThenAsync(result, continueWith))\n }\n\n return Result.andThenAsync(effect, continueWith)\n}\n\nconst recoverRuntime = (\n effect: RuntimeEffect,\n recover: RuntimeContinuation\n): Promise<AnyResult> => {\n const continueWith = (error: any) => Promise.resolve(invoke(recover(error)))\n\n if (isAsyncEffect(effect)) {\n return Promise.resolve(effect).then((result) => Result.tryRecoverAsync(result, continueWith))\n }\n\n return Result.tryRecoverAsync(effect, continueWith)\n}\n\nconst mapProgram = <Input extends RuntimeProgram, B>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => B\n): MappedProgram<Input, B> => asProgram<MappedProgram<Input, B>>(() => mapRuntime(program(), fn))\n\nconst mapErrorProgram = <Input extends RuntimeProgram, E2>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => E2\n): ErrorMappedProgram<Input, E2> =>\n asProgram<ErrorMappedProgram<Input, E2>>(() => mapErrorRuntime(program(), fn))\n\nconst tapProgram = <Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => any\n): TappedProgram<Input> => asProgram<TappedProgram<Input>>(() => tapRuntime(program(), fn))\n\nconst tapErrorProgram = <Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => any\n): TappedProgram<Input> => asProgram<TappedProgram<Input>>(() => tapErrorRuntime(program(), fn))\n\n/** Lazily map the successful Result value of a Program. */\nexport function map<A, B>(fn: (value: A) => B): MapOperation<A, B>\nexport function map<Input extends RuntimeProgram, B>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => B\n): MappedProgram<Input, B>\nexport function map(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its success channel.\n return mapProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return mapProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily map the error Result value of a Program. */\nexport function mapError<E1, E2>(fn: (error: E1) => E2): MapErrorOperation<E1, E2>\nexport function mapError<Input extends RuntimeProgram, E2>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => E2\n): ErrorMappedProgram<Input, E2>\nexport function mapError(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its error channel.\n return mapErrorProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return mapErrorProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily continue a successful Program with an Effect or Program. */\nexport function andThen<A, Next>(\n next: (value: A) => Next & ProgramOutput<Next>\n): AndThenOperation<A, Next>\nexport function andThen<Input extends RuntimeProgram, Next>(\n program: ProgramInput<Input>,\n next: (value: EffectSuccess<Input>) => Next & ProgramOutput<Next>\n): ChainedProgram<Input, Next>\nexport function andThen(\n first: RuntimeProgram | RuntimeContinuation,\n second?: RuntimeContinuation\n): any {\n if (second === undefined) {\n return (program: RuntimeProgram) =>\n // SAFETY: The curried overload supplies a Program and a continuation for its success channel.\n () =>\n andThenRuntime(program(), first as RuntimeContinuation)\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return () => andThenRuntime((first as RuntimeProgram)(), second)\n}\n\n/** Lazily observe a successful Program value without changing its Result. */\nexport function tap<A>(fn: (value: A) => void): TapOperation<A>\nexport function tap<Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (value: EffectSuccess<Input>) => void\n): TappedProgram<Input>\nexport function tap(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its success channel.\n return tapProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return tapProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily observe a failed Program value without changing its Result. */\nexport function tapError<E>(fn: (error: E) => void): TapErrorOperation<E>\nexport function tapError<Input extends RuntimeProgram>(\n program: ProgramInput<Input>,\n fn: (error: EffectError<Input>) => void\n): TappedProgram<Input>\nexport function tapError(first: RuntimeProgram | RuntimeCallback, second?: RuntimeCallback): any {\n if (second === undefined) {\n return (program: RuntimeProgram) => {\n // SAFETY: The curried overload supplies a Program and a callback that accepts its error channel.\n return tapErrorProgram(program as ProgramInput<typeof program>, first)\n }\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return tapErrorProgram(first as ProgramInput<RuntimeProgram>, second)\n}\n\n/** Lazily recover a failed Program with an Effect or Program. */\nexport function recover<E, Next>(\n fn: (error: E) => Next & ProgramOutput<Next>\n): RecoverOperation<E, Next>\nexport function recover<Input extends RuntimeProgram, Next>(\n program: ProgramInput<Input>,\n recover: (error: EffectError<Input>) => Next & ProgramOutput<Next>\n): RecoveredProgram<Input, Next>\nexport function recover(\n first: RuntimeProgram | RuntimeContinuation,\n second?: RuntimeContinuation\n): any {\n if (second === undefined) {\n return (program: RuntimeProgram) =>\n // SAFETY: The curried overload supplies a Program and a recovery callback for its error channel.\n () =>\n recoverRuntime(program(), first as RuntimeContinuation)\n }\n\n // SAFETY: The data-first overload supplies a Program as its first argument.\n return () => recoverRuntime((first as RuntimeProgram)(), second)\n}\n","import { Err } from 'better-result'\n\nimport type { Result as ResultType } from 'better-result'\n\ntype AnyResult = ResultType<any, any>\n\ntype ProgramCollectionFailure =\n | { readonly kind: 'result'; readonly result: AnyResult }\n | { readonly kind: 'defect'; readonly cause: unknown }\n\ntype ProgramCollectionDefect = { readonly cause: unknown }\n\ntype ProgramCollectionOutcome = {\n readonly results: Array<AnyResult | undefined>\n readonly defects: Array<ProgramCollectionDefect | undefined>\n}\n\nexport type ProgramCollectionOptions = {\n readonly concurrency: number | undefined\n readonly stopOnResultError: boolean\n}\n\ntype ProgramTask = (index: number) => AnyResult | PromiseLike<AnyResult>\n\ntype SchedulerState = {\n nextIndex: number\n stopScheduling: boolean\n readonly results: Array<AnyResult | undefined>\n readonly defects: Array<ProgramCollectionDefect | undefined>\n}\n\n/** Validate the shared bounded-concurrency option before a Program is run. */\nexport const 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\nconst runWorker = async (\n length: number,\n task: ProgramTask,\n stopOnResultError: boolean,\n state: SchedulerState\n): Promise<void> => {\n while (!state.stopScheduling) {\n const index = state.nextIndex++\n\n if (index >= length) {\n return\n }\n\n try {\n const result = await task(index)\n state.results[index] = result\n\n if (result instanceof Err) {\n state.stopScheduling ||= stopOnResultError\n }\n } catch (cause) {\n state.defects[index] = { cause }\n state.stopScheduling = true\n }\n }\n}\n\n/** Run claimed Programs with a shared FIFO worker pool and no cancellation. */\nexport const runProgramCollection = async (\n length: number,\n task: ProgramTask,\n options: ProgramCollectionOptions\n): Promise<ProgramCollectionOutcome> => {\n const state: SchedulerState = {\n nextIndex: 0,\n stopScheduling: false,\n results: Array.from({ length }),\n defects: Array.from({ length })\n }\n const workerCount = Math.min(options.concurrency ?? length, length)\n const workers = Array.from({ length: workerCount }, () =>\n runWorker(length, task, options.stopOnResultError, state)\n )\n\n await Promise.all(workers)\n\n return state\n}\n\n/** Select the first defect by input index, independent of settlement order. */\nexport const firstProgramDefect = (\n defects: readonly (ProgramCollectionDefect | undefined)[]\n): ProgramCollectionDefect | undefined => {\n for (const defect of defects) {\n if (defect !== undefined) {\n return defect\n }\n }\n\n return undefined\n}\n\n/** Select the first short-circuiting failure by input index. */\nexport const firstProgramFailure = (\n results: readonly (AnyResult | undefined)[],\n defects: readonly (ProgramCollectionDefect | undefined)[]\n): ProgramCollectionFailure | undefined => {\n const length = Math.max(results.length, defects.length)\n\n for (let index = 0; index < length; index++) {\n const defect = defects[index]\n if (defect !== undefined) {\n return { kind: 'defect', cause: defect.cause }\n }\n\n const result = results[index]\n if (result instanceof Err) {\n return { kind: 'result', result }\n }\n }\n\n return undefined\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 matchError,\n matchErrorPartial,\n recover,\n recoverAsync,\n tap,\n tapAsync,\n tapBoth,\n tapBothAsync,\n tapError,\n tapErrorAsync,\n zip\n} from './combinators'\nimport {\n andThen as programAndThen,\n map as programMap,\n mapError as programMapError,\n recover as programRecover,\n tap as programTap,\n tapError as programTapError\n} from './program-combinators'\nimport {\n firstProgramDefect,\n firstProgramFailure,\n runProgramCollection,\n validateProgramConcurrency\n} from './program-scheduler'\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\ntype ProgramResultFor<Child> = Child extends AnyProgram\n ? ResultType<EffectSuccess<Child>, EffectError<Child>>\n : never\n\ntype ProgramAllResultsSuccess<Programs extends readonly AnyProgram[]> =\n number extends Programs['length']\n ? ReadonlyArray<ResultType<EffectSuccess<Programs[number]>, EffectError<Programs[number]>>>\n : { readonly [Index in keyof Programs]: ProgramResultFor<Programs[Index]> }\n\ntype ProgramAllResultsResult<Programs extends readonly AnyProgram[]> = ProgramType<\n ProgramAllResultsSuccess<Programs>,\n never,\n ProgramAllRequirements<Programs>\n>\n\ntype ProgramForEachResult<Child extends AnyProgram> = ProgramType<\n ReadonlyArray<EffectSuccess<Child>>,\n EffectError<Child>,\n EffectRequirements<Child>\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 runShortCircuitingCollection = async (\n length: number,\n task: (index: number) => AnyResult | PromiseLike<AnyResult>,\n concurrency: number | undefined\n): Promise<AnyResult> => {\n const outcome = await runProgramCollection(length, task, {\n concurrency,\n stopOnResultError: true\n })\n const failure = firstProgramFailure(outcome.results, outcome.defects)\n\n if (failure?.kind === 'defect') {\n throw failure.cause\n }\n\n if (failure?.kind === 'result') {\n return failure.result\n }\n\n // SAFETY: The scheduler records one Result per claimed index before completing successfully.\n return Result.all(outcome.results as AnyResult[])\n}\n\nconst runAllResultsCollection = async (\n length: number,\n task: (index: number) => AnyResult | PromiseLike<AnyResult>,\n concurrency: number | undefined\n): Promise<AnyResult> => {\n const outcome = await runProgramCollection(length, task, {\n concurrency,\n stopOnResultError: false\n })\n const defect = firstProgramDefect(outcome.defects)\n\n if (defect !== undefined) {\n throw defect.cause\n }\n\n // SAFETY: The scheduler records each Result object at its input index.\n return Result.ok(outcome.results as AnyResult[])\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 const concurrency = options.concurrency\n validateProgramConcurrency(concurrency)\n const program = () =>\n runShortCircuitingCollection(programs.length, (index) => programs[index]!(), concurrency)\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/** Build a lazy Program collection from an input array and Program factory. */\nexport function programForEach<const Items extends readonly unknown[], Child extends AnyProgram>(\n items: Items,\n makeProgram: (item: Items[number], index: number) => Child,\n options: ProgramAllOptions = {}\n): ProgramForEachResult<Child> {\n const concurrency = options.concurrency\n validateProgramConcurrency(concurrency)\n const program = () =>\n runShortCircuitingCollection(\n items.length,\n (index) => makeProgram(items[index]!, index)(),\n concurrency\n )\n\n // SAFETY: Program channels are declaration-only and are restored from the factory's result type.\n return program as ProgramForEachResult<Child>\n}\n\n/** Build a lazy Program collection that retains every child Result. */\nexport function programAllResults<const Programs extends readonly AnyProgram[]>(\n programs: Programs,\n options: ProgramAllOptions = {}\n): ProgramAllResultsResult<Programs> {\n const concurrency = options.concurrency\n validateProgramConcurrency(concurrency)\n const program = () =>\n runAllResultsCollection(programs.length, (index) => programs[index]!(), concurrency)\n\n // SAFETY: Program channels are declaration-only and are restored from the input tuple here.\n return program as ProgramAllResultsResult<Programs>\n}\n\n/** Value-level namespace for lazy Program combinators. */\nexport const Program = {\n all: programAll,\n forEach: programForEach,\n allResults: programAllResults,\n map: programMap,\n mapError: programMapError,\n andThen: programAndThen,\n tap: programTap,\n tapError: programTapError,\n recover: programRecover\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\nclass AcquireReleaseResultFailure<R, E> {\n constructor(readonly result: Err<R, E>) {}\n}\n\n/**\n * Acquire a Result-valued resource and register only successful acquisitions.\n *\n * Typed acquisition failures remain unchanged in the Effect error channel;\n * unexpected acquisition and registration failures are normalized by\n * `better-result`. Release failures remain Scope cleanup failures.\n */\nexport function acquireReleaseResult<R, E>(\n acquire: () => MaybePromise<ResultType<R, E>>,\n release: (resource: R, outcome: ScopeOutcome) => MaybePromise<void>\n): AsyncGenerator<Err<never, E | UnhandledException>, R, unknown> {\n const scope = Scope.current()\n const registered = Result.tryPromise(async (): Promise<ResultType<R, E>> => {\n try {\n const resource = await scope.acquire(async () => {\n const result = await acquire()\n\n if (Result.isError(result)) {\n throw new AcquireReleaseResultFailure(result)\n }\n\n return result.value\n }, release)\n\n return Result.ok(resource)\n } catch (cause) {\n if (cause instanceof AcquireReleaseResultFailure) {\n return cause.result\n }\n\n throw cause\n }\n })\n\n return Result.await(registered.then((result) => result.andThen((acquired) => acquired)))\n}\n\n/**\n * Lazily acquire and register a disposable resource in the current Scope.\n *\n * Disposal is delegated to `Scope.add`, including protocol preference,\n * validation, race-safe registration, and cleanup error handling.\n */\nexport function acquireDisposable<R extends DisposableResource>(\n acquire: () => MaybePromise<R>\n): AsyncGenerator<Err<never, UnhandledException>, R, unknown> {\n const scope = Scope.current()\n\n return Result.await(Result.tryPromise(async () => scope.add(await acquire())))\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 acquireReleaseResult: typeof acquireReleaseResult\n readonly acquireDisposable: typeof acquireDisposable\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 tapAsync: typeof tapAsync\n readonly tapError: typeof tapError\n readonly tapErrorAsync: typeof tapErrorAsync\n readonly tapBoth: typeof tapBoth\n readonly tapBothAsync: typeof tapBothAsync\n readonly matchError: typeof matchError\n readonly matchErrorPartial: typeof matchErrorPartial\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 /** Acquire a Result-valued resource and register successful acquisitions. */\n acquireReleaseResult,\n /** Acquire and register a disposable resource in the current Scope. */\n acquireDisposable,\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 successful values asynchronously without changing the Result. */\n tapAsync,\n /** Observe error values without changing the Result. */\n tapError,\n /** Observe error values asynchronously without changing the Result. */\n tapErrorAsync,\n /** Observe the active Result branch without changing the Result. */\n tapBoth,\n /** Observe the active Result branch asynchronously without changing the Result. */\n tapBothAsync,\n /** Match every tagged error variant and map it to a new error value. */\n matchError,\n /** Match selected tagged errors and retain unhandled variants. */\n matchErrorPartial,\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":";;;;AAwLA,MAAM,YAAmB,UAAuC;CAE9D,OAAO;AACT;AAEA,MAAM,aACJ,QACA,OAC+B;CAE/B,OAAO,OAAO,IAAI,QAAQ,EAAE;AAC9B;AAEA,MAAM,kBACJ,QACA,OACgC;CAEhC,OAAO,OAAO,SAAS,QAAQ,EAAE;AACnC;AAEA,MAAM,iBAQJ,QACA,SACsD;CAEtD,MAAM,aAAa;CAGnB,OAAO,OAAO,QAAQ,QAAQ,UAAU;AAC1C;AAEA,MAAM,sBAQJ,QACA,SAC+D;CAE/D,MAAM,cAAc,UAAa;EAE/B,OAAO,QAAQ,QAAQ,KAAK,KAAK,CAAC;CACpC;CAGA,OAAO,OAAO,aAAa,QAAQ,UAAU;AAG/C;AAmBA,SAAgBA,MAAI,OAAwB,QAAkC;CAC5E,IAAI,iBAAiB,YAAY,WAAW,KAAA,GAAW;EAErD,MAAM,WAAW;EAEjB,QAAQ,WAA2B;GAEjC,OAAOA,MAAI,QAAiB,QAAiB;EAC/C;CACF;CAGA,MAAM,KAAK;CAEX,IAAI,cAAc,KAAK,GACrB,OAAO,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAAM,WAAW;EAE7C,OAAO,UAAU,QAAgC,EAAE;CACrD,CAAC;CAIH,OAAO,UAAU,OAA+B,EAAE;AACpD;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UAC4D;CAC5D,MAAM,QAAQ,MAAM,QAAQ;CAE5B,OAAO,OAAO,MAAM,OAAO,iBAAiB,MAAM,IAAI,QAAQ,CAAC,CAAC;AAClE;AAqCA,MAAa,SAA0B;;CAErC;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA,KAAA;;CAEA,UAAA;;CAEA,SAAA;;CAEA;;CAEA,KAAA;;CAEA;;CAEA,UAAA;;CAEA;;CAEA;;CAEA;;CAEA,YAAA;;CAEA,mBAAA;;CAEA,SAAA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;;CAEA;AACF"}
|
package/dist/errors-Dnjhzbt0.mjs
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
//#region src/service/errors.ts
|
|
2
|
-
const formatResolutionPath = (path) => path.map((service) => service.serviceTag).join(" → ");
|
|
3
|
-
/** Thrown when a Service is accessed without an active runtime resolver. */
|
|
4
|
-
var ServiceRuntimeNotConfiguredError = class extends Error {
|
|
5
|
-
constructor() {
|
|
6
|
-
super("No ServiceResolver is available in the current runtime context");
|
|
7
|
-
this.name = "ServiceRuntimeNotConfiguredError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
/** Thrown when a runtime has no provider for the requested Service tag. */
|
|
11
|
-
var ServiceNotFoundError = class extends Error {
|
|
12
|
-
service;
|
|
13
|
-
constructor(service) {
|
|
14
|
-
super(`Service "${service.serviceTag}" was not provided`);
|
|
15
|
-
this.service = service;
|
|
16
|
-
this.name = "ServiceNotFoundError";
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
/** Thrown when resolving a Service re-enters a Service already in its path. */
|
|
20
|
-
var CircularDependencyError = class extends Error {
|
|
21
|
-
path;
|
|
22
|
-
constructor(path) {
|
|
23
|
-
const normalizedPath = Object.freeze([...path]);
|
|
24
|
-
super(`Circular Service dependency detected:\n${formatResolutionPath(normalizedPath)}`);
|
|
25
|
-
this.name = "CircularDependencyError";
|
|
26
|
-
this.path = normalizedPath;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
/** Thrown when a registered Service provider fails during lazy acquisition. */
|
|
30
|
-
var ServiceAcquisitionError = class extends Error {
|
|
31
|
-
service;
|
|
32
|
-
cause;
|
|
33
|
-
constructor(service, resolutionPath, cause) {
|
|
34
|
-
const normalizedPath = Object.freeze([...resolutionPath]);
|
|
35
|
-
super(`Failed to acquire Service "${service.serviceTag}"` + (normalizedPath.length > 0 ? ` while resolving: ${formatResolutionPath(normalizedPath)}` : ""));
|
|
36
|
-
this.service = service;
|
|
37
|
-
this.name = "ServiceAcquisitionError";
|
|
38
|
-
this.cause = cause;
|
|
39
|
-
this.resolutionPath = normalizedPath;
|
|
40
|
-
}
|
|
41
|
-
resolutionPath;
|
|
42
|
-
};
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/layer/errors.ts
|
|
45
|
-
/** Thrown when a Layer registers the same Service tag more than once. */
|
|
46
|
-
var DuplicateServiceError = class extends Error {
|
|
47
|
-
service;
|
|
48
|
-
constructor(service) {
|
|
49
|
-
super(`Duplicate service tag "${service.serviceTag}"`);
|
|
50
|
-
this.service = service;
|
|
51
|
-
this.name = "DuplicateServiceError";
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
/** Thrown when one Service tag is associated with incompatible constructors. */
|
|
55
|
-
var ServiceTagCollisionError = class extends Error {
|
|
56
|
-
existing;
|
|
57
|
-
incoming;
|
|
58
|
-
constructor(existing, incoming) {
|
|
59
|
-
super(`Service tag "${incoming.serviceTag}" is already associated with "${existing.name}" and cannot be associated with "${incoming.name}"`);
|
|
60
|
-
this.existing = existing;
|
|
61
|
-
this.incoming = incoming;
|
|
62
|
-
this.name = "ServiceTagCollisionError";
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
/** Thrown when a backend fails while registering a Layer provider. */
|
|
66
|
-
var LayerRegistrationError = class extends Error {
|
|
67
|
-
service;
|
|
68
|
-
registrationCause;
|
|
69
|
-
cleanupCause;
|
|
70
|
-
constructor(service, registrationCause, cleanupCause) {
|
|
71
|
-
super(service ? `Failed to register service "${service.serviceTag}"` : "Failed to build Layer", { cause: registrationCause });
|
|
72
|
-
this.service = service;
|
|
73
|
-
this.registrationCause = registrationCause;
|
|
74
|
-
this.cleanupCause = cleanupCause;
|
|
75
|
-
this.name = "LayerRegistrationError";
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
/** Thrown when one or more Layer-owned resources fail during disposal. */
|
|
79
|
-
var LayerDisposeError = class extends Error {
|
|
80
|
-
causes;
|
|
81
|
-
constructor(causes) {
|
|
82
|
-
super(`Failed to dispose Layer (${causes.length} error${causes.length === 1 ? "" : "s"})`);
|
|
83
|
-
this.causes = causes;
|
|
84
|
-
this.name = "LayerDisposeError";
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
/** Thrown when a Layer generator yields a value other than a Service requirement. */
|
|
88
|
-
var LayerGeneratorYieldError = class extends Error {
|
|
89
|
-
service;
|
|
90
|
-
constructor(service) {
|
|
91
|
-
super(`Layer.gen("${service.serviceTag}") yielded an unsupported value`);
|
|
92
|
-
this.service = service;
|
|
93
|
-
this.name = "LayerGeneratorYieldError";
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
//#endregion
|
|
97
|
-
export { ServiceTagCollisionError as a, ServiceNotFoundError as c, LayerRegistrationError as i, ServiceRuntimeNotConfiguredError as l, LayerDisposeError as n, CircularDependencyError as o, LayerGeneratorYieldError as r, ServiceAcquisitionError as s, DuplicateServiceError as t };
|
|
98
|
-
|
|
99
|
-
//# sourceMappingURL=errors-Dnjhzbt0.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-Dnjhzbt0.mjs","names":[],"sources":["../src/service/errors.ts","../src/layer/errors.ts"],"sourcesContent":["import type { AnyServiceToken } from './types'\n\nconst formatResolutionPath = (path: readonly AnyServiceToken[]): string =>\n path.map((service) => service.serviceTag).join(' → ')\n\n/** Thrown when a Service is accessed without an active runtime resolver. */\nexport class ServiceRuntimeNotConfiguredError extends Error {\n constructor() {\n super('No ServiceResolver is available in the current runtime context')\n\n this.name = 'ServiceRuntimeNotConfiguredError'\n }\n}\n\n/** Thrown when a runtime has no provider for the requested Service tag. */\nexport class ServiceNotFoundError extends Error {\n constructor(readonly service: AnyServiceToken) {\n super(`Service \"${service.serviceTag}\" was not provided`)\n\n this.name = 'ServiceNotFoundError'\n }\n}\n\n/** Thrown when resolving a Service re-enters a Service already in its path. */\nexport class CircularDependencyError extends Error {\n readonly path: readonly AnyServiceToken[]\n\n constructor(path: readonly AnyServiceToken[]) {\n const normalizedPath = Object.freeze([...path])\n\n super(`Circular Service dependency detected:\\n${formatResolutionPath(normalizedPath)}`)\n\n this.name = 'CircularDependencyError'\n this.path = normalizedPath\n }\n}\n\n/** Thrown when a registered Service provider fails during lazy acquisition. */\nexport class ServiceAcquisitionError extends Error {\n override readonly cause: unknown\n\n constructor(\n readonly service: AnyServiceToken,\n resolutionPath: readonly AnyServiceToken[],\n cause: unknown\n ) {\n const normalizedPath = Object.freeze([...resolutionPath])\n\n super(\n `Failed to acquire Service \"${service.serviceTag}\"` +\n (normalizedPath.length > 0\n ? ` while resolving: ${formatResolutionPath(normalizedPath)}`\n : '')\n )\n\n this.name = 'ServiceAcquisitionError'\n this.cause = cause\n this.resolutionPath = normalizedPath\n }\n\n readonly resolutionPath: readonly AnyServiceToken[]\n}\n","import type { AnyServiceToken, ServiceClass } from '../service'\nimport type { ScopeOutcome } from '../scope'\n\ntype LayerCause = Extract<ScopeOutcome, { readonly status: 'failure' }>['cause']\n\n/** Thrown when a Layer registers the same Service tag more than once. */\nexport class DuplicateServiceError extends Error {\n constructor(readonly service: ServiceClass<any>) {\n super(`Duplicate service tag \"${service.serviceTag}\"`)\n\n this.name = 'DuplicateServiceError'\n }\n}\n\n/** Thrown when one Service tag is associated with incompatible constructors. */\nexport class ServiceTagCollisionError extends Error {\n constructor(\n readonly existing: AnyServiceToken,\n readonly incoming: AnyServiceToken\n ) {\n super(\n `Service tag \"${incoming.serviceTag}\" is already associated with \"${existing.name}\" ` +\n `and cannot be associated with \"${incoming.name}\"`\n )\n\n this.name = 'ServiceTagCollisionError'\n }\n}\n\n/** Thrown when a backend fails while registering a Layer provider. */\nexport class LayerRegistrationError extends Error {\n constructor(\n readonly service: ServiceClass<any> | undefined,\n readonly registrationCause: LayerCause,\n readonly cleanupCause?: LayerCause\n ) {\n super(\n service ? `Failed to register service \"${service.serviceTag}\"` : 'Failed to build Layer',\n {\n cause: registrationCause\n }\n )\n\n this.name = 'LayerRegistrationError'\n }\n}\n\n/** Thrown when one or more Layer-owned resources fail during disposal. */\nexport class LayerDisposeError extends Error {\n constructor(readonly causes: readonly unknown[]) {\n super(`Failed to dispose Layer (${causes.length} error${causes.length === 1 ? '' : 's'})`)\n\n this.name = 'LayerDisposeError'\n }\n}\n\n/** Thrown when a Layer generator yields a value other than a Service requirement. */\nexport class LayerGeneratorYieldError extends Error {\n constructor(readonly service: ServiceClass<any>) {\n super(`Layer.gen(\"${service.serviceTag}\") yielded an unsupported value`)\n\n this.name = 'LayerGeneratorYieldError'\n }\n}\n"],"mappings":";AAEA,MAAM,wBAAwB,SAC5B,KAAK,KAAK,YAAY,QAAQ,UAAU,CAAC,CAAC,KAAK,KAAK;;AAGtD,IAAa,mCAAb,cAAsD,MAAM;CAC1D,cAAc;EACZ,MAAM,gEAAgE;EAEtE,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,uBAAb,cAA0C,MAAM;CACzB;CAArB,YAAY,SAAmC;EAC7C,MAAM,YAAY,QAAQ,WAAW,mBAAmB;EADrC,KAAA,UAAA;EAGnB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,0BAAb,cAA6C,MAAM;CACjD;CAEA,YAAY,MAAkC;EAC5C,MAAM,iBAAiB,OAAO,OAAO,CAAC,GAAG,IAAI,CAAC;EAE9C,MAAM,0CAA0C,qBAAqB,cAAc,GAAG;EAEtF,KAAK,OAAO;EACZ,K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O;CACd;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-C7Qild0_.d.mts","names":[],"sources":["../src/runtime/types.ts","../src/runtime/runtime.ts","../src/runtime/signal.ts","../src/effect/combinators.ts","../src/effect/program-combinators.ts","../src/effect/effect.ts","../src/function/pipe.ts","../src/resource/errors.ts","../src/resource/types.ts","../src/resource/resource.ts"],"mappings":";;;;;;;;;;;;;KAcY,WAAW,UAAU,cAAc,QAAQ,MAAM,SAAS;;;;;;;;;;;;;;;;;;cC6DzD,QAAQ,iBAAiB;mBACC;UAA9B;;;;;;;;;;;SAYA,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;SAEhC,KAAK,UAAU,YACpB,OAAO,IAAI,cAAc,IACzB,UAAU,iBACT,QAAQ,QAAQ,oBAAoB;;;;;;;SAwBhC,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,SAAS,cACT,SAAS,kBAAkB,oBAAoB,IAAI,IACnD,UAAU,iBACT,QAAQ,QAAQ;SAEZ,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,SAAS,kBAAkB,oBAAoB,IAAI,IACnD,UAAU,iBACT,QAAQ,QAAQ;SAEZ,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,SAAS,gBACT,SAAS,kBAAkB,oBAAoB,IAAI,KAClD,QAAQ,QAAQ;;SA2EZ,IAAI,GAAG,UAAU,YACtB,OAAO,IAAI,cAAc,IACzB,MAAM,SAAS,QAAQ,oBAAoB,QAAQ,IAAI,YAAY,IACnE,UAAU,iBACT,QAAQ,QAAQ;;EAiDb,UAAU;;EAehB,IAAI,GACF,SAAS,kBAAkB,UAAU,IACrC,UAAU,oBACT,QAAQ,QAAQ;;EAKnB,QAAQ,gBAAgB,YAAY,GAClC,OAAO,UAAU,uBAAuB,UAAU,UAClD,SAAS,kBAAkB,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;WAHZ;EAGY,YAAA;SAMd,MAAM,iBAAc,YAAA,cAAA;;cAMhB,sBAAuB,mBAAc,YAAA,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-rQhZk3Nt.d.mts","names":[],"sources":["../src/internal/variance.ts","../src/utils/types.ts","../src/internal/missing-dependencies.ts","../src/layer/metadata.ts","../src/layer/inference.ts","../src/layer/types.ts","../src/layer/layer.ts","../src/layer/backend.ts","../src/layer/map-layer-backend.ts","../src/layer/errors.ts","../src/runtime/observer.ts","../src/runtime/outcome.ts"],"mappings":";;;KACY,UAAU,WAAW;;KAGrB,UAAU,MAAM,OAAO,MAAM;;;KCJ7B,aAAa,KAAK,IAAI,YAAY;;;KCElC,oBAAoB,gBAAgB;;WAErC,iBAAiB;;;;;cCCP;UAEJ,kBACX,iBAAiB,gBACjB,oBAAoB;WAEf,UAAU;WACV,UAAU;;UAGJ,qBACX,iBAAiB,gBACjB,uBAAuB;WAElB,UAAU;WACV,gBAAgB;;UAGV,oBACX,gBAAgB,cAAc,YAAY,yBAC1C,eAAe,iBAAiB,YAAY;YAEtC;aACC,SAAS;aACT,QAAQ;;;;;KCfhB,MAAM,mBAAmB;KACzB,QAAQ,MAAM;KAEd,UAAQ,GAAG,YAAY,KAAK,qBAC5B,oBAAoB;;KAMb,aAAa,kBAAkB;;KAG/B,oBAAoB,UAAU,cACxC,UAAU,YAAY,gBAAgB,aAAa;KAEzC,oBAAoB,UAAU,cACxC,UAAU,YAAY,iBAAiB,YAAY;KAEhD,cAAc,YACjB,MAAM,iCAEF,iBAAiB,4BACA,aAAa;KAK/B,eAAe,aAAa,YAAY,cAAc,eACzD,aAAa,gBACJ,aAAa,WACnB,aAAa,iBAAiB,aAAa;KAK3C,oBAAoB,aAAa,YAAY,cAAc,eAC9D,gBAAgB,gBACP,gBAAgB,WACtB,gBAAgB,iBAAiB,gBAAgB;KAKjD,YAAY,aAAa,YAAY,cAAc,cACtD,eAAe,MAAM,sBAAs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ChB;EAAA,YAAA;;;cAQV,iCAAiC;WACvB,SAAS;EAAT,YAAA,SAAS;;;;;KCpDpB;WACD,SAAS;WACT,yBAAyB;WACzB,SAAS;;;KAIR;WACD,SAAS;WACT,yBAAyB;WACzB,SAAS;;;KAIR;WACD,OAAO;;;KAIN;WACD,OAAO;WACP,SAAS;;;KAIR;WACD,SAAS;WACT,SAAS;WACT;;;KAIC;WACD,oBAAoB,OAAO,+BAA+B;WAC1D,oBAAoB,OAAO,+BAA+B;WAC1D,oBAAoB,OAAO,+BAA+B;WAC1D,kBAAkB,OAAO,6BAA6B;WACtD,qBAAqB,OAAO,gCAAgC;;;cAI1D;EACa,aAAA,oBAAS,sBAAoB;;;;;KCnC3C;;WAED,SAAS;;WAET,OAAO;;;KAIN,0BACV,YAAY,2BAA2B,8BACpC;;KAGO;;WAED,UAAU;;WAEV;;WAEA,qBAAqB;;WAErB,mBAAmB;;WAEnB,iBAAiB;;WAEjB,SAAS;;;KAIR;WACD,SAAS;;;KAIR;;WAED;;WAEA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal-identity-DmUpBeeL.mjs","names":[],"sources":["../src/layer/internal-identity.ts"],"sourcesContent":["import type { AnyServiceToken } from '../service'\n\nimport { ServiceTagCollisionError } from './errors'\n\nimport type { LayerRegistration } from './types'\n\ntype LayerAcquiredValue = Awaited<ReturnType<LayerRegistration['acquire']>>\n\nconst serviceMemberNames = (token: AnyServiceToken): readonly (string | symbol)[] => {\n const names = new Set<string | symbol>()\n let prototype = token.prototype\n\n while (prototype && prototype !== Object.prototype) {\n for (const name of Object.getOwnPropertyNames(prototype)) {\n if (name !== 'constructor') {\n names.add(name)\n }\n }\n\n for (const symbol of Object.getOwnPropertySymbols(prototype)) {\n names.add(symbol)\n }\n\n prototype = Object.getPrototypeOf(prototype)\n }\n\n return [...names]\n}\n\n/**\n * Check the runtime portion of a same-tag association before returning it.\n * TypeScript remains authoritative for full structural compatibility; this\n * check catches the common incompatible-method collision after erasure.\n */\nexport const assertServiceCompatibility = (\n requested: AnyServiceToken,\n registered: AnyServiceToken,\n instance: LayerAcquiredValue\n): void => {\n if (requested === registered || requested.serviceTag !== registered.serviceTag) {\n return\n }\n\n const candidate = Object(instance)\n\n // SAFETY: Service providers are object instances; Object() lets this runtime boundary reject rogue primitive values without trusting their static type.\n if (candidate !== instance) {\n throw new ServiceTagCollisionError(registered, requested)\n }\n\n for (const name of serviceMemberNames(requested)) {\n if (!(name in candidate)) {\n throw new ServiceTagCollisionError(registered, requested)\n }\n }\n}\n"],"mappings":";;AAQA,MAAM,sBAAsB,UAAyD;CACnF,MAAM,wBAAQ,IAAI,IAAqB;CACvC,IAAI,YAAY,MAAM;CAEtB,OAAO,aAAa,cAAc,OAAO,WAAW;EAClD,KAAK,MAAM,QAAQ,OAAO,oBAAoB,SAAS,GACrD,IAAI,SAAS,eACX,MAAM,IAAI,IAAI;EAIlB,KAAK,MAAM,UAAU,OAAO,sBAAsB,SAAS,GACzD,MAAM,IAAI,MAAM;EAGlB,YAAY,OAAO,eAAe,SAAS;CAC7C;CAEA,OAAO,CAAC,GAAG,KAAK;AAClB;;;;;;AAOA,MAAa,8BACX,WACA,YACA,aACS;CACT,IAAI,cAAc,cAAc,UAAU,eAAe,WAAW,YAClE;CAGF,MAAM,YAAY,OAAO,QAAQ;CAGjC,IAAI,cAAc,UAChB,MAAM,IAAI,yBAAyB,YAAY,SAAS;CAG1D,KAAK,MAAM,QAAQ,mBAAmB,SAAS,GAC7C,IAAI,EAAE,QAAQ,YACZ,MAAM,IAAI,yBAAyB,YAAY,SAAS;AAG9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.mts","names":[],"sources":["../../src/runtime/node.ts"],"mappings":";;;;cA2Ba,qCAAqC;EAChD,IAAI,GAAG,SAAS,gBAAgB,eAAe,IAAI;EAInD,WAAW;;;cAYA,2BAAyB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node.mjs","names":[],"sources":["../../src/runtime/node.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\n\nimport { RuntimeContextNotConfiguredError } from './errors'\n\nimport {\n currentRuntimeContextFrame,\n setRuntimeContextFrameCarrier,\n withActiveRuntimeContextStorage\n} from './context'\n\nimport type {\n ActiveRuntimeContextFrame,\n RuntimeContext,\n RuntimeContextFrameCarrier,\n RuntimeContextStorage\n} from './context'\n\nconst asyncLocalStorage = new AsyncLocalStorage<ActiveRuntimeContextFrame>()\n\nconst frameCarrier: RuntimeContextFrameCarrier = {\n run: (frame, program) => asyncLocalStorage.run(frame, program),\n current: () => asyncLocalStorage.getStore()\n}\n\nsetRuntimeContextFrameCarrier(frameCarrier)\n\n/** RuntimeContextStorage backed by Node/Bun async context propagation. */\nexport class NodeRuntimeContextStorage implements RuntimeContextStorage {\n run<A>(context: RuntimeContext, program: () => A): A {\n return withActiveRuntimeContextStorage(this, context, program)\n }\n\n current(): RuntimeContext {\n const frame = currentRuntimeContextFrame()\n\n if (!frame || frame.storage !== this) {\n throw new RuntimeContextNotConfiguredError()\n }\n\n return frame.context\n }\n}\n\n/** Shared Node/Bun storage used by the compatibility APIs and default Runtime. */\nexport const nodeRuntimeContextStorage = new NodeRuntimeContextStorage()\n\nexport { RuntimeContextNotConfiguredError } from './errors'\n\nexport type { RuntimeContext, RuntimeContextStorage } from './context'\n"],"mappings":";;;AAiBA,MAAM,oBAAoB,IAAI,kBAA6C;AAO3E,8BAA8B;CAJ5B,MAAM,OAAO,YAAY,kBAAkB,IAAI,OAAO,OAAO;CAC7D,eAAe,kBAAkB,SAAS;AAGH,CAAC;;AAG1C,IAAa,4BAAb,MAAwE;CACtE,IAAO,SAAyB,SAAqB;EACnD,OAAO,gCAAgC,MAAM,SAAS,OAAO;CAC/D;CAEA,UAA0B;EACxB,MAAM,QAAQ,2BAA2B;EAEzC,IAAI,CAAC,SAAS,MAAM,YAAY,MAC9B,MAAM,IAAI,iCAAiC;EAG7C,OAAO,MAAM;CACf;AACF;;AAGA,MAAa,4BAA4B,IAAI,0BAA0B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-DnMn0X0X.mjs","names":[],"sources":["../src/layer/map-layer-backend.ts","../src/runtime/outcome.ts","../src/runtime/observer.ts","../src/layer/resolution.ts","../src/layer/runtime.ts","../src/runtime/runtime.ts"],"sourcesContent":["import { assertServiceCompatibility } from './internal-identity'\n\nimport { DuplicateServiceError, ServiceTagCollisionError } from './errors'\n\nimport type { LayerBackend, LayerBackendDisposeOptions } from './backend'\nimport type { LayerRegistration } from './types'\n\nimport { ServiceNotFoundError, type AnyServiceToken } from '../service'\n\ntype LayerAcquiredValue = Awaited<ReturnType<LayerRegistration['acquire']>>\n\n/** Native map-backed Layer backend used by Runtime when no adapter is supplied. */\nexport class MapLayerBackend implements LayerBackend {\n private readonly providers = new Map<string, LayerRegistration>()\n\n private readonly instances = new Map<string, LayerAcquiredValue>()\n\n private readonly pending = new Map<string, Promise<LayerAcquiredValue>>()\n\n /** Register a provider, rejecting duplicate or colliding Service tags. */\n register(registration: LayerRegistration): void {\n const tag = registration.service.serviceTag\n const existing = this.providers.get(tag)\n\n if (existing) {\n if (existing.service !== registration.service) {\n throw new ServiceTagCollisionError(existing.service, registration.service)\n }\n\n throw new DuplicateServiceError(registration.service)\n }\n\n this.providers.set(tag, registration)\n }\n\n /** Resolve and cache a provider instance by Service tag. */\n async resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>> {\n const tag = token.serviceTag\n const provider = this.providers.get(tag)\n\n if (!provider) {\n throw new ServiceNotFoundError(token)\n }\n\n const validate = (instance: LayerAcquiredValue): InstanceType<T> => {\n assertServiceCompatibility(token, provider.service, instance)\n\n // SAFETY: The provider and requested token share a tag, and compatibility checks verify the registered members before restoring the token-specific instance type.\n return instance as InstanceType<T>\n }\n\n const cached = this.instances.get(tag)\n\n if (cached !== undefined) {\n return validate(cached)\n }\n\n const pending = this.pending.get(tag)\n\n if (pending) {\n return validate(await pending)\n }\n\n const acquisition = Promise.resolve()\n .then(() => provider.acquire())\n .then((instance) => {\n validate(instance)\n this.instances.set(tag, instance)\n\n return instance\n })\n .finally(() => {\n this.pending.delete(tag)\n })\n\n this.pending.set(tag, acquisition)\n\n return validate(await acquisition)\n }\n\n /** Clear pending acquisitions, cached instances, and provider registrations. */\n async disposeAll(options?: LayerBackendDisposeOptions): Promise<void> {\n const acquisitions = [...this.pending.values()]\n\n if (acquisitions.length > 0) {\n const observePending = options?.onPendingAcquisitions\n\n if (observePending) {\n await observePending(acquisitions)\n }\n\n await Promise.allSettled(acquisitions)\n }\n\n this.instances.clear()\n this.pending.clear()\n this.providers.clear()\n }\n}\n","import { Err } from 'better-result'\n\nimport type { CleanupFailureDiagnostic, MaybePromise, ScopeOutcome } from '../scope'\n\nimport type { LayerDisposeError } from '../layer/errors'\n\nimport type { LayerBackend } from '../layer/backend'\n\nimport type { RuntimeContextStorage } from './context'\n\nimport type { RuntimeObserver } from './observer'\n\n/** Aggregated cleanup information reported during Runtime shutdown. */\nexport type RuntimeShutdownDiagnostic = {\n /** Final outcome supplied to the Runtime root Scope. */\n readonly outcome: ScopeOutcome\n /** Aggregated root-Scope and backend cleanup failure. */\n readonly error: LayerDisposeError\n}\n\n/** Observer notified about cleanup failures without changing primary results. */\nexport type CleanupFailureObserver = (\n diagnostic: CleanupFailureDiagnostic | RuntimeShutdownDiagnostic\n) => MaybePromise<void>\n\n/** Optional Runtime configuration for cleanup diagnostics. */\nexport type RuntimeOptions = {\n /** Backend used to register and resolve the Layer. Defaults to MapLayerBackend. */\n readonly backend?: LayerBackend\n /** Resolve every Layer provider before Runtime.make resolves. */\n readonly warmup?: boolean\n /** Best-effort lifecycle and Service resolution observers. */\n readonly observers?: readonly RuntimeObserver[]\n /** Optional observer for best-effort cleanup diagnostics. */\n readonly onCleanupFailure?: CleanupFailureObserver\n /** Context storage used by Service, Scope and Layer resolution. */\n readonly contextStorage?: RuntimeContextStorage\n /** Optional signal exposed through the RuntimeContext. */\n readonly signal?: AbortSignal\n}\n\n/** Optional signal supplied to one managed Runtime execution. */\nexport type RuntimeRunOptions = {\n readonly signal?: AbortSignal\n}\n\n/** Cooperative shutdown policy for a managed Runtime. */\nexport type RuntimeDisposeOptions = {\n /** Time to let active executions settle before requesting cancellation. */\n readonly gracePeriod?: number\n /** Abort active execution signals after the grace period expires. */\n readonly abortAfterGracePeriod?: boolean\n}\n\n/** Classify only a nominal better-result Err as a failed Runtime outcome. */\nexport const classifyRuntimeOutcome = <A>(value: A): ScopeOutcome => {\n if (value instanceof Err) {\n return {\n status: 'failure',\n cause: value.error\n }\n }\n\n return {\n status: 'success'\n }\n}\n","import type { AnyServiceToken } from '../service'\nimport type { Scope } from '../scope'\nimport type { ScopeOutcome } from '../scope'\nimport type { MaybePromise } from '../utils/types'\n\n/** Event emitted after a Service resolution attempt settles. */\nexport type RuntimeServiceResolveEvent = {\n readonly service: AnyServiceToken\n readonly resolutionPath: readonly AnyServiceToken[]\n readonly outcome: ScopeOutcome\n}\n\n/** Event emitted after a provider acquisition attempt settles. */\nexport type RuntimeServiceAcquireEvent = {\n readonly service: AnyServiceToken\n readonly resolutionPath: readonly AnyServiceToken[]\n readonly outcome: ScopeOutcome\n}\n\n/** Event emitted immediately before a program starts in an execution Scope. */\nexport type RuntimeExecutionStartEvent = {\n readonly scope: Scope\n}\n\n/** Event emitted after a program and its execution Scope settle. */\nexport type RuntimeExecutionEndEvent = {\n readonly scope: Scope\n readonly outcome: ScopeOutcome\n}\n\n/** Event emitted after a Layer provider release callback settles. */\nexport type RuntimeResourceReleaseEvent = {\n readonly service: AnyServiceToken\n readonly outcome: ScopeOutcome\n readonly error?: unknown\n}\n\n/** Optional best-effort hooks for Runtime lifecycle and resolution events. */\nexport type RuntimeObserver = {\n readonly onServiceResolve?: (event: RuntimeServiceResolveEvent) => MaybePromise<void>\n readonly onServiceAcquire?: (event: RuntimeServiceAcquireEvent) => MaybePromise<void>\n readonly onExecutionStart?: (event: RuntimeExecutionStartEvent) => MaybePromise<void>\n readonly onExecutionEnd?: (event: RuntimeExecutionEndEvent) => MaybePromise<void>\n readonly onResourceRelease?: (event: RuntimeResourceReleaseEvent) => MaybePromise<void>\n}\n\n/** Compose best-effort Runtime observers into one observer. */\nexport const RuntimeObserver = {\n compose: (...observers: readonly RuntimeObserver[]): RuntimeObserver => ({\n onServiceResolve: (event) => {\n notifyRuntimeObservers(observers, (observer) => observer.onServiceResolve, event)\n },\n onServiceAcquire: (event) => {\n notifyRuntimeObservers(observers, (observer) => observer.onServiceAcquire, event)\n },\n onExecutionStart: (event) => {\n notifyRuntimeObservers(observers, (observer) => observer.onExecutionStart, event)\n },\n onExecutionEnd: (event) => {\n notifyRuntimeObservers(observers, (observer) => observer.onExecutionEnd, event)\n },\n onResourceRelease: (event) => {\n notifyRuntimeObservers(observers, (observer) => observer.onResourceRelease, event)\n }\n })\n}\n\nexport const notifyRuntimeObservers = <Event>(\n observers: readonly RuntimeObserver[],\n select: (observer: RuntimeObserver) => ((event: Event) => MaybePromise<void>) | undefined,\n event: Event\n): void => {\n for (const observer of observers) {\n const callback = select(observer)\n\n if (!callback) {\n continue\n }\n\n try {\n void Promise.resolve(callback(event)).catch(() => {})\n } catch {\n // Observability must never change the Runtime result.\n }\n }\n}\n","import {\n CircularDependencyError,\n ServiceAcquisitionError,\n ServiceNotFoundError,\n type AnyServiceToken,\n type ServiceResolver\n} from '../service'\n\nimport { getRuntimeContext, makeRuntimeContext, runRuntimeContext } from '../runtime/context'\n\nimport { defaultRuntimeContextStorage } from '../runtime/default'\n\nimport type { RuntimeContextStorage } from '../runtime/context'\n\nimport { notifyRuntimeObservers, type RuntimeObserver } from '../runtime/observer'\n\nimport type { ScopeOutcome } from '../scope'\n\nimport { ServiceTagCollisionError } from './errors'\n\nconst findCycleStart = (path: readonly AnyServiceToken[], token: AnyServiceToken): number =>\n path.findIndex((current) => current.serviceTag === token.serviceTag)\n\nconst shouldPreserve = (cause: unknown): boolean =>\n cause instanceof CircularDependencyError ||\n cause instanceof ServiceAcquisitionError ||\n cause instanceof ServiceNotFoundError ||\n cause instanceof ServiceTagCollisionError\n\n/** Wrap a backend with Runtime-local resolution paths and acquisition errors. */\nexport const createResolutionResolver = (\n resolver: ServiceResolver,\n storage: RuntimeContextStorage = defaultRuntimeContextStorage,\n observers: readonly RuntimeObserver[] = []\n): ServiceResolver => {\n const wrapped: ServiceResolver = {\n async resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>> {\n const context = getRuntimeContext(storage)\n const path = context?.resolutionPath ?? []\n const cycleStart = findCycleStart(path, token)\n const resolutionPath = [...path, token]\n\n const notifyResolve = (outcome: ScopeOutcome): void => {\n notifyRuntimeObservers(observers, (observer) => observer.onServiceResolve, {\n service: token,\n resolutionPath,\n outcome\n })\n }\n\n if (cycleStart >= 0) {\n const error = new CircularDependencyError([...path.slice(cycleStart), token])\n notifyResolve({ status: 'failure', cause: error })\n throw error\n }\n\n const nextContext = makeRuntimeContext(\n wrapped,\n context?.scope,\n resolutionPath,\n context?.signal,\n context\n )\n\n return await runRuntimeContext(storage, nextContext, async () => {\n try {\n const instance = await resolver.resolve(token)\n notifyResolve({ status: 'success' })\n return instance\n } catch (cause) {\n if (shouldPreserve(cause)) {\n notifyResolve({ status: 'failure', cause })\n throw cause\n }\n\n const error = new ServiceAcquisitionError(token, resolutionPath, cause)\n notifyResolve({ status: 'failure', cause: error })\n throw error\n }\n })\n }\n }\n\n return wrapped\n}\n","import type { AnyService, AnyServiceToken, ServiceResolver } from '../service'\n\nimport { Scope, type CloseableScope } from '../scope'\nimport { runScoped } from '../scope/internal'\nimport { ScopeRuntime } from '../scope/runtime'\n\nimport {\n getRuntimeContext,\n makeRuntimeContext,\n runRuntimeContext,\n type RuntimeContextStorage\n} from '../runtime/context'\n\nimport { defaultRuntimeContextStorage } from '../runtime/default'\n\nimport {\n classifyRuntimeOutcome,\n type CleanupFailureObserver,\n type RuntimeDisposeOptions,\n type RuntimeOptions,\n type RuntimeRunOptions,\n type RuntimeShutdownDiagnostic\n} from '../runtime/outcome'\n\nimport { linkAbortSignals, type AbortSignalLink } from '../runtime/signal'\n\nimport { LayerDisposeError, LayerRegistrationError } from './errors'\n\nimport { createResolutionResolver } from './resolution'\n\nimport { notifyRuntimeObservers, type RuntimeObserver } from '../runtime/observer'\n\nimport type { LayerBackend } from './backend'\n\nimport { MapLayerBackend } from './map-layer-backend'\n\nimport type {\n CompleteExecution,\n CompleteExecutionLayer,\n CompleteInput,\n LayerInput,\n ProvidedEnvironment\n} from './inference'\n\nimport type { LayerRegistration } from './types'\n\nimport type { ScopeFinalizer, ScopeOutcome } from '../scope'\n\ntype LayerProvider = LayerInput['providers'][number]\n\ninterface RuntimeHandleCore<Provided extends AnyService> {\n /** The backend used to resolve this Layer's providers. */\n readonly backend: LayerBackend\n\n /** Run a program in a child Scope of the Layer's root Scope. */\n run<A>(program: CompleteExecution<Provided, A>, options?: RuntimeRunOptions): Promise<Awaited<A>>\n\n /** Run a program with providers owned by that execution's child Scope. */\n runWith<Request extends LayerInput, A>(\n layer: Request & CompleteExecutionLayer<Provided, Request>,\n program: CompleteExecution<Provided | ProvidedEnvironment<Request>, A>,\n options?: RuntimeRunOptions\n ): Promise<Awaited<A>>\n\n /** Resolve every registered provider before accepting normal executions. */\n warmup(): Promise<void>\n\n /** Stop new executions and release Layer-owned resources. */\n dispose(input?: RuntimeDisposeOptions | ScopeOutcome): Promise<void>\n}\n\n/** Runtime-facing handle that owns a Layer's resources and execution scopes. */\nexport type RuntimeHandle<Provided extends AnyService = any> = RuntimeHandleCore<Provided>\n\nconst SCOPE_SUCCESS: ScopeOutcome = Object.freeze({ status: 'success' })\n\nclass RuntimeHandleDisposedError extends Error {\n constructor() {\n super('Cannot run a program using a disposed Layer')\n\n this.name = 'RuntimeHandleDisposedError'\n }\n}\n\nconst normalizeDisposeCauses = (cause: unknown): readonly unknown[] => {\n if (cause instanceof AggregateError) {\n return [...cause.errors]\n }\n\n return [cause]\n}\n\nconst isScopeOutcome = (\n input: RuntimeDisposeOptions | ScopeOutcome | undefined\n): input is ScopeOutcome => input !== undefined && 'status' in input\n\nconst validateDisposeOptions = (options: RuntimeDisposeOptions): void => {\n const { gracePeriod } = options\n\n if (gracePeriod !== undefined && (!Number.isFinite(gracePeriod) || gracePeriod < 0)) {\n throw new RangeError('Runtime dispose gracePeriod must be a finite non-negative number')\n }\n}\n\ntype ActiveExecution = {\n readonly promise: Promise<unknown>\n}\n\nconst notifyShutdownFailure = async (\n observer: CleanupFailureObserver | undefined,\n diagnostic: RuntimeShutdownDiagnostic\n): Promise<void> => {\n if (!observer) {\n return\n }\n\n try {\n await observer(diagnostic)\n } catch {\n // Shutdown diagnostics are best effort and never affect the primary result.\n }\n}\n\nconst releaseLayerResource = async (\n service: LayerProvider['service'],\n release: ScopeFinalizer,\n outcome: ScopeOutcome,\n observers: readonly RuntimeObserver[]\n): Promise<void> => {\n try {\n await release(outcome)\n notifyRuntimeObservers(observers, (observer) => observer.onResourceRelease, {\n service,\n outcome\n })\n } catch (cause) {\n notifyRuntimeObservers(observers, (observer) => observer.onResourceRelease, {\n service,\n outcome,\n error: cause\n })\n throw cause\n }\n}\n\nconst bindProviderToScope = (\n provider: LayerProvider,\n scope: CloseableScope,\n contextStorage: RuntimeContextStorage,\n resolver: ServiceResolver,\n observers: readonly RuntimeObserver[]\n): LayerRegistration => ({\n service: provider.service,\n\n acquire: () => {\n const current = getRuntimeContext(contextStorage)\n const context = makeRuntimeContext(\n resolver,\n scope,\n current?.resolutionPath ?? [],\n current?.signal,\n current\n )\n\n return runRuntimeContext(contextStorage, context, () =>\n ScopeRuntime.run(\n scope,\n async () => {\n const resolutionPath = current?.resolutionPath ?? [provider.service]\n\n try {\n const instance = provider.acquireWithRelease\n ? (\n await scope.acquire(provider.acquireWithRelease, (acquired, outcome) =>\n releaseLayerResource(provider.service, acquired.release, outcome, observers)\n )\n ).instance\n : provider.release\n ? await scope.acquire(\n () => provider.acquire(),\n (resource, outcome) =>\n releaseLayerResource(\n provider.service,\n (releaseOutcome) => provider.release!(resource, releaseOutcome),\n outcome,\n observers\n )\n )\n : await provider.acquire()\n\n notifyRuntimeObservers(observers, (observer) => observer.onServiceAcquire, {\n service: provider.service,\n resolutionPath,\n outcome: SCOPE_SUCCESS\n })\n\n return instance\n } catch (cause) {\n notifyRuntimeObservers(observers, (observer) => observer.onServiceAcquire, {\n service: provider.service,\n resolutionPath,\n outcome: {\n status: 'failure',\n cause\n }\n })\n throw cause\n }\n },\n contextStorage\n )\n )\n }\n})\n\n/** Resolve request-local providers first, then fall back to the Runtime root. */\nclass ExecutionLayerBackend implements LayerBackend {\n private readonly localTags = new Set<string>()\n\n constructor(\n private readonly local: MapLayerBackend,\n private readonly root: LayerBackend\n ) {}\n\n register(registration: LayerRegistration): void {\n this.localTags.add(registration.service.serviceTag)\n this.local.register(registration)\n }\n\n async resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>> {\n if (this.localTags.has(token.serviceTag)) {\n return await this.local.resolve(token)\n }\n\n return await this.root.resolve(token)\n }\n\n async disposeAll(): Promise<void> {\n await this.local.disposeAll()\n this.localTags.clear()\n }\n}\n\nclass RuntimeHandleImpl<Provided extends AnyService> implements RuntimeHandleCore<Provided> {\n private disposePromise: Promise<void> | undefined\n\n private warmupPromise: Promise<void> | undefined\n\n private readonly executions = new Set<ActiveExecution>()\n\n private readonly shutdownController = new AbortController()\n\n private state: 'active' | 'disposing' | 'disposed' = 'active'\n\n constructor(\n readonly backend: LayerBackend,\n private readonly resolver: ServiceResolver,\n private readonly rootScope: CloseableScope,\n private readonly onCleanupFailure: CleanupFailureObserver | undefined,\n private readonly contextStorage: RuntimeContextStorage,\n private readonly signal: AbortSignal | undefined,\n private readonly observers: readonly RuntimeObserver[],\n private readonly services: readonly AnyServiceToken[]\n ) {}\n\n run<A>(\n program: CompleteExecution<Provided, A>,\n options?: RuntimeRunOptions\n ): Promise<Awaited<A>> {\n this.assertActive()\n\n const executionScope = this.rootScope.fork()\n const signalLink = linkAbortSignals(\n this.signal,\n options?.signal,\n this.shutdownController.signal\n )\n\n return this.startExecution<Awaited<A>>(signalLink, () =>\n this.runExecution(executionScope, program, this.resolver, signalLink.signal)\n )\n }\n\n runWith<Request extends LayerInput, A>(\n layer: Request & CompleteExecutionLayer<Provided, Request>,\n program: CompleteExecution<Provided | ProvidedEnvironment<Request>, A>,\n options?: RuntimeRunOptions\n ): Promise<Awaited<A>> {\n this.assertActive()\n\n const executionScope = this.rootScope.fork()\n const localBackend = new MapLayerBackend()\n const backend = new ExecutionLayerBackend(localBackend, this.backend)\n const resolver = createResolutionResolver(backend, this.contextStorage, this.observers)\n const signalLink = linkAbortSignals(\n this.signal,\n options?.signal,\n this.shutdownController.signal\n )\n\n return this.startExecution<Awaited<A>>(signalLink, async (): Promise<Awaited<A>> => {\n try {\n return await this.runExecution<Awaited<A>>(\n executionScope,\n async (): Promise<Awaited<A>> => {\n for (const provider of layer.providers) {\n backend.register(\n bindProviderToScope(\n provider,\n executionScope,\n this.contextStorage,\n resolver,\n this.observers\n )\n )\n }\n\n return await program()\n },\n resolver,\n signalLink.signal\n )\n } finally {\n await localBackend.disposeAll()\n }\n })\n }\n\n warmup(): Promise<void> {\n this.assertActive()\n\n if (this.warmupPromise) {\n return this.warmupPromise\n }\n\n const warmup = runRuntimeContext(\n this.contextStorage,\n makeRuntimeContext(this.resolver, this.rootScope, [], this.signal),\n async () => {\n for (const service of this.services) {\n await this.resolver.resolve(service)\n }\n }\n )\n\n this.warmupPromise = warmup\n\n void warmup.then(\n () => {\n if (this.warmupPromise === warmup) {\n this.warmupPromise = undefined\n }\n },\n () => {\n if (this.warmupPromise === warmup) {\n this.warmupPromise = undefined\n }\n }\n )\n\n return warmup\n }\n\n private startExecution<A>(signalLink: AbortSignalLink, run: () => PromiseLike<A>): Promise<A> {\n let resolveExecution!: (value: A | PromiseLike<A>) => void\n let rejectExecution!: (cause?: unknown) => void\n\n const execution = new Promise<A>((resolve, reject) => {\n resolveExecution = resolve\n rejectExecution = reject\n })\n\n const activeExecution: ActiveExecution = { promise: execution }\n\n this.executions.add(activeExecution)\n\n void execution.then(\n () => {\n this.executions.delete(activeExecution)\n signalLink.dispose()\n },\n () => {\n this.executions.delete(activeExecution)\n signalLink.dispose()\n }\n )\n\n try {\n const running = run()\n\n void running.then(\n (value) => {\n resolveExecution(value)\n },\n (cause) => {\n rejectExecution(cause)\n }\n )\n } catch (cause) {\n rejectExecution(cause)\n }\n\n return execution\n }\n\n private runExecution<A>(\n executionScope: CloseableScope,\n program: () => A | PromiseLike<A>,\n resolver: ServiceResolver = this.resolver,\n signal: AbortSignal = this.shutdownController.signal\n ): Promise<Awaited<A>> {\n let outcome!: ScopeOutcome\n const onOutcome = (determinedOutcome: ScopeOutcome): void => {\n outcome = determinedOutcome\n }\n const runOptions = this.onCleanupFailure\n ? {\n classify: classifyRuntimeOutcome,\n onOutcome,\n onCleanupFailure: this.onCleanupFailure\n }\n : {\n classify: classifyRuntimeOutcome,\n onOutcome\n }\n\n notifyRuntimeObservers(this.observers, (observer) => observer.onExecutionStart, {\n scope: executionScope\n })\n\n const execution = runScoped(executionScope, program, {\n ...runOptions,\n contextStorage: this.contextStorage,\n context: makeRuntimeContext(resolver, executionScope, [], signal)\n })\n\n return execution.then(\n (value) => {\n notifyRuntimeObservers(this.observers, (observer) => observer.onExecutionEnd, {\n scope: executionScope,\n outcome\n })\n return value\n },\n (cause) => {\n notifyRuntimeObservers(this.observers, (observer) => observer.onExecutionEnd, {\n scope: executionScope,\n outcome\n })\n throw cause\n }\n )\n }\n\n dispose(input?: RuntimeDisposeOptions | ScopeOutcome): Promise<void> {\n if (this.disposePromise) {\n return this.disposePromise\n }\n\n const outcome =\n isScopeOutcome(input) || input === undefined ? (input ?? SCOPE_SUCCESS) : SCOPE_SUCCESS\n const options = isScopeOutcome(input) || input === undefined ? {} : input\n\n validateDisposeOptions(options)\n this.state = 'disposing'\n\n const executions = [...this.executions]\n\n this.disposePromise = this.performDispose(executions, outcome, options)\n\n return this.disposePromise\n }\n\n private async performDispose(\n executions: readonly ActiveExecution[],\n outcome: ScopeOutcome,\n options: RuntimeDisposeOptions\n ): Promise<void> {\n const failures: unknown[] = []\n\n await Promise.allSettled(this.warmupPromise ? [this.warmupPromise] : [])\n await this.waitForExecutions(executions, options)\n\n try {\n const signalLink = linkAbortSignals(this.signal, this.shutdownController.signal)\n\n try {\n await runRuntimeContext(\n this.contextStorage,\n makeRuntimeContext(this.resolver, this.rootScope, [], signalLink.signal),\n () => this.rootScope.close(outcome)\n )\n } finally {\n signalLink.dispose()\n }\n } catch (cause) {\n failures.push(cause)\n }\n\n try {\n await this.backend.disposeAll()\n } catch (cause) {\n failures.push(cause)\n }\n\n this.state = 'disposed'\n\n if (failures.length > 0) {\n const error = new LayerDisposeError(failures.flatMap(normalizeDisposeCauses))\n\n await notifyShutdownFailure(this.onCleanupFailure, {\n outcome,\n error\n })\n\n throw error\n }\n }\n\n private async waitForExecutions(\n executions: readonly ActiveExecution[],\n options: RuntimeDisposeOptions\n ): Promise<void> {\n const settled = Promise.allSettled(executions.map((execution) => execution.promise))\n\n if (options.abortAfterGracePeriod !== true || executions.length === 0) {\n await settled\n return\n }\n\n const gracePeriod = options.gracePeriod ?? 0\n let timer: ReturnType<typeof setTimeout> | undefined\n\n const timedOut = await Promise.race([\n settled.then(() => false),\n new Promise<boolean>((resolve) => {\n timer = setTimeout(() => resolve(true), gracePeriod)\n })\n ])\n\n if (timer !== undefined) {\n clearTimeout(timer)\n }\n\n if (timedOut && !this.shutdownController.signal.aborted) {\n this.shutdownController.abort(new Error('Runtime shutdown grace period exceeded'))\n }\n\n await settled\n }\n\n private assertActive(): void {\n if (this.state !== 'active') {\n throw new RuntimeHandleDisposedError()\n }\n }\n}\n\n/** Build a Runtime handle for a complete Layer and register its providers. */\nexport const createRuntimeHandle = async <L extends LayerInput>(\n layer: L & CompleteInput<L>,\n backend: LayerBackend,\n options: RuntimeOptions = {}\n): Promise<RuntimeHandle<ProvidedEnvironment<L>>> => {\n const rootScope = Scope.make()\n const contextStorage = options.contextStorage ?? defaultRuntimeContextStorage\n const observers = options.observers ?? []\n const resolver = createResolutionResolver(backend, contextStorage, observers)\n ScopeRuntime.bind(rootScope, contextStorage)\n let current: LayerProvider | undefined\n\n try {\n for (const provider of layer.providers) {\n current = provider\n\n await backend.register(\n bindProviderToScope(provider, rootScope, contextStorage, resolver, observers)\n )\n }\n } catch (registrationCause) {\n const outcome: ScopeOutcome = {\n status: 'failure',\n cause: registrationCause\n }\n const cleanupCauses: unknown[] = []\n\n try {\n await runRuntimeContext(\n contextStorage,\n makeRuntimeContext(resolver, rootScope, [], options.signal),\n () => rootScope.close(outcome)\n )\n } catch (cause) {\n cleanupCauses.push(cause)\n }\n\n try {\n await backend.disposeAll()\n } catch (cause) {\n cleanupCauses.push(cause)\n }\n\n if (cleanupCauses.length > 0) {\n const shutdownError = new LayerDisposeError(cleanupCauses.flatMap(normalizeDisposeCauses))\n\n await notifyShutdownFailure(options.onCleanupFailure, {\n outcome,\n error: shutdownError\n })\n }\n\n const cleanupCause =\n cleanupCauses.length === 1\n ? cleanupCauses[0]\n : cleanupCauses.length > 1\n ? new LayerDisposeError(cleanupCauses.flatMap(normalizeDisposeCauses))\n : undefined\n\n throw new LayerRegistrationError(current?.service, registrationCause, cleanupCause)\n }\n\n return new RuntimeHandleImpl<ProvidedEnvironment<L>>(\n backend,\n resolver,\n rootScope,\n options.onCleanupFailure,\n contextStorage,\n options.signal,\n observers,\n layer.providers.map((provider) => provider.service)\n )\n}\n","import type { LayerBackend } from '../layer'\n\nimport { MapLayerBackend } from '../layer/map-layer-backend'\n\nimport { createRuntimeHandle, type RuntimeHandle } from '../layer/runtime'\n\nimport type {\n CompleteExecutionLayer,\n LayerInput,\n CompleteInput,\n ProvidedEnvironment\n} from '../layer/inference'\n\nimport type { CompleteExecution } from '../layer/inference'\n\nimport type { AnyService } from '../service'\n\nimport {\n classifyRuntimeOutcome,\n type RuntimeDisposeOptions,\n type RuntimeOptions,\n type RuntimeRunOptions,\n type RuntimeShutdownDiagnostic\n} from './outcome'\n\nimport type { ScopeOutcome } from '../scope'\n\nimport type { RuntimeFor } from './types'\n\nimport type { RuntimeObserver } from './observer'\n\ntype RuntimeBackendInput = LayerBackend | RuntimeOptions | undefined\n\ntype RuntimeConfig = {\n readonly backend: LayerBackend\n readonly options: RuntimeOptions\n}\n\nconst isLayerBackend = (value: RuntimeBackendInput): value is LayerBackend =>\n value !== undefined && 'register' in value && 'resolve' in value && 'disposeAll' in value\n\nconst resolveRuntimeConfig = (\n backendOrOptions: RuntimeBackendInput,\n legacyOptions?: RuntimeOptions\n): RuntimeConfig => {\n if (isLayerBackend(backendOrOptions)) {\n return {\n backend: backendOrOptions,\n options: legacyOptions ?? {}\n }\n }\n\n const options = backendOrOptions ?? {}\n\n return {\n backend: options.backend ?? new MapLayerBackend(),\n options\n }\n}\n\n/**\n * Long-lived execution environment backed by a complete Layer.\n *\n * A Runtime owns Layer resources until `dispose()` is called. Each `run()` is\n * isolated in a child Scope, while Layer-scoped resources remain shared.\n *\n * @example\n * ```ts\n * const runtime = await Runtime.make(AppLive)\n * const result = await runtime.run(loadUser('u1'))\n * await runtime.dispose()\n * ```\n *\n * @typeParam Provided The branded Service instances supplied by the Layer.\n */\nexport class Runtime<Provided extends AnyService = any> {\n private constructor(private readonly handle: RuntimeHandle<Provided>) {}\n\n /**\n * Create a long-lived Runtime that owns its Layer resources.\n *\n * @example\n * ```ts\n * const runtime = await Runtime.make(AppLive)\n * const result = await runtime.run(program)\n * await runtime.dispose()\n * ```\n */\n static make<L extends LayerInput>(\n layer: L & CompleteInput<L>,\n backend: LayerBackend,\n options?: RuntimeOptions\n ): Promise<Runtime<ProvidedEnvironment<L>>>\n\n static make<L extends LayerInput>(\n layer: L & CompleteInput<L>,\n options?: RuntimeOptions\n ): Promise<Runtime<ProvidedEnvironment<L>>>\n\n static async make<L extends LayerInput>(\n layer: L & CompleteInput<L>,\n backendOrOptions?: LayerBackend | RuntimeOptions,\n legacyOptions?: RuntimeOptions\n ): Promise<Runtime<ProvidedEnvironment<L>>> {\n const { backend, options } = resolveRuntimeConfig(backendOrOptions, legacyOptions)\n const handle = await createRuntimeHandle(layer, backend, options)\n const runtime = new Runtime<ProvidedEnvironment<L>>(handle)\n\n if (options.warmup) {\n await runtime.warmup()\n }\n\n return runtime\n }\n\n /**\n * Run one program and dispose its Layer resources before resolving.\n *\n * This is convenient for request-style or command-style execution where a\n * Runtime should not outlive the operation.\n */\n static run<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n backend: LayerBackend,\n program: CompleteExecution<ProvidedEnvironment<L>, A>,\n options?: RuntimeOptions\n ): Promise<Awaited<A>>\n\n static run<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n program: CompleteExecution<ProvidedEnvironment<L>, A>,\n options?: RuntimeOptions\n ): Promise<Awaited<A>>\n\n static run<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n options: RuntimeOptions,\n program: CompleteExecution<ProvidedEnvironment<L>, A>\n ): Promise<Awaited<A>>\n\n static async run<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n backendOrProgramOrOptions:\n | LayerBackend\n | RuntimeOptions\n | CompleteExecution<ProvidedEnvironment<L>, A>,\n programOrOptions?: CompleteExecution<ProvidedEnvironment<L>, A> | RuntimeOptions,\n legacyOptions?: RuntimeOptions\n ): Promise<Awaited<A>> {\n let program: CompleteExecution<ProvidedEnvironment<L>, A>\n let backendOrOptions: RuntimeBackendInput\n let options: RuntimeOptions | undefined\n\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch needs to distinguish a Program callback from configuration.\n if (typeof backendOrProgramOrOptions === 'function') {\n program = backendOrProgramOrOptions\n // SAFETY: The function overload branch establishes that this argument is the optional RuntimeOptions value.\n backendOrOptions = programOrOptions as RuntimeOptions | undefined\n options = undefined\n } else {\n backendOrOptions = backendOrProgramOrOptions\n // SAFETY: The non-function overload branch establishes that this argument is the complete execution callback.\n program = programOrOptions as CompleteExecution<ProvidedEnvironment<L>, A>\n options = legacyOptions\n }\n\n const config = resolveRuntimeConfig(backendOrOptions, options)\n let programOutcome: ScopeOutcome | undefined\n const outcomeObserver: RuntimeObserver = {\n onExecutionEnd: ({ outcome }) => {\n programOutcome = outcome\n }\n }\n const runtimeOptions: RuntimeOptions = {\n ...config.options,\n observers: [outcomeObserver, ...(config.options.observers ?? [])]\n }\n const runtime = await Runtime.make(layer, config.backend, runtimeOptions)\n\n let value!: Awaited<A>\n let executionFailed = false\n let executionFailure: unknown\n\n try {\n value = await runtime.runUnchecked(program)\n } catch (cause) {\n executionFailed = true\n executionFailure = cause\n }\n\n const outcome: ScopeOutcome =\n programOutcome ??\n ({\n status: 'failure',\n cause: executionFailure\n } as const)\n\n try {\n await runtime.disposeWithOutcome(outcome)\n } catch (shutdownFailure) {\n if (!executionFailed && outcome.status === 'success') {\n throw shutdownFailure\n }\n }\n\n if (executionFailed) {\n throw executionFailure\n }\n\n return value\n }\n\n /** Run a callback with a managed Runtime and always dispose it afterward. */\n static use<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n use: (runtime: Runtime<ProvidedEnvironment<L>>) => A | PromiseLike<A>,\n options?: RuntimeOptions\n ): Promise<Awaited<A>>\n\n static async use<A, L extends LayerInput>(\n layer: L & CompleteInput<L>,\n use: (runtime: Runtime<ProvidedEnvironment<L>>) => A | PromiseLike<A>,\n options?: RuntimeOptions\n ): Promise<Awaited<A>> {\n const runtime = await Runtime.make(layer, options)\n\n let value!: Awaited<A>\n let executionFailed = false\n let executionFailure: unknown\n let programOutcome: ScopeOutcome | undefined\n\n try {\n value = await use(runtime)\n programOutcome = classifyRuntimeOutcome(value)\n } catch (cause) {\n executionFailed = true\n executionFailure = cause\n programOutcome = {\n status: 'failure',\n cause\n }\n }\n\n const outcome: ScopeOutcome =\n programOutcome ??\n ({\n status: 'failure',\n cause: executionFailure\n } as const)\n\n try {\n await runtime.disposeWithOutcome(outcome)\n } catch (shutdownFailure) {\n if (!executionFailed && outcome.status === 'success') {\n throw shutdownFailure\n }\n }\n\n if (executionFailed) {\n throw executionFailure\n }\n\n return value\n }\n\n /** Resolve every Layer provider and dispose the Runtime if warmup fails. */\n async warmup(): Promise<void> {\n try {\n await this.handle.warmup()\n } catch (cause) {\n try {\n await this.handle.dispose({ status: 'failure', cause })\n } catch {\n // Warmup failure remains the primary error; cleanup is best effort.\n }\n\n throw cause\n }\n }\n\n /** Run one execution in this Runtime's child Scope. */\n run<A>(\n program: CompleteExecution<Provided, A>,\n options?: RuntimeRunOptions\n ): Promise<Awaited<A>> {\n return this.handle.run(program, options)\n }\n\n /** Run one execution with a Layer owned by that execution's child Scope. */\n runWith<Request extends LayerInput, A>(\n layer: Request & CompleteExecutionLayer<Provided, Request>,\n program: CompleteExecution<Provided | ProvidedEnvironment<Request>, A>,\n options?: RuntimeRunOptions\n ): Promise<Awaited<A>> {\n return this.handle.runWith(layer, program, options)\n }\n\n private runUnchecked<A>(program: () => A | PromiseLike<A>): Promise<Awaited<A>> {\n // SAFETY: One-shot Runtime.run performs the same complete-program validation at its public boundary before using this internal escape hatch.\n return this.handle.run(program as CompleteExecution<Provided, A>)\n }\n\n /** Stop new executions and release the Runtime's Layer resources. */\n dispose(options?: RuntimeDisposeOptions): Promise<void>\n\n /** @deprecated Scope outcomes are kept for internal compatibility. */\n dispose(outcome: ScopeOutcome): Promise<void>\n\n dispose(optionsOrOutcome?: RuntimeDisposeOptions | ScopeOutcome): Promise<void> {\n return this.handle.dispose(optionsOrOutcome)\n }\n\n /** Release Runtime-owned resources through JavaScript's async disposal protocol. */\n async [Symbol.asyncDispose](): Promise<void> {\n await this.dispose()\n }\n\n private disposeWithOutcome(outcome: ScopeOutcome): Promise<void> {\n return this.handle.dispose(outcome)\n }\n}\n\n/** Type-level aliases for naming Runtime handles and shutdown options. */\nexport declare namespace Runtime {\n /** Name a Runtime type from a concrete Layer. */\n export type For<L extends LayerInput> = RuntimeFor<L>\n\n /** Optional Runtime shutdown configuration. */\n export type Options = RuntimeOptions\n\n /** Optional signal supplied to one managed Runtime execution. */\n export type RunOptions = RuntimeRunOptions\n\n /** Cooperative shutdown policy for a managed Runtime. */\n export type DisposeOptions = RuntimeDisposeOptions\n\n /** Diagnostic reported for aggregated Runtime shutdown cleanup failures. */\n export type ShutdownDiagnostic = RuntimeShutdownDiagnostic\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,kBAAb,MAAqD;CACnD,4BAA6B,IAAI,IAA+B;CAEhE,4BAA6B,IAAI,IAAgC;CAEjE,0BAA2B,IAAI,IAAyC;;CAGxE,SAAS,cAAuC;EAC9C,MAAM,MAAM,aAAa,QAAQ;EACjC,MAAM,WAAW,KAAK,UAAU,IAAI,GAAG;EAEvC,IAAI,UAAU;GACZ,IAAI,SAAS,YAAY,aAAa,SACpC,MAAM,IAAI,yBAAyB,SAAS,SAAS,aAAa,OAAO;GAG3E,MAAM,IAAI,sBAAsB,aAAa,OAAO;EACtD;EAEA,KAAK,UAAU,IAAI,KAAK,YAAY;CACtC;;CAGA,MAAM,QAAmC,OAAoC;EAC3E,MAAM,MAAM,MAAM;EAClB,MAAM,WAAW,KAAK,UAAU,IAAI,GAAG;EAEvC,IAAI,CAAC,UACH,MAAM,IAAI,qBAAqB,KAAK;EAGtC,MAAM,YAAY,aAAkD;GAClE,2BAA2B,OAAO,SAAS,SAAS,QAAQ;GAG5D,OAAO;EACT;EAEA,MAAM,SAAS,KAAK,UAAU,IAAI,GAAG;EAErC,IAAI,WAAW,KAAA,GACb,OAAO,SAAS,MAAM;EAGxB,MAAM,UAAU,KAAK,QAAQ,IAAI,GAAG;EAEpC,IAAI,SACF,OAAO,SAAS,MAAM,OAAO;EAG/B,MAAM,cAAc,QAAQ,QAAQ,CAAC,CAClC,WAAW,SAAS,QAAQ,CAAC,CAAC,CAC9B,MAAM,aAAa;GAClB,SAAS,QAAQ;GACjB,KAAK,UAAU,IAAI,KAAK,QAAQ;GAEhC,OAAO;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EAGR,OAAO;CACT;;CAGA,MAAM,SAAwB;EAC5B,IAAI;GACF,MAAM,KAAK,OAAO,OAAO;EAC3B,SAAS,OAAO;GACd,IAAI;IACF,MAAM,KAAK,OAAO,QAAQ;KAAE,QAAQ;KAAW;IAAM,CAAC;GACxD,QAAQ,CAER;GAEA,MAAM;EACR;CACF;;CAGA,IACE,SACA,SACqB;EACrB,OAAO,KAAK,OAAO,IAAI,SAAS,OAAO;CACzC;;CAGA,QACE,OACA,SACA,SACqB;EACrB,OAAO,KAAK,OAAO,QAAQ,OAAO,SAAS,OAAO;CACpD;CAEA,aAAwB,SAAwD;EAE9E,OAAO,KAAK,OAAO,IAAI,OAAyC;CAClE;CAQA,QAAQ,kBAAwE;EAC9E,OAAO,KAAK,OAAO,QAAQ,gBAAgB;CAC7C;;CAGA,OAAO,OAAO,gBAA+B;EAC3C,MAAM,KAAK,QAAQ;CACrB;CAEA,mBAA2B,SAAsC;EAC/D,OAAO,KAAK,OAAO,QAAQ,OAAO;CACpC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scope-GGnmTQck.mjs","names":[],"sources":["../src/scope/runtime.ts","../src/scope/internal.ts","../src/scope/scope.ts"],"sourcesContent":["import { ScopeRuntimeNotConfiguredError } from './errors'\n\nimport { RuntimeContextNotConfiguredError } from '../runtime/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 current\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 (cause) {\n if (cause instanceof RuntimeContextNotConfiguredError) {\n throw new ScopeRuntimeNotConfiguredError()\n }\n\n throw cause\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 CompleteRuntimeContext,\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 onOutcome?: (outcome: ScopeOutcome) => void\n readonly onCleanupFailure?: (diagnostic: CleanupFailureDiagnostic) => MaybePromise<void>\n readonly contextStorage?: RuntimeContextStorage\n readonly context?: CompleteRuntimeContext\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 let outcome: ScopeOutcome\n let outcomeStatus: ScopeOutcome['status']\n\n if (programFailed) {\n outcome = {\n status: 'failure',\n cause: programFailure\n }\n outcomeStatus = 'failure'\n } else {\n try {\n outcome = options.classify(value)\n // Read the discriminant before cleanup so a throwing classifier or proxy is a program failure.\n outcomeStatus = outcome.status\n } catch (cause) {\n programFailed = true\n programFailure = cause\n outcome = {\n status: 'failure',\n cause\n }\n outcomeStatus = 'failure'\n }\n }\n\n options.onOutcome?.(outcome)\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 (outcomeStatus === '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 = Promise.resolve().then(() => this.closeWithRuntime(outcome))\n\n return this.closePromise\n }\n\n private async closeWithRuntime(outcome: ScopeOutcome): Promise<void> {\n let started = false\n\n try {\n await ScopeRuntime.run(this, () => {\n started = true\n return this.closeInternal(outcome)\n })\n } catch (storageFailure) {\n if (started) {\n throw storageFailure\n }\n\n // Context propagation cannot prevent direct Scope cleanup.\n try {\n await this.closeInternal(outcome)\n } catch (cleanupFailure) {\n const cleanupCauses =\n cleanupFailure instanceof ScopeCloseError ? cleanupFailure.causes : [cleanupFailure]\n\n throw new ScopeCloseError([storageFailure, ...cleanupCauses])\n }\n\n throw storageFailure\n }\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"],"mappings":";;;AAgBA,MAAM,gCAAgB,IAAI,QAAuC;;AAGjE,IAAa,eAAb,MAA0B;;CAExB,OAAO,IACL,OACA,SACA,UAAiC,cAAc,IAAI,KAAK,KAAK,4BAA4B,GACtF;EACH,cAAc,IAAI,OAAO,OAAO;EAEhC,MAAM,UAAU,kBAAkB,OAAO;EACzC,MAAM,UAAU,mBACd,SAAS,UACT,OACA,SAAS,kBAAkB,CAAC,GAC5B,SAAS,QACT,OACF;EAEA,OAAO,kBAAkB,SAAS,SAAS,OAAO;CACpD;;CAGA,OAAO,UAAiB;EACtB,IAAI;EAEJ,IAAI;GACF,UAAU,sBAAsB;EAClC,SAAS,OAAO;GACd,IA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