better-effect 0.7.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -1
- package/dist/adapters/iti.d.mts +1 -1
- package/dist/adapters/iti.mjs +2 -1
- package/dist/adapters/iti.mjs.map +1 -1
- package/dist/{internal-identity-Cm4-KIUj.mjs → errors-Dnjhzbt0.mjs} +2 -25
- package/dist/errors-Dnjhzbt0.mjs.map +1 -0
- package/dist/{index-BddlcJK6.d.mts → index-BSRPIYII.d.mts} +58 -3
- package/dist/index-BSRPIYII.d.mts.map +1 -0
- package/dist/index-yOfq7LKL.d.mts +406 -0
- package/dist/index-yOfq7LKL.d.mts.map +1 -0
- package/dist/index.d.mts +4 -303
- package/dist/index.mjs +382 -262
- package/dist/index.mjs.map +1 -1
- package/dist/internal-identity-DmUpBeeL.mjs +27 -0
- package/dist/internal-identity-DmUpBeeL.mjs.map +1 -0
- package/dist/{map-layer-backend-BodcEeNA.mjs → map-layer-backend-gal-mcRv.mjs} +3 -2
- package/dist/{map-layer-backend-BodcEeNA.mjs.map → map-layer-backend-gal-mcRv.mjs.map} +1 -1
- package/dist/signal-BgUtPQj5.mjs +271 -0
- package/dist/signal-BgUtPQj5.mjs.map +1 -0
- package/dist/standard-services.d.mts +116 -0
- package/dist/standard-services.d.mts.map +1 -0
- package/dist/standard-services.mjs +180 -0
- package/dist/standard-services.mjs.map +1 -0
- package/dist/testing.mjs +1 -1
- package/package.json +6 -2
- package/dist/index-BddlcJK6.d.mts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/internal-identity-Cm4-KIUj.mjs.map +0 -1
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { a as ServiceTagCollisionError, l as ServiceRuntimeNotConfiguredError, r as LayerGeneratorYieldError, t as DuplicateServiceError } from "./errors-Dnjhzbt0.mjs";
|
|
2
|
+
import { a as runRuntimeContext, i as makeRuntimeContext, n as currentRuntimeContext, o as setDefaultRuntimeContextStorage, r as getRuntimeContext } from "./context-B4yO5LaH.mjs";
|
|
3
|
+
import { nodeRuntimeContextStorage } from "./runtime/node.mjs";
|
|
4
|
+
//#region src/runtime/default.ts
|
|
5
|
+
/** The Node/Bun storage used by the main Runtime entrypoint. */
|
|
6
|
+
const defaultRuntimeContextStorage = nodeRuntimeContextStorage;
|
|
7
|
+
setDefaultRuntimeContextStorage(defaultRuntimeContextStorage);
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/service/runtime.ts
|
|
10
|
+
/** Provides the resolver context used by Service tokens during execution. */
|
|
11
|
+
var ServiceRuntime = class ServiceRuntime {
|
|
12
|
+
/**
|
|
13
|
+
* Run a callback with a resolver available to `yield* Service` expressions.
|
|
14
|
+
*
|
|
15
|
+
* The context is scoped to the callback and is restored afterward.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const value = ServiceRuntime.run(resolver, () => {
|
|
20
|
+
* return ServiceRuntime.resolve(Database)
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
static run(resolver, program, storage = defaultRuntimeContextStorage) {
|
|
25
|
+
const current = getRuntimeContext(storage);
|
|
26
|
+
const context = makeRuntimeContext(resolver, current?.scope, current?.resolver === resolver ? current.resolutionPath : [], current?.signal);
|
|
27
|
+
return runRuntimeContext(storage, context, program);
|
|
28
|
+
}
|
|
29
|
+
/** Return the resolver active in the current execution context. */
|
|
30
|
+
static current() {
|
|
31
|
+
let context;
|
|
32
|
+
try {
|
|
33
|
+
context = currentRuntimeContext();
|
|
34
|
+
} catch {
|
|
35
|
+
throw new ServiceRuntimeNotConfiguredError();
|
|
36
|
+
}
|
|
37
|
+
if (!context.resolver) throw new ServiceRuntimeNotConfiguredError();
|
|
38
|
+
return context.resolver;
|
|
39
|
+
}
|
|
40
|
+
/** Resolve a Service token using the active resolver. */
|
|
41
|
+
static async resolve(token) {
|
|
42
|
+
return await ServiceRuntime.current().resolve(token);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/service/service.ts
|
|
47
|
+
/**
|
|
48
|
+
* Declare a class-backed Service with a stable string-literal identity.
|
|
49
|
+
*
|
|
50
|
+
* The returned class is simultaneously the implementation type, the runtime
|
|
51
|
+
* dependency token, and the value yielded by `yield*` in an Effect generator.
|
|
52
|
+
* The explicit self type preserves exact instance inference, while the second
|
|
53
|
+
* call captures the tag as a literal for Layer composition and diagnostics.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* class Database extends Service<Database>()('Database') {
|
|
58
|
+
* query(): string {
|
|
59
|
+
* return 'ok'
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
*
|
|
63
|
+
* const database = yield* Database
|
|
64
|
+
* database.query()
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @typeParam Self The instance type implemented by the declared Service.
|
|
68
|
+
*/
|
|
69
|
+
function Service() {
|
|
70
|
+
return function(tag) {
|
|
71
|
+
if (tag.length === 0) throw new TypeError("Service tags must not be empty");
|
|
72
|
+
class BaseService {
|
|
73
|
+
/** The stable logical identity used by Layers and resolver backends. */
|
|
74
|
+
static serviceTag = tag;
|
|
75
|
+
/**
|
|
76
|
+
* Type-check a structural implementation of this Service.
|
|
77
|
+
*
|
|
78
|
+
* This is an identity helper. It returns the supplied value unchanged
|
|
79
|
+
* and does not invoke a constructor or modify its prototype.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* class Database extends Service<Database>()('Database') {
|
|
84
|
+
* query(sql: string): string {
|
|
85
|
+
* return sql
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* const database = Database.of({
|
|
90
|
+
* query: (sql) => `Result: ${sql}`
|
|
91
|
+
* })
|
|
92
|
+
*
|
|
93
|
+
* database.query('SELECT 1')
|
|
94
|
+
* // 'Result: SELECT 1'
|
|
95
|
+
* // database is the original object, not an instance of Database
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
static of(implementation) {
|
|
99
|
+
return implementation;
|
|
100
|
+
}
|
|
101
|
+
/** Resolve this Service from the resolver active in the current runtime. */
|
|
102
|
+
static async *[Symbol.asyncIterator]() {
|
|
103
|
+
return await ServiceRuntime.resolve(this);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return BaseService;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/layer/internal.ts
|
|
111
|
+
const runLayerGenerator = async (service, factory) => {
|
|
112
|
+
const iterator = factory();
|
|
113
|
+
const state = await iterator.next();
|
|
114
|
+
if (!state.done) try {
|
|
115
|
+
await iterator.return(void 0);
|
|
116
|
+
} finally {
|
|
117
|
+
throw new LayerGeneratorYieldError(service);
|
|
118
|
+
}
|
|
119
|
+
return state.value;
|
|
120
|
+
};
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/layer/layer.ts
|
|
123
|
+
/**
|
|
124
|
+
* Declarative collection of Service providers.
|
|
125
|
+
*
|
|
126
|
+
* A Layer describes how to acquire implementations; it does not execute
|
|
127
|
+
* providers until a `Runtime` is created. Use `merge` to compose distinct
|
|
128
|
+
* providers and `override` when replacing an existing provider intentionally.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* const AppLive = Layer.merge(
|
|
133
|
+
* Layer.succeed(Database, database),
|
|
134
|
+
* Layer.make(UserRepository)
|
|
135
|
+
* )
|
|
136
|
+
*
|
|
137
|
+
* const runtime = await Runtime.make(AppLive, backend)
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
var Layer = class Layer {
|
|
141
|
+
/** The provider registrations retained by this Layer. */
|
|
142
|
+
providers;
|
|
143
|
+
constructor(providers) {
|
|
144
|
+
this.providers = Object.freeze([...providers]);
|
|
145
|
+
}
|
|
146
|
+
static make(service, acquire) {
|
|
147
|
+
const defaultAcquire = () => {
|
|
148
|
+
return new service();
|
|
149
|
+
};
|
|
150
|
+
const normalizedAcquire = normalizeAcquire(acquire ?? defaultAcquire);
|
|
151
|
+
return new Layer([{
|
|
152
|
+
service,
|
|
153
|
+
acquire: normalizedAcquire
|
|
154
|
+
}]);
|
|
155
|
+
}
|
|
156
|
+
/** Create a Layer from an already-constructed Service instance. */
|
|
157
|
+
static succeed(service, instance) {
|
|
158
|
+
const normalizedAcquire = normalizeAcquire(() => instance);
|
|
159
|
+
return new Layer([{
|
|
160
|
+
service,
|
|
161
|
+
acquire: normalizedAcquire
|
|
162
|
+
}]);
|
|
163
|
+
}
|
|
164
|
+
/** Define a provider with Runtime-root cleanup. */
|
|
165
|
+
static scoped(service, acquire, release) {
|
|
166
|
+
return new Layer([{
|
|
167
|
+
service,
|
|
168
|
+
acquire: normalizeAcquire(acquire),
|
|
169
|
+
release: (instance, outcome) => {
|
|
170
|
+
return release(instance, outcome);
|
|
171
|
+
}
|
|
172
|
+
}]);
|
|
173
|
+
}
|
|
174
|
+
/** Define a provider whose acquisition can yield contextual Services. */
|
|
175
|
+
static scopedGen(service, factory, release) {
|
|
176
|
+
return new Layer([{
|
|
177
|
+
service,
|
|
178
|
+
acquire: () => runLayerGenerator(service, factory),
|
|
179
|
+
release: (instance, outcome) => {
|
|
180
|
+
return release(instance, outcome);
|
|
181
|
+
}
|
|
182
|
+
}]);
|
|
183
|
+
}
|
|
184
|
+
/** Define a provider whose acquisition can yield contextual Services. */
|
|
185
|
+
static gen(service, factory) {
|
|
186
|
+
return new Layer([{
|
|
187
|
+
service,
|
|
188
|
+
acquire: () => runLayerGenerator(service, factory)
|
|
189
|
+
}]);
|
|
190
|
+
}
|
|
191
|
+
/** Compose Layers without replacing providers. */
|
|
192
|
+
static merge(...layers) {
|
|
193
|
+
const providers = /* @__PURE__ */ new Map();
|
|
194
|
+
for (const layer of layers) for (const provider of layer.providers) {
|
|
195
|
+
const service = provider.service;
|
|
196
|
+
const existing = providers.get(service.serviceTag);
|
|
197
|
+
if (existing) {
|
|
198
|
+
if (existing.service !== service) throw new ServiceTagCollisionError(existing.service, service);
|
|
199
|
+
throw new DuplicateServiceError(service);
|
|
200
|
+
}
|
|
201
|
+
providers.set(service.serviceTag, provider);
|
|
202
|
+
}
|
|
203
|
+
return new Layer([...providers.values()]);
|
|
204
|
+
}
|
|
205
|
+
/** Mark a Layer composition root as complete without changing its runtime value. */
|
|
206
|
+
static complete(layer) {
|
|
207
|
+
return layer;
|
|
208
|
+
}
|
|
209
|
+
/** Replace providers in a base Layer, using tag identity and compatible contracts. */
|
|
210
|
+
static override(base, ...overrides) {
|
|
211
|
+
const providers = /* @__PURE__ */ new Map();
|
|
212
|
+
for (const provider of base.providers) providers.set(provider.service.serviceTag, provider);
|
|
213
|
+
for (const layer of overrides) for (const provider of layer.providers) providers.set(provider.service.serviceTag, provider);
|
|
214
|
+
return new Layer([...providers.values()]);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const normalizeAcquire = (acquire) => () => {
|
|
218
|
+
return acquire();
|
|
219
|
+
};
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/runtime/signal.ts
|
|
222
|
+
const neverAbortedSignal = new AbortController().signal;
|
|
223
|
+
/** Link caller, Runtime and shutdown signals without owning the caller's controller. */
|
|
224
|
+
const linkAbortSignals = (...signals) => {
|
|
225
|
+
const active = signals.filter((signal) => signal !== void 0);
|
|
226
|
+
if (active.length === 0) return {
|
|
227
|
+
signal: neverAbortedSignal,
|
|
228
|
+
dispose: () => {}
|
|
229
|
+
};
|
|
230
|
+
if (active.length === 1) return {
|
|
231
|
+
signal: active[0],
|
|
232
|
+
dispose: () => {}
|
|
233
|
+
};
|
|
234
|
+
const controller = new AbortController();
|
|
235
|
+
const listeners = [];
|
|
236
|
+
let disposed = false;
|
|
237
|
+
const dispose = () => {
|
|
238
|
+
if (disposed) return;
|
|
239
|
+
disposed = true;
|
|
240
|
+
for (const [source, listener] of listeners) source.removeEventListener("abort", listener);
|
|
241
|
+
listeners.length = 0;
|
|
242
|
+
};
|
|
243
|
+
const abortFrom = (source) => {
|
|
244
|
+
if (controller.signal.aborted) return;
|
|
245
|
+
controller.abort(source.reason);
|
|
246
|
+
dispose();
|
|
247
|
+
};
|
|
248
|
+
for (const source of active) {
|
|
249
|
+
if (source.aborted) {
|
|
250
|
+
abortFrom(source);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
const listener = () => abortFrom(source);
|
|
254
|
+
listeners.push([source, listener]);
|
|
255
|
+
source.addEventListener("abort", listener, { once: true });
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
signal: controller.signal,
|
|
259
|
+
dispose
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
/** Return the current cooperative-cancellation signal. */
|
|
263
|
+
const currentAbortSignal = () => currentRuntimeContext().signal ?? neverAbortedSignal;
|
|
264
|
+
/** Yieldable access to the signal of the current Runtime execution. */
|
|
265
|
+
const CurrentAbortSignal = { *[Symbol.iterator]() {
|
|
266
|
+
return currentAbortSignal();
|
|
267
|
+
} };
|
|
268
|
+
//#endregion
|
|
269
|
+
export { ServiceRuntime as a, Service as i, linkAbortSignals as n, defaultRuntimeContextStorage as o, Layer as r, CurrentAbortSignal as t };
|
|
270
|
+
|
|
271
|
+
//# sourceMappingURL=signal-BgUtPQj5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal-BgUtPQj5.mjs","names":["Constructor"],"sources":["../src/runtime/default.ts","../src/service/runtime.ts","../src/service/service.ts","../src/layer/internal.ts","../src/layer/layer.ts","../src/runtime/signal.ts"],"sourcesContent":["import { nodeRuntimeContextStorage } from './node'\n\nimport { setDefaultRuntimeContextStorage } from './context'\n\n/** The Node/Bun storage used by the main Runtime entrypoint. */\nexport const defaultRuntimeContextStorage = nodeRuntimeContextStorage\n\nsetDefaultRuntimeContextStorage(defaultRuntimeContextStorage)\n","import { ServiceRuntimeNotConfiguredError } from './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 )\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 {\n throw new ServiceRuntimeNotConfiguredError()\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 const resolver = ServiceRuntime.current()\n\n return await resolver.resolve(token)\n }\n}\n","import { ServiceRuntime } from './runtime'\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 if (tag.length === 0) {\n throw new TypeError('Service tags must not be empty')\n }\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 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 type { AnyService, ServiceClass, ServiceContract, ServiceRequirements } from '../service'\nimport type { 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'\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\ninterface LayerProvider extends LayerRegistration {\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\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\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([...providers])\n }\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 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 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 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 acquire: normalizedAcquire\n }\n ]) as LayerResult<ProviderEntry<InstanceType<S>, ServiceRequirements<InstanceType<S>>>>\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 // SAFETY: The public callbacks constrain acquisition and release to the requested Service.\n return new Layer([\n {\n service,\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 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 // SAFETY: The generator and release callback are checked against the requested Service.\n return new Layer([\n {\n service,\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 // SAFETY: The generator result is normalized to the requested Service at the runtime boundary.\n return new Layer([\n {\n service,\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 existing = providers.get(service.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(service.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, const Overrides extends readonly LayerInput[]>(\n base: Base & ValidateLayerInput<Base>,\n ...overrides: Overrides & ValidateOverrides<Base, Overrides>\n ): OverrideLayerResult<Base, Overrides> {\n const providers = new Map<string, LayerProvider>()\n\n for (const provider of base.providers) {\n providers.set(provider.service.serviceTag, provider)\n }\n\n for (const layer of overrides) {\n for (const provider of layer.providers) {\n providers.set(provider.service.serviceTag, provider)\n }\n }\n\n // SAFETY: Runtime provider replacement preserves the computed override metadata.\n return new Layer([...providers.values()]) as OverrideLayerResult<Base, Overrides>\n }\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","import { currentRuntimeContext } from './context'\n\nconst neverAbortedSignal = new AbortController().signal\n\ntype SignalListener = readonly [AbortSignal, () => void]\n\nexport type AbortSignalLink = {\n readonly signal: AbortSignal\n readonly dispose: () => void\n}\n\n/** Link caller, Runtime and shutdown signals without owning the caller's controller. */\nexport const linkAbortSignals = (\n ...signals: readonly (AbortSignal | undefined)[]\n): AbortSignalLink => {\n const active = signals.filter((signal): signal is AbortSignal => signal !== undefined)\n\n if (active.length === 0) {\n return { signal: neverAbortedSignal, dispose: () => {} }\n }\n\n if (active.length === 1) {\n return { signal: active[0]!, dispose: () => {} }\n }\n\n const controller = new AbortController()\n const listeners: SignalListener[] = []\n let disposed = false\n\n const dispose = (): void => {\n if (disposed) {\n return\n }\n\n disposed = true\n\n for (const [source, listener] of listeners) {\n source.removeEventListener('abort', listener)\n }\n\n listeners.length = 0\n }\n\n const abortFrom = (source: AbortSignal): void => {\n if (controller.signal.aborted) {\n return\n }\n\n controller.abort(source.reason)\n dispose()\n }\n\n for (const source of active) {\n if (source.aborted) {\n abortFrom(source)\n break\n }\n\n const listener = (): void => abortFrom(source)\n listeners.push([source, listener])\n source.addEventListener('abort', listener, { once: true })\n }\n\n return { signal: controller.signal, dispose }\n}\n\n/** Return the current cooperative-cancellation signal. */\nexport const currentAbortSignal = (): AbortSignal =>\n currentRuntimeContext().signal ?? neverAbortedSignal\n\n/** Yieldable access to the signal of the current Runtime execution. */\nexport const CurrentAbortSignal = {\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<never, AbortSignal, unknown> {\n return currentAbortSignal()\n }\n} as const\n"],"mappings":";;;;;AAKA,MAAa,+BAA+B;AAE5C,gCAAgC,4BAA4B;;;;ACe5D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,CAAC,QAAQ,QAAQ,CAAC;EACjC,OAAO,iBAAiB,SAAS,UAAU,EAAE,MAAM,KAAK,CAAC;CAC3D;CAEA,OAAO;EAAE,QAAQ,WAAW;EAAQ;CAAQ;AAC9C;;AAGA,MAAa,2BACX,sBAAsB,CAAC,CAAC,UAAU;;AAGpC,MAAa,qBAAqB,EAEhC,EAAE,OAAO,YAAoD;CAC3D,OAAO,mBAAmB;AAC5B,EACF"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { I as ServiceIdentity, V as ServiceToken, b as Service, j as ServiceRequirement } from "./index-BFgG9zZC.mjs";
|
|
2
|
+
import { S as LayerResult, w as ProviderEntry } from "./index-BSRPIYII.mjs";
|
|
3
|
+
import { t as CurrentAbortSignal } from "./index-yOfq7LKL.mjs";
|
|
4
|
+
//#region src/standard-services/index.d.ts
|
|
5
|
+
declare const Clock_base: (abstract new () => ServiceIdentity<"Clock">) & {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly serviceTag: "Clock";
|
|
8
|
+
} & {
|
|
9
|
+
readonly of: Service.FactoryOf<Clock, "Clock">;
|
|
10
|
+
readonly [Symbol.asyncIterator]: (this: ServiceToken<"Clock", Clock & ServiceIdentity<"Clock">>) => AsyncGenerator<ServiceRequirement<Clock>, Clock, unknown>;
|
|
11
|
+
};
|
|
12
|
+
/** Host-backed time and waiting service. */
|
|
13
|
+
declare class Clock extends Clock_base {
|
|
14
|
+
now(): Date;
|
|
15
|
+
sleep(milliseconds: number): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/** The default host Clock provider. */
|
|
18
|
+
declare const ClockLive: LayerResult<ProviderEntry<Clock, never>>;
|
|
19
|
+
/** Deterministic Clock implementation for tests. */
|
|
20
|
+
declare class ClockTest implements Service.Contract<Clock> {
|
|
21
|
+
private currentTime;
|
|
22
|
+
private readonly waiters;
|
|
23
|
+
constructor(initial?: Date | number);
|
|
24
|
+
now(): Date;
|
|
25
|
+
setTime(value: Date | number): void;
|
|
26
|
+
advance(milliseconds: number): void;
|
|
27
|
+
sleep(milliseconds: number): Promise<void>;
|
|
28
|
+
static layer(initial?: Date | number): LayerResult<ProviderEntry<Clock, never>>;
|
|
29
|
+
private flushWaiters;
|
|
30
|
+
}
|
|
31
|
+
declare const ClockTestLayer: (initial?: Date | number) => LayerResult<ProviderEntry<Clock, never>>;
|
|
32
|
+
declare const Random_base: (abstract new () => ServiceIdentity<"Random">) & {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly serviceTag: "Random";
|
|
35
|
+
} & {
|
|
36
|
+
readonly of: Service.FactoryOf<Random, "Random">;
|
|
37
|
+
readonly [Symbol.asyncIterator]: (this: ServiceToken<"Random", Random & ServiceIdentity<"Random">>) => AsyncGenerator<ServiceRequirement<Random>, Random, unknown>;
|
|
38
|
+
};
|
|
39
|
+
/** Host-backed pseudo-random number service. */
|
|
40
|
+
declare class Random extends Random_base {
|
|
41
|
+
next(): number;
|
|
42
|
+
nextInt(maxExclusive: number): number;
|
|
43
|
+
}
|
|
44
|
+
/** The default host Random provider. */
|
|
45
|
+
declare const RandomLive: LayerResult<ProviderEntry<Random, never>>;
|
|
46
|
+
/** Reproducible pseudo-random implementation with isolated mutable state. */
|
|
47
|
+
declare class RandomSeeded implements Service.Contract<Random> {
|
|
48
|
+
private state;
|
|
49
|
+
constructor(seed: number);
|
|
50
|
+
next(): number;
|
|
51
|
+
nextInt(maxExclusive: number): number;
|
|
52
|
+
static layer(seed: number): LayerResult<ProviderEntry<Random, never>>;
|
|
53
|
+
}
|
|
54
|
+
declare const RandomSeededLayer: (seed: number) => LayerResult<ProviderEntry<Random, never>>;
|
|
55
|
+
type LoggerLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
56
|
+
type LoggerEvent = {
|
|
57
|
+
level: LoggerLevel;
|
|
58
|
+
message: string;
|
|
59
|
+
data?: LoggerData;
|
|
60
|
+
};
|
|
61
|
+
type LoggerData = string | number | boolean | bigint | null | readonly LoggerData[] | {
|
|
62
|
+
readonly [key: string]: LoggerData;
|
|
63
|
+
};
|
|
64
|
+
declare const Logger_base: (abstract new () => ServiceIdentity<"Logger">) & {
|
|
65
|
+
readonly name: string;
|
|
66
|
+
readonly serviceTag: "Logger";
|
|
67
|
+
} & {
|
|
68
|
+
readonly of: Service.FactoryOf<Logger, "Logger">;
|
|
69
|
+
readonly [Symbol.asyncIterator]: (this: ServiceToken<"Logger", Logger & ServiceIdentity<"Logger">>) => AsyncGenerator<ServiceRequirement<Logger>, Logger, unknown>;
|
|
70
|
+
};
|
|
71
|
+
/** Structured host logger bridge. */
|
|
72
|
+
declare class Logger extends Logger_base {
|
|
73
|
+
log(event: LoggerEvent): void;
|
|
74
|
+
log(level: LoggerLevel, message: string, data?: LoggerData): void;
|
|
75
|
+
debug(message: string, data?: LoggerData): void;
|
|
76
|
+
info(message: string, data?: LoggerData): void;
|
|
77
|
+
warn(message: string, data?: LoggerData): void;
|
|
78
|
+
error(message: string, data?: LoggerData): void;
|
|
79
|
+
}
|
|
80
|
+
/** The default host Logger provider. */
|
|
81
|
+
declare const LoggerLive: LayerResult<ProviderEntry<Logger, never>>;
|
|
82
|
+
/** Ordered in-memory Logger implementation for tests. */
|
|
83
|
+
declare class LoggerTest implements Service.Contract<Logger> {
|
|
84
|
+
readonly events: LoggerEvent[];
|
|
85
|
+
log(event: LoggerEvent): void;
|
|
86
|
+
log(level: LoggerLevel, message: string, data?: LoggerData): void;
|
|
87
|
+
debug(message: string, data?: LoggerData): void;
|
|
88
|
+
info(message: string, data?: LoggerData): void;
|
|
89
|
+
warn(message: string, data?: LoggerData): void;
|
|
90
|
+
error(message: string, data?: LoggerData): void;
|
|
91
|
+
clear(): void;
|
|
92
|
+
static make(): {
|
|
93
|
+
logger: LoggerTest;
|
|
94
|
+
layer: LayerResult<ProviderEntry<Logger, never>>;
|
|
95
|
+
};
|
|
96
|
+
static layer(logger?: LoggerTest): LayerResult<ProviderEntry<Logger, never>>;
|
|
97
|
+
}
|
|
98
|
+
declare const LoggerTestLayer: () => LayerResult<ProviderEntry<Logger, never>>;
|
|
99
|
+
declare const CurrentRequest_base: (abstract new () => ServiceIdentity<"CurrentRequest">) & {
|
|
100
|
+
readonly name: string;
|
|
101
|
+
readonly serviceTag: "CurrentRequest";
|
|
102
|
+
} & {
|
|
103
|
+
readonly of: Service.FactoryOf<CurrentRequest, "CurrentRequest">;
|
|
104
|
+
readonly [Symbol.asyncIterator]: (this: ServiceToken<"CurrentRequest", CurrentRequest & ServiceIdentity<"CurrentRequest">>) => AsyncGenerator<ServiceRequirement<CurrentRequest>, CurrentRequest, unknown>;
|
|
105
|
+
};
|
|
106
|
+
/** Execution-local request value carried by a normal Service provider. */
|
|
107
|
+
declare class CurrentRequest extends CurrentRequest_base {
|
|
108
|
+
readonly value: unknown;
|
|
109
|
+
readonly request: unknown;
|
|
110
|
+
constructor(value: unknown);
|
|
111
|
+
static layer(value: unknown): LayerResult<ProviderEntry<CurrentRequest, never>>;
|
|
112
|
+
}
|
|
113
|
+
declare const CurrentRequestLayer: (value: unknown) => LayerResult<ProviderEntry<CurrentRequest, never>>;
|
|
114
|
+
//#endregion
|
|
115
|
+
export { Clock, ClockLive, ClockTest, ClockTestLayer, CurrentAbortSignal, CurrentRequest, CurrentRequestLayer, Logger, LoggerData, LoggerEvent, LoggerLevel, LoggerLive, LoggerTest, LoggerTestLayer, Random, RandomLive, RandomSeeded, RandomSeededLayer };
|
|
116
|
+
//# sourceMappingURL=standard-services.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-services.d.mts","names":[],"sources":["../src/standard-services/index.ts"],"mappings":";;;;;;;;;;;;cAaa,cAAc;EACzB,OAAO;EAIP,MAAM,uBAAuB;;;cAOlB,WAAS,YAAA,cAAA;;cAQT,qBAAqB,QAAQ,SAAS;UACzC;mBAES;EAEL,YAAA,UAAS;EAQrB,OAAO;EAIP,QAAQ,OAAO;EAWf,QAAQ;EAMR,MAAM,uBAAuB;SAStB,MAAM,UAAS,gBAAiB,YAAA,cAAA;UAI/B;;cAYG,iBAAkB,UAAS,kBAAiB,YAAA,cAAA;;;;;;;;;cAG5C,eAAe;EAC1B;EAIA,QAAQ;;;cAUG,YAAU,YAAA,cAAA;;cAGV,wBAAwB,QAAQ,SAAS;UAC5C;EAEI,YAAA;EAQZ;EAKA,QAAQ;SAQD,MAAM,eAAY,YAAA,cAAA;;cAKd,oBAAqB,iBAAY,YAAA,cAAA;KAElC;KAEA;EACV,OAAO;EACP;EACA,OAAO;;KAGG,kEAMC;YACG,cAAc;;;;;;;;;;cAqBjB,eAAe;EAC1B,IAAI,OAAO;EACX,IAAI,OAAO,aAAa,iBAAiB,OAAO;EAahD,MAAM,iBAAiB,OAAO;EAI9B,KAAK,iBAAiB,OAAO;EAI7B,KAAK,iBAAiB,OAAO;EAI7B,MAAM,iBAAiB,OAAO;;;cAMnB,YAAU,YAAA,cAAA;;cAGV,sBAAsB,QAAQ,SAAS;WACzC,QAAQ;EAEjB,IAAI,OAAO;EACX,IAAI,OAAO,aAAa,iBAAiB,OAAO;EAOhD,MAAM,iBAAiB,OAAO;EAI9B,KAAK,iBAAiB,OAAO;EAI7B,KAAK,iBAAiB,OAAO;EAI7B,MAAM,iBAAiB,OAAO;EAI9B;SAIO;;;;SAKA,MAAM,SAAQ,aAA6B,YAAA,cAAA;;cAKvC,uBAAe,YAAA,cAAA;;;;;;;;;cAGf,uBAAuB;WAIb;WAHZ;EAGY,YAAA;SAMd,MAAM,iBAAc,YAAA,cAAA;;cAMhB,sBAAuB,mBAAc,YAAA,cAAA"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { i as Service, r as Layer, t as CurrentAbortSignal } from "./signal-BgUtPQj5.mjs";
|
|
2
|
+
//#region src/standard-services/index.ts
|
|
3
|
+
const assertDelay = (milliseconds) => {
|
|
4
|
+
if (!Number.isFinite(milliseconds) || milliseconds < 0) throw new RangeError("Delay must be a finite non-negative number");
|
|
5
|
+
};
|
|
6
|
+
/** Host-backed time and waiting service. */
|
|
7
|
+
var Clock = class extends Service()("Clock") {
|
|
8
|
+
now() {
|
|
9
|
+
return /* @__PURE__ */ new Date();
|
|
10
|
+
}
|
|
11
|
+
sleep(milliseconds) {
|
|
12
|
+
assertDelay(milliseconds);
|
|
13
|
+
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** The default host Clock provider. */
|
|
17
|
+
const ClockLive = Layer.make(Clock);
|
|
18
|
+
/** Deterministic Clock implementation for tests. */
|
|
19
|
+
var ClockTest = class ClockTest {
|
|
20
|
+
currentTime;
|
|
21
|
+
waiters = [];
|
|
22
|
+
constructor(initial = 0) {
|
|
23
|
+
this.currentTime = initial instanceof Date ? initial.getTime() : initial;
|
|
24
|
+
if (!Number.isFinite(this.currentTime)) throw new RangeError("ClockTest time must be finite");
|
|
25
|
+
}
|
|
26
|
+
now() {
|
|
27
|
+
return new Date(this.currentTime);
|
|
28
|
+
}
|
|
29
|
+
setTime(value) {
|
|
30
|
+
const next = value instanceof Date ? value.getTime() : value;
|
|
31
|
+
if (!Number.isFinite(next)) throw new RangeError("ClockTest time must be finite");
|
|
32
|
+
this.currentTime = next;
|
|
33
|
+
this.flushWaiters();
|
|
34
|
+
}
|
|
35
|
+
advance(milliseconds) {
|
|
36
|
+
assertDelay(milliseconds);
|
|
37
|
+
this.currentTime += milliseconds;
|
|
38
|
+
this.flushWaiters();
|
|
39
|
+
}
|
|
40
|
+
sleep(milliseconds) {
|
|
41
|
+
assertDelay(milliseconds);
|
|
42
|
+
return new Promise((resolve) => {
|
|
43
|
+
this.waiters.push({
|
|
44
|
+
at: this.currentTime + milliseconds,
|
|
45
|
+
resolve
|
|
46
|
+
});
|
|
47
|
+
this.flushWaiters();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
static layer(initial = 0) {
|
|
51
|
+
return Layer.succeed(Clock, new ClockTest(initial));
|
|
52
|
+
}
|
|
53
|
+
flushWaiters() {
|
|
54
|
+
for (let index = this.waiters.length - 1; index >= 0; index--) {
|
|
55
|
+
const waiter = this.waiters[index];
|
|
56
|
+
if (waiter.at <= this.currentTime) {
|
|
57
|
+
this.waiters.splice(index, 1);
|
|
58
|
+
waiter.resolve();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const ClockTestLayer = (initial = 0) => ClockTest.layer(initial);
|
|
64
|
+
/** Host-backed pseudo-random number service. */
|
|
65
|
+
var Random = class extends Service()("Random") {
|
|
66
|
+
next() {
|
|
67
|
+
return Math.random();
|
|
68
|
+
}
|
|
69
|
+
nextInt(maxExclusive) {
|
|
70
|
+
if (!Number.isInteger(maxExclusive) || maxExclusive <= 0) throw new RangeError("Random.nextInt maxExclusive must be a positive integer");
|
|
71
|
+
return Math.floor(this.next() * maxExclusive);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/** The default host Random provider. */
|
|
75
|
+
const RandomLive = Layer.make(Random);
|
|
76
|
+
/** Reproducible pseudo-random implementation with isolated mutable state. */
|
|
77
|
+
var RandomSeeded = class RandomSeeded {
|
|
78
|
+
state;
|
|
79
|
+
constructor(seed) {
|
|
80
|
+
if (!Number.isFinite(seed)) throw new RangeError("RandomSeeded seed must be finite");
|
|
81
|
+
this.state = seed >>> 0;
|
|
82
|
+
}
|
|
83
|
+
next() {
|
|
84
|
+
this.state = 1664525 * this.state + 1013904223 >>> 0;
|
|
85
|
+
return this.state / 4294967296;
|
|
86
|
+
}
|
|
87
|
+
nextInt(maxExclusive) {
|
|
88
|
+
if (!Number.isInteger(maxExclusive) || maxExclusive <= 0) throw new RangeError("RandomSeeded.nextInt maxExclusive must be a positive integer");
|
|
89
|
+
return Math.floor(this.next() * maxExclusive);
|
|
90
|
+
}
|
|
91
|
+
static layer(seed) {
|
|
92
|
+
return Layer.succeed(Random, new RandomSeeded(seed));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const RandomSeededLayer = (seed) => RandomSeeded.layer(seed);
|
|
96
|
+
const isLoggerLevel = (value) => value === "debug" || value === "info" || value === "warn" || value === "error";
|
|
97
|
+
const toLoggerEvent = (input, message, data) => {
|
|
98
|
+
if (!isLoggerLevel(input)) return input;
|
|
99
|
+
const event = {
|
|
100
|
+
level: input,
|
|
101
|
+
message: message ?? ""
|
|
102
|
+
};
|
|
103
|
+
if (data !== void 0) event.data = data;
|
|
104
|
+
return event;
|
|
105
|
+
};
|
|
106
|
+
/** Structured host logger bridge. */
|
|
107
|
+
var Logger = class extends Service()("Logger") {
|
|
108
|
+
log(first, message, data) {
|
|
109
|
+
const event = toLoggerEvent(first, message, data);
|
|
110
|
+
const write = console[event.level];
|
|
111
|
+
if (event.data === void 0) write.call(console, event.message);
|
|
112
|
+
else write.call(console, event.message, event.data);
|
|
113
|
+
}
|
|
114
|
+
debug(message, data) {
|
|
115
|
+
this.log("debug", message, data);
|
|
116
|
+
}
|
|
117
|
+
info(message, data) {
|
|
118
|
+
this.log("info", message, data);
|
|
119
|
+
}
|
|
120
|
+
warn(message, data) {
|
|
121
|
+
this.log("warn", message, data);
|
|
122
|
+
}
|
|
123
|
+
error(message, data) {
|
|
124
|
+
this.log("error", message, data);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
/** The default host Logger provider. */
|
|
128
|
+
const LoggerLive = Layer.make(Logger);
|
|
129
|
+
/** Ordered in-memory Logger implementation for tests. */
|
|
130
|
+
var LoggerTest = class LoggerTest {
|
|
131
|
+
events = [];
|
|
132
|
+
log(first, message, data) {
|
|
133
|
+
const event = toLoggerEvent(first, message, data);
|
|
134
|
+
this.events.push(event);
|
|
135
|
+
}
|
|
136
|
+
debug(message, data) {
|
|
137
|
+
this.log("debug", message, data);
|
|
138
|
+
}
|
|
139
|
+
info(message, data) {
|
|
140
|
+
this.log("info", message, data);
|
|
141
|
+
}
|
|
142
|
+
warn(message, data) {
|
|
143
|
+
this.log("warn", message, data);
|
|
144
|
+
}
|
|
145
|
+
error(message, data) {
|
|
146
|
+
this.log("error", message, data);
|
|
147
|
+
}
|
|
148
|
+
clear() {
|
|
149
|
+
this.events.length = 0;
|
|
150
|
+
}
|
|
151
|
+
static make() {
|
|
152
|
+
const logger = new LoggerTest();
|
|
153
|
+
return {
|
|
154
|
+
logger,
|
|
155
|
+
layer: Layer.succeed(Logger, logger)
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
static layer(logger = new LoggerTest()) {
|
|
159
|
+
return Layer.succeed(Logger, logger);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const LoggerTestLayer = () => LoggerTest.layer();
|
|
163
|
+
/** Execution-local request value carried by a normal Service provider. */
|
|
164
|
+
var CurrentRequest = class CurrentRequest extends Service()("CurrentRequest") {
|
|
165
|
+
value;
|
|
166
|
+
request;
|
|
167
|
+
constructor(value) {
|
|
168
|
+
super();
|
|
169
|
+
this.value = value;
|
|
170
|
+
this.request = value;
|
|
171
|
+
}
|
|
172
|
+
static layer(value) {
|
|
173
|
+
return Layer.succeed(CurrentRequest, new CurrentRequest(value));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const CurrentRequestLayer = (value) => CurrentRequest.layer(value);
|
|
177
|
+
//#endregion
|
|
178
|
+
export { Clock, ClockLive, ClockTest, ClockTestLayer, CurrentAbortSignal, CurrentRequest, CurrentRequestLayer, Logger, LoggerLive, LoggerTest, LoggerTestLayer, Random, RandomLive, RandomSeeded, RandomSeededLayer };
|
|
179
|
+
|
|
180
|
+
//# sourceMappingURL=standard-services.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-services.mjs","names":[],"sources":["../src/standard-services/index.ts"],"sourcesContent":["import { CurrentAbortSignal } from '../runtime'\nimport { Layer } from '../layer'\nimport { Service } from '../service'\n\nexport { CurrentAbortSignal }\n\nconst assertDelay = (milliseconds: number): void => {\n if (!Number.isFinite(milliseconds) || milliseconds < 0) {\n throw new RangeError('Delay must be a finite non-negative number')\n }\n}\n\n/** Host-backed time and waiting service. */\nexport class Clock extends Service<Clock>()('Clock') {\n now(): Date {\n return new Date()\n }\n\n sleep(milliseconds: number): Promise<void> {\n assertDelay(milliseconds)\n return new Promise((resolve) => setTimeout(resolve, milliseconds))\n }\n}\n\n/** The default host Clock provider. */\nexport const ClockLive = Layer.make(Clock)\n\ntype ClockWaiter = {\n readonly at: number\n readonly resolve: () => void\n}\n\n/** Deterministic Clock implementation for tests. */\nexport class ClockTest implements Service.Contract<Clock> {\n private currentTime: number\n\n private readonly waiters: ClockWaiter[] = []\n\n constructor(initial: Date | number = 0) {\n this.currentTime = initial instanceof Date ? initial.getTime() : initial\n\n if (!Number.isFinite(this.currentTime)) {\n throw new RangeError('ClockTest time must be finite')\n }\n }\n\n now(): Date {\n return new Date(this.currentTime)\n }\n\n setTime(value: Date | number): void {\n const next = value instanceof Date ? value.getTime() : value\n\n if (!Number.isFinite(next)) {\n throw new RangeError('ClockTest time must be finite')\n }\n\n this.currentTime = next\n this.flushWaiters()\n }\n\n advance(milliseconds: number): void {\n assertDelay(milliseconds)\n this.currentTime += milliseconds\n this.flushWaiters()\n }\n\n sleep(milliseconds: number): Promise<void> {\n assertDelay(milliseconds)\n\n return new Promise((resolve) => {\n this.waiters.push({ at: this.currentTime + milliseconds, resolve })\n this.flushWaiters()\n })\n }\n\n static layer(initial: Date | number = 0) {\n return Layer.succeed(Clock, new ClockTest(initial))\n }\n\n private flushWaiters(): void {\n for (let index = this.waiters.length - 1; index >= 0; index--) {\n const waiter = this.waiters[index]!\n\n if (waiter.at <= this.currentTime) {\n this.waiters.splice(index, 1)\n waiter.resolve()\n }\n }\n }\n}\n\nexport const ClockTestLayer = (initial: Date | number = 0) => ClockTest.layer(initial)\n\n/** Host-backed pseudo-random number service. */\nexport class Random extends Service<Random>()('Random') {\n next(): number {\n return Math.random()\n }\n\n nextInt(maxExclusive: number): number {\n if (!Number.isInteger(maxExclusive) || maxExclusive <= 0) {\n throw new RangeError('Random.nextInt maxExclusive must be a positive integer')\n }\n\n return Math.floor(this.next() * maxExclusive)\n }\n}\n\n/** The default host Random provider. */\nexport const RandomLive = Layer.make(Random)\n\n/** Reproducible pseudo-random implementation with isolated mutable state. */\nexport class RandomSeeded implements Service.Contract<Random> {\n private state: number\n\n constructor(seed: number) {\n if (!Number.isFinite(seed)) {\n throw new RangeError('RandomSeeded seed must be finite')\n }\n\n this.state = seed >>> 0\n }\n\n next(): number {\n this.state = (1664525 * this.state + 1013904223) >>> 0\n return this.state / 0x1_0000_0000\n }\n\n nextInt(maxExclusive: number): number {\n if (!Number.isInteger(maxExclusive) || maxExclusive <= 0) {\n throw new RangeError('RandomSeeded.nextInt maxExclusive must be a positive integer')\n }\n\n return Math.floor(this.next() * maxExclusive)\n }\n\n static layer(seed: number) {\n return Layer.succeed(Random, new RandomSeeded(seed))\n }\n}\n\nexport const RandomSeededLayer = (seed: number) => RandomSeeded.layer(seed)\n\nexport type LoggerLevel = 'debug' | 'info' | 'warn' | 'error'\n\nexport type LoggerEvent = {\n level: LoggerLevel\n message: string\n data?: LoggerData\n}\n\nexport type LoggerData =\n | string\n | number\n | boolean\n | bigint\n | null\n | readonly LoggerData[]\n | { readonly [key: string]: LoggerData }\ntype LoggerInput = LoggerEvent | LoggerLevel\n\nconst isLoggerLevel = (value: LoggerInput): value is LoggerLevel =>\n value === 'debug' || value === 'info' || value === 'warn' || value === 'error'\n\nconst toLoggerEvent = (input: LoggerInput, message?: string, data?: LoggerData): LoggerEvent => {\n if (!isLoggerLevel(input)) {\n return input\n }\n\n const event: LoggerEvent = { level: input, message: message ?? '' }\n\n if (data !== undefined) {\n event.data = data\n }\n\n return event\n}\n\n/** Structured host logger bridge. */\nexport class Logger extends Service<Logger>()('Logger') {\n log(event: LoggerEvent): void\n log(level: LoggerLevel, message: string, data?: LoggerData): void\n log(first: LoggerInput, message?: string, data?: LoggerData): void {\n const event = toLoggerEvent(first, message, data)\n\n const write = console[event.level]\n\n if (event.data === undefined) {\n write.call(console, event.message)\n } else {\n write.call(console, event.message, event.data)\n }\n }\n\n debug(message: string, data?: LoggerData): void {\n this.log('debug', message, data)\n }\n\n info(message: string, data?: LoggerData): void {\n this.log('info', message, data)\n }\n\n warn(message: string, data?: LoggerData): void {\n this.log('warn', message, data)\n }\n\n error(message: string, data?: LoggerData): void {\n this.log('error', message, data)\n }\n}\n\n/** The default host Logger provider. */\nexport const LoggerLive = Layer.make(Logger)\n\n/** Ordered in-memory Logger implementation for tests. */\nexport class LoggerTest implements Service.Contract<Logger> {\n readonly events: LoggerEvent[] = []\n\n log(event: LoggerEvent): void\n log(level: LoggerLevel, message: string, data?: LoggerData): void\n log(first: LoggerInput, message?: string, data?: LoggerData): void {\n const event = toLoggerEvent(first, message, data)\n\n this.events.push(event)\n }\n\n debug(message: string, data?: LoggerData): void {\n this.log('debug', message, data)\n }\n\n info(message: string, data?: LoggerData): void {\n this.log('info', message, data)\n }\n\n warn(message: string, data?: LoggerData): void {\n this.log('warn', message, data)\n }\n\n error(message: string, data?: LoggerData): void {\n this.log('error', message, data)\n }\n\n clear(): void {\n this.events.length = 0\n }\n\n static make() {\n const logger = new LoggerTest()\n return { logger, layer: Layer.succeed(Logger, logger) }\n }\n\n static layer(logger: LoggerTest = new LoggerTest()) {\n return Layer.succeed(Logger, logger)\n }\n}\n\nexport const LoggerTestLayer = () => LoggerTest.layer()\n\n/** Execution-local request value carried by a normal Service provider. */\nexport class CurrentRequest extends Service<CurrentRequest>()('CurrentRequest') {\n readonly request: unknown\n\n // oxlint-disable-next-line anti-slop/no-unknown-parameters\n constructor(readonly value: unknown) {\n super()\n this.request = value\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-parameters\n static layer(value: unknown) {\n return Layer.succeed(CurrentRequest, new CurrentRequest(value))\n }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters\nexport const CurrentRequestLayer = (value: unknown) => CurrentRequest.layer(value)\n"],"mappings":";;AAMA,MAAM,eAAe,iBAA+B;CAClD,IAAI,CAAC,OA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AO;GAAE;GAAQ,OAAO,MAAM,QAAQ,QAAQ,MAAM;EAAE;CACxD;CAEA,OAAO,MAAM,SAAqB,IAAI,WAAW,GAAG;EAClD,OAAO,MAAM,QAAQ,QAAQ,MAAM;CACrC;AACF;AAEA,MAAa,wBAAwB,WAAW,MAAM;;AAGtD,IAAa,iBAAb,MAAa,uBAAuB,QAAwB,CAAC,CAAC,gBAAgB,CAAC,CAAC;CAIzD;CAHrB;CAGA,YAAY,OAAyB;EACnC,MAAM;EADa,KAAA,QAAA;EAEnB,KAAK,UAAU;CACjB;CAGA,OAAO,MAAM,OAAgB;EAC3B,OAAO,MAAM,QAAQ,gBAAgB,IAAI,eAAe,KAAK,CAAC;CAChE;AACF;AAGA,MAAa,uBAAuB,UAAmB,eAAe,MAAM,KAAK"}
|
package/dist/testing.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MapLayerBackend } from "./map-layer-backend-
|
|
1
|
+
import { t as MapLayerBackend } from "./map-layer-backend-gal-mcRv.mjs";
|
|
2
2
|
export { MapLayerBackend as MemoryLayerBackend };
|