better-effect 0.11.0 → 0.13.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 +544 -10
- package/dist/adapters/iti.d.mts +3 -2
- 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/bun.d.mts +43 -0
- package/dist/bun.d.mts.map +1 -0
- package/dist/bun.mjs +40 -0
- package/dist/bun.mjs.map +1 -0
- package/dist/{context-BUEf1qjL.mjs → context-BphfFUMO.mjs} +4 -2
- package/dist/context-BphfFUMO.mjs.map +1 -0
- package/dist/current-request-CIU7AHhF.d.mts +22 -0
- package/dist/current-request-CIU7AHhF.d.mts.map +1 -0
- package/dist/current-request-DDKNyymv.mjs +20 -0
- package/dist/current-request-DDKNyymv.mjs.map +1 -0
- package/dist/disposable-CP-Q2H3l.mjs +57 -0
- package/dist/disposable-CP-Q2H3l.mjs.map +1 -0
- package/dist/{effect-2ZcGZI8A.mjs → effect-CPdV7Yv8.mjs} +56 -10
- package/dist/effect-CPdV7Yv8.mjs.map +1 -0
- package/dist/hono.d.mts +7 -5
- package/dist/hono.d.mts.map +1 -1
- package/dist/hono.mjs +88 -30
- package/dist/hono.mjs.map +1 -1
- package/dist/{index-heuaRmXR.d.mts → index-AiKM71-u.d.mts} +3 -1
- package/dist/{index-heuaRmXR.d.mts.map → index-AiKM71-u.d.mts.map} +1 -1
- package/dist/index-BodMy6rO.d.mts +180 -0
- package/dist/index-BodMy6rO.d.mts.map +1 -0
- package/dist/{index-C7Qild0_.d.mts → index-CCi07kUw.d.mts} +15 -151
- package/dist/index-CCi07kUw.d.mts.map +1 -0
- package/dist/index-DAKn0qHk.d.mts +19 -0
- package/dist/index-DAKn0qHk.d.mts.map +1 -0
- package/dist/{index-DStz0JMN.d.mts → index-cXgyMa0v.d.mts} +75 -22
- package/dist/index-cXgyMa0v.d.mts.map +1 -0
- package/dist/index.d.mts +7 -4
- package/dist/index.mjs +8 -6
- 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-D16GKxuX.mjs} +31 -112
- package/dist/layer-D16GKxuX.mjs.map +1 -0
- package/dist/next.d.mts +116 -0
- package/dist/next.d.mts.map +1 -0
- package/dist/next.mjs +68 -0
- package/dist/next.mjs.map +1 -0
- package/dist/node-context-Ca18oNSg.mjs +25 -0
- package/dist/node-context-Ca18oNSg.mjs.map +1 -0
- package/dist/node-context-DczjAcrX.d.mts +12 -0
- package/dist/node-context-DczjAcrX.d.mts.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/observer-9nhbL7Pr.d.mts +68 -0
- package/dist/observer-9nhbL7Pr.d.mts.map +1 -0
- package/dist/opentelemetry.d.mts +94 -0
- package/dist/opentelemetry.d.mts.map +1 -0
- package/dist/opentelemetry.mjs +453 -0
- package/dist/opentelemetry.mjs.map +1 -0
- package/dist/{index-rQhZk3Nt.d.mts → outcome-DI8LPIQ4.d.mts} +27 -72
- package/dist/outcome-DI8LPIQ4.d.mts.map +1 -0
- package/dist/{scope-GGnmTQck.mjs → program-metadata-BxjGkT17.mjs} +19 -4
- package/dist/program-metadata-BxjGkT17.mjs.map +1 -0
- package/dist/registration-drnZk0SY.mjs +182 -0
- package/dist/registration-drnZk0SY.mjs.map +1 -0
- package/dist/runtime/explicit.d.mts +1 -1
- package/dist/runtime/explicit.mjs +1 -1
- package/dist/runtime/node.d.mts +3 -12
- package/dist/runtime/node.mjs +2 -24
- package/dist/{runtime-DnMn0X0X.mjs → runtime-C_55ofnL.mjs} +245 -67
- package/dist/runtime-C_55ofnL.mjs.map +1 -0
- package/dist/signal-nfgFyNCk.mjs +52 -0
- package/dist/signal-nfgFyNCk.mjs.map +1 -0
- package/dist/{standard-services-BFBq-4lo.mjs → standard-services-vnGIafkS.mjs} +200 -30
- package/dist/standard-services-vnGIafkS.mjs.map +1 -0
- package/dist/standard-services.d.mts +4 -3
- package/dist/standard-services.mjs +4 -3
- package/dist/testing.d.mts +67 -7
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +192 -9
- package/dist/testing.mjs.map +1 -1
- package/dist/types-oihI-ESv.d.mts +54 -0
- package/dist/types-oihI-ESv.d.mts.map +1 -0
- package/dist/web-Bq3MfMrj.mjs +147 -0
- package/dist/web-Bq3MfMrj.mjs.map +1 -0
- package/dist/web.d.mts +47 -0
- package/dist/web.d.mts.map +1 -0
- package/dist/web.mjs +2 -0
- package/package.json +39 -3
- package/dist/context-BUEf1qjL.mjs.map +0 -1
- 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,13 +1,11 @@
|
|
|
1
|
-
import { F as ServiceContract, H as ServiceToken, L as ServiceIdentityTypeId, M as AnyService, N as AnyServiceToken, O as InferYieldRequirements, P as ServiceClass, T as EffectRequirements, U as ServiceTokenOf, V as ServiceTagOf, a as ServiceResolver, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, f as DisposableResource, h as ScopeOutcome, j as ServiceRequirement, m as ScopeFinalizer, p as MaybePromise
|
|
1
|
+
import { F as ServiceContract, H as ServiceToken, L as ServiceIdentityTypeId, M as AnyService, N as AnyServiceToken, O as InferYieldRequirements, P as ServiceClass, T as EffectRequirements, U as ServiceTokenOf, V as ServiceTagOf, a as ServiceResolver, c as RuntimeContextStorage, d as CleanupFailureDiagnostic, f as DisposableResource, h as ScopeOutcome, j as ServiceRequirement, m as ScopeFinalizer, p as MaybePromise, z as ServiceRequirements } from "./index-AiKM71-u.mjs";
|
|
2
|
+
import { a as RuntimeObserver, l as MaybePromise$1, t as RuntimeExecutionAttributes } from "./observer-9nhbL7Pr.mjs";
|
|
2
3
|
//#region src/internal/variance.d.ts
|
|
3
4
|
/** Type-level marker for a value produced by `A`. */
|
|
4
5
|
type Covariant<A> = () => A;
|
|
5
6
|
/** Type-level marker that both consumes and produces `A`. */
|
|
6
7
|
type Invariant<A> = (value: A) => A;
|
|
7
8
|
//#endregion
|
|
8
|
-
//#region src/utils/types.d.ts
|
|
9
|
-
type MaybePromise<T> = T | PromiseLike<T>;
|
|
10
|
-
//#endregion
|
|
11
9
|
//#region src/internal/missing-dependencies.d.ts
|
|
12
10
|
type MissingDependencies<Missing extends AnyService> = {
|
|
13
11
|
/** Names the Services that must be supplied before execution. */
|
|
@@ -187,8 +185,16 @@ type CompleteExecution<Provided extends AnyService, A> = CompleteExecutionWithRe
|
|
|
187
185
|
interface LayerRegistration {
|
|
188
186
|
/** The class-backed Service token provided by this registration. */
|
|
189
187
|
readonly service: ServiceClass<any, any>;
|
|
188
|
+
/**
|
|
189
|
+
* The canonical tag captured when the provider was created.
|
|
190
|
+
*
|
|
191
|
+
* This remains optional for direct backend registrations created against the
|
|
192
|
+
* pre-inspection API; backends capture the token tag synchronously when it is
|
|
193
|
+
* omitted.
|
|
194
|
+
*/
|
|
195
|
+
readonly serviceTag?: string;
|
|
190
196
|
/** Lazily acquire the Service instance; concrete types are erased at this backend boundary. */
|
|
191
|
-
readonly acquire: () => MaybePromise<unknown>;
|
|
197
|
+
readonly acquire: () => MaybePromise$1<unknown>;
|
|
192
198
|
}
|
|
193
199
|
/** Generator shape used by `Layer.gen` and `Layer.scopedGen`. */
|
|
194
200
|
type LayerGenerator<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown> = ServiceRequirement<unknown>> = () => AsyncGenerator<Yield, ServiceContract<InstanceType<S>>, unknown>;
|
|
@@ -206,10 +212,12 @@ type CapturedLayerAcquisition = {
|
|
|
206
212
|
readonly release: ScopeFinalizer;
|
|
207
213
|
};
|
|
208
214
|
interface LayerProvider extends LayerRegistration {
|
|
215
|
+
/** The tag captured before this provider can cross an asynchronous boundary. */
|
|
216
|
+
readonly serviceTag: string;
|
|
209
217
|
/** Provider storage deliberately erases the concrete instance type. */
|
|
210
|
-
readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise<void>;
|
|
218
|
+
readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise$1<void>;
|
|
211
219
|
/** Capture acquisition-local cleanup without retaining the acquired instance. */
|
|
212
|
-
readonly acquireWithRelease?: () => MaybePromise<CapturedLayerAcquisition>;
|
|
220
|
+
readonly acquireWithRelease?: () => MaybePromise$1<CapturedLayerAcquisition>;
|
|
213
221
|
}
|
|
214
222
|
/** A Service class whose constructor can be called without arguments. */
|
|
215
223
|
type DefaultConstructibleServiceClass<Tag extends string = string, Instance extends AnyService = AnyService> = ServiceClass<Tag, Instance> & (new () => Instance);
|
|
@@ -250,17 +258,17 @@ declare class Layer<in out Provided extends AnyService = AnyService, out Require
|
|
|
250
258
|
static readonly empty: Layer<never, never>;
|
|
251
259
|
/** Create a Layer that lazily acquires a Service instance. */
|
|
252
260
|
static make<S extends DefaultConstructibleServiceClass<any, any>>(service: S): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
253
|
-
static make<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
261
|
+
static make<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise$1<ServiceContract<InstanceType<S>>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
254
262
|
/** Create a Layer from an already-constructed Service instance. */
|
|
255
263
|
static succeed<S extends ServiceClass<any, any>>(service: S, instance: ServiceContract<InstanceType<S>>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
256
264
|
/** Alias a source Service under a compatible target contract. */
|
|
257
265
|
static alias<From extends ServiceClass<any, any>, To extends ServiceClass<any, any>>(options: LayerAliasOptions<From, To>): LayerResult<ProviderEntry<InstanceType<To>, InstanceType<From> | ServiceRequirements<InstanceType<To>>>>;
|
|
258
266
|
/** Define a provider with Runtime-root cleanup. */
|
|
259
|
-
static scoped<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
267
|
+
static scoped<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise$1<ServiceContract<InstanceType<S>>>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise$1<void>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
260
268
|
/** Define a provider with Runtime-root cleanup through its disposal protocol. */
|
|
261
|
-
static scopedDisposable<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise<ServiceContract<InstanceType<S>> & DisposableResource>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
269
|
+
static scopedDisposable<S extends ServiceClass<any, any>>(service: S, acquire: () => MaybePromise$1<ServiceContract<InstanceType<S>> & DisposableResource>): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>;
|
|
262
270
|
/** Define a provider whose acquisition can yield contextual Services. */
|
|
263
|
-
static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
|
|
271
|
+
static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>, release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise$1<void>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
|
|
264
272
|
/** Define a provider whose acquisition can yield contextual Services. */
|
|
265
273
|
static gen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(service: S, factory: LayerGenerator<S, Yield>): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>;
|
|
266
274
|
/** Compose Layers without replacing providers. */
|
|
@@ -298,23 +306,9 @@ type LayerBackendDisposeOptions = {
|
|
|
298
306
|
/** Runtime adapter responsible for registering, resolving, and disposing Layer providers. */
|
|
299
307
|
interface LayerBackend extends ServiceResolver {
|
|
300
308
|
/** Register one Service provider with the backend. */
|
|
301
|
-
register(registration: LayerRegistration): MaybePromise<void>;
|
|
309
|
+
register(registration: LayerRegistration): MaybePromise$1<void>;
|
|
302
310
|
/** Dispose all backend-owned instances and provider registrations. */
|
|
303
|
-
disposeAll(options?: LayerBackendDisposeOptions): MaybePromise<void>;
|
|
304
|
-
}
|
|
305
|
-
//#endregion
|
|
306
|
-
//#region src/layer/map-layer-backend.d.ts
|
|
307
|
-
/** Native map-backed Layer backend used by Runtime when no adapter is supplied. */
|
|
308
|
-
declare class MapLayerBackend implements LayerBackend {
|
|
309
|
-
private readonly providers;
|
|
310
|
-
private readonly instances;
|
|
311
|
-
private readonly pending;
|
|
312
|
-
/** Register a provider, rejecting duplicate or colliding Service tags. */
|
|
313
|
-
register(registration: LayerRegistration): void;
|
|
314
|
-
/** Resolve and cache a provider instance by Service tag. */
|
|
315
|
-
resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>>;
|
|
316
|
-
/** Clear pending acquisitions, cached instances, and provider registrations. */
|
|
317
|
-
disposeAll(options?: LayerBackendDisposeOptions): Promise<void>;
|
|
311
|
+
disposeAll(options?: LayerBackendDisposeOptions): MaybePromise$1<void>;
|
|
318
312
|
}
|
|
319
313
|
//#endregion
|
|
320
314
|
//#region src/layer/errors.d.ts
|
|
@@ -350,47 +344,6 @@ declare class LayerGeneratorYieldError extends Error {
|
|
|
350
344
|
constructor(service: ServiceClass<any>);
|
|
351
345
|
}
|
|
352
346
|
//#endregion
|
|
353
|
-
//#region src/runtime/observer.d.ts
|
|
354
|
-
/** Event emitted after a Service resolution attempt settles. */
|
|
355
|
-
type RuntimeServiceResolveEvent = {
|
|
356
|
-
readonly service: AnyServiceToken;
|
|
357
|
-
readonly resolutionPath: readonly AnyServiceToken[];
|
|
358
|
-
readonly outcome: ScopeOutcome;
|
|
359
|
-
};
|
|
360
|
-
/** Event emitted after a provider acquisition attempt settles. */
|
|
361
|
-
type RuntimeServiceAcquireEvent = {
|
|
362
|
-
readonly service: AnyServiceToken;
|
|
363
|
-
readonly resolutionPath: readonly AnyServiceToken[];
|
|
364
|
-
readonly outcome: ScopeOutcome;
|
|
365
|
-
};
|
|
366
|
-
/** Event emitted immediately before a program starts in an execution Scope. */
|
|
367
|
-
type RuntimeExecutionStartEvent = {
|
|
368
|
-
readonly scope: Scope;
|
|
369
|
-
};
|
|
370
|
-
/** Event emitted after a program and its execution Scope settle. */
|
|
371
|
-
type RuntimeExecutionEndEvent = {
|
|
372
|
-
readonly scope: Scope;
|
|
373
|
-
readonly outcome: ScopeOutcome;
|
|
374
|
-
};
|
|
375
|
-
/** Event emitted after a Layer provider release callback settles. */
|
|
376
|
-
type RuntimeResourceReleaseEvent = {
|
|
377
|
-
readonly service: AnyServiceToken;
|
|
378
|
-
readonly outcome: ScopeOutcome;
|
|
379
|
-
readonly error?: unknown;
|
|
380
|
-
};
|
|
381
|
-
/** Optional best-effort hooks for Runtime lifecycle and resolution events. */
|
|
382
|
-
type RuntimeObserver = {
|
|
383
|
-
readonly onServiceResolve?: (event: RuntimeServiceResolveEvent) => MaybePromise<void>;
|
|
384
|
-
readonly onServiceAcquire?: (event: RuntimeServiceAcquireEvent) => MaybePromise<void>;
|
|
385
|
-
readonly onExecutionStart?: (event: RuntimeExecutionStartEvent) => MaybePromise<void>;
|
|
386
|
-
readonly onExecutionEnd?: (event: RuntimeExecutionEndEvent) => MaybePromise<void>;
|
|
387
|
-
readonly onResourceRelease?: (event: RuntimeResourceReleaseEvent) => MaybePromise<void>;
|
|
388
|
-
};
|
|
389
|
-
/** Compose best-effort Runtime observers into one observer. */
|
|
390
|
-
declare const RuntimeObserver: {
|
|
391
|
-
compose: (...observers: readonly RuntimeObserver[]) => RuntimeObserver;
|
|
392
|
-
};
|
|
393
|
-
//#endregion
|
|
394
347
|
//#region src/runtime/outcome.d.ts
|
|
395
348
|
/** Aggregated cleanup information reported during Runtime shutdown. */
|
|
396
349
|
type RuntimeShutdownDiagnostic = {
|
|
@@ -400,7 +353,7 @@ type RuntimeShutdownDiagnostic = {
|
|
|
400
353
|
readonly error: LayerDisposeError;
|
|
401
354
|
};
|
|
402
355
|
/** Observer notified about cleanup failures without changing primary results. */
|
|
403
|
-
type CleanupFailureObserver = (diagnostic: CleanupFailureDiagnostic | RuntimeShutdownDiagnostic) => MaybePromise
|
|
356
|
+
type CleanupFailureObserver = (diagnostic: CleanupFailureDiagnostic | RuntimeShutdownDiagnostic) => MaybePromise<void>;
|
|
404
357
|
/** Optional Runtime configuration for cleanup diagnostics. */
|
|
405
358
|
type RuntimeOptions = {
|
|
406
359
|
/** Backend used to register and resolve the Layer. Defaults to MapLayerBackend. */
|
|
@@ -416,9 +369,11 @@ type RuntimeOptions = {
|
|
|
416
369
|
/** Optional signal exposed through the RuntimeContext. */
|
|
417
370
|
readonly signal?: AbortSignal;
|
|
418
371
|
};
|
|
419
|
-
/** Optional signal supplied to one
|
|
372
|
+
/** Optional signal and diagnostic attributes supplied to one Runtime execution. */
|
|
420
373
|
type RuntimeRunOptions = {
|
|
421
374
|
readonly signal?: AbortSignal;
|
|
375
|
+
/** Copied once and exposed as a readonly event view. */
|
|
376
|
+
readonly attributes?: RuntimeExecutionAttributes;
|
|
422
377
|
};
|
|
423
378
|
/** Cooperative shutdown policy for a managed Runtime. */
|
|
424
379
|
type RuntimeDisposeOptions = {
|
|
@@ -428,5 +383,5 @@ type RuntimeDisposeOptions = {
|
|
|
428
383
|
readonly abortAfterGracePeriod?: boolean;
|
|
429
384
|
};
|
|
430
385
|
//#endregion
|
|
431
|
-
export {
|
|
432
|
-
//# sourceMappingURL=
|
|
386
|
+
export { ProviderEntry as A, OverrideLayerResult as C, ValidateOneOverride as D, ValidateLayerInput as E, ValidateOverrides as O, MissingServices as S, RequiredEnvironment as T, CompleteInput as _, RuntimeShutdownDiagnostic as a, LayerInputState as b, LayerGeneratorYieldError as c, LayerBackend as d, LayerBackendDisposeOptions as f, CompleteExecutionLayer as g, CompleteExecution as h, RuntimeRunOptions as i, MissingDependencies as j, ValidateOverridesWitness as k, LayerRegistrationError as l, LayerRegistration as m, RuntimeDisposeOptions as n, DuplicateServiceError as o, Layer as p, RuntimeOptions as r, LayerDisposeError as s, CleanupFailureObserver as t, ServiceTagCollisionError as u, ExecutionMissing as v, ProvidedEnvironment as w, LayerResult as x, LayerInput as y };
|
|
387
|
+
//# sourceMappingURL=outcome-DI8LPIQ4.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome-DI8LPIQ4.d.mts","names":[],"sources":["../src/internal/variance.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/errors.ts","../src/runtime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mB,UAC7B,WAAW,YAAY,kBAAkB,MAAM,aACjD,oBAAoB,MAAM;SAEtB,SAAS,aAAa,kBAAkB,2BAA2B,cACxE,MAAM,OAAO,mBAAmB,UAC7B,WAAW,YAAY,kBAAkB,MAAM,aACjD,oBAAoB,MAAM;;;kBAuCN;;OAEX,MAAM;;OAGN,SAAS,UAAU,cAAc,oBAAoB;;OAGrD,SAAS,UAAU,cAAc,oBAAoB;;OAGrD,QAAQ,UAAU,cAAc,oBAAoB;;OAGpD,SAAS,UAAU,cAAc,cAAc;;;;;KCjYjD;;;;;WAKD,yBACP,uBAAuB,8BACb;;;UAIG,qBAAqB;;EAEpC,SAAS,cAAc,oBAAoB;;EAG3C,WAAW,UAAU,6BAA6B;;;;KClB/C,aAAa,QAAQ;WAAyB;;;cAGtC,8BAA8B;WACpB,SAAS;EAAT,YAAA,SAAS;;;cAQnB,iCAAiC;WAEjC,UAAU;WACV,UAAU;EADV,YAAA,UAAU,iBACV,UAAU;;;cAYV,+BAA+B;WAE/B,SAAS;WACT,mBAAmB;WACnB,eAAe;EAFf,YAAA,SAAS,+BACT,mBAAmB,YACnB,eAAe;;;cAgBf,0BAA0B;WAChB;EAAA,YAAA;;;cAQV,iCAAiC;WACvB,SAAS;EAAT,YAAA,SAAS;;;;;KChDpB;;WAED,SAAS;;WAET,OAAO;;;KAIN,0BACV,YAAY,2BAA2B,8BACpC;;KAGO;;WAED,UAAU;;WAEV;;WAEA,qBAAqB;;WAErB,mBAAmB;;WAEnB,iBAAiB;;WAEjB,SAAS;;;KAIR;WACD,SAAS;;WAET,aAAa;;;KAIZ;;WAED;;WAEA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as RuntimeContextNotConfiguredError, i as getRuntimeContext, l as makeRuntimeContext, n as currentRuntimeContext, t as activeRuntimeContextStorage, u as runRuntimeContext } from "./context-
|
|
2
|
-
import { a as
|
|
1
|
+
import { h as RuntimeContextNotConfiguredError, i as getRuntimeContext, l as makeRuntimeContext, n as currentRuntimeContext, t as activeRuntimeContextStorage, u as runRuntimeContext } from "./context-BphfFUMO.mjs";
|
|
2
|
+
import { a as ScopeClosedError, i as ScopeCloseError, n as getDisposeFinalizer, o as ScopeRuntimeNotConfiguredError, r as ResourceNotDisposableError } from "./disposable-CP-Q2H3l.mjs";
|
|
3
3
|
//#region src/scope/runtime.ts
|
|
4
4
|
const scopeStorages = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
/** Bridges the current Scope through async execution context. */
|
|
@@ -240,6 +240,21 @@ const Scope = {
|
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
242
|
//#endregion
|
|
243
|
-
|
|
243
|
+
//#region src/effect/program-metadata.ts
|
|
244
|
+
const programNames = /* @__PURE__ */ new WeakMap();
|
|
245
|
+
/** Return the private diagnostic name attached to a callable Program. */
|
|
246
|
+
const getProgramName = (program) => programNames.get(program);
|
|
247
|
+
/** Attach a name without changing the callable Program facade. */
|
|
248
|
+
const setProgramName = (program, name) => {
|
|
249
|
+
programNames.set(program, name);
|
|
250
|
+
return program;
|
|
251
|
+
};
|
|
252
|
+
/** Copy a source Program's name to a lazily-created derived Program. */
|
|
253
|
+
const inheritProgramName = (source, derived) => {
|
|
254
|
+
const name = getProgramName(source);
|
|
255
|
+
return name === void 0 ? derived : setProgramName(derived, name);
|
|
256
|
+
};
|
|
257
|
+
//#endregion
|
|
258
|
+
export { runScoped as a, Scope as i, inheritProgramName as n, ScopeRuntime as o, setProgramName as r, getProgramName as t };
|
|
244
259
|
|
|
245
|
-
//# sourceMappingURL=
|
|
260
|
+
//# sourceMappingURL=program-metadata-BxjGkT17.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program-metadata-BxjGkT17.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,KAAK,OAAc,SAAsC;EAC9D,cAAc,IAAI,OAAO,OAAO;CAClC;AACF;;;ACzCA,MAAM,uBAAuB,OAC3B,UACA,eACkB;CAClB,IAAI,CAAC,UACH;CAGF,IAAI;EACF,MAAM,SAAS,UAAU;CAC3B,QAAQ,CAER;AACF;AAEA,MAAa,YAAY,OACvB,OACA,SACA,YACwB;CACxB,IAAI;CAEJ,IAAI,gBAAgB;CACpB,IAAI;CAE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;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;CAEtE,IAAI,YAAY,iBAAiB,OAAO;EACtC,IAAI,WAAW,cAAc,WAAW,UAAU,OAAO,WAAW,aAAa,OAC/E;EAGF,IAAI,WAAW,cAAc,WAAW,UAAU,OAAO,WAAW,aAAa,MAAM;GACrF,OAAO,eA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AE,KAC1D,yBACJ,EACE,OAAO,kBACT,CACF;EAXS,KAAA,UAAA;EACA,KAAA,oBAAA;EACA,KAAA,eAAA;EAWT,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,oBAAb,cAAuC,MAAM;CACtB;CAArB,YAAY,QAAqC;EAC/C,MAAM,4BAA4B,OAAO,OAAO,QAAQ,OAAO,WAAW,IAAI,KAAK,IAAI,EAAE;EADtE,KAAA,SAAA;EAGnB,KAAK,OAAO;CACd;AACF;;AAGA,IAAa,2BAAb,cAA8C,MAAM;CAC7B;CAArB,YAAY,SAAqC;EAC/C,MAAM,cAAc,kBAAkB,OAAO,EAAE,gCAAgC;EAD5D,KAAA,UAAA;EAGnB,KAAK,OAAO;CACd;AACF;;;AC7DA,MAAM,2BAA2B,SAAkB,oBAAqC;CACtF,MAAM,WAAW,kBAAkB,OAAO;CAE1C,IAAI,oBAAoB,KAAA,GACtB,OAAO;CAGT,MAAM,eAAe,mBAAmB,eAAe;CAEvD,IAAI,iBAAiB,UACnB,MAAM,IAAI,UAAU,yDAAyD;CAG/E,OAAO;AACT;;AAGA,MAAa,+BAA+B,iBAA4C;CAEtF,IAAI,OAAO,iBAAiB,YAAY,iBAAiB,MACvD,MAAM,IAAI,UAAU,qCAAqC;CAG3D,OAAO,wBAAwB,aAAa,SAAS,aAAa,UAAU;AAC9E;;AAGA,MAAa,8BAA8B,iBAAuD;CAChG,MAAM,UAAU,aAAa;CAC7B,MAAM,kBAAkB,aAAa;CACrC,MAAM,UAAU,aAAa;CAC7B,MAAM,aAAa,wBAAwB,SAAS,eAAe;CAEnE,OAAO,OAAO,OAAO;EACnB;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as RuntimeContextStorage, s as RuntimeContext } from "../index-
|
|
1
|
+
import { c as RuntimeContextStorage, s as RuntimeContext } from "../index-AiKM71-u.mjs";
|
|
2
2
|
import { n as RuntimeContextOverlapError, t as RuntimeContextNotConfiguredError } from "../errors-BKcsQ0ip.mjs";
|
|
3
3
|
//#region src/runtime/explicit.d.ts
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getRuntimeContextLineage, c as isRuntimeContextFrameCarrierInstalled, g as RuntimeContextOverlapError, h as RuntimeContextNotConfiguredError, m as withActiveRuntimeContextStorage, o as inheritRuntimeContextLineage, p as setRuntimeContextLineage, r as currentRuntimeContextFrame, s as isDerivedRuntimeContext } from "../context-
|
|
1
|
+
import { a as getRuntimeContextLineage, c as isRuntimeContextFrameCarrierInstalled, g as RuntimeContextOverlapError, h as RuntimeContextNotConfiguredError, m as withActiveRuntimeContextStorage, o as inheritRuntimeContextLineage, p as setRuntimeContextLineage, r as currentRuntimeContextFrame, s as isDerivedRuntimeContext } from "../context-BphfFUMO.mjs";
|
|
2
2
|
import { t as isPromiseLike } from "../runtime-CDcCF5cb.mjs";
|
|
3
3
|
//#region src/runtime/explicit.ts
|
|
4
4
|
let fallbackRootLease = false;
|
package/dist/runtime/node.d.mts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { c as RuntimeContextStorage, s as RuntimeContext } from "../index-
|
|
1
|
+
import { c as RuntimeContextStorage, s as RuntimeContext } from "../index-AiKM71-u.mjs";
|
|
2
2
|
import { t as RuntimeContextNotConfiguredError } from "../errors-BKcsQ0ip.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
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-DczjAcrX.mjs";
|
|
4
|
+
export { NodeRuntimeContextStorage, type RuntimeContext, RuntimeContextNotConfiguredError, type RuntimeContextStorage, nodeRuntimeContextStorage };
|
package/dist/runtime/node.mjs
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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-BphfFUMO.mjs";
|
|
2
|
+
import { n as nodeRuntimeContextStorage, t as NodeRuntimeContextStorage } from "../node-context-Ca18oNSg.mjs";
|
|
23
3
|
export { NodeRuntimeContextStorage, RuntimeContextNotConfiguredError, nodeRuntimeContextStorage };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=node.mjs.map
|