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.
Files changed (67) hide show
  1. package/README.md +220 -6
  2. package/dist/adapters/iti.d.mts +2 -1
  3. package/dist/adapters/iti.d.mts.map +1 -1
  4. package/dist/adapters/iti.mjs +11 -10
  5. package/dist/adapters/iti.mjs.map +1 -1
  6. package/dist/{effect-2ZcGZI8A.mjs → effect-CK4YZaX0.mjs} +56 -10
  7. package/dist/effect-CK4YZaX0.mjs.map +1 -0
  8. package/dist/hono.d.mts +3 -3
  9. package/dist/hono.mjs +3 -3
  10. package/dist/{index-DStz0JMN.d.mts → index-B1nH4luq.d.mts} +73 -6
  11. package/dist/index-B1nH4luq.d.mts.map +1 -0
  12. package/dist/index-BMdU_Z72.d.mts +18 -0
  13. package/dist/index-BMdU_Z72.d.mts.map +1 -0
  14. package/dist/{index-C7Qild0_.d.mts → index-CX6iAoCB.d.mts} +15 -151
  15. package/dist/index-CX6iAoCB.d.mts.map +1 -0
  16. package/dist/index-GYJ4qm9K.d.mts +179 -0
  17. package/dist/index-GYJ4qm9K.d.mts.map +1 -0
  18. package/dist/index-heuaRmXR.d.mts.map +1 -1
  19. package/dist/index.d.mts +5 -3
  20. package/dist/index.mjs +6 -5
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/{internal-identity-DmUpBeeL.mjs → internal-identity-CbXoZIfw.mjs} +3 -3
  23. package/dist/internal-identity-CbXoZIfw.mjs.map +1 -0
  24. package/dist/{signal-B97cs85Z.mjs → layer-D56fRdLt.mjs} +30 -111
  25. package/dist/layer-D56fRdLt.mjs.map +1 -0
  26. package/dist/node-context-DWsCUBRa.d.mts +12 -0
  27. package/dist/node-context-DWsCUBRa.d.mts.map +1 -0
  28. package/dist/node-context-lggRF4bR.mjs +25 -0
  29. package/dist/node-context-lggRF4bR.mjs.map +1 -0
  30. package/dist/node.d.mts +51 -0
  31. package/dist/node.d.mts.map +1 -0
  32. package/dist/node.mjs +233 -0
  33. package/dist/node.mjs.map +1 -0
  34. package/dist/{index-rQhZk3Nt.d.mts → outcome-CB43bnFW.d.mts} +29 -19
  35. package/dist/outcome-CB43bnFW.d.mts.map +1 -0
  36. package/dist/{scope-GGnmTQck.mjs → program-metadata-DhQCCirO.mjs} +18 -3
  37. package/dist/program-metadata-DhQCCirO.mjs.map +1 -0
  38. package/dist/registration-drnZk0SY.mjs +182 -0
  39. package/dist/registration-drnZk0SY.mjs.map +1 -0
  40. package/dist/runtime/node.d.mts +2 -11
  41. package/dist/runtime/node.mjs +2 -24
  42. package/dist/{runtime-DnMn0X0X.mjs → runtime-CBMrX8Wl.mjs} +210 -47
  43. package/dist/runtime-CBMrX8Wl.mjs.map +1 -0
  44. package/dist/signal-D2UTcaaG.mjs +105 -0
  45. package/dist/signal-D2UTcaaG.mjs.map +1 -0
  46. package/dist/{standard-services-BFBq-4lo.mjs → standard-services-GBZ32tll.mjs} +200 -16
  47. package/dist/standard-services-GBZ32tll.mjs.map +1 -0
  48. package/dist/standard-services.d.mts +3 -3
  49. package/dist/standard-services.mjs +3 -3
  50. package/dist/testing.d.mts +65 -6
  51. package/dist/testing.d.mts.map +1 -1
  52. package/dist/testing.mjs +191 -8
  53. package/dist/testing.mjs.map +1 -1
  54. package/package.json +8 -3
  55. package/dist/effect-2ZcGZI8A.mjs.map +0 -1
  56. package/dist/errors-Dnjhzbt0.mjs +0 -99
  57. package/dist/errors-Dnjhzbt0.mjs.map +0 -1
  58. package/dist/index-C7Qild0_.d.mts.map +0 -1
  59. package/dist/index-DStz0JMN.d.mts.map +0 -1
  60. package/dist/index-rQhZk3Nt.d.mts.map +0 -1
  61. package/dist/internal-identity-DmUpBeeL.mjs.map +0 -1
  62. package/dist/runtime/node.d.mts.map +0 -1
  63. package/dist/runtime/node.mjs.map +0 -1
  64. package/dist/runtime-DnMn0X0X.mjs.map +0 -1
  65. package/dist/scope-GGnmTQck.mjs.map +0 -1
  66. package/dist/signal-B97cs85Z.mjs.map +0 -1
  67. package/dist/standard-services-BFBq-4lo.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program-metadata-DhQCCirO.mjs","names":[],"sources":["../src/scope/runtime.ts","../src/scope/internal.ts","../src/scope/scope.ts","../src/effect/program-metadata.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","export type ProgramIdentity = (...arguments_: never[]) => void\n\nconst programNames = new WeakMap<ProgramIdentity, string>()\n\n/** Return the private diagnostic name attached to a callable Program. */\nexport const getProgramName = (program: ProgramIdentity): string | undefined =>\n programNames.get(program)\n\n/** Attach a name without changing the callable Program facade. */\nexport const setProgramName = <Program extends ProgramIdentity>(\n program: Program,\n name: string\n): Program => {\n programNames.set(program, name)\n return program\n}\n\n/** Copy a source Program's name to a lazily-created derived Program. */\nexport const inheritProgramName = <Source extends ProgramIdentity, Derived extends ProgramIdentity>(\n source: Source,\n derived: Derived\n): Derived => {\n const name = getProgramName(source)\n\n return name === undefined ? derived : setProgramName(derived, name)\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,IAAI,iBAAiB,kCACnB,MAAM,IAAI,+BAA+B;GAG3C,MAAM;EACR;EAEA,IAAI,CAAC,QAAQ,OACX,MAAM,IAAI,+BAA+B;EAG3C,OAAO,QAAQ;CACjB;;CAGA,OAAO,K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A,MAAa,QAAQ;;CAEnB,OAAuB;EACrB,OAAO,IAAI,UAAU;CACvB;;CAGA,UAAiB;EACf,OAAO,aAAa,QAAQ;CAC9B;;CAGA,QAAW,OAAc,SAAqB;EAC5C,OAAO,aAAa,IAAI,OAAO,OAAO;CACxC;;CAIA,EAAE,OAAO,YAA8C;EACrD,OAAO,aAAa,QAAQ;CAC9B;;;;;;;;;;;;;;;;CAiBA,IAAO,SAAoE;EACzE,MAAM,QAAQ,IAAI,UAAU;EAE5B,OAAO,UAAU,aAAa,QAAQ,KAAK,GAAG,EAC5C,gBAAgB,cAClB,CAAC;CACH;AACF;;;ACzQA,MAAM,+BAAe,IAAI,QAAiC;;AAG1D,MAAa,kBAAkB,YAC7B,aAAa,IAAI,OAAO;;AAG1B,MAAa,kBACX,SACA,SACY;CACZ,aAAa,IAAI,SAAS,IAAI;CAC9B,OAAO;AACT;;AAGA,MAAa,sBACX,QACA,YACY;CACZ,MAAM,OAAO,eAAe,MAAM;CAElC,OAAO,SAAS,KAAA,IAAY,UAAU,eAAe,SAAS,IAAI;AACpE"}
@@ -0,0 +1,182 @@
1
+ //#region src/service/tag.ts
2
+ const serviceTags = /* @__PURE__ */ new WeakMap();
3
+ const isObjectLike = (value) => value !== null && Object(value) === value;
4
+ const lockServiceTag = (token, tag) => {
5
+ const descriptor = Object.getOwnPropertyDescriptor(token, "serviceTag");
6
+ if (descriptor?.configurable === false) {
7
+ if ("value" in descriptor && descriptor.value === tag && descriptor.writable === false) return;
8
+ if ("value" in descriptor && descriptor.value === tag && descriptor.writable === true) {
9
+ Object.defineProperty(token, "serviceTag", { writable: false });
10
+ return;
11
+ }
12
+ throw new TypeError("Service tags must be immutable");
13
+ }
14
+ Object.defineProperty(token, "serviceTag", {
15
+ value: tag,
16
+ writable: false,
17
+ enumerable: descriptor?.enumerable ?? true,
18
+ configurable: false
19
+ });
20
+ };
21
+ /** Validate the runtime form of a Service tag without coercing it. */
22
+ const validateServiceTag = (tag) => {
23
+ if (typeof tag !== "string" || tag.length === 0) throw new TypeError("Service tags must be non-empty primitive strings");
24
+ return tag;
25
+ };
26
+ /** Record a declaration tag and make the public static property immutable. */
27
+ const registerServiceTag = (token, tag) => {
28
+ const canonicalTag = validateServiceTag(tag);
29
+ const existing = serviceTags.get(token);
30
+ if (existing !== void 0) {
31
+ if (existing !== canonicalTag) throw new TypeError("A Service tag cannot be changed after declaration");
32
+ return;
33
+ }
34
+ lockServiceTag(token, canonicalTag);
35
+ serviceTags.set(token, canonicalTag);
36
+ };
37
+ /** Capture a token's logical tag once so later mutable aliases cannot drift. */
38
+ const captureServiceTag = (token) => {
39
+ if (!isObjectLike(token)) throw new TypeError("Service tokens must be objects or functions");
40
+ const known = serviceTags.get(token);
41
+ if (known !== void 0) return known;
42
+ let prototype = Object.getPrototypeOf(token);
43
+ while (isObjectLike(prototype)) {
44
+ const inherited = serviceTags.get(prototype);
45
+ if (inherited !== void 0) {
46
+ lockServiceTag(token, inherited);
47
+ serviceTags.set(token, inherited);
48
+ return inherited;
49
+ }
50
+ prototype = Object.getPrototypeOf(prototype);
51
+ }
52
+ const tag = validateServiceTag(token.serviceTag);
53
+ lockServiceTag(token, tag);
54
+ serviceTags.set(token, tag);
55
+ return tag;
56
+ };
57
+ //#endregion
58
+ //#region src/service/errors.ts
59
+ const formatResolutionPath = (path) => path.map((service) => captureServiceTag(service)).join(" → ");
60
+ /** Thrown when a Service is accessed without an active runtime resolver. */
61
+ var ServiceRuntimeNotConfiguredError = class extends Error {
62
+ constructor() {
63
+ super("No ServiceResolver is available in the current runtime context");
64
+ this.name = "ServiceRuntimeNotConfiguredError";
65
+ }
66
+ };
67
+ /** Thrown when a runtime has no provider for the requested Service tag. */
68
+ var ServiceNotFoundError = class extends Error {
69
+ service;
70
+ constructor(service) {
71
+ super(`Service "${captureServiceTag(service)}" was not provided`);
72
+ this.service = service;
73
+ this.name = "ServiceNotFoundError";
74
+ }
75
+ };
76
+ /** Thrown when resolving a Service re-enters a Service already in its path. */
77
+ var CircularDependencyError = class extends Error {
78
+ path;
79
+ constructor(path) {
80
+ const normalizedPath = Object.freeze([...path]);
81
+ super(`Circular Service dependency detected:\n${formatResolutionPath(normalizedPath)}`);
82
+ this.name = "CircularDependencyError";
83
+ this.path = normalizedPath;
84
+ }
85
+ };
86
+ /** Thrown when a registered Service provider fails during lazy acquisition. */
87
+ var ServiceAcquisitionError = class extends Error {
88
+ service;
89
+ cause;
90
+ constructor(service, resolutionPath, cause) {
91
+ const normalizedPath = Object.freeze([...resolutionPath]);
92
+ super(`Failed to acquire Service "${captureServiceTag(service)}"` + (normalizedPath.length > 0 ? ` while resolving: ${formatResolutionPath(normalizedPath)}` : ""));
93
+ this.service = service;
94
+ this.name = "ServiceAcquisitionError";
95
+ this.cause = cause;
96
+ this.resolutionPath = normalizedPath;
97
+ }
98
+ resolutionPath;
99
+ };
100
+ //#endregion
101
+ //#region src/layer/errors.ts
102
+ /** Thrown when a Layer registers the same Service tag more than once. */
103
+ var DuplicateServiceError = class extends Error {
104
+ service;
105
+ constructor(service) {
106
+ super(`Duplicate service tag "${captureServiceTag(service)}"`);
107
+ this.service = service;
108
+ this.name = "DuplicateServiceError";
109
+ }
110
+ };
111
+ /** Thrown when one Service tag is associated with incompatible constructors. */
112
+ var ServiceTagCollisionError = class extends Error {
113
+ existing;
114
+ incoming;
115
+ constructor(existing, incoming) {
116
+ super(`Service tag "${captureServiceTag(incoming)}" is already associated with "${existing.name}" and cannot be associated with "${incoming.name}"`);
117
+ this.existing = existing;
118
+ this.incoming = incoming;
119
+ this.name = "ServiceTagCollisionError";
120
+ }
121
+ };
122
+ /** Thrown when a backend fails while registering a Layer provider. */
123
+ var LayerRegistrationError = class extends Error {
124
+ service;
125
+ registrationCause;
126
+ cleanupCause;
127
+ constructor(service, registrationCause, cleanupCause) {
128
+ super(service ? `Failed to register service "${captureServiceTag(service)}"` : "Failed to build Layer", { cause: registrationCause });
129
+ this.service = service;
130
+ this.registrationCause = registrationCause;
131
+ this.cleanupCause = cleanupCause;
132
+ this.name = "LayerRegistrationError";
133
+ }
134
+ };
135
+ /** Thrown when one or more Layer-owned resources fail during disposal. */
136
+ var LayerDisposeError = class extends Error {
137
+ causes;
138
+ constructor(causes) {
139
+ super(`Failed to dispose Layer (${causes.length} error${causes.length === 1 ? "" : "s"})`);
140
+ this.causes = causes;
141
+ this.name = "LayerDisposeError";
142
+ }
143
+ };
144
+ /** Thrown when a Layer generator yields a value other than a Service requirement. */
145
+ var LayerGeneratorYieldError = class extends Error {
146
+ service;
147
+ constructor(service) {
148
+ super(`Layer.gen("${captureServiceTag(service)}") yielded an unsupported value`);
149
+ this.service = service;
150
+ this.name = "LayerGeneratorYieldError";
151
+ }
152
+ };
153
+ //#endregion
154
+ //#region src/layer/registration.ts
155
+ const validateRegistrationTag = (service, registrationTag) => {
156
+ const tokenTag = captureServiceTag(service);
157
+ if (registrationTag === void 0) return tokenTag;
158
+ const canonicalTag = validateServiceTag(registrationTag);
159
+ if (canonicalTag !== tokenTag) throw new TypeError("Layer registration tag does not match its Service token");
160
+ return canonicalTag;
161
+ };
162
+ /** Capture and validate the logical identity carried by a backend registration. */
163
+ const captureLayerRegistrationTag = (registration) => {
164
+ if (typeof registration !== "object" || registration === null) throw new TypeError("Layer registrations must be objects");
165
+ return validateRegistrationTag(registration.service, registration.serviceTag);
166
+ };
167
+ /** Detach a registration from mutable caller-owned objects at the backend boundary. */
168
+ const normalizeLayerRegistration = (registration) => {
169
+ const service = registration.service;
170
+ const registrationTag = registration.serviceTag;
171
+ const acquire = registration.acquire;
172
+ const serviceTag = validateRegistrationTag(service, registrationTag);
173
+ return Object.freeze({
174
+ service,
175
+ serviceTag,
176
+ acquire
177
+ });
178
+ };
179
+ //#endregion
180
+ export { LayerGeneratorYieldError as a, CircularDependencyError as c, ServiceRuntimeNotConfiguredError as d, captureServiceTag as f, LayerDisposeError as i, ServiceAcquisitionError as l, validateServiceTag as m, normalizeLayerRegistration as n, LayerRegistrationError as o, registerServiceTag as p, DuplicateServiceError as r, ServiceTagCollisionError as s, captureLayerRegistrationTag as t, ServiceNotFoundError as u };
181
+
182
+ //# sourceMappingURL=registration-drnZk0SY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-drnZk0SY.mjs","names":[],"sources":["../src/service/tag.ts","../src/service/errors.ts","../src/layer/errors.ts","../src/layer/registration.ts"],"sourcesContent":["const serviceTags = new WeakMap<object, string>()\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- This boundary validates untrusted JavaScript token values.\nconst isObjectLike = (value: unknown): value is object => value !== null && Object(value) === value\n\n// oxlint-disable-next-line anti-slop/no-object-parameters -- Tokens are validated object-like owners at this internal boundary.\nconst lockServiceTag = (token: object, tag: string): void => {\n const descriptor = Object.getOwnPropertyDescriptor(token, 'serviceTag')\n\n if (descriptor?.configurable === false) {\n if ('value' in descriptor && descriptor.value === tag && descriptor.writable === false) {\n return\n }\n\n if ('value' in descriptor && descriptor.value === tag && descriptor.writable === true) {\n Object.defineProperty(token, 'serviceTag', { writable: false })\n return\n }\n\n throw new TypeError('Service tags must be immutable')\n }\n\n Object.defineProperty(token, 'serviceTag', {\n value: tag,\n writable: false,\n enumerable: descriptor?.enumerable ?? true,\n configurable: false\n })\n}\n\n/** Validate the runtime form of a Service tag without coercing it. */\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Validate the public JavaScript declaration boundary.\nexport const validateServiceTag = (tag: unknown): string => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Reject boxed and object tag aliases instead of coercing them.\n if (typeof tag !== 'string' || tag.length === 0) {\n throw new TypeError('Service tags must be non-empty primitive strings')\n }\n\n return tag\n}\n\n/** Record a declaration tag and make the public static property immutable. */\n// oxlint-disable-next-line anti-slop/no-object-parameters -- The declaration owner is always a class constructor.\nexport const registerServiceTag = (token: object, tag: string): void => {\n const canonicalTag = validateServiceTag(tag)\n const existing = serviceTags.get(token)\n\n if (existing !== undefined) {\n if (existing !== canonicalTag) {\n throw new TypeError('A Service tag cannot be changed after declaration')\n }\n\n return\n }\n\n lockServiceTag(token, canonicalTag)\n serviceTags.set(token, canonicalTag)\n}\n\n/** Capture a token's logical tag once so later mutable aliases cannot drift. */\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Validate unchecked Service tokens at each runtime boundary.\nexport const captureServiceTag = (token: unknown): string => {\n if (!isObjectLike(token)) {\n throw new TypeError('Service tokens must be objects or functions')\n }\n\n const known = serviceTags.get(token)\n\n if (known !== undefined) {\n return known\n }\n\n let prototype = Object.getPrototypeOf(token)\n\n while (isObjectLike(prototype)) {\n const inherited = serviceTags.get(prototype)\n\n if (inherited !== undefined) {\n lockServiceTag(token, inherited)\n serviceTags.set(token, inherited)\n\n return inherited\n }\n\n prototype = Object.getPrototypeOf(prototype)\n }\n\n // SAFETY: The object-like check above limits this assertion to a token-shaped object; the value is validated immediately below.\n const tag = validateServiceTag((token as { readonly serviceTag?: unknown }).serviceTag)\n lockServiceTag(token, tag)\n serviceTags.set(token, tag)\n\n return tag\n}\n","import { captureServiceTag } from './tag'\nimport type { AnyServiceToken } from './types'\n\nconst formatResolutionPath = (path: readonly AnyServiceToken[]): string =>\n path.map((service) => captureServiceTag(service)).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 \"${captureServiceTag(service)}\" 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 \"${captureServiceTag(service)}\"` +\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 { captureServiceTag } from '../service/tag'\nimport 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 \"${captureServiceTag(service)}\"`)\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 \"${captureServiceTag(incoming)}\" 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\n ? `Failed to register service \"${captureServiceTag(service)}\"`\n : '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(\"${captureServiceTag(service)}\") yielded an unsupported value`)\n\n this.name = 'LayerGeneratorYieldError'\n }\n}\n","import { captureServiceTag, validateServiceTag } from '../service/tag'\n\nimport type { LayerRegistration } from './types'\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Validate unchecked registrations at the adapter boundary.\nconst validateRegistrationTag = (service: unknown, registrationTag: unknown): string => {\n const tokenTag = captureServiceTag(service)\n\n if (registrationTag === undefined) {\n return tokenTag\n }\n\n const canonicalTag = validateServiceTag(registrationTag)\n\n if (canonicalTag !== tokenTag) {\n throw new TypeError('Layer registration tag does not match its Service token')\n }\n\n return canonicalTag\n}\n\n/** Capture and validate the logical identity carried by a backend registration. */\nexport const captureLayerRegistrationTag = (registration: LayerRegistration): string => {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- Reject forged registrations before reading their fields.\n if (typeof registration !== 'object' || registration === null) {\n throw new TypeError('Layer registrations must be objects')\n }\n\n return validateRegistrationTag(registration.service, registration.serviceTag)\n}\n\n/** Detach a registration from mutable caller-owned objects at the backend boundary. */\nexport const normalizeLayerRegistration = (registration: LayerRegistration): LayerRegistration => {\n const service = registration.service\n const registrationTag = registration.serviceTag\n const acquire = registration.acquire\n const serviceTag = validateRegistrationTag(service, registrationTag)\n\n return Object.freeze({\n service,\n serviceTag,\n acquire\n })\n}\n"],"mappings":";AAAA,MAAM,8BAAc,IAAI,QAAwB;AAGhD,MAAM,gBAAgB,UAAoC,UAAU,QAAQ,OAAO,KAAK,MAAM;AAG9F,MAAM,kBAAkB,OAAe,QAAsB;CAC3D,MAAM,aAAa,OAAO,yBAAyB,OAAO,YAAY;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  import { c as RuntimeContextStorage, s as RuntimeContext } from "../index-heuaRmXR.mjs";
2
2
  import { t as RuntimeContextNotConfiguredError } from "../errors-BKcsQ0ip.mjs";
3
- //#region src/runtime/node.d.ts
4
- /** RuntimeContextStorage backed by Node/Bun async context propagation. */
5
- declare class NodeRuntimeContextStorage implements RuntimeContextStorage {
6
- run<A>(context: RuntimeContext, program: () => A): A;
7
- current(): RuntimeContext;
8
- }
9
- /** Shared Node/Bun storage used by the compatibility APIs and default Runtime. */
10
- declare const nodeRuntimeContextStorage: NodeRuntimeContextStorage;
11
- //#endregion
12
- export { NodeRuntimeContextStorage, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, nodeRuntimeContextStorage };
13
- //# sourceMappingURL=node.d.mts.map
3
+ import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "../node-context-DWsCUBRa.mjs";
4
+ export { NodeRuntimeContextStorage, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, nodeRuntimeContextStorage };
@@ -1,25 +1,3 @@
1
- import { f as setRuntimeContextFrameCarrier, h as RuntimeContextNotConfiguredError, m as withActiveRuntimeContextStorage, r as currentRuntimeContextFrame } from "../context-BUEf1qjL.mjs";
2
- import { AsyncLocalStorage } from "node:async_hooks";
3
- //#region src/runtime/node.ts
4
- const asyncLocalStorage = new AsyncLocalStorage();
5
- setRuntimeContextFrameCarrier({
6
- run: (frame, program) => asyncLocalStorage.run(frame, program),
7
- current: () => asyncLocalStorage.getStore()
8
- });
9
- /** RuntimeContextStorage backed by Node/Bun async context propagation. */
10
- var NodeRuntimeContextStorage = class {
11
- run(context, program) {
12
- return withActiveRuntimeContextStorage(this, context, program);
13
- }
14
- current() {
15
- const frame = currentRuntimeContextFrame();
16
- if (!frame || frame.storage !== this) throw new RuntimeContextNotConfiguredError();
17
- return frame.context;
18
- }
19
- };
20
- /** Shared Node/Bun storage used by the compatibility APIs and default Runtime. */
21
- const nodeRuntimeContextStorage = new NodeRuntimeContextStorage();
22
- //#endregion
1
+ import { h as RuntimeContextNotConfiguredError } from "../context-BUEf1qjL.mjs";
2
+ import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "../node-context-lggRF4bR.mjs";
23
3
  export { NodeRuntimeContextStorage, RuntimeContextNotConfiguredError, nodeRuntimeContextStorage };
24
-
25
- //# sourceMappingURL=node.mjs.map