better-effect 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +337 -88
- package/dist/adapters/iti.d.mts +2 -3
- package/dist/adapters/iti.d.mts.map +1 -1
- package/dist/adapters/iti.mjs +2 -2
- package/dist/bun.d.mts +75 -23
- package/dist/bun.d.mts.map +1 -1
- package/dist/bun.mjs +170 -33
- package/dist/bun.mjs.map +1 -1
- package/dist/{context-BphfFUMO.mjs → context-DSGSqcJj.mjs} +12 -3
- package/dist/context-DSGSqcJj.mjs.map +1 -0
- package/dist/{current-request-DDKNyymv.mjs → current-request-Bc1YHL0w.mjs} +3 -2
- package/dist/{current-request-DDKNyymv.mjs.map → current-request-Bc1YHL0w.mjs.map} +1 -1
- package/dist/{current-request-CIU7AHhF.d.mts → current-request-Dm-QQ3Xr.d.mts} +4 -4
- package/dist/current-request-Dm-QQ3Xr.d.mts.map +1 -0
- package/dist/{effect-CPdV7Yv8.mjs → effect-W0IQXY8P.mjs} +21 -2
- package/dist/effect-W0IQXY8P.mjs.map +1 -0
- package/dist/{errors-BKcsQ0ip.d.mts → errors-CpHMzPiP.d.mts} +6 -2
- package/dist/errors-CpHMzPiP.d.mts.map +1 -0
- package/dist/hono.d.mts +63 -27
- package/dist/hono.d.mts.map +1 -1
- package/dist/hono.mjs +111 -45
- package/dist/hono.mjs.map +1 -1
- package/dist/{index-CCi07kUw.d.mts → index-3Bkl-sxS.d.mts} +7 -2
- package/dist/{index-CCi07kUw.d.mts.map → index-3Bkl-sxS.d.mts.map} +1 -1
- package/dist/{index-cXgyMa0v.d.mts → index-C2ed9Ilq.d.mts} +32 -7
- package/dist/index-C2ed9Ilq.d.mts.map +1 -0
- package/dist/{index-BodMy6rO.d.mts → index-ClNndn2-.d.mts} +93 -63
- package/dist/index-ClNndn2-.d.mts.map +1 -0
- package/dist/{index-DAKn0qHk.d.mts → index-Cy1VsU-u.d.mts} +2 -4
- package/dist/index-Cy1VsU-u.d.mts.map +1 -0
- package/dist/index.d.mts +6 -8
- package/dist/index.mjs +8 -9
- package/dist/index.mjs.map +1 -1
- package/dist/{internal-identity-CbXoZIfw.mjs → internal-identity-BuHBtP0k.mjs} +2 -2
- package/dist/{internal-identity-CbXoZIfw.mjs.map → internal-identity-BuHBtP0k.mjs.map} +1 -1
- package/dist/layer-2kjHVv4N.mjs +343 -0
- package/dist/layer-2kjHVv4N.mjs.map +1 -0
- package/dist/layer-C2OaqTmB.d.mts +987 -0
- package/dist/layer-C2OaqTmB.d.mts.map +1 -0
- package/dist/next.d.mts +102 -26
- package/dist/next.d.mts.map +1 -1
- package/dist/next.mjs +157 -40
- package/dist/next.mjs.map +1 -1
- package/dist/{node-context-DczjAcrX.d.mts → node-context-1YEjrU9g.d.mts} +2 -2
- package/dist/{node-context-DczjAcrX.d.mts.map → node-context-1YEjrU9g.d.mts.map} +1 -1
- package/dist/{node-context-Ca18oNSg.mjs → node-context-g3bCcY9t.mjs} +2 -2
- package/dist/{node-context-Ca18oNSg.mjs.map → node-context-g3bCcY9t.mjs.map} +1 -1
- package/dist/node.d.mts +11 -6
- package/dist/node.d.mts.map +1 -1
- package/dist/node.mjs +156 -10
- package/dist/node.mjs.map +1 -1
- package/dist/opentelemetry.d.mts +20 -2
- package/dist/opentelemetry.d.mts.map +1 -1
- package/dist/opentelemetry.mjs +423 -5
- package/dist/opentelemetry.mjs.map +1 -1
- package/dist/{registration-drnZk0SY.mjs → registration-Bwe2GbVu.mjs} +8 -2
- package/dist/registration-Bwe2GbVu.mjs.map +1 -0
- package/dist/runtime/explicit.d.mts +2 -2
- package/dist/runtime/explicit.mjs +1 -1
- package/dist/runtime/node.d.mts +3 -3
- package/dist/runtime/node.mjs +2 -2
- package/dist/runtime-qpcVwaz_.mjs +1680 -0
- package/dist/runtime-qpcVwaz_.mjs.map +1 -0
- package/dist/service-CO9VJQYa.mjs +74 -0
- package/dist/service-CO9VJQYa.mjs.map +1 -0
- package/dist/{signal-nfgFyNCk.mjs → signal-5Rg9bUUe.mjs} +2 -2
- package/dist/{signal-nfgFyNCk.mjs.map → signal-5Rg9bUUe.mjs.map} +1 -1
- package/dist/{standard-services-vnGIafkS.mjs → standard-services-B-iMM_W7.mjs} +38 -4
- package/dist/standard-services-B-iMM_W7.mjs.map +1 -0
- package/dist/standard-services.d.mts +4 -4
- package/dist/standard-services.mjs +3 -3
- package/dist/testing.d.mts +25 -7
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +51 -7
- package/dist/testing.mjs.map +1 -1
- package/dist/{types-oihI-ESv.d.mts → types-BFTqCCcw.d.mts} +32 -5
- package/dist/types-BFTqCCcw.d.mts.map +1 -0
- package/dist/web-effect-B9hp9jIe.mjs +380 -0
- package/dist/web-effect-B9hp9jIe.mjs.map +1 -0
- package/dist/web.d.mts +22 -13
- package/dist/web.d.mts.map +1 -1
- package/dist/web.mjs +1 -1
- package/package.json +10 -16
- package/dist/context-BphfFUMO.mjs.map +0 -1
- package/dist/current-request-CIU7AHhF.d.mts.map +0 -1
- package/dist/disposable-CP-Q2H3l.mjs +0 -57
- package/dist/disposable-CP-Q2H3l.mjs.map +0 -1
- package/dist/effect-CPdV7Yv8.mjs.map +0 -1
- package/dist/errors-BKcsQ0ip.d.mts.map +0 -1
- package/dist/index-AiKM71-u.d.mts +0 -376
- package/dist/index-AiKM71-u.d.mts.map +0 -1
- package/dist/index-BodMy6rO.d.mts.map +0 -1
- package/dist/index-DAKn0qHk.d.mts.map +0 -1
- package/dist/index-cXgyMa0v.d.mts.map +0 -1
- package/dist/layer-D16GKxuX.mjs +0 -269
- package/dist/layer-D16GKxuX.mjs.map +0 -1
- package/dist/observer-9nhbL7Pr.d.mts +0 -68
- package/dist/observer-9nhbL7Pr.d.mts.map +0 -1
- package/dist/outcome-DI8LPIQ4.d.mts +0 -387
- package/dist/outcome-DI8LPIQ4.d.mts.map +0 -1
- package/dist/program-metadata-BxjGkT17.mjs +0 -260
- package/dist/program-metadata-BxjGkT17.mjs.map +0 -1
- package/dist/registration-drnZk0SY.mjs.map +0 -1
- package/dist/runtime-C_55ofnL.mjs +0 -791
- package/dist/runtime-C_55ofnL.mjs.map +0 -1
- package/dist/standard-services-vnGIafkS.mjs.map +0 -1
- package/dist/types-oihI-ESv.d.mts.map +0 -1
- package/dist/web-Bq3MfMrj.mjs +0 -147
- package/dist/web-Bq3MfMrj.mjs.map +0 -1
package/dist/layer-D16GKxuX.mjs
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import { a as LayerGeneratorYieldError, d as ServiceRuntimeNotConfiguredError, f as captureServiceTag, m as validateServiceTag, p as registerServiceTag, r as DuplicateServiceError, s as ServiceTagCollisionError, t as captureLayerRegistrationTag } from "./registration-drnZk0SY.mjs";
|
|
2
|
-
import { h as RuntimeContextNotConfiguredError, i as getRuntimeContext, l as makeRuntimeContext, n as currentRuntimeContext, u as runRuntimeContext } from "./context-BphfFUMO.mjs";
|
|
3
|
-
import { n as getDisposeFinalizer, r as ResourceNotDisposableError, s as defaultRuntimeContextStorage } from "./disposable-CP-Q2H3l.mjs";
|
|
4
|
-
//#region src/service/runtime.ts
|
|
5
|
-
/** Provides the resolver context used by Service tokens during execution. */
|
|
6
|
-
var ServiceRuntime = class ServiceRuntime {
|
|
7
|
-
/**
|
|
8
|
-
* Run a callback with a resolver available to `yield* Service` expressions.
|
|
9
|
-
*
|
|
10
|
-
* The context is scoped to the callback and is restored afterward.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* const value = ServiceRuntime.run(resolver, () => {
|
|
15
|
-
* return ServiceRuntime.resolve(Database)
|
|
16
|
-
* })
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
static run(resolver, program, storage = defaultRuntimeContextStorage) {
|
|
20
|
-
const current = getRuntimeContext(storage);
|
|
21
|
-
const context = makeRuntimeContext(resolver, current?.scope, current?.resolver === resolver ? current.resolutionPath : [], current?.signal, current?.resolver === resolver ? current : void 0, current?.executionId);
|
|
22
|
-
return runRuntimeContext(storage, context, program);
|
|
23
|
-
}
|
|
24
|
-
/** Return the resolver active in the current execution context. */
|
|
25
|
-
static current() {
|
|
26
|
-
let context;
|
|
27
|
-
try {
|
|
28
|
-
context = currentRuntimeContext();
|
|
29
|
-
} catch (cause) {
|
|
30
|
-
if (cause instanceof RuntimeContextNotConfiguredError) throw new ServiceRuntimeNotConfiguredError();
|
|
31
|
-
throw cause;
|
|
32
|
-
}
|
|
33
|
-
if (!context.resolver) throw new ServiceRuntimeNotConfiguredError();
|
|
34
|
-
return context.resolver;
|
|
35
|
-
}
|
|
36
|
-
/** Resolve a Service token using the active resolver. */
|
|
37
|
-
static async resolve(token) {
|
|
38
|
-
captureServiceTag(token);
|
|
39
|
-
return await ServiceRuntime.current().resolve(token);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/service/service.ts
|
|
44
|
-
/**
|
|
45
|
-
* Declare a class-backed Service with a stable string-literal identity.
|
|
46
|
-
*
|
|
47
|
-
* The returned class is simultaneously the implementation type, the runtime
|
|
48
|
-
* dependency token, and the value yielded by `yield*` in an Effect generator.
|
|
49
|
-
* The explicit self type preserves exact instance inference, while the second
|
|
50
|
-
* call captures the tag as a literal for Layer composition and diagnostics.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* class Database extends Service<Database>()('Database') {
|
|
55
|
-
* query(): string {
|
|
56
|
-
* return 'ok'
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
*
|
|
60
|
-
* const database = yield* Database
|
|
61
|
-
* database.query()
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* @typeParam Self The instance type implemented by the declared Service.
|
|
65
|
-
*/
|
|
66
|
-
function Service() {
|
|
67
|
-
return function(tag) {
|
|
68
|
-
validateServiceTag(tag);
|
|
69
|
-
class BaseService {
|
|
70
|
-
/** The stable logical identity used by Layers and resolver backends. */
|
|
71
|
-
static serviceTag = tag;
|
|
72
|
-
/**
|
|
73
|
-
* Type-check a structural implementation of this Service.
|
|
74
|
-
*
|
|
75
|
-
* This is an identity helper. It returns the supplied value unchanged
|
|
76
|
-
* and does not invoke a constructor or modify its prototype.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```ts
|
|
80
|
-
* class Database extends Service<Database>()('Database') {
|
|
81
|
-
* query(sql: string): string {
|
|
82
|
-
* return sql
|
|
83
|
-
* }
|
|
84
|
-
* }
|
|
85
|
-
*
|
|
86
|
-
* const database = Database.of({
|
|
87
|
-
* query: (sql) => `Result: ${sql}`
|
|
88
|
-
* })
|
|
89
|
-
*
|
|
90
|
-
* database.query('SELECT 1')
|
|
91
|
-
* // 'Result: SELECT 1'
|
|
92
|
-
* // database is the original object, not an instance of Database
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
static of(implementation) {
|
|
96
|
-
return implementation;
|
|
97
|
-
}
|
|
98
|
-
/** Resolve this Service from the resolver active in the current runtime. */
|
|
99
|
-
static async *[Symbol.asyncIterator]() {
|
|
100
|
-
return await ServiceRuntime.resolve(this);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
registerServiceTag(BaseService, tag);
|
|
104
|
-
return BaseService;
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/layer/internal.ts
|
|
109
|
-
const runLayerGenerator = async (service, factory) => {
|
|
110
|
-
const iterator = factory();
|
|
111
|
-
const state = await iterator.next();
|
|
112
|
-
if (!state.done) try {
|
|
113
|
-
await iterator.return(void 0);
|
|
114
|
-
} finally {
|
|
115
|
-
throw new LayerGeneratorYieldError(service);
|
|
116
|
-
}
|
|
117
|
-
return state.value;
|
|
118
|
-
};
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/layer/layer.ts
|
|
121
|
-
/**
|
|
122
|
-
* Declarative collection of Service providers.
|
|
123
|
-
*
|
|
124
|
-
* A Layer describes how to acquire implementations; it does not execute
|
|
125
|
-
* providers until a `Runtime` is created. Use `merge` to compose distinct
|
|
126
|
-
* providers and `override` when replacing an existing provider intentionally.
|
|
127
|
-
*
|
|
128
|
-
* @example
|
|
129
|
-
* ```ts
|
|
130
|
-
* const AppLive = Layer.merge(
|
|
131
|
-
* Layer.succeed(Database, database),
|
|
132
|
-
* Layer.make(UserRepository)
|
|
133
|
-
* )
|
|
134
|
-
*
|
|
135
|
-
* const runtime = await Runtime.make(AppLive, backend)
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
var Layer = class Layer {
|
|
139
|
-
/** The provider registrations retained by this Layer. */
|
|
140
|
-
providers;
|
|
141
|
-
constructor(providers) {
|
|
142
|
-
this.providers = Object.freeze(providers.map((provider) => Object.freeze({
|
|
143
|
-
...provider,
|
|
144
|
-
serviceTag: captureLayerRegistrationTag(provider)
|
|
145
|
-
})));
|
|
146
|
-
}
|
|
147
|
-
/** A stable provider-free Layer for composition roots with no Services. */
|
|
148
|
-
static empty = Object.freeze(new Layer([]));
|
|
149
|
-
static make(service, acquire) {
|
|
150
|
-
const serviceTag = captureServiceTag(service);
|
|
151
|
-
const defaultAcquire = () => {
|
|
152
|
-
return new service();
|
|
153
|
-
};
|
|
154
|
-
const normalizedAcquire = normalizeAcquire(acquire ?? defaultAcquire);
|
|
155
|
-
return new Layer([{
|
|
156
|
-
service,
|
|
157
|
-
serviceTag,
|
|
158
|
-
acquire: normalizedAcquire
|
|
159
|
-
}]);
|
|
160
|
-
}
|
|
161
|
-
/** Create a Layer from an already-constructed Service instance. */
|
|
162
|
-
static succeed(service, instance) {
|
|
163
|
-
const serviceTag = captureServiceTag(service);
|
|
164
|
-
const normalizedAcquire = normalizeAcquire(() => instance);
|
|
165
|
-
return new Layer([{
|
|
166
|
-
service,
|
|
167
|
-
serviceTag,
|
|
168
|
-
acquire: normalizedAcquire
|
|
169
|
-
}]);
|
|
170
|
-
}
|
|
171
|
-
/** Alias a source Service under a compatible target contract. */
|
|
172
|
-
static alias(options) {
|
|
173
|
-
const { from, to } = options;
|
|
174
|
-
captureServiceTag(from);
|
|
175
|
-
return Layer.gen(to, async function* () {
|
|
176
|
-
return await ServiceRuntime.resolve(from);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
/** Define a provider with Runtime-root cleanup. */
|
|
180
|
-
static scoped(service, acquire, release) {
|
|
181
|
-
const serviceTag = captureServiceTag(service);
|
|
182
|
-
return new Layer([{
|
|
183
|
-
service,
|
|
184
|
-
serviceTag,
|
|
185
|
-
acquire: normalizeAcquire(acquire),
|
|
186
|
-
release: (instance, outcome) => {
|
|
187
|
-
return release(instance, outcome);
|
|
188
|
-
}
|
|
189
|
-
}]);
|
|
190
|
-
}
|
|
191
|
-
/** Define a provider with Runtime-root cleanup through its disposal protocol. */
|
|
192
|
-
static scopedDisposable(service, acquire) {
|
|
193
|
-
const acquireWithRelease = async () => {
|
|
194
|
-
const instance = await acquire();
|
|
195
|
-
const finalizer = getDisposeFinalizer(instance);
|
|
196
|
-
if (!finalizer) throw new ResourceNotDisposableError();
|
|
197
|
-
return {
|
|
198
|
-
instance,
|
|
199
|
-
release: finalizer
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
const serviceTag = captureServiceTag(service);
|
|
203
|
-
return new Layer([{
|
|
204
|
-
service,
|
|
205
|
-
serviceTag,
|
|
206
|
-
acquire: async () => (await acquireWithRelease()).instance,
|
|
207
|
-
acquireWithRelease
|
|
208
|
-
}]);
|
|
209
|
-
}
|
|
210
|
-
/** Define a provider whose acquisition can yield contextual Services. */
|
|
211
|
-
static scopedGen(service, factory, release) {
|
|
212
|
-
const serviceTag = captureServiceTag(service);
|
|
213
|
-
return new Layer([{
|
|
214
|
-
service,
|
|
215
|
-
serviceTag,
|
|
216
|
-
acquire: () => runLayerGenerator(service, factory),
|
|
217
|
-
release: (instance, outcome) => {
|
|
218
|
-
return release(instance, outcome);
|
|
219
|
-
}
|
|
220
|
-
}]);
|
|
221
|
-
}
|
|
222
|
-
/** Define a provider whose acquisition can yield contextual Services. */
|
|
223
|
-
static gen(service, factory) {
|
|
224
|
-
const serviceTag = captureServiceTag(service);
|
|
225
|
-
return new Layer([{
|
|
226
|
-
service,
|
|
227
|
-
serviceTag,
|
|
228
|
-
acquire: () => runLayerGenerator(service, factory)
|
|
229
|
-
}]);
|
|
230
|
-
}
|
|
231
|
-
/** Compose Layers without replacing providers. */
|
|
232
|
-
static merge(...layers) {
|
|
233
|
-
const providers = /* @__PURE__ */ new Map();
|
|
234
|
-
for (const layer of layers) for (const provider of layer.providers) {
|
|
235
|
-
const service = provider.service;
|
|
236
|
-
const serviceTag = captureLayerRegistrationTag(provider);
|
|
237
|
-
const existing = providers.get(serviceTag);
|
|
238
|
-
if (existing) {
|
|
239
|
-
if (existing.service !== service) throw new ServiceTagCollisionError(existing.service, service);
|
|
240
|
-
throw new DuplicateServiceError(service);
|
|
241
|
-
}
|
|
242
|
-
providers.set(serviceTag, provider);
|
|
243
|
-
}
|
|
244
|
-
return new Layer([...providers.values()]);
|
|
245
|
-
}
|
|
246
|
-
/** Mark a Layer composition root as complete without changing its runtime value. */
|
|
247
|
-
static complete(layer) {
|
|
248
|
-
return layer;
|
|
249
|
-
}
|
|
250
|
-
static override(base, ...overrides) {
|
|
251
|
-
const providers = /* @__PURE__ */ new Map();
|
|
252
|
-
for (const provider of base.providers) providers.set(captureLayerRegistrationTag(provider), provider);
|
|
253
|
-
for (const layer of overrides) for (const provider of layer.providers) providers.set(captureLayerRegistrationTag(provider), provider);
|
|
254
|
-
return new Layer([...providers.values()]);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
Object.defineProperty(Layer, "empty", {
|
|
258
|
-
value: Layer.empty,
|
|
259
|
-
writable: false,
|
|
260
|
-
enumerable: true,
|
|
261
|
-
configurable: false
|
|
262
|
-
});
|
|
263
|
-
const normalizeAcquire = (acquire) => () => {
|
|
264
|
-
return acquire();
|
|
265
|
-
};
|
|
266
|
-
//#endregion
|
|
267
|
-
export { Service as n, ServiceRuntime as r, Layer as t };
|
|
268
|
-
|
|
269
|
-
//# sourceMappingURL=layer-D16GKxuX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layer-D16GKxuX.mjs","names":["Constructor"],"sources":["../src/service/runtime.ts","../src/service/service.ts","../src/layer/internal.ts","../src/layer/layer.ts"],"sourcesContent":["import { ServiceRuntimeNotConfiguredError } from './errors'\nimport { captureServiceTag } from './tag'\n\nimport { RuntimeContextNotConfiguredError } from '../runtime/errors'\n\nimport {\n currentRuntimeContext,\n getRuntimeContext,\n makeRuntimeContext,\n runRuntimeContext\n} from '../runtime/context'\n\nimport { defaultRuntimeContextStorage } from '../runtime/default'\n\nimport type { AnyServiceToken } from './types'\n\nimport type { RuntimeContextStorage } from '../runtime/context'\n\n/** Resolves class-backed Service tokens for a runtime execution. */\nexport interface ServiceResolver {\n /** Resolve a token to its corresponding Service instance. */\n resolve<T extends AnyServiceToken>(token: T): InstanceType<T> | PromiseLike<InstanceType<T>>\n}\n\n/** Provides the resolver context used by Service tokens during execution. */\nexport class ServiceRuntime {\n /**\n * Run a callback with a resolver available to `yield* Service` expressions.\n *\n * The context is scoped to the callback and is restored afterward.\n *\n * @example\n * ```ts\n * const value = ServiceRuntime.run(resolver, () => {\n * return ServiceRuntime.resolve(Database)\n * })\n * ```\n */\n static run<A>(\n resolver: ServiceResolver,\n program: () => A,\n storage: RuntimeContextStorage = defaultRuntimeContextStorage\n ): A {\n const current = getRuntimeContext(storage)\n const context = makeRuntimeContext(\n resolver,\n current?.scope,\n current?.resolver === resolver ? current.resolutionPath : [],\n current?.signal,\n current?.resolver === resolver ? current : undefined,\n current?.executionId\n )\n\n return runRuntimeContext(storage, context, program)\n }\n\n /** Return the resolver active in the current execution context. */\n static current(): ServiceResolver {\n let context\n\n try {\n context = currentRuntimeContext()\n } catch (cause) {\n if (cause instanceof RuntimeContextNotConfiguredError) {\n throw new ServiceRuntimeNotConfiguredError()\n }\n\n throw cause\n }\n\n if (!context.resolver) {\n throw new ServiceRuntimeNotConfiguredError()\n }\n\n return context.resolver\n }\n\n /** Resolve a Service token using the active resolver. */\n static async resolve<T extends AnyServiceToken>(token: T): Promise<InstanceType<T>> {\n captureServiceTag(token)\n const resolver = ServiceRuntime.current()\n\n return await resolver.resolve(token)\n }\n}\n","import { ServiceRuntime } from './runtime'\nimport { registerServiceTag, validateServiceTag } from './tag'\n\nimport type { ServiceRequirement } from '../effect/types'\n\nimport type {\n AnyService,\n AnyServiceToken,\n ServiceClass,\n ServiceContract,\n ServiceIdentity,\n ServiceIdentityTypeId,\n ServiceInstance,\n ServiceRequirements,\n ServiceTag,\n ServiceToken,\n ServiceTokenOf\n} from './types'\n\ntype ServiceTagLiteral<Tag extends string> = string extends Tag\n ? never\n : Tag extends ''\n ? never\n : Tag\n\ninterface ServiceFactory<Self> {\n <const Tag extends string>(\n tag: ServiceTagLiteral<Tag>\n ): (abstract new () => ServiceIdentity<Tag>) & {\n readonly name: string\n readonly serviceTag: Tag\n } & {\n readonly of: Service.FactoryOf<Self, Tag>\n readonly [Symbol.asyncIterator]: (\n this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>\n ) => AsyncGenerator<ServiceRequirement<Self>, Self, unknown>\n }\n}\n\n/**\n * Declare a class-backed Service with a stable string-literal identity.\n *\n * The returned class is simultaneously the implementation type, the runtime\n * dependency token, and the value yielded by `yield*` in an Effect generator.\n * The explicit self type preserves exact instance inference, while the second\n * call captures the tag as a literal for Layer composition and diagnostics.\n *\n * @example\n * ```ts\n * class Database extends Service<Database>()('Database') {\n * query(): string {\n * return 'ok'\n * }\n * }\n *\n * const database = yield* Database\n * database.query()\n * ```\n *\n * @typeParam Self The instance type implemented by the declared Service.\n */\nexport function Service<Self>(): ServiceFactory<Self> {\n return function <const Tag extends string>(tag: ServiceTagLiteral<Tag>) {\n validateServiceTag(tag)\n\n abstract class BaseService implements ServiceIdentity<Tag> {\n /** The stable logical identity used by Layers and resolver backends. */\n static readonly serviceTag: Tag = tag\n declare readonly [ServiceIdentityTypeId]: Tag\n\n /**\n * Type-check a structural implementation of this Service.\n *\n * This is an identity helper. It returns the supplied value unchanged\n * and does not invoke a constructor or modify its prototype.\n *\n * @example\n * ```ts\n * class Database extends Service<Database>()('Database') {\n * query(sql: string): string {\n * return sql\n * }\n * }\n *\n * const database = Database.of({\n * query: (sql) => `Result: ${sql}`\n * })\n *\n * database.query('SELECT 1')\n * // 'Result: SELECT 1'\n * // database is the original object, not an instance of Database\n * ```\n */\n static of(this: void, implementation: ServiceContract<Self & ServiceIdentity<Tag>>): Self {\n // SAFETY: ServiceContract removes only the phantom marker; this boundary restores Self.\n return implementation as Self\n }\n\n /** Resolve this Service from the resolver active in the current runtime. */\n // oxlint-disable-next-line require-yield\n static async *[Symbol.asyncIterator](\n this: ServiceToken<Tag, Self & ServiceIdentity<Tag>>\n ): AsyncGenerator<ServiceRequirement<Self>, Self, unknown> {\n return await ServiceRuntime.resolve(this)\n }\n }\n\n registerServiceTag(BaseService, tag)\n\n return BaseService\n }\n}\n\n/** Type-level aliases for Service tokens and their instance contracts. */\nexport declare namespace Service {\n /** The widened Service instance constraint. */\n export type Any = AnyService\n\n /** A class-backed Service token with a stable tag and instance contract. */\n export type Token<Tag extends string = string, Instance extends AnyService = any> = ServiceToken<\n Tag,\n Instance\n >\n\n /** A constructible Service class with a stable tag and instance contract. */\n export type Class<\n Tag extends string = string,\n Instance extends AnyService = AnyService\n > = ServiceClass<Tag, Instance>\n\n /** Extract the instance represented by a Service token. */\n export type Instance<T extends AnyServiceToken> = ServiceInstance<T>\n\n /** Extract the stable tag represented by a Service instance. */\n export type Tag<S extends AnyService> = ServiceTag<S>\n\n /** A branded Service instance identity with a stable tag. */\n export type Identity<Tag extends string = string> = ServiceIdentity<Tag>\n\n /** Remove the internal identity marker from a Service implementation contract. */\n export type Contract<S extends AnyService> = ServiceContract<S>\n\n /** Extract the Service token represented by a branded Service instance. */\n export type TokenOf<S extends AnyService> = ServiceTokenOf<S>\n\n /** Declaration bridge for the recursive structural `Service.of` signature. */\n export type FactoryOf<Self, Tag extends string> = (\n this: void,\n implementation: ServiceContract<Self & ServiceIdentity<Tag>>\n ) => Self\n\n /** Extract Effect Service requirements from a Service instance. */\n export type Requirements<S extends AnyService> = ServiceRequirements<S>\n}\n","import { LayerGeneratorYieldError } from './errors'\n\nimport type { ServiceRequirement } from '../effect/types'\nimport type { ServiceClass } from '../service'\n\nimport type { LayerGenerator } from './types'\n\nexport const runLayerGenerator = async <\n S extends ServiceClass<any, any>,\n Yield extends ServiceRequirement<unknown>\n>(\n service: S,\n factory: LayerGenerator<S, Yield>\n): Promise<InstanceType<S>> => {\n const iterator = factory()\n\n const state = await iterator.next()\n\n if (!state.done) {\n try {\n // SAFETY: The iterator is closed only to discard an invalid yield; its return value is ignored.\n await iterator.return(undefined as never)\n } finally {\n // oxlint-disable-next-line no-unsafe-finally\n throw new LayerGeneratorYieldError(service)\n }\n }\n\n // SAFETY: The public generator boundary accepts only the requested Service contract.\n return state.value as InstanceType<S>\n}\n","import type { ServiceRequirement } from '../effect/types'\nimport { ServiceRuntime } from '../service'\nimport { captureServiceTag } from '../service/tag'\nimport type { AnyService, ServiceClass, ServiceContract, ServiceRequirements } from '../service'\nimport { ResourceNotDisposableError } from '../scope'\nimport { getDisposeFinalizer } from '../scope/disposable'\n\nimport type { DisposableResource, ScopeFinalizer, ScopeOutcome } from '../scope'\nimport type { Covariant, Invariant } from '../internal/variance'\nimport type { MaybePromise } from '../utils/types'\n\nimport { DuplicateServiceError, ServiceTagCollisionError } from './errors'\nimport { runLayerGenerator } from './internal'\nimport { captureLayerRegistrationTag } from './registration'\n\nimport type {\n LayerInput,\n CompleteInput,\n LayerResult,\n MergeResult,\n OverrideLayerResult,\n ValidateLayerInput,\n ValidateLayerTuple,\n ValidateOverrides,\n ProvidedEnvironment,\n RequiredEnvironment\n} from './inference'\nimport type { ProviderEntry } from './metadata'\nimport type { LayerGenerator, LayerGeneratorRequirements, LayerRegistration } from './types'\n\ndeclare const LayerTypeId: unique symbol\n\ninterface LayerVariance<in out Provided, out Required> {\n readonly _Provided: Invariant<Provided>\n readonly _Required: Covariant<Required>\n}\n\ntype CapturedLayerAcquisition = {\n readonly instance: unknown\n readonly release: ScopeFinalizer\n}\n\ninterface LayerProvider extends LayerRegistration {\n /** The tag captured before this provider can cross an asynchronous boundary. */\n readonly serviceTag: string\n\n /** Provider storage deliberately erases the concrete instance type. */\n // oxlint-disable-next-line anti-slop/no-unknown-parameters\n readonly release?: (instance: unknown, outcome: ScopeOutcome) => MaybePromise<void>\n\n /** Capture acquisition-local cleanup without retaining the acquired instance. */\n readonly acquireWithRelease?: () => MaybePromise<CapturedLayerAcquisition>\n}\n\n/** A Service class whose constructor can be called without arguments. */\ntype DefaultConstructibleServiceClass<\n Tag extends string = string,\n Instance extends AnyService = AnyService\n> = ServiceClass<Tag, Instance> & (new () => Instance)\n\ntype IsUnion<Type, Candidate = Type> = Type extends unknown\n ? [Candidate] extends [Type]\n ? false\n : true\n : never\n\ntype InvalidUnionAliasToken = {\n readonly __betterEffectUnionLayerAliasToken: unique symbol\n}\n\ntype RejectUnionAliasToken<Token> = IsUnion<Token> extends true ? InvalidUnionAliasToken : unknown\n\ntype LayerAliasOptions<From extends ServiceClass<any, any>, To extends ServiceClass<any, any>> = {\n readonly from: From\n readonly to: To\n} & RejectUnionAliasToken<From> &\n RejectUnionAliasToken<To> &\n ([ServiceContract<InstanceType<From>>] extends [ServiceContract<InstanceType<To>>]\n ? unknown\n : {\n readonly __betterEffectIncompatibleLayerAlias: unique symbol\n })\n\n/**\n * Declarative collection of Service providers.\n *\n * A Layer describes how to acquire implementations; it does not execute\n * providers until a `Runtime` is created. Use `merge` to compose distinct\n * providers and `override` when replacing an existing provider intentionally.\n *\n * @example\n * ```ts\n * const AppLive = Layer.merge(\n * Layer.succeed(Database, database),\n * Layer.make(UserRepository)\n * )\n *\n * const runtime = await Runtime.make(AppLive, backend)\n * ```\n */\nexport class Layer<\n in out Provided extends AnyService = AnyService,\n out Required extends AnyService = AnyService\n> {\n declare readonly [LayerTypeId]: LayerVariance<Provided, Required>\n\n /** The provider registrations retained by this Layer. */\n readonly providers: readonly LayerProvider[]\n\n private constructor(providers: readonly LayerProvider[]) {\n this.providers = Object.freeze(\n providers.map((provider) =>\n Object.freeze({\n ...provider,\n serviceTag: captureLayerRegistrationTag(provider)\n })\n )\n )\n }\n\n /** A stable provider-free Layer for composition roots with no Services. */\n static readonly empty: Layer<never, never> = Object.freeze(new Layer<never, never>([]))\n\n /** Create a Layer that lazily acquires a Service instance. */\n static make<S extends DefaultConstructibleServiceClass<any, any>>(\n service: S\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n\n static make<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n\n static make<S extends ServiceClass<any, any>>(\n service: S,\n acquire?: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n const defaultAcquire = (): InstanceType<S> => {\n // SAFETY: The no-argument overload constrains `service` to a default constructible class.\n const Constructor = service as new () => InstanceType<S>\n\n return new Constructor()\n }\n\n const normalizedAcquire = normalizeAcquire<S>(acquire ?? defaultAcquire)\n\n // SAFETY: Runtime storage erases only the concrete provider metadata; the public constructor result restores its typed provenance.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizedAcquire\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Create a Layer from an already-constructed Service instance. */\n static succeed<S extends ServiceClass<any, any>>(\n service: S,\n instance: ServiceContract<InstanceType<S>>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n const normalizedAcquire = normalizeAcquire<S>(() => instance)\n\n // SAFETY: The structural instance has been checked against the requested Service contract.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizedAcquire\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Alias a source Service under a compatible target contract. */\n static alias<From extends ServiceClass<any, any>, To extends ServiceClass<any, any>>(\n options: LayerAliasOptions<From, To>\n ): LayerResult<\n ProviderEntry<InstanceType<To>, InstanceType<From> | ServiceRequirements<InstanceType<To>>>\n > {\n const { from, to } = options\n void captureServiceTag(from)\n\n // Keep alias acquisition in the normal Layer generator path so Runtime supplies the active resolver and resolution diagnostics.\n // oxlint-disable-next-line require-yield\n const alias = Layer.gen(to, async function* () {\n const source = await ServiceRuntime.resolve(from)\n\n // SAFETY: LayerAliasOptions checks that the source implementation satisfies the target contract.\n return source as ServiceContract<InstanceType<To>>\n })\n\n // SAFETY: The alias factory resolves the declared source token before returning the target contract.\n return alias as LayerResult<\n ProviderEntry<InstanceType<To>, InstanceType<From> | ServiceRequirements<InstanceType<To>>>\n >\n }\n\n /** Define a provider with Runtime-root cleanup. */\n static scoped<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>,\n release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The public callbacks constrain acquisition and release to the requested Service.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: normalizeAcquire<S>(acquire),\n release: (instance, outcome) => {\n // SAFETY: The backend invokes release with the instance acquired for this token.\n return release(instance as InstanceType<S>, outcome)\n }\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Define a provider with Runtime-root cleanup through its disposal protocol. */\n static scopedDisposable<S extends ServiceClass<any, any>>(\n service: S,\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>> & DisposableResource>\n ): LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>> {\n const acquireWithRelease = async (): Promise<CapturedLayerAcquisition> => {\n const instance = await acquire()\n const finalizer = getDisposeFinalizer(instance)\n\n if (!finalizer) {\n throw new ResourceNotDisposableError()\n }\n\n return { instance, release: finalizer }\n }\n\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The public callback constrains the acquired value and this runtime-only carrier is erased at the Layer boundary.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: async () => (await acquireWithRelease()).instance,\n acquireWithRelease\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\n }\n\n /** Define a provider whose acquisition can yield contextual Services. */\n static scopedGen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(\n service: S,\n factory: LayerGenerator<S, Yield>,\n release: (instance: InstanceType<S>, outcome: ScopeOutcome) => MaybePromise<void>\n ): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The generator and release callback are checked against the requested Service.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: () => runLayerGenerator(service, factory),\n release: (instance, outcome) => {\n // SAFETY: The backend invokes release with the instance acquired for this token.\n return release(instance as InstanceType<S>, outcome)\n }\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>\n }\n\n /** Define a provider whose acquisition can yield contextual Services. */\n static gen<S extends ServiceClass<any, any>, Yield extends ServiceRequirement<unknown>>(\n service: S,\n factory: LayerGenerator<S, Yield>\n ): LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>> {\n const serviceTag = captureServiceTag(service)\n\n // SAFETY: The generator result is normalized to the requested Service at the runtime boundary.\n return new Layer([\n {\n service,\n serviceTag,\n acquire: () => runLayerGenerator(service, factory)\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, LayerGeneratorRequirements<S, Yield>>>\n }\n\n /** Compose Layers without replacing providers. */\n static merge<const Layers extends readonly LayerInput[]>(\n ...layers: Layers & ValidateLayerTuple<Layers>\n ): MergeResult<Layers> {\n const providers = new Map<string, LayerProvider>()\n\n for (const layer of layers) {\n for (const provider of layer.providers) {\n const service = provider.service\n const serviceTag = captureLayerRegistrationTag(provider)\n const existing = providers.get(serviceTag)\n\n if (existing) {\n if (existing.service !== service) {\n throw new ServiceTagCollisionError(existing.service, service)\n }\n\n throw new DuplicateServiceError(service)\n }\n\n providers.set(serviceTag, provider)\n }\n }\n\n // SAFETY: The heterogeneous provider list is erased only at this internal storage boundary.\n return new Layer([...providers.values()]) as MergeResult<Layers>\n }\n\n /** Mark a Layer composition root as complete without changing its runtime value. */\n static complete<L extends LayerInput>(layer: L & CompleteInput<L>): L {\n return layer\n }\n\n /** Replace providers in a base Layer, using tag identity and compatible contracts. */\n static override<Base extends LayerInput>(\n base: Base & ValidateLayerInput<Base>\n ): OverrideLayerResult<Base, readonly []>\n\n static override<\n Base extends LayerInput,\n const Overrides extends readonly [LayerInput, ...LayerInput[]]\n >(\n base: Base & ValidateLayerInput<Base>,\n ...overrides: Overrides & ValidateOverrides<Base, Overrides>\n ): OverrideLayerResult<Base, Overrides>\n\n static override<Base extends LayerInput, const Overrides extends readonly LayerInput[]>(\n base: Base & ValidateLayerInput<Base>,\n ...overrides: Overrides & ValidateOverrides<Base, Overrides>\n ): OverrideLayerResult<Base, Overrides>\n\n static override(base: LayerInput, ...overrides: readonly LayerInput[]): Layer<any, any> {\n const providers = new Map<string, LayerProvider>()\n\n for (const provider of base.providers) {\n providers.set(captureLayerRegistrationTag(provider), provider)\n }\n\n for (const layer of overrides) {\n for (const provider of layer.providers) {\n providers.set(captureLayerRegistrationTag(provider), provider)\n }\n }\n\n // SAFETY: Runtime provider replacement preserves the computed override metadata.\n return new Layer([...providers.values()]) as Layer<any, any>\n }\n}\n\n// TypeScript's `readonly` does not affect the runtime property descriptor. Keep\n// the class field's enumerable behavior while locking the singleton binding.\nObject.defineProperty(Layer, 'empty', {\n value: Layer.empty,\n writable: false,\n enumerable: true,\n configurable: false\n})\n\nconst normalizeAcquire =\n <S extends ServiceClass<any, any>>(\n acquire: () => MaybePromise<ServiceContract<InstanceType<S>>>\n ): (() => MaybePromise<InstanceType<S>>) =>\n () => {\n // SAFETY: ServiceContract removes only the declaration-only identity; runtime values are unchanged.\n return acquire() as MaybePromise<InstanceType<S>>\n }\n\n/** Type-level aliases for inspecting Layer environments and completeness. */\nexport declare namespace Layer {\n /** The widened Layer shape accepted by generic Layer infrastructure. */\n export type Any = LayerInput\n\n /** Extract the branded Service instances provided by a Layer. */\n export type Provided<L extends LayerInput> = ProvidedEnvironment<L>\n\n /** Extract the external Service requirements of a Layer. */\n export type Required<L extends LayerInput> = RequiredEnvironment<L>\n\n /** Extract the Services still missing from a Layer composition. */\n export type Missing<L extends LayerInput> = RequiredEnvironment<L>\n\n /** Validate a Layer's requirements and input shape. */\n export type Complete<L extends LayerInput> = CompleteInput<L>\n}\n"],"mappings":"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"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { N as AnyServiceToken, _ as ScopeCloseError, h as ScopeOutcome, u as Scope } from "./index-AiKM71-u.mjs";
|
|
2
|
-
//#region src/utils/types.d.ts
|
|
3
|
-
type MaybePromise<T> = T | PromiseLike<T>;
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region src/runtime/observer.d.ts
|
|
6
|
-
/** Event emitted after a Service resolution attempt settles. */
|
|
7
|
-
type RuntimeServiceResolveEvent = {
|
|
8
|
-
readonly service: AnyServiceToken;
|
|
9
|
-
readonly resolutionPath: readonly AnyServiceToken[];
|
|
10
|
-
readonly outcome: ScopeOutcome;
|
|
11
|
-
/** Runtime execution owner, omitted for warmup and other root activity. */
|
|
12
|
-
readonly executionId?: string;
|
|
13
|
-
};
|
|
14
|
-
/** Event emitted after a provider acquisition attempt settles. */
|
|
15
|
-
type RuntimeServiceAcquireEvent = {
|
|
16
|
-
readonly service: AnyServiceToken;
|
|
17
|
-
readonly resolutionPath: readonly AnyServiceToken[];
|
|
18
|
-
readonly outcome: ScopeOutcome;
|
|
19
|
-
/** Runtime execution owner, omitted for warmup and other root activity. */
|
|
20
|
-
readonly executionId?: string;
|
|
21
|
-
};
|
|
22
|
-
/** Values supplied to one Runtime execution for diagnostic correlation. */
|
|
23
|
-
type RuntimeExecutionAttributes = Readonly<Record<string, unknown>>;
|
|
24
|
-
/** Metadata shared by the start and end events for one execution. */
|
|
25
|
-
type RuntimeExecutionMetadata = {
|
|
26
|
-
readonly executionId: string;
|
|
27
|
-
readonly name?: string;
|
|
28
|
-
readonly attributes?: RuntimeExecutionAttributes;
|
|
29
|
-
/** Monotonic host timestamp captured immediately before the Program starts. */
|
|
30
|
-
readonly startedAt: number;
|
|
31
|
-
};
|
|
32
|
-
/** Event emitted immediately before a program starts in an execution Scope. */
|
|
33
|
-
type RuntimeExecutionStartEvent = RuntimeExecutionMetadata & {
|
|
34
|
-
readonly scope: Scope;
|
|
35
|
-
};
|
|
36
|
-
/** Event emitted after a program and its execution Scope settle. */
|
|
37
|
-
type RuntimeExecutionEndEvent = RuntimeExecutionMetadata & {
|
|
38
|
-
readonly scope: Scope;
|
|
39
|
-
/** The program outcome used to run execution-scope cleanup. */
|
|
40
|
-
readonly outcome: ScopeOutcome;
|
|
41
|
-
/** Execution-scope cleanup failure, without changing the primary program outcome. */
|
|
42
|
-
readonly cleanupFailure?: ScopeCloseError;
|
|
43
|
-
/** Monotonic elapsed time for the Program and its execution cleanup. */
|
|
44
|
-
readonly durationMs: number;
|
|
45
|
-
};
|
|
46
|
-
/** Event emitted after a Layer provider release callback settles. */
|
|
47
|
-
type RuntimeResourceReleaseEvent = {
|
|
48
|
-
readonly service: AnyServiceToken;
|
|
49
|
-
readonly outcome: ScopeOutcome;
|
|
50
|
-
readonly error?: unknown;
|
|
51
|
-
/** Runtime execution owner, omitted for Runtime-root cleanup. */
|
|
52
|
-
readonly executionId?: string;
|
|
53
|
-
};
|
|
54
|
-
/** Optional best-effort hooks for Runtime lifecycle and resolution events. */
|
|
55
|
-
type RuntimeObserver = {
|
|
56
|
-
readonly onServiceResolve?: (event: RuntimeServiceResolveEvent) => MaybePromise<void>;
|
|
57
|
-
readonly onServiceAcquire?: (event: RuntimeServiceAcquireEvent) => MaybePromise<void>;
|
|
58
|
-
readonly onExecutionStart?: (event: RuntimeExecutionStartEvent) => MaybePromise<void>;
|
|
59
|
-
readonly onExecutionEnd?: (event: RuntimeExecutionEndEvent) => MaybePromise<void>;
|
|
60
|
-
readonly onResourceRelease?: (event: RuntimeResourceReleaseEvent) => MaybePromise<void>;
|
|
61
|
-
};
|
|
62
|
-
/** Compose best-effort Runtime observers into one observer. */
|
|
63
|
-
declare const RuntimeObserver: {
|
|
64
|
-
compose: (...observers: readonly RuntimeObserver[]) => RuntimeObserver;
|
|
65
|
-
};
|
|
66
|
-
//#endregion
|
|
67
|
-
export { RuntimeObserver as a, RuntimeServiceResolveEvent as c, RuntimeExecutionStartEvent as i, MaybePromise as l, RuntimeExecutionEndEvent as n, RuntimeResourceReleaseEvent as o, RuntimeExecutionMetadata as r, RuntimeServiceAcquireEvent as s, RuntimeExecutionAttributes as t };
|
|
68
|
-
//# sourceMappingURL=observer-9nhbL7Pr.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observer-9nhbL7Pr.d.mts","names":[],"sources":["../src/utils/types.ts","../src/runtime/observer.ts"],"mappings":";;KAAY,aAAa,KAAK,IAAI,YAAY;;;;KCMlC;WACD,SAAS;WACT,yBAAyB;WACzB,SAAS;;WAET;;;KAIC;WACD,SAAS;WACT,yBAAyB;WACzB,SAAS;;WAET;;;KAKC,6BAA6B,SAAS;;KAGtC;WACD;WACA;WAEA,aAAa;;WAEb;;;KAIC,6BAA6B;WAC9B,OAAO;;;KAIN,2BAA2B;WAC5B,OAAO;;WAEP,SAAS;;WAET,iBAAiB;;WAEjB;;;KAIC;WACD,SAAS;WACT,SAAS;WACT;;WAEA;;;KAIC;WACD,oBAAoB,OAAO,+BAA+B;WAC1D,oBAAoB,OAAO,+BAA+B;WAC1D,oBAAoB,OAAO,+BAA+B;WAC1D,kBAAkB,OAAO,6BAA6B;WACtD,qBAAqB,OAAO,gCAAgC;;;cAI1D;EACa,aAAA,oBAAS,sBAAoB"}
|