@nicolastoulemont/std 0.2.0 → 0.3.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/dist/index-BFhV56qy.d.mts.map +1 -1
- package/dist/index-BR7takNf.d.mts.map +1 -1
- package/dist/index.d.mts +669 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1355 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -2
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/std.ts"],"sourcesContent":["import { data, record } from \"./adt\"\nimport { Brand } from \"./brand\"\nimport { array, struct, tagged, tuple } from \"./data\"\nimport { Either } from \"./either\"\nimport { Err, TaggedError } from \"./err\"\nimport { flow } from \"./flow\"\nimport { fn } from \"./fn\"\nimport { gen } from \"./gen\"\nimport { Option } from \"./option\"\nimport { pipe } from \"./pipe\"\nimport { Predicate } from \"./predicate\"\nimport { Result } from \"./result\"\n\n/**\n * Main Std namespace containing all utility functions and types.\n */\nexport const Std = {\n array,\n data,\n flow,\n fn,\n gen,\n pipe,\n record,\n struct,\n tagged,\n tuple,\n // Spreading the result utilities since we want to make it a 1st class citizen\n ...Result,\n Option,\n Either,\n Err,\n TaggedError,\n Predicate,\n Brand,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,MAAa,MAAM;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["resultErr","resultOk","gen","result","service","impl","ctx","gen","layerGen","layerResult","gen","gen","fxGen","fxResult","resultErr"],"sources":["../src/fx/fx.ts","../src/fx/service.ts","../src/fx/context.ts","../src/fx/layer.ts","../src/fx/scope.ts","../src/fx/memo-map.ts","../src/fx/provide.ts","../src/std.ts"],"sourcesContent":["import { ok as resultOk, err as resultErr } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { Fx as FxType, SyncFx, AsyncFx, FxGenerator, AsyncFxGenerator, ServiceRequest } from \"./fx.types\"\n\n// ============================================================================\n// Fx.gen - Create composable computations\n// ============================================================================\n\n/**\n * Create a composable computation from a sync generator function.\n * Returns a SyncFx that can be stored, passed around, and executed later.\n *\n * @template A - The success value type\n * @template E - The error type\n * @template R - The required services type\n * @param generatorFn - A function that returns a sync generator\n * @returns SyncFx<A, E, R>\n *\n * @example\n * ```ts\n * const getUser = (id: string) => Fx.gen(function* () {\n * const db = yield* Database\n * const logger = yield* Logger\n *\n * logger.info(`Fetching user ${id}`)\n * return yield* db.query<User>(`SELECT * FROM users WHERE id = '${id}'`)\n * })\n * // Type: Fx<User[], DatabaseError, Database | Logger>\n *\n * // Execute later with dependencies provided\n * const result = pipe(getUser(\"123\"), provide(AppLayer)).run()\n * ```\n */\nfunction fxGen<A, E, R>(generatorFn: () => FxGenerator<A, E, R>): SyncFx<A, E, R>\n\n/**\n * Create a composable computation from an async generator function.\n * Returns an AsyncFx that can be stored, passed around, and executed later.\n *\n * @template A - The success value type\n * @template E - The error type\n * @template R - The required services type\n * @param generatorFn - A function that returns an async generator\n * @returns AsyncFx<A, E, R>\n *\n * @example\n * ```ts\n * const fetchData = (url: string) => Fx.gen(async function* () {\n * const logger = yield* Logger\n *\n * logger.info(`Fetching ${url}`)\n * const response = await fetch(url)\n * return yield* Result.fromTry(async () => await response.json())\n * })\n * // Type: Fx<unknown, Error, Logger>\n * ```\n */\nfunction fxGen<A, E, R>(generatorFn: () => AsyncFxGenerator<A, E, R>): AsyncFx<A, E, R>\n\n/**\n * Implementation of unified Fx.gen function.\n * Detects sync vs async generator and returns appropriate computation type.\n */\nfunction fxGen<A, E, R>(\n generatorFn: () => FxGenerator<A, E, R> | AsyncFxGenerator<A, E, R>,\n): SyncFx<A, E, R> | AsyncFx<A, E, R> {\n // Check if we're dealing with async generator\n const testGen = generatorFn()\n const isAsync = Symbol.asyncIterator in testGen\n\n if (isAsync) {\n return {\n _tag: \"AsyncFx\",\n run: async () => {\n const gen = generatorFn() as AsyncFxGenerator<A, E, R>\n const result = await gen.next()\n\n if (result.done !== true) {\n // Yielded value is either an error or service request\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n throw new Error(`Service \"${yielded.serviceKey}\" not provided. Use provide() to inject services.`)\n }\n return resultErr(yielded as E)\n }\n\n return resultOk(result.value)\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<R>, A, unknown> {\n const gen = generatorFn() as AsyncFxGenerator<A, E, R>\n let result = await gen.next()\n\n while (!result.done) {\n // Pass through yields (errors or service requests)\n const injected = yield result.value\n result = await gen.next(injected)\n }\n\n return result.value\n },\n } as AsyncFx<A, E, R>\n }\n\n // Sync generator\n return {\n _tag: \"SyncFx\",\n run: () => {\n const gen = generatorFn() as FxGenerator<A, E, R>\n const result = gen.next()\n\n if (result.done !== true) {\n const yielded = result.value\n if (typeof yielded === \"object\" && yielded !== null && \"_tag\" in yielded && yielded._tag === \"ServiceRequest\") {\n throw new Error(`Service \"${yielded.serviceKey}\" not provided. Use provide() to inject services.`)\n }\n return resultErr(yielded as E)\n }\n\n return resultOk(result.value)\n },\n *[Symbol.iterator](): Generator<E | ServiceRequest<R>, A, unknown> {\n const gen = generatorFn() as FxGenerator<A, E, R>\n let result = gen.next()\n\n while (!result.done) {\n const injected = yield result.value\n result = gen.next(injected)\n }\n\n return result.value\n },\n } as SyncFx<A, E, R>\n}\n\n// ============================================================================\n// Fx.fn - Execute computations immediately\n// ============================================================================\n\n/**\n * Execute a sync computation immediately and return the result.\n * For computations without service dependencies.\n *\n * @template A - The success value type\n * @template E - The error type\n * @param generatorFn - A function that returns a sync generator\n * @returns Result<A, E>\n *\n * @example\n * ```ts\n * const result = Fx.fn(function* () {\n * const a = yield* Result.ok(10)\n * const b = yield* Result.ok(20)\n * return a + b\n * })\n * // Type: Result<number, never>\n * // result = { ok: true, value: 30 }\n * ```\n */\nfunction fxFn<A, E>(generatorFn: () => FxGenerator<A, E, never>): Result<A, E>\n\n/**\n * Execute an async computation immediately and return a Promise of the result.\n * For computations without service dependencies.\n *\n * @template A - The success value type\n * @template E - The error type\n * @param generatorFn - A function that returns an async generator\n * @returns Promise<Result<A, E>>\n *\n * @example\n * ```ts\n * const result = await Fx.fn(async function* () {\n * const response = await fetch(\"/api/users\")\n * const data = yield* Result.fromTry(async () => await response.json())\n * return data\n * })\n * // Type: Promise<Result<unknown, Error>>\n * ```\n */\nfunction fxFn<A, E>(generatorFn: () => AsyncFxGenerator<A, E, never>): Promise<Result<A, E>>\n\n/**\n * Execute a sync computation with service dependencies immediately.\n * The second argument is required when the computation has service requirements (R ≠ never).\n *\n * @template A - The success value type\n * @template E - The error type from the computation\n * @template E2 - The error type from the provider (layer)\n * @template R - The required services type\n * @param generatorFn - A function that returns a sync generator with service requirements\n * @param provider - A function that provides the services (e.g., provide(AppLayer))\n * @returns Result<A, E | E2>\n *\n * @example\n * ```ts\n * const result = Fx.fn(function* () {\n * const config = yield* Config\n * const logger = yield* Logger\n * logger.info(`DB URL: ${config.dbUrl}`)\n * return config.dbUrl\n * }, provide(AppLayer))\n * // Type: Result<string, never>\n * ```\n */\nfunction fxFn<A, E, E2, R>(\n generatorFn: () => FxGenerator<A, E, R>,\n provider: (fx: FxType<A, E, R>) => FxType<A, E | E2, never>,\n): Result<A, E | E2>\n\n/**\n * Execute an async computation with service dependencies immediately.\n * The second argument is required when the computation has service requirements (R ≠ never).\n *\n * @template A - The success value type\n * @template E - The error type from the computation\n * @template E2 - The error type from the provider (layer)\n * @template R - The required services type\n * @param generatorFn - A function that returns an async generator with service requirements\n * @param provider - A function that provides the services (e.g., provide(AppLayer))\n * @returns Promise<Result<A, E | E2>>\n *\n * @example\n * ```ts\n * const result = await Fx.fn(async function* () {\n * const config = yield* Config\n * await doAsyncWork()\n * return config.dbUrl\n * }, provide(AppLayer))\n * // Type: Promise<Result<string, never>>\n * ```\n */\n// oxlint-disable-next-line no-redundant-type-constituents\nfunction fxFn<A, E, E2, R>(\n generatorFn: () => AsyncFxGenerator<A, E, R>,\n provider: (fx: FxType<A, E, R>) => FxType<A, E | E2, never>,\n): Promise<Result<A, E | E2>>\n\n/**\n * Implementation of Fx.fn.\n */\nfunction fxFn<A, E, E2, R>(\n generatorFn: () => FxGenerator<A, E, R> | AsyncFxGenerator<A, E, R>,\n provider?: (fx: FxType<A, E, R>) => FxType<A, E | E2, never>,\n): Result<A, E | E2> | Promise<Result<A, E | E2>> {\n const testGen = generatorFn()\n const isAsync = Symbol.asyncIterator in testGen\n\n // If a provider is given, create the Fx, apply provider, then run\n if (provider) {\n if (isAsync) {\n const fx: AsyncFx<A, E, R> = {\n _tag: \"AsyncFx\",\n run: async () => {\n throw new Error(\"Should not be called directly - use provider\")\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<R>, A, unknown> {\n const gen = generatorFn() as AsyncFxGenerator<A, E, R>\n let result = await gen.next()\n\n while (!result.done) {\n const injected = yield result.value\n result = await gen.next(injected)\n }\n\n return result.value\n },\n }\n\n const provided = provider(fx)\n return provided.run()\n } else {\n const fx: SyncFx<A, E, R> = {\n _tag: \"SyncFx\",\n run: () => {\n throw new Error(\"Should not be called directly - use provider\")\n },\n *[Symbol.iterator](): Generator<E | ServiceRequest<R>, A, unknown> {\n const gen = generatorFn() as FxGenerator<A, E, R>\n let result = gen.next()\n\n while (!result.done) {\n const injected = yield result.value\n result = gen.next(injected)\n }\n\n return result.value\n },\n }\n\n const provided = provider(fx)\n return provided.run()\n }\n }\n\n // No provider - execute directly (R must be never)\n if (isAsync) {\n return (async () => {\n const gen = generatorFn() as AsyncFxGenerator<A, E, never>\n let result = await gen.next()\n\n while (!result.done) {\n // For fn() without provider, there should be no service requests (R = never)\n // Only errors can be yielded\n return resultErr(result.value as E)\n }\n\n return resultOk(result.value)\n })()\n }\n\n const gen = generatorFn() as FxGenerator<A, E, never>\n let result = gen.next()\n\n while (!result.done) {\n return resultErr(result.value as E)\n }\n\n return resultOk(result.value)\n}\n\n// ============================================================================\n// Fx.ok / Fx.err - Convenience aliases\n// ============================================================================\n\n/**\n * Convenience alias for Result.ok.\n * Creates a successful Result that can be yielded in an Fx computation.\n *\n * @param value - The success value\n * @returns Result<T, never>\n *\n * @example\n * ```ts\n * const workflow = Fx.gen(function* () {\n * const value = yield* Fx.ok(42)\n * return value * 2\n * })\n * ```\n */\nconst fxOk = resultOk\n\n/**\n * Convenience alias for Result.err.\n * Creates an error Result that can be yielded in an Fx computation.\n *\n * @param error - The error value\n * @returns Result<never, E>\n *\n * @example\n * ```ts\n * const workflow = Fx.gen(function* () {\n * const config = yield* Config\n *\n * if (!config.dbUrl) {\n * return yield* Fx.err(new ValidationError({ field: \"dbUrl\" }))\n * }\n *\n * return config.dbUrl\n * })\n * ```\n */\nconst fxErr = resultErr\n\n// ============================================================================\n// Exports\n// ============================================================================\n\n// Export individual functions\nexport const gen = fxGen\nexport const fn = fxFn\nexport const ok = fxOk\nexport const err = fxErr\n\n/**\n * Fx namespace containing utilities for creating and running effectful computations.\n *\n * Fx provides a minimal API inspired by Effect.ts:\n * - `Fx.gen()` - Create composable computations with service dependencies\n * - `Fx.fn()` - Execute computations immediately\n * - `Fx.ok()` - Create successful results (alias for Result.ok)\n * - `Fx.err()` - Create error results (alias for Result.err)\n *\n * @example\n * ```ts\n * import { Fx, Service, Layer, provide, pipe } from \"@repo/std\"\n *\n * // Define services\n * class Config extends Service<Config>()(\"Config\") {\n * readonly dbUrl!: string\n * }\n *\n * class Logger extends Service<Logger>()(\"Logger\") {\n * readonly info!: (msg: string) => void\n * }\n *\n * // Create layers\n * const ConfigLive = Layer.ok(Config, { dbUrl: \"postgres://...\" })\n * const LoggerLive = Layer.fx(Logger)(\n * Fx.gen(function* () {\n * const config = yield* Config\n * return { info: (msg) => console.log(`[${config.dbUrl}] ${msg}`) }\n * })\n * )\n *\n * // Create workflow\n * const myWorkflow = Fx.gen(function* () {\n * const logger = yield* Logger\n * logger.info(\"Hello from Fx!\")\n * return \"done\"\n * })\n *\n * // Compose and run\n * const AppLayer = pipe(ConfigLive, Layer.provide(LoggerLive))\n * const result = pipe(myWorkflow, provide(AppLayer)).run()\n * ```\n */\nexport const Fx = {\n gen: fxGen,\n fn: fxFn,\n ok: fxOk,\n err: fxErr,\n} as const\n","import type { ServiceRequest } from \"./fx.types\"\n\n// ============================================================================\n// Service Class Types\n// ============================================================================\n\n/**\n * The interface returned by Service()().\n * Acts as both a type tag and a runtime lookup key.\n */\nexport type ServiceClass<Self, Key extends string = string> = {\n readonly _tag: \"Service\"\n readonly key: Key\n readonly _Self: Self // Phantom type\n\n /**\n * Yielding the service class in a gen computation\n * returns the service instance from context.\n */\n [Symbol.iterator](): Generator<ServiceRequest<Self>, Self, unknown>\n}\n\n/**\n * Extract the service type from a ServiceClass.\n */\nexport type ServiceOf<T> = T extends ServiceClass<infer S> ? S : never\n\n/**\n * Extract the key from a ServiceClass.\n */\nexport type ServiceKey<T> = T extends ServiceClass<unknown, infer K> ? K : never\n\n// ============================================================================\n// Service Factory\n// ============================================================================\n\n/**\n * Define a service with a unique key.\n * The returned class acts as both a type and a runtime tag for lookup.\n *\n * Usage follows a double-invocation pattern:\n * - First call provides the Self type parameter\n * - Second call provides the unique key\n *\n * @example\n * ```ts\n * class Config extends Service<Config>()(\"Config\") {\n * readonly dbUrl!: string\n * readonly logLevel!: \"debug\" | \"info\" | \"error\"\n * }\n *\n * class Logger extends Service<Logger>()(\"Logger\") {\n * readonly info!: (msg: string) => void\n * readonly error!: (msg: string) => void\n * }\n *\n * // Use in Fx.gen:\n * const workflow = Fx.gen(function* () {\n * const config = yield* Config\n * const logger = yield* Logger\n * logger.info(`DB URL: ${config.dbUrl}`)\n * })\n * ```\n */\nexport function Service<Self>(): <Key extends string>(key: Key) => ServiceClass<Self, Key> & (new () => Self) {\n return <Key extends string>(key: Key): ServiceClass<Self, Key> & (new () => Self) => {\n // Create the base class with proper prototype\n const ServiceBase = class {\n static readonly _tag = \"Service\" as const\n static readonly key: Key = key\n static readonly _Self: Self = undefined as unknown as Self;\n\n /**\n * Yielding the class returns a ServiceRequest.\n * The runtime intercepts this and provides the actual service instance.\n */\n static *[Symbol.iterator](): Generator<ServiceRequest<Self>, Self, Self> {\n const serviceInstance = yield {\n _tag: \"ServiceRequest\",\n _service: undefined as unknown as Self,\n serviceKey: key,\n }\n return serviceInstance\n }\n }\n\n // Return with correct typing\n return ServiceBase as unknown as ServiceClass<Self, Key> & (new () => Self)\n }\n}\n\n/**\n * Create a service tag without class syntax.\n * Useful for simple services that don't need class inheritance.\n *\n * @example\n * ```ts\n * interface ConfigService {\n * readonly dbUrl: string\n * readonly logLevel: \"debug\" | \"info\" | \"error\"\n * }\n *\n * const Config = serviceTag<ConfigService>(\"Config\")\n *\n * // Use in Fx.gen:\n * const workflow = Fx.gen(function* () {\n * const config = yield* Config\n * console.log(config.dbUrl)\n * })\n * ```\n */\nexport function serviceTag<S>(key: string): ServiceClass<S> {\n return {\n _tag: \"Service\",\n key,\n _Self: undefined as unknown as S,\n *[Symbol.iterator](): Generator<ServiceRequest<S>, S, S> {\n const serviceInstance = yield {\n _tag: \"ServiceRequest\",\n _service: undefined as unknown as S,\n serviceKey: key,\n }\n return serviceInstance\n },\n }\n}\n\n/**\n * Check if a value is a ServiceClass.\n */\nexport const isServiceClass = (value: unknown): value is ServiceClass<unknown> =>\n typeof value === \"object\" && value !== null && \"_tag\" in value && value._tag === \"Service\"\n","import type { ServiceClass } from \"./service\"\n\n// ============================================================================\n// Context Type\n// ============================================================================\n\n/**\n * Context<Services> is an immutable map storing service implementations.\n * The Services type parameter tracks which services are available.\n */\nexport type Context<Services = never> = {\n readonly _tag: \"Context\"\n readonly _services: ReadonlyMap<string, unknown>\n readonly _Services: Services // Phantom type for tracking available services\n}\n\n// ============================================================================\n// Context Constructors\n// ============================================================================\n\n/**\n * Create an empty context with no services.\n */\nconst empty = (): Context => ({\n _tag: \"Context\",\n _services: new Map(),\n _Services: undefined as never,\n})\n\n/**\n * Create a context with a single service.\n *\n * @param service - The service class (tag)\n * @param impl - The service implementation\n * @returns A context containing the service\n *\n * @example\n * ```ts\n * const ctx = Context.make(Config, { dbUrl: \"postgres://...\", logLevel: \"info\" })\n * ```\n */\nconst make = <S>(service: ServiceClass<S>, impl: S): Context<S> => ({\n _tag: \"Context\",\n _services: new Map([[service.key, impl]]),\n _Services: undefined as unknown as S,\n})\n\n// ============================================================================\n// Context Operations\n// ============================================================================\n\n/**\n * Add a service to an existing context (returns new context).\n * Curried for use with pipe.\n *\n * @param service - The service class (tag)\n * @param impl - The service implementation\n * @returns A function that takes a context and returns a new context with the service added\n *\n * @example\n * ```ts\n * const ctx = pipe(\n * Context.empty(),\n * Context.add(Config, configImpl),\n * Context.add(Logger, loggerImpl),\n * )\n * ```\n */\nconst add =\n <S>(service: ServiceClass<S>, impl: S) =>\n <Existing>(ctx: Context<Existing>): Context<Existing | S> => ({\n _tag: \"Context\",\n _services: new Map([...ctx._services, [service.key, impl]]),\n _Services: undefined as unknown as Existing | S,\n })\n\n/**\n * Merge two contexts together.\n * If both contexts have the same service, the second context's implementation wins.\n *\n * @param a - First context\n * @param b - Second context\n * @returns A new context with services from both\n *\n * @example\n * ```ts\n * const ctx = Context.merge(configContext, loggerContext)\n * ```\n */\nconst merge = <A, B>(a: Context<A>, b: Context<B>): Context<A | B> => ({\n _tag: \"Context\",\n _services: new Map([...a._services, ...b._services]),\n _Services: undefined as unknown as A | B,\n})\n\n/**\n * Get a service from a context.\n * Throws if the service is not found.\n *\n * @param service - The service class (tag)\n * @returns The service implementation\n * @throws Error if service not found\n *\n * @example\n * ```ts\n * const config = Context.get(ctx, Config)\n * ```\n */\n// Use overload to handle both curried and uncurried calls\nfunction get<S>(ctx: Context<S>, service: ServiceClass<S>): S\nfunction get<S>(service: ServiceClass<S>): (ctx: Context<S>) => S\nfunction get<S>(\n ctxOrService: Context<S> | ServiceClass<S>,\n maybeService?: ServiceClass<S>,\n): S | ((ctx: Context<S>) => S) {\n // Curried form: get(service)(ctx)\n if (maybeService === undefined) {\n const service = ctxOrService as ServiceClass<S>\n return (ctx: Context<S>): S => {\n const impl = ctx._services.get(service.key)\n if (impl === undefined) {\n throw new Error(\n `Service \"${service.key}\" not found in context. Available services: [${[...ctx._services.keys()].join(\", \")}]`,\n )\n }\n return impl as S\n }\n }\n\n // Uncurried form: get(ctx, service)\n const ctx = ctxOrService as Context<S>\n const service = maybeService\n const impl = ctx._services.get(service.key)\n if (impl === undefined) {\n throw new Error(\n `Service \"${service.key}\" not found in context. Available services: [${[...ctx._services.keys()].join(\", \")}]`,\n )\n }\n return impl as S\n}\n\n/**\n * Unsafely get a service from a context by key string.\n * Used internally by the runtime when resolving ServiceRequests.\n * Returns undefined if not found (caller should handle).\n */\nconst unsafeGet = (ctx: Context<unknown>, key: string): unknown => ctx._services.get(key)\n\n/**\n * Check if a context contains a specific service.\n *\n * @param ctx - The context to check\n * @param service - The service class (tag)\n * @returns true if the service is in the context\n */\nconst has = <S>(ctx: Context<unknown>, service: ServiceClass<S>): boolean => ctx._services.has(service.key)\n\n/**\n * Get all service keys in a context.\n */\nconst keys = (ctx: Context<unknown>): string[] => [...ctx._services.keys()]\n\n/**\n * Get the size (number of services) in a context.\n */\nconst size = (ctx: Context<unknown>): number => ctx._services.size\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Check if a value is a Context.\n */\nconst isContext = (value: unknown): value is Context<unknown> =>\n typeof value === \"object\" && value !== null && \"_tag\" in value && value._tag === \"Context\"\n\n// ============================================================================\n// Context Namespace\n// ============================================================================\n\n/**\n * Context namespace containing utilities for managing service contexts.\n *\n * A Context is an immutable map of services that can be provided to Fx computations.\n * Services are identified by their unique keys.\n *\n * @example\n * ```ts\n * import { Context, Service } from \"@repo/std\"\n *\n * class Config extends Service<Config>()(\"Config\") {\n * readonly dbUrl!: string\n * }\n *\n * class Logger extends Service<Logger>()(\"Logger\") {\n * readonly info!: (msg: string) => void\n * }\n *\n * // Create a context with services\n * const ctx = pipe(\n * Context.empty(),\n * Context.add(Config, { dbUrl: \"postgres://...\" }),\n * Context.add(Logger, { info: console.log }),\n * )\n *\n * // Or use make and merge\n * const configCtx = Context.make(Config, { dbUrl: \"postgres://...\" })\n * const loggerCtx = Context.make(Logger, { info: console.log })\n * const fullCtx = Context.merge(configCtx, loggerCtx)\n * ```\n */\nexport const Context = {\n empty,\n make,\n add,\n merge,\n get,\n unsafeGet,\n has,\n keys,\n size,\n isContext,\n} as const\n","import { ok } from \"../result/result\"\nimport { Context } from \"./context\"\nimport type { Fx, SyncFx, AsyncFx, ServiceRequest } from \"./fx.types\"\nimport type { Layer as LayerType, MergeROut, MergeError, UnprovidedDeps } from \"./layer.types\"\nimport type { ScopeService, ExcludeScope } from \"./scope\"\nimport type { ServiceClass } from \"./service\"\n\n/**\n * Create a layer from a synchronous value (no dependencies).\n */\n// oxlint-disable-next-line no-redundant-type-constituents\nconst layerOk = <S>(service: ServiceClass<S>, impl: S): LayerType<S, never> => ({\n _tag: \"Layer\",\n _ROut: undefined as unknown as S,\n _E: undefined as never,\n _RIn: undefined as never,\n build: (): Fx<Context<S>, never> => ({\n _tag: \"SyncFx\",\n run: () => ok(Context.make(service, impl)),\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<never, Context<S>, unknown> {\n return Context.make(service, impl)\n },\n }),\n})\n\n/**\n * Create a layer that always fails with an error.\n */\nconst layerErr = <E>(error: E): LayerType<never, E> => ({\n _tag: \"Layer\",\n _ROut: undefined as never,\n _E: undefined as unknown as E,\n _RIn: undefined as never,\n build: (): Fx<Context, E> => ({\n _tag: \"SyncFx\",\n run: () => ({\n ok: false,\n error,\n *[Symbol.iterator]() {\n yield error\n throw new Error(\"Unreachable\")\n },\n }),\n *[Symbol.iterator](): Generator<E, never, unknown> {\n yield error\n throw new Error(\"Unreachable\")\n },\n }),\n})\n\n/**\n * Create a layer from an Fx computation (can have dependencies).\n */\nconst layerFx =\n <S>(service: ServiceClass<S>) =>\n <E, R>(fx: Fx<S, E, R>): LayerType<S, E, R> => ({\n _tag: \"Layer\",\n _ROut: undefined as unknown as S,\n _E: undefined as unknown as E,\n _RIn: undefined as unknown as R,\n build: (): Fx<Context<S>, E, R> => {\n if (fx._tag === \"AsyncFx\") {\n return {\n _tag: \"AsyncFx\",\n run: async () => {\n throw new Error(\"Layer build should use iterator\")\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<R>, Context<S>, unknown> {\n const gen = fx[Symbol.asyncIterator]()\n let result = await gen.next()\n while (!result.done) {\n const value = yield result.value\n result = await gen.next(value)\n }\n return Context.make(service, result.value)\n },\n } as AsyncFx<Context<S>, E, R>\n }\n\n return {\n _tag: \"SyncFx\",\n run: () => {\n throw new Error(\"Layer build should use iterator\")\n },\n *[Symbol.iterator](): Generator<E | ServiceRequest<R>, Context<S>, unknown> {\n const gen = fx[Symbol.iterator]()\n let result = gen.next()\n while (!result.done) {\n const value = yield result.value\n result = gen.next(value)\n }\n return Context.make(service, result.value)\n },\n } as SyncFx<Context<S>, E, R>\n },\n })\n\n/**\n * Create a scoped layer (with resource cleanup).\n */\nconst layerScoped =\n <S>(service: ServiceClass<S>) =>\n <E, R>(fx: Fx<S, E, R | ScopeService>): LayerType<S, E, ExcludeScope<R>> => ({\n _tag: \"Layer\",\n _ROut: undefined as unknown as S,\n _E: undefined as unknown as E,\n _RIn: undefined as unknown as ExcludeScope<R>,\n build: (_memoMap, scope): Fx<Context<S>, E, ExcludeScope<R>> => {\n if (fx._tag === \"AsyncFx\") {\n return {\n _tag: \"AsyncFx\",\n run: async () => {\n throw new Error(\"Layer build should use iterator\")\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<ExcludeScope<R>>, Context<S>, unknown> {\n const gen = fx[Symbol.asyncIterator]()\n let result = await gen.next()\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\" &&\n (yielded as ServiceRequest<unknown>).serviceKey === \"@std/Scope\"\n ) {\n result = await gen.next(scope)\n } else {\n const value = yield yielded as E | ServiceRequest<ExcludeScope<R>>\n result = await gen.next(value)\n }\n }\n return Context.make(service, result.value)\n },\n } as AsyncFx<Context<S>, E, ExcludeScope<R>>\n }\n\n return {\n _tag: \"SyncFx\",\n run: () => {\n throw new Error(\"Layer build should use iterator\")\n },\n *[Symbol.iterator](): Generator<E | ServiceRequest<ExcludeScope<R>>, Context<S>, unknown> {\n const gen = fx[Symbol.iterator]()\n let result = gen.next()\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\" &&\n (yielded as ServiceRequest<unknown>).serviceKey === \"@std/Scope\"\n ) {\n result = gen.next(scope)\n } else {\n const value = yield yielded as E | ServiceRequest<ExcludeScope<R>>\n result = gen.next(value)\n }\n }\n return Context.make(service, result.value)\n },\n } as SyncFx<Context<S>, E, ExcludeScope<R>>\n },\n })\n\n// ============================================================================\n// Layer Composition\n// ============================================================================\n\n/**\n * Provide dependencies to a layer and merge outputs.\n */\nconst layerProvide =\n <DepsROut, DepsE, DepsRIn>(deps: LayerType<DepsROut, DepsE, DepsRIn>) =>\n <ROut, E, RIn extends DepsROut>(layer: LayerType<ROut, E, RIn>): LayerType<ROut | DepsROut, E | DepsE, DepsRIn> => ({\n _tag: \"Layer\",\n _ROut: undefined as unknown as ROut | DepsROut,\n _E: undefined as unknown as E | DepsE,\n _RIn: undefined as unknown as DepsRIn,\n build: (memoMap, scope): Fx<Context<ROut | DepsROut>, E | DepsE, DepsRIn> => {\n const depsBuildFx = deps.build(memoMap, scope)\n\n if (depsBuildFx._tag === \"AsyncFx\") {\n return {\n _tag: \"AsyncFx\",\n run: async () => {\n throw new Error(\"Layer build should use iterator\")\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<\n E | DepsE | ServiceRequest<DepsRIn>,\n Context<ROut | DepsROut>,\n unknown\n > {\n const depsGen = depsBuildFx[Symbol.asyncIterator]()\n let depsResult = await depsGen.next()\n while (!depsResult.done) {\n const value = yield depsResult.value\n depsResult = await depsGen.next(value)\n }\n const depsCtx = depsResult.value\n\n const layerBuildFx = layer.build(memoMap, scope)\n if (layerBuildFx._tag === \"AsyncFx\") {\n const layerGen = layerBuildFx[Symbol.asyncIterator]()\n let layerResult = await layerGen.next()\n while (!layerResult.done) {\n const yielded = layerResult.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = depsCtx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n layerResult = await layerGen.next(service)\n continue\n }\n }\n const value = yield yielded as E | ServiceRequest<DepsRIn>\n layerResult = await layerGen.next(value)\n }\n return Context.merge(depsCtx, layerResult.value)\n }\n\n const layerGen = layerBuildFx[Symbol.iterator]()\n let layerResult = layerGen.next()\n while (!layerResult.done) {\n const yielded = layerResult.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = depsCtx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n layerResult = layerGen.next(service)\n continue\n }\n }\n const value = yield yielded as E | ServiceRequest<DepsRIn>\n layerResult = layerGen.next(value)\n }\n return Context.merge(depsCtx, layerResult.value)\n },\n } as AsyncFx<Context<ROut | DepsROut>, E | DepsE, DepsRIn>\n }\n\n return {\n _tag: \"SyncFx\",\n run: () => {\n throw new Error(\"Layer build should use iterator\")\n },\n *[Symbol.iterator](): Generator<E | DepsE | ServiceRequest<DepsRIn>, Context<ROut | DepsROut>, unknown> {\n const depsGen = depsBuildFx[Symbol.iterator]()\n let depsResult = depsGen.next()\n while (!depsResult.done) {\n const value = yield depsResult.value\n depsResult = depsGen.next(value)\n }\n const depsCtx = depsResult.value\n\n const layerBuildFx = layer.build(memoMap, scope)\n if (layerBuildFx._tag === \"SyncFx\") {\n const syncGen = layerBuildFx[Symbol.iterator]()\n let layerResult = syncGen.next()\n while (!layerResult.done) {\n const yielded = layerResult.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = depsCtx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n layerResult = syncGen.next(service)\n continue\n }\n }\n const value = yield yielded as E | ServiceRequest<DepsRIn>\n layerResult = syncGen.next(value)\n }\n return Context.merge(depsCtx, layerResult.value)\n }\n throw new Error(\"Cannot use async layer in sync context\")\n },\n } as SyncFx<Context<ROut | DepsROut>, E | DepsE, DepsRIn>\n },\n })\n\n/**\n * Merge multiple layers with automatic dependency resolution.\n */\nconst layerMerge = <L extends LayerType<unknown, unknown, unknown>[]>(\n ...layers: L\n): LayerType<MergeROut<L>, MergeError<L>, UnprovidedDeps<L>> => ({\n _tag: \"Layer\",\n _ROut: undefined as unknown as MergeROut<L>,\n _E: undefined as unknown as MergeError<L>,\n _RIn: undefined as unknown as UnprovidedDeps<L>,\n build: (memoMap, scope): Fx<Context<MergeROut<L>>, MergeError<L>, UnprovidedDeps<L>> => {\n const hasAsync = layers.some((l) => l.build(memoMap, scope)._tag === \"AsyncFx\")\n\n if (hasAsync) {\n return {\n _tag: \"AsyncFx\",\n run: async () => {\n throw new Error(\"Layer build should use iterator\")\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<\n MergeError<L> | ServiceRequest<UnprovidedDeps<L>>,\n Context<MergeROut<L>>,\n unknown\n > {\n let ctx = Context.empty() as Context<unknown>\n for (const layer of layers) {\n const buildFx = layer.build(memoMap, scope)\n if (buildFx._tag === \"AsyncFx\") {\n const gen = buildFx[Symbol.asyncIterator]()\n let result = await gen.next()\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n result = await gen.next(service)\n continue\n }\n }\n const value = yield yielded as MergeError<L> | ServiceRequest<UnprovidedDeps<L>>\n result = await gen.next(value)\n }\n ctx = Context.merge(ctx, result.value)\n } else {\n const gen = buildFx[Symbol.iterator]()\n let result = gen.next()\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n result = gen.next(service)\n continue\n }\n }\n const value = yield yielded as MergeError<L> | ServiceRequest<UnprovidedDeps<L>>\n result = gen.next(value)\n }\n ctx = Context.merge(ctx, result.value)\n }\n }\n return ctx as Context<MergeROut<L>>\n },\n } as AsyncFx<Context<MergeROut<L>>, MergeError<L>, UnprovidedDeps<L>>\n }\n\n return {\n _tag: \"SyncFx\",\n run: () => {\n throw new Error(\"Layer build should use iterator\")\n },\n *[Symbol.iterator](): Generator<\n MergeError<L> | ServiceRequest<UnprovidedDeps<L>>,\n Context<MergeROut<L>>,\n unknown\n > {\n let ctx = Context.empty() as Context<unknown>\n for (const layer of layers) {\n const buildFx = layer.build(memoMap, scope)\n if (buildFx._tag !== \"SyncFx\") {\n throw new Error(\"Expected sync layer in sync context\")\n }\n const gen = buildFx[Symbol.iterator]()\n let result = gen.next()\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n result = gen.next(service)\n continue\n }\n }\n const value = yield yielded as MergeError<L> | ServiceRequest<UnprovidedDeps<L>>\n result = gen.next(value)\n }\n ctx = Context.merge(ctx, result.value)\n }\n return ctx as Context<MergeROut<L>>\n },\n } as SyncFx<Context<MergeROut<L>>, MergeError<L>, UnprovidedDeps<L>>\n },\n})\n\n// ============================================================================\n// Layer Namespace\n// ============================================================================\n\nexport const Layer = {\n ok: layerOk,\n err: layerErr,\n fx: layerFx,\n scoped: layerScoped,\n provide: layerProvide,\n merge: layerMerge,\n} as const\n","import { ok } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { SyncFx, AsyncFx, ServiceRequest } from \"./fx.types\"\nimport { Service } from \"./service\"\n\n// ============================================================================\n// Scope Service\n// ============================================================================\n\n/**\n * Scope manages resource lifecycles with finalizers.\n * Finalizers run in LIFO (Last In, First Out) order when the scope closes.\n *\n * @example\n * ```ts\n * const DatabaseLive = Layer.scoped(Database)(\n * Fx.gen(function* () {\n * const scope = yield* Scope\n *\n * const connection = createConnection()\n *\n * // Register cleanup - runs when scope closes\n * yield* scope.addFinalizer(() =>\n * Fx.gen(function* () {\n * connection.close()\n * })\n * )\n *\n * return { query: (sql) => connection.query(sql) }\n * })\n * )\n * ```\n */\nexport type ScopeService = {\n /**\n * Add a finalizer to be run when the scope closes.\n * Finalizers are run in LIFO order.\n *\n * @param finalizer - A function that returns an Fx to run on cleanup\n * @returns An Fx that completes when the finalizer is registered\n */\n addFinalizer(finalizer: () => SyncFx<void, never> | AsyncFx<void, never>): SyncFx<void, never>\n\n /**\n * Close the scope, running all finalizers in LIFO order.\n *\n * @param exit - The exit status of the computation\n * @returns An Fx that completes when all finalizers have run\n */\n close(exit: Result<unknown, unknown>): SyncFx<void, never> | AsyncFx<void, never>\n\n /**\n * Fork a child scope.\n * The child scope will be closed when the parent scope closes.\n *\n * @returns A new child scope\n */\n fork(): ScopeService\n}\n\n// Create the Scope service tag\nclass ScopeTag extends Service<ScopeService>()(\"@std/Scope\") {}\nexport { ScopeTag as Scope }\n\n// ============================================================================\n// Scope Implementation\n// ============================================================================\n\n/**\n * Create a new Scope instance.\n * This is the concrete implementation of the ScopeService interface.\n */\nexport function createScope(): ScopeService {\n type Finalizer = () => SyncFx<void, never> | AsyncFx<void, never>\n const finalizers: Finalizer[] = []\n let closed = false\n const children: ScopeService[] = []\n\n const scope: ScopeService = {\n addFinalizer(finalizer: Finalizer): SyncFx<void, never> {\n return {\n _tag: \"SyncFx\",\n get run() {\n return (() => {\n if (!closed) {\n finalizers.push(finalizer)\n }\n return ok(undefined)\n }) as () => Result<void, never>\n },\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<ServiceRequest<never>, void, unknown> {\n if (!closed) {\n finalizers.push(finalizer)\n }\n },\n } as SyncFx<void, never>\n },\n\n close(exit: Result<unknown, unknown>): SyncFx<void, never> | AsyncFx<void, never> {\n // Check if any finalizer is async\n const hasAsyncFinalizer = finalizers.some((f) => {\n const fx = f()\n return fx._tag === \"AsyncFx\"\n })\n\n if (hasAsyncFinalizer) {\n return {\n _tag: \"AsyncFx\",\n get run() {\n return (async () => {\n if (closed) return ok(undefined)\n closed = true\n\n // Close children first (in reverse order)\n for (const child of [...children].toReversed()) {\n const childClose = child.close(exit)\n if (childClose._tag === \"AsyncFx\") {\n await (childClose.run as () => Promise<Result<void, never>>)()\n } else {\n ;(childClose.run as () => Result<void, never>)()\n }\n }\n\n // Run finalizers in LIFO order\n const reversed = [...finalizers].toReversed()\n for (const finalizer of reversed) {\n const fx = finalizer()\n if (fx._tag === \"AsyncFx\") {\n await (fx.run as () => Promise<Result<void, never>>)()\n } else {\n ;(fx.run as () => Result<void, never>)()\n }\n }\n\n return ok(undefined)\n }) as () => Promise<Result<void, never>>\n },\n // oxlint-disable-next-line require-yield\n async *[Symbol.asyncIterator](): AsyncGenerator<ServiceRequest<never>, void, unknown> {\n if (closed) return\n closed = true\n\n // Close children first\n for (const child of [...children].toReversed()) {\n const childClose = child.close(exit)\n if (childClose._tag === \"AsyncFx\") {\n await (childClose.run as () => Promise<Result<void, never>>)()\n } else {\n ;(childClose.run as () => Result<void, never>)()\n }\n }\n\n // Run finalizers in LIFO order\n const reversed = [...finalizers].toReversed()\n for (const finalizer of reversed) {\n const fx = finalizer()\n if (fx._tag === \"AsyncFx\") {\n await (fx.run as () => Promise<Result<void, never>>)()\n } else {\n ;(fx.run as () => Result<void, never>)()\n }\n }\n },\n } as AsyncFx<void, never>\n }\n\n // Sync version\n return {\n _tag: \"SyncFx\",\n get run() {\n return (() => {\n if (closed) return ok(undefined)\n closed = true\n\n // Close children first\n for (const child of [...children].toReversed()) {\n const childClose = child.close(exit)\n ;(childClose.run as () => Result<void, never>)()\n }\n\n // Run finalizers in LIFO order\n const reversed = [...finalizers].toReversed()\n for (const finalizer of reversed) {\n const fx = finalizer()\n // oxlint-disable-next-line no-redundant-type-constituents\n ;(fx.run as () => Result<void, never>)()\n }\n\n return ok(undefined)\n }) as () => Result<void, never>\n },\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<ServiceRequest<never>, void, unknown> {\n if (closed) return\n closed = true\n\n // Close children first\n for (const child of [...children].toReversed()) {\n const childClose = child.close(exit)\n ;(childClose.run as () => Result<void, never>)()\n }\n\n // Run finalizers in LIFO order\n const reversed = [...finalizers].toReversed()\n for (const finalizer of reversed) {\n const fx = finalizer()\n ;(fx.run as () => Result<void, never>)()\n }\n },\n } as SyncFx<void, never>\n },\n\n fork(): ScopeService {\n const child = createScope()\n children.push(child)\n return child\n },\n }\n\n return scope\n}\n\n// ============================================================================\n// Helper Types\n// ============================================================================\n\n/**\n * Type utility to exclude Scope from requirements.\n * Used by Layer.scoped to auto-provide Scope.\n */\nexport type ExcludeScope<R> = Exclude<R, ScopeService>\n","import { ok } from \"../result/result\"\nimport type { Context } from \"./context\"\nimport type { Fx, SyncFx, AsyncFx, ServiceRequest } from \"./fx.types\"\nimport type { Layer } from \"./layer.types\"\nimport type { ScopeService } from \"./scope\"\n\n// ============================================================================\n// MemoMap\n// ============================================================================\n\ntype AnyLayer = Layer<unknown, unknown, unknown>\n\n/**\n * MemoMap caches built layers so each layer is only built once.\n * Multiple dependents share the same service instance.\n *\n * This implements the \"service singleton\" pattern where a service\n * is instantiated once and shared across all consumers.\n *\n * @example\n * ```ts\n * // Database is built once, shared by DocumentService and TeamService\n * const AppLayer = Layer.merge(\n * ConfigLive,\n * LoggerLive,\n * DatabaseLive, // Built once\n * DocumentServiceLive, // Uses shared Database\n * TeamServiceLive, // Uses same Database instance\n * )\n * ```\n */\nexport class MemoMap {\n private cache = new Map<\n AnyLayer,\n {\n promise?: Promise<Context<unknown>>\n context?: Context<unknown>\n building?: boolean\n }\n >()\n\n /**\n * Get a cached context or build the layer if not cached.\n *\n * @param layer - The layer to get or build\n * @param scope - The scope for resource management\n * @param deps - Context containing the layer's dependencies\n * @returns An Fx producing the layer's context\n */\n getOrBuild<ROut, E, RIn>(layer: Layer<ROut, E, RIn>, scope: ScopeService, deps: Context<RIn>): Fx<Context<ROut>, E> {\n const cached = this.cache.get(layer as AnyLayer)\n\n // Already built - return cached context\n if (cached?.context) {\n return {\n _tag: \"SyncFx\",\n run: () => ok(cached.context as Context<ROut>),\n // oxlint-disable-next-line require-yield\n *[Symbol.iterator](): Generator<E | ServiceRequest<never>, Context<ROut>, unknown> {\n return cached.context as Context<ROut>\n },\n } as SyncFx<Context<ROut>, E>\n }\n\n // Building in progress (async) - wait for it\n if (cached?.promise) {\n return {\n _tag: \"AsyncFx\",\n run: async () => {\n const ctx = await cached.promise!\n return ok(ctx as Context<ROut>)\n },\n // oxlint-disable-next-line require-yield\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<never>, Context<ROut>, unknown> {\n const ctx = await cached.promise!\n return ctx as Context<ROut>\n },\n } as AsyncFx<Context<ROut>, E>\n }\n\n // Need to build - mark as building\n this.cache.set(layer as AnyLayer, { building: true })\n\n // Build the layer with provided dependencies\n const buildFx = layer.build(this, scope)\n const cacheRef = this.cache\n\n // Determine if async\n if (buildFx._tag === \"AsyncFx\") {\n // Create a promise for the build\n const buildPromise = (async () => {\n const gen = buildFx[Symbol.asyncIterator]()\n let result = await gen.next()\n\n // Resolve service requests from deps\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = deps._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(\n `Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found during layer build`,\n )\n }\n result = await gen.next(service)\n } else {\n // It's an error - rethrow\n throw yielded\n }\n }\n\n const ctx = result.value\n cacheRef.set(layer as AnyLayer, { context: ctx })\n return ctx\n })()\n\n this.cache.set(layer as AnyLayer, { promise: buildPromise })\n\n return {\n _tag: \"AsyncFx\",\n run: async () => {\n try {\n const ctx = await buildPromise\n return ok(ctx)\n } catch (e) {\n return {\n ok: false,\n error: e as E,\n *[Symbol.iterator]() {\n yield e as E\n throw new Error(\"Unreachable\")\n },\n }\n }\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<never>, Context<ROut>, unknown> {\n try {\n const ctx = await buildPromise\n return ctx\n } catch (e) {\n yield e as E\n throw new Error(\"Unreachable\", { cause: e })\n }\n },\n } as AsyncFx<Context<ROut>, E>\n }\n\n // Sync build\n return {\n _tag: \"SyncFx\",\n run: () => {\n const gen = buildFx[Symbol.iterator]()\n let result = gen.next()\n\n // Resolve service requests from deps\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = deps._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(\n `Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found during layer build`,\n )\n }\n result = gen.next(service)\n } else {\n // It's an error\n return {\n ok: false,\n error: yielded as E,\n *[Symbol.iterator]() {\n yield yielded as E\n throw new Error(\"Unreachable\")\n },\n }\n }\n }\n\n const ctx = result.value\n cacheRef.set(layer as AnyLayer, { context: ctx })\n return ok(ctx)\n },\n *[Symbol.iterator](): Generator<E | ServiceRequest<never>, Context<ROut>, unknown> {\n const gen = buildFx[Symbol.iterator]()\n let result = gen.next()\n\n // Resolve service requests from deps\n while (!result.done) {\n const yielded = result.value\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = deps._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(\n `Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found during layer build`,\n )\n }\n result = gen.next(service)\n } else {\n // It's an error - yield it\n yield yielded as E\n throw new Error(\"Unreachable\")\n }\n }\n\n cacheRef.set(layer as AnyLayer, { context: result.value })\n return result.value\n },\n } as SyncFx<Context<ROut>, E>\n }\n\n /**\n * Clear the cache.\n * Useful for testing.\n */\n clear(): void {\n this.cache.clear()\n }\n\n /**\n * Get the number of cached layers.\n */\n get size(): number {\n return this.cache.size\n }\n}\n\n/**\n * Create a new MemoMap instance.\n */\nexport const createMemoMap = (): MemoMap => new MemoMap()\n","import { ok, err as resultErr } from \"../result/result\"\nimport type { Result } from \"../result/result.types\"\nimport type { Context } from \"./context\"\nimport type { Fx, SyncFx, AsyncFx, ServiceRequest } from \"./fx.types\"\nimport type { Layer } from \"./layer.types\"\nimport { MemoMap } from \"./memo-map\"\nimport { createScope } from \"./scope\"\nimport type { ServiceClass } from \"./service\"\n\n// ============================================================================\n// Provide Layer\n// ============================================================================\n\n/**\n * Provide a layer to an Fx computation, resolving all service requirements.\n * Creates a new scope for resource management.\n *\n * @param layer - The layer providing services (must have no external requirements)\n * @returns A function that takes an Fx and returns an Fx with dependencies resolved\n *\n * @example\n * ```ts\n * const result = pipe(\n * updateDocumentWorkflow(userId, docId, data),\n * provide(AppLayer)\n * ).run()\n * ```\n */\nexport const provide =\n <ROut, E2>(layer: Layer<ROut, E2>) =>\n <A, E, R extends ROut>(fx: Fx<A, E, R>): Fx<A, E | E2, never> => {\n // Determine if the layer or fx is async\n const memoMap = new MemoMap()\n const scope = createScope()\n const layerBuildFx = layer.build(memoMap, scope)\n\n if (layerBuildFx._tag === \"AsyncFx\" || fx._tag === \"AsyncFx\") {\n return {\n _tag: \"AsyncFx\",\n get run() {\n return (async () => {\n try {\n // Build the layer\n let ctx: Context<ROut>\n\n if (layerBuildFx._tag === \"AsyncFx\") {\n const gen = layerBuildFx[Symbol.asyncIterator]()\n let result = await gen.next()\n\n while (!result.done) {\n // Layer should have no requirements, but handle just in case\n result = await gen.next(undefined)\n }\n ctx = result.value\n } else {\n const gen = layerBuildFx[Symbol.iterator]()\n let result = gen.next()\n\n while (!result.done) {\n result = gen.next(undefined)\n }\n ctx = result.value\n }\n\n // Run the fx with the context\n if (fx._tag === \"AsyncFx\") {\n const fxGen = fx[Symbol.asyncIterator]()\n let fxResult = await fxGen.next()\n\n while (!fxResult.done) {\n const yielded = fxResult.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n }\n fxResult = await fxGen.next(service)\n } else {\n // It's an error\n return resultErr(yielded as E)\n }\n }\n\n return ok(fxResult.value)\n }\n\n // Sync fx\n const fxGen = fx[Symbol.iterator]()\n let fxResult = fxGen.next()\n\n while (!fxResult.done) {\n const yielded = fxResult.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n }\n fxResult = fxGen.next(service)\n } else {\n return resultErr(yielded as E)\n }\n }\n\n return ok(fxResult.value)\n } finally {\n // Close scope\n const closeResult = scope.close({ _tag: \"Success\", value: undefined })\n if (closeResult._tag === \"AsyncFx\") {\n await (closeResult.run as () => Promise<Result<void, never>>)()\n } else {\n ;(closeResult.run as () => Result<void, never>)()\n }\n }\n }) as () => Promise<Result<A, E | E2>>\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | E2 | ServiceRequest<Exclude<R, ROut>>, A, unknown> {\n try {\n // Build the layer\n let ctx: Context<ROut>\n\n if (layerBuildFx._tag === \"AsyncFx\") {\n const gen = layerBuildFx[Symbol.asyncIterator]()\n let result = await gen.next()\n\n while (!result.done) {\n yield result.value as E2\n result = await gen.next(undefined)\n }\n ctx = result.value\n } else {\n const gen = layerBuildFx[Symbol.iterator]()\n let result = gen.next()\n\n while (!result.done) {\n yield result.value as E2\n result = gen.next(undefined)\n }\n ctx = result.value\n }\n\n // Run the fx with the context\n if (fx._tag === \"AsyncFx\") {\n const fxGen = fx[Symbol.asyncIterator]()\n let fxResult = await fxGen.next()\n\n while (!fxResult.done) {\n const yielded = fxResult.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n fxResult = await fxGen.next(service)\n continue\n }\n }\n\n // Pass through (error or unsatisfied service)\n const value = yield yielded as E | ServiceRequest<Exclude<R, ROut>>\n fxResult = await fxGen.next(value)\n }\n\n return fxResult.value\n }\n\n // Sync fx\n const fxGen = fx[Symbol.iterator]()\n let fxResult = fxGen.next()\n\n while (!fxResult.done) {\n const yielded = fxResult.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n fxResult = fxGen.next(service)\n continue\n }\n }\n\n const value = yield yielded as E | ServiceRequest<Exclude<R, ROut>>\n fxResult = fxGen.next(value)\n }\n\n return fxResult.value\n } finally {\n const closeResult = scope.close({ _tag: \"Success\", value: undefined })\n if (closeResult._tag === \"AsyncFx\") {\n await (closeResult.run as () => Promise<Result<void, never>>)()\n } else {\n ;(closeResult.run as () => Result<void, never>)()\n }\n }\n },\n } as AsyncFx<A, E | E2>\n }\n\n // Both sync\n return {\n _tag: \"SyncFx\",\n get run() {\n return (() => {\n try {\n // Build the layer\n const layerGen = layerBuildFx[Symbol.iterator]()\n let layerResult = layerGen.next()\n\n while (!layerResult.done) {\n layerResult = layerGen.next(undefined)\n }\n\n const ctx = layerResult.value\n\n // Run the fx with the context\n const fxGen = fx[Symbol.iterator]()\n let fxResult = fxGen.next()\n\n while (!fxResult.done) {\n const yielded = fxResult.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n }\n fxResult = fxGen.next(service)\n } else {\n return resultErr(yielded as E)\n }\n }\n\n return ok(fxResult.value)\n } finally {\n const closeResult = scope.close({ _tag: \"Success\", value: undefined })\n ;(closeResult.run as () => Result<void, never>)()\n }\n }) as () => Result<A, E | E2>\n },\n *[Symbol.iterator](): Generator<E | E2 | ServiceRequest<Exclude<R, ROut>>, A, unknown> {\n try {\n // Build the layer\n const layerGen = layerBuildFx[Symbol.iterator]()\n let layerResult = layerGen.next()\n\n while (!layerResult.done) {\n yield layerResult.value as E2\n layerResult = layerGen.next(undefined)\n }\n\n const ctx = layerResult.value\n\n // Run the fx with the context\n const fxGen = fx[Symbol.iterator]()\n let fxResult = fxGen.next()\n\n while (!fxResult.done) {\n const yielded = fxResult.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service !== undefined) {\n fxResult = fxGen.next(service)\n continue\n }\n }\n\n const value = yield yielded as E | ServiceRequest<Exclude<R, ROut>>\n fxResult = fxGen.next(value)\n }\n\n return fxResult.value\n } finally {\n const closeResult = scope.close({ _tag: \"Success\", value: undefined })\n ;(closeResult.run as () => Result<void, never>)()\n }\n },\n } as SyncFx<A, E | E2>\n }\n\n// ============================================================================\n// Provide Context\n// ============================================================================\n\n/**\n * Provide a context directly to an Fx computation.\n *\n * @param ctx - The context containing services\n * @returns A function that takes an Fx and returns an Fx with dependencies resolved\n *\n * @example\n * ```ts\n * const ctx = Context.make(Config, configImpl)\n * const result = pipe(\n * myWorkflow,\n * provideContext(ctx)\n * ).run()\n * ```\n */\nexport const provideContext =\n <R>(ctx: Context<R>) =>\n <A, E>(fx: Fx<A, E, R>): Fx<A, E> => {\n if (fx._tag === \"AsyncFx\") {\n return {\n _tag: \"AsyncFx\",\n get run() {\n return (async () => {\n const gen = fx[Symbol.asyncIterator]()\n let result = await gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n }\n result = await gen.next(service)\n } else {\n return resultErr(yielded as E)\n }\n }\n\n return ok(result.value)\n }) as () => Promise<Result<A, E>>\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<never>, A, unknown> {\n const gen = fx[Symbol.asyncIterator]()\n let result = await gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n }\n result = await gen.next(service)\n } else {\n yield yielded as E\n result = await gen.next(undefined)\n }\n }\n\n return result.value\n },\n } as AsyncFx<A, E>\n }\n\n return {\n _tag: \"SyncFx\",\n get run() {\n return (() => {\n const gen = fx[Symbol.iterator]()\n let result = gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n }\n result = gen.next(service)\n } else {\n return resultErr(yielded as E)\n }\n }\n\n return ok(result.value)\n }) as () => Result<A, E>\n },\n *[Symbol.iterator](): Generator<E | ServiceRequest<never>, A, unknown> {\n const gen = fx[Symbol.iterator]()\n let result = gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n const service = ctx._services.get((yielded as ServiceRequest<unknown>).serviceKey)\n if (service === undefined) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n }\n result = gen.next(service)\n } else {\n yield yielded as E\n result = gen.next(undefined)\n }\n }\n\n return result.value\n },\n } as SyncFx<A, E>\n }\n\n// ============================================================================\n// Provide Service\n// ============================================================================\n\n/**\n * Provide a single service to an Fx computation.\n *\n * @param service - The service class (tag)\n * @param impl - The service implementation\n * @returns A function that takes an Fx and returns an Fx with the service provided\n *\n * @example\n * ```ts\n * const result = pipe(\n * myWorkflow,\n * provideService(Config, configImpl),\n * provideService(Logger, loggerImpl),\n * ).run()\n * ```\n */\nexport const provideService =\n <S>(service: ServiceClass<S>, impl: S) =>\n <A, E, R>(fx: Fx<A, E, R | S>): Fx<A, E, Exclude<R, S>> => {\n if (fx._tag === \"AsyncFx\") {\n return {\n _tag: \"AsyncFx\",\n get run() {\n return (async () => {\n const gen = fx[Symbol.asyncIterator]()\n let result = await gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\" &&\n (yielded as ServiceRequest<unknown>).serviceKey === service.key\n ) {\n result = await gen.next(impl)\n } else if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n // Can't resolve - throw\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n } else {\n return resultErr(yielded as E)\n }\n }\n\n return ok(result.value)\n }) as () => Promise<Result<A, E>>\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<E | ServiceRequest<Exclude<R, S>>, A, unknown> {\n const gen = fx[Symbol.asyncIterator]()\n let result = await gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\" &&\n (yielded as ServiceRequest<unknown>).serviceKey === service.key\n ) {\n result = await gen.next(impl)\n } else {\n const value = yield yielded as E | ServiceRequest<Exclude<R, S>>\n result = await gen.next(value)\n }\n }\n\n return result.value\n },\n } as AsyncFx<A, E, Exclude<R, S>>\n }\n\n return {\n _tag: \"SyncFx\",\n get run() {\n return (() => {\n const gen = fx[Symbol.iterator]()\n let result = gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\" &&\n (yielded as ServiceRequest<unknown>).serviceKey === service.key\n ) {\n result = gen.next(impl)\n } else if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\"\n ) {\n throw new Error(`Service \"${(yielded as ServiceRequest<unknown>).serviceKey}\" not found`)\n } else {\n return resultErr(yielded as E)\n }\n }\n\n return ok(result.value)\n }) as () => Result<A, E>\n },\n *[Symbol.iterator](): Generator<E | ServiceRequest<Exclude<R, S>>, A, unknown> {\n const gen = fx[Symbol.iterator]()\n let result = gen.next()\n\n while (!result.done) {\n const yielded = result.value\n\n if (\n typeof yielded === \"object\" &&\n yielded !== null &&\n \"_tag\" in yielded &&\n yielded._tag === \"ServiceRequest\" &&\n (yielded as ServiceRequest<unknown>).serviceKey === service.key\n ) {\n result = gen.next(impl)\n } else {\n const value = yield yielded as E | ServiceRequest<Exclude<R, S>>\n result = gen.next(value)\n }\n }\n\n return result.value\n },\n } as SyncFx<A, E, Exclude<R, S>>\n }\n","import { data, record } from \"./adt\"\nimport { Brand } from \"./brand\"\nimport { array, struct, tagged, tuple } from \"./data\"\nimport { Either } from \"./either\"\nimport { Err, TaggedError } from \"./err\"\nimport { flow } from \"./flow\"\nimport { fn } from \"./fn\"\nimport { Fx, Service, Layer, Context, Scope, provide } from \"./fx\"\nimport { gen } from \"./gen\"\nimport { Option } from \"./option\"\nimport { pipe } from \"./pipe\"\nimport { Predicate } from \"./predicate\"\nimport { Result } from \"./result\"\n\n/**\n * Main Std namespace containing all utility functions and types.\n */\nexport const Std = {\n array,\n data,\n flow,\n fn,\n gen,\n pipe,\n record,\n struct,\n tagged,\n tuple,\n // Spreading the result utilities since we want to make it a 1st class citizen\n ...Result,\n Option,\n Either,\n Err,\n TaggedError,\n Predicate,\n Brand,\n // Fx - Dependency injection system\n Fx,\n Service,\n Layer,\n Context,\n Scope,\n provide,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+DA,SAAS,MACP,aACoC;CAEpC,MAAM,UAAU,aAAa;AAG7B,KAFgB,OAAO,iBAAiB,QAGtC,QAAO;EACL,MAAM;EACN,KAAK,YAAY;GAEf,MAAM,SAAS,MADH,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SAEzF,QAAOG,IAAU,QAAa;;AAIlC,WAAO,GAAG,OAAO,MAAM;;;EAG3B,EAAE,OAAO,YAAsE;GAC7E,MAAMH,QAAM,GAAG,OAAO,WAAW;GACjC,IAAI,SAASA,MAAI,MAAM;AAEvB,UAAO,CAAC,OAAO,MAAM;IACnB,MAAM,UAAU,OAAO;AAEvB,QACE,OAAO,YAAY,YACnB,YAAY,QACZ,UAAU,WACV,QAAQ,SAAS,oBAChB,QAAoC,eAAe,QAAQ,IAE5D,UAASA,MAAI,KAAK,KAAK;SAClB;KACL,MAAM,QAAQ,MAAM;AACpB,cAASA,MAAI,KAAK,MAAM;;;AAI5B,UAAO,OAAO;;EAEjB;;;;;;;;AC5jBL,MAAa,MAAM;CACjB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nicolastoulemont/std",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Collection of utilty function for this monorepo",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"files": [
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
"types": "./dist/fn/index.d.mts",
|
|
44
44
|
"default": "./dist/fn/index.mjs"
|
|
45
45
|
},
|
|
46
|
+
"./fx": {
|
|
47
|
+
"types": "./dist/fx/index.d.mts",
|
|
48
|
+
"default": "./dist/fx/index.mjs"
|
|
49
|
+
},
|
|
46
50
|
"./gen": {
|
|
47
51
|
"types": "./dist/gen/index.d.mts",
|
|
48
52
|
"default": "./dist/gen/index.mjs"
|
|
@@ -71,7 +75,7 @@
|
|
|
71
75
|
"@standard-schema/spec": "^1.0.0",
|
|
72
76
|
"@types/node": "^24.1.0",
|
|
73
77
|
"knip": "^5.77.4",
|
|
74
|
-
"oxlint": "^1.
|
|
78
|
+
"oxlint": "^1.42.0",
|
|
75
79
|
"oxlint-tsgolint": "latest",
|
|
76
80
|
"tsdown": "^0.19.0",
|
|
77
81
|
"typescript": "^5.9.3",
|