From 8577d4837d8b1e7e90b6ee6c64dcde1f30a49dc7 Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Tue, 14 Oct 2025 09:13:37 +0200 Subject: [PATCH 1/6] prep --- packages/vue/src/experimental/commander2.ts | 1688 +++++++++++++++++++ 1 file changed, 1688 insertions(+) create mode 100644 packages/vue/src/experimental/commander2.ts diff --git a/packages/vue/src/experimental/commander2.ts b/packages/vue/src/experimental/commander2.ts new file mode 100644 index 0000000000..21e6464673 --- /dev/null +++ b/packages/vue/src/experimental/commander2.ts @@ -0,0 +1,1688 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { asResult, type MissingDependencies, reportRuntimeError } from "@effect-app/vue" +import { reportMessage } from "@effect-app/vue/errorReporter" +import { type Result } from "@effect-atom/atom/Result" +import { Cause, Context, Effect, type Exit, flow, Match, Option, Runtime, S } from "effect-app" +import { SupportedErrors } from "effect-app/client" +import { OperationFailure, OperationSuccess } from "effect-app/Operations" +import { wrapEffect } from "effect-app/utils" +import { id, type RuntimeFiber } from "effect/Fiber" +import { type NoInfer } from "effect/Types" +import { isGeneratorFunction, type YieldWrap } from "effect/Utils" +import { type FormatXMLElementFn, type PrimitiveType } from "intl-messageformat" +import { computed, type ComputedRef, reactive, ref } from "vue" +import { CommandContext } from "./commander.js" +import { Confirm } from "./confirm.js" +import { I18n } from "./intl.js" +import { WithToast } from "./withToast.js" + +type IntlRecord = Record> +type FnOptions = { + i18nCustomKey?: I18nCustomKey + /** + * passed to the i18n formatMessage calls so you can use it in translation messagee + * including the Command `action` string. + * Automatically wrapped with Computed if just a thunk. + * provided as Command.state tag, so you can access it in the function. + */ + state?: ComputedRef | (() => State) + disableSharedWaiting?: boolean +} + +type FnOptionsInternal = { + i18nCustomKey?: I18nCustomKey | undefined + state?: IntlRecord | undefined +} + +export type EmitWithCallback = (event: Event, value: A, onDone: () => void) => void + +export declare namespace Commander { + export type CommanderBase = + & Commander.Gen + & Commander.NonGen + & Commander.CommandContextLocal + & { + state: Context.Tag<`Commander.Command.${Id}.state`, State> + } + + export type CommanderFn = + CommanderBase + + export type CommanderWrap< + RT, + Id extends string, + I18nCustomKey extends string, + State extends IntlRecord | undefined, + I extends any[], + A, + E, + R + > = + & CommandContextLocal + & GenWrap + & NonGenWrap + & { + state: Context.Tag<`Commander.Command.${Id}.state`, State> + } + + export interface CommandContextLocal { + id: Id + i18nKey: I18nKey + namespace: `action.${I18nKey}` + namespaced: (k: K) => `action.${I18nKey}.${K}` + } + + export interface CommandProps< + A, + E, + Id extends string, + I18nKey extends string, + State extends IntlRecord | undefined + > extends CommandContextLocal { + /** reactive */ + action: string + /** reactive */ + label: string + /** reactive */ + result: Result + /** reactive */ + waiting: boolean + /** reactive */ + state: ComputedRef + } + + export interface CommandOut< + Args extends Array, + A, + E, + R, + Id extends string, + I18nKey extends string, + State extends IntlRecord | undefined + > extends CommandProps { + new(): {} + + /** click handlers */ + handle: ((...args: Args) => RuntimeFiber, never>) & { + /** @deprecated don't exist */ + effect: (...args: Args) => Effect.Effect + } + + // // TODO: if we keep them, it would probably be nicer as an option api, deciding the return value like in Atom? + // /** @experimental */ + // compose: (...args: Args) => Effect.Effect, R> + // /** @experimental */ + // compose2: (...args: Args) => Effect.Effect + // /** + // * @experimental + // * captures the current span and returns an Effect that when run will execute the command + // */ + // handleEffect: (...args: Args) => Effect.Effect, never>> + // /** + // * @experimental + // */ + // exec: (...args: Args) => Effect.Effect, never, Exclude> + } + + type CommandOutHelper< + Args extends Array, + Eff extends Effect.Effect, + Id extends string, + I18nKey extends string, + State extends IntlRecord | undefined + > = CommandOut< + Args, + Effect.Effect.Success, + Effect.Effect.Error, + Effect.Effect.Context, + Id, + I18nKey, + State + > + + export type Gen = { + < + Eff extends YieldWrap>, + AEff, + Args extends Array + >( + body: (...args: Args) => Generator + ): CommandOut< + Args, + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never, + Id, + I18nKey, + State + > + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B, + C extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B, + C, + D extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B, + C, + D, + E extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B, + C, + D, + E, + F extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B, + C, + D, + E, + F, + G extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F, + g: (_: F, ...args: NoInfer) => G + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B, + C, + D, + E, + F, + G, + H extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F, + g: (_: F, ...args: NoInfer) => G, + h: (_: G, ...args: NoInfer) => H + ): CommandOutHelper + < + Eff extends YieldWrap>, + AEff, + Args extends Array, + A, + B, + C, + D, + E, + F, + G, + H, + I extends Effect.Effect + >( + body: (...args: Args) => Generator, + a: ( + _: Effect.Effect< + AEff, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? E + : never, + [Eff] extends [never] ? never + : [Eff] extends [YieldWrap>] ? R + : never + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F, + g: (_: F, ...args: NoInfer) => G, + h: (_: G, ...args: NoInfer) => H, + i: (_: H, ...args: NoInfer) => I + ): CommandOutHelper + } + + export type NonGen = { + < + Eff extends Effect.Effect, + Args extends Array + >( + body: (...args: Args) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + C, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + C, + D, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + C, + D, + E, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + C, + D, + E, + F, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + C, + D, + E, + F, + G, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => G, + g: (_: G, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + C, + D, + E, + F, + G, + H, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => G, + g: (_: G, ...args: NoInfer) => H, + h: (_: H, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + A, + B, + C, + D, + E, + F, + G, + H, + I, + Args extends Array + >( + body: (...args: Args) => A, + a: (_: A, ...args: NoInfer) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => G, + g: (_: G, ...args: NoInfer) => H, + h: (_: H, ...args: NoInfer) => I, + i: (_: H, ...args: NoInfer) => Eff + ): CommandOutHelper + } + + export type GenWrap< + RT, + Id extends string, + I18nKey extends string, + Args extends Array, + AEff, + EEff, + REff, + State extends IntlRecord | undefined + > = { + (): Exclude extends never ? CommandOut< + Args, + AEff, + EEff, + REff, + Id, + I18nKey, + State + > + : MissingDependencies & {} + < + A extends Effect.Effect + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A + ): CommandOutHelper + < + A, + B extends Effect.Effect + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B + ): CommandOutHelper + < + A, + B, + C extends Effect.Effect + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C + ): CommandOutHelper + < + A, + B, + C, + D extends Effect.Effect + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D + ): CommandOutHelper + < + A, + B, + C, + D, + E extends Effect.Effect + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E + ): CommandOutHelper + < + A, + B, + C, + D, + E, + F extends Effect.Effect + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F + ): CommandOutHelper + < + A, + B, + C, + D, + E, + F, + G extends Effect.Effect + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F, + g: (_: F, ...args: NoInfer) => G + ): CommandOutHelper + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F, + g: (_: F, ...args: NoInfer) => G, + h: (_: G, ...args: NoInfer) => H + ): CommandOutHelper + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => A, + b: (_: A, ...args: NoInfer) => B, + c: (_: B, ...args: NoInfer) => C, + d: (_: C, ...args: NoInfer) => D, + e: (_: D, ...args: NoInfer) => E, + f: (_: E, ...args: NoInfer) => F, + g: (_: F, ...args: NoInfer) => G, + h: (_: G, ...args: NoInfer) => H, + i: (_: H, ...args: NoInfer) => I + ): CommandOutHelper + } + + export type NonGenWrap< + RT, + Id extends string, + I18nKey extends string, + Args extends Array, + AEff, + EEff, + REff, + State extends IntlRecord | undefined + > = { + (): Exclude extends never ? CommandOutHelper, Id, I18nKey, State> + : MissingDependencies & {} + < + Eff extends Effect.Effect, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + C, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + C, + D, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + C, + D, + E, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + C, + D, + E, + F, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + C, + D, + E, + F, + G, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => G, + g: (_: G, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + C, + D, + E, + F, + G, + H, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => G, + g: (_: G, ...args: NoInfer) => H, + h: (_: H, ...args: NoInfer) => Eff + ): CommandOutHelper + < + Eff extends Effect.Effect, + B, + C, + D, + E, + F, + G, + H, + I, + Args extends Array + >( + a: ( + _: Effect.Effect< + AEff, + EEff, + REff + >, + ...args: NoInfer + ) => B, + b: (_: B, ...args: NoInfer) => C, + c: (_: C, ...args: NoInfer) => D, + d: (_: D, ...args: NoInfer) => E, + e: (_: E, ...args: NoInfer) => F, + f: (_: F, ...args: NoInfer) => G, + g: (_: G, ...args: NoInfer) => H, + h: (_: H, ...args: NoInfer) => I, + i: (_: H, ...args: NoInfer) => Eff + ): CommandOutHelper + } +} + +type ErrorRenderer = (e: E, action: string, ...args: Args) => string | undefined + +const renderErrorMaker = I18n.use( + ({ intl }) => + (action: string, errorRenderer?: ErrorRenderer) => + (e: E, ...args: Args): string => { + if (errorRenderer) { + const m = errorRenderer(e, action, ...args) + if (m !== undefined) { + return m + } + } + if (!S.is(SupportedErrors)(e) && !S.ParseResult.isParseError(e)) { + if (typeof e === "object" && e !== null) { + if ("message" in e) { + return `${e.message}` + } + if ("_tag" in e) { + return `${e._tag}` + } + } + return "" + } + const e2: SupportedErrors | S.ParseResult.ParseError = e + return Match.value(e2).pipe( + Match.tags({ + NotFoundError: (e) => { + return intl.formatMessage({ id: "handle.not_found" }, { type: e.type, id: e.id }) + }, + ParseError: (e) => { + console.warn(e.toString()) + return intl.formatMessage({ id: "validation.failed" }) + } + }), + Match.orElse((e) => `${e.message ?? e._tag ?? e}`) + ) + } +) + +const defaultFailureMessageHandler = , AME, AMR>( + actionMaker: + | string + | ((o: Option.Option, ...args: Args) => string) + | ((o: Option.Option, ...args: Args) => Effect.Effect), + errorRenderer?: ErrorRenderer +) => + Effect.fnUntraced(function*(o: Option.Option, ...args: Args) { + const action = yield* wrapEffect(actionMaker)(o, ...args) + const { intl } = yield* I18n + const renderError = yield* renderErrorMaker + + return Option.match(o, { + onNone: () => + intl.formatMessage( + { id: "handle.unexpected_error2" }, + { + action, + error: "" // TODO consider again Cause.pretty(cause), // will be reported to Sentry/Otel anyway.. and we shouldn't bother users with error dumps? + } + ), + onSome: (e) => + S.is(OperationFailure)(e) + ? { + level: "warn" as const, + message: intl.formatMessage( + { id: "handle.with_warnings" }, + { action } + ) + e.message + ? "\n" + e.message + : "" + } + : `${ + intl.formatMessage( + { id: "handle.with_errors" }, + { action } + ) + }:\n` + renderError(action, errorRenderer)(e, ...args) + }) + }) + +export const CommanderStatic = { + /** Version of @see confirmOrInterrupt that automatically includes the action name in the default messages */ + confirmOrInterrupt: Effect.fnUntraced(function*( + message: string | undefined = undefined + ) { + const context = yield* CommandContext + const { intl } = yield* I18n + + yield* Confirm.confirmOrInterrupt( + message + ?? intl.formatMessage( + { id: "handle.confirmation" }, + { action: context.action } + ) + ) + }), + /** Version of @see confirm that automatically includes the action name in the default messages */ + confirm: Effect.fnUntraced(function*( + message: string | undefined = undefined + ) { + const context = yield* CommandContext + const { intl } = yield* I18n + return yield* Confirm.confirm( + message + ?? intl.formatMessage( + { id: "handle.confirmation" }, + { action: context.action } + ) + ) + }), + updateAction: + >(update: (currentActionId: string, ...args: Args) => string) => + (_: Effect.Effect, ...input: Args) => + Effect.updateService( + _, + CommandContext, + (c) => ({ ...c, action: update(c.action, ...input) }) + ), + defaultFailureMessageHandler, + renderError: renderErrorMaker, + /** + * Version of withDefaultToast that automatically includes the action name in the default messages and uses intl. + * uses the Command id as i18n namespace. `action.{id}` is the main action name, + * and `action.{id}.waiting`, `action.{id}.success`, `action.{id}.failure` can be used to override the default messages for the respective states. + * + * the computed `state` provided to the Command can be used for interpolation in the i18n messages. (the state is captured at the start of each command execution and remains stable throughout) + * + * Note: if you provide `onWaiting` or `onSuccess` as `null`, no toast will be shown for that state. + * If you provide a string or function, it will be used instead of the i18n message. + * If you provide an `errorRenderer`, it will be used to render errors in the failure message. + */ + withDefaultToast: >( + options?: { + /** + * if true, previous toasts with this key will be replaced + */ + stableToastId?: undefined | true | string | ((id: string, ...args: Args) => true | string | undefined) + errorRenderer?: ErrorRenderer + onWaiting?: null | undefined | string | ((id: string, ...args: Args) => string | null | undefined) + onSuccess?: null | undefined | string | ((a: A, action: string, ...args: Args) => string | null | undefined) + } + ) => + ( + self: Effect.Effect, + ...args: Args + ) => + Effect.gen(function*() { + const cc = yield* CommandContext + const { intl } = yield* I18n + const withToast = yield* WithToast + const customWaiting = cc.namespaced("waiting") + const hasCustomWaiting = !!intl.messages[customWaiting] + const customSuccess = cc.namespaced("success") + const hasCustomSuccess = !!intl.messages[customSuccess] + const customFailure = cc.namespaced("failure") + const hasCustomFailure = !!intl.messages[customFailure] + const stableToastId = options?.stableToastId + ? typeof options.stableToastId === "string" + ? options.stableToastId + : typeof options.stableToastId === "boolean" + ? cc.id + : typeof options.stableToastId === "function" + ? (...args: Args) => { + const r = (options.stableToastId as any)(id, ...args) + if (typeof r === "string") return r + if (r === true) return cc.id + return undefined + } + : undefined + : undefined + return yield* self.pipe( + (_) => + withToast({ + onWaiting: options?.onWaiting === null ? null : hasCustomWaiting + ? intl.formatMessage({ + id: customWaiting + }, cc.state) + : intl.formatMessage( + { id: "handle.waiting" }, + { action: cc.action } + ), + onSuccess: options?.onSuccess === null + ? null + : (a, ..._args) => + hasCustomSuccess + ? intl.formatMessage( + { id: customSuccess }, + cc.state + ) + : (intl.formatMessage({ id: "handle.success" }, { action: cc.action }) + + (S.is(OperationSuccess)(a) && a.message ? "\n" + a.message : "")), + onFailure: defaultFailureMessageHandler( + hasCustomFailure ? intl.formatMessage({ id: customFailure }, cc.state) : cc.action, + options?.errorRenderer + ), + stableToastId + })(_, ...args) + ) + }) +} + +const makeBaseInfo = ( + id: Id, + options?: Pick, "i18nCustomKey"> +) => { + if (!id) throw new Error("must specify an id") + const i18nKey: I18nKey = options?.i18nCustomKey ?? id as unknown as I18nKey + + const namespace = `action.${i18nKey}` as const + + const context = { + id, + i18nKey, + namespace, + namespaced: (k: K) => `${namespace}.${k}` as const + } + + return context +} + +const waitState = ref>({}) +const registerWait = (id: string) => { + // console.debug("register wait", id) + waitState.value[id] = waitState.value[id] ? waitState.value[id] + 1 : 1 +} +const unregisterWait = (id: string) => { + // console.debug("unregister wait", id) + if (waitState.value[id]) { + waitState.value[id] = waitState.value[id] - 1 + if (waitState.value[id] <= 0) { + delete waitState.value[id] + } + } +} + +const getStateValues = ( + options?: FnOptions +): ComputedRef => { + const state_ = options?.state + const state = !state_ ? computed(() => undefined as State) : typeof state_ === "function" + ? computed(state_) + : state_ + return state +} + +// class preserves JSDoc throughout.. +export class CommanderImpl { + private runFork: ( + effect: Effect.Effect, + options?: Runtime.RunForkOptions + ) => RuntimeFiber + + constructor(private readonly rt: Runtime.Runtime, private readonly intl: I18n) { + this.runFork = Runtime.runFork(this.rt) + } + + readonly makeContext = ( + id: Id, + options?: FnOptionsInternal + ) => { + if (!id) throw new Error("must specify an id") + const i18nKey: I18nKey = options?.i18nCustomKey ?? id as unknown as I18nKey + + const namespace = `action.${i18nKey}` as const + + // must remain stable through out single call + const action = this.intl.formatMessage({ + id: namespace, + defaultMessage: id + }, { ...options?.state, _isLabel: false }) + + const label = this.intl.formatMessage({ + id: namespace, + defaultMessage: id + }, { ...options?.state, _isLabel: true }) + + const context = CommandContext.of({ + ...makeBaseInfo(id, options), + action, + label, + state: options?.state + }) + + return context + } + + readonly makeCommand = < + const Id extends string, + const State extends IntlRecord | undefined, + const I18nKey extends string = Id + >( + id_: Id | { id: Id }, + options?: FnOptions, + errorDef?: Error + ) => { + const id = typeof id_ === "string" ? id_ : id_.id + const state = getStateValues(options) + + return Object.assign( + , A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( + handler: (...args: Args) => Effect.Effect + ) => { + // we capture the definition stack here, so we can append it to later stack traces + const limit = Error.stackTraceLimit + Error.stackTraceLimit = 2 + const localErrorDef = new Error() + Error.stackTraceLimit = limit + if (!errorDef) { + errorDef = localErrorDef + } + + const key = `Commander.Command.${id}.state` as const + const stateTag = Context.GenericTag(key) + + const makeContext_ = () => this.makeContext(id, { ...options, state: state?.value }) + const initialContext = makeContext_() + const context = computed(() => makeContext_()) + const action = computed(() => context.value.action) + const label = computed(() => context.value.label) + + const errorReporter = (self: Effect.Effect) => + self.pipe( + Effect.tapErrorCause( + Effect.fnUntraced(function*(cause) { + if (Cause.isInterruptedOnly(cause)) { + console.info(`Interrupted while trying to ${id}`) + return + } + + const fail = Cause.failureOption(cause) + if (Option.isSome(fail)) { + // if (fail.value._tag === "SuppressErrors") { + // console.info( + // `Suppressed error trying to ${action}`, + // fail.value, + // ) + // return + // } + const message = `Failure trying to ${id}` + yield* reportMessage(message, { + action: id, + error: fail.value + }) + return + } + + const context = yield* CommandContext + const extra = { + action: context.action, + message: `Unexpected Error trying to ${id}` + } + yield* reportRuntimeError(cause, extra) + }, Effect.uninterruptible) + ) + ) + + const currentState = Effect.sync(() => state.value) + + const theHandler = flow( + handler, + errorReporter, + // all must be within the Effect.fn to fit within the Span + Effect.provideServiceEffect( + stateTag, + currentState + ), + Effect.provideServiceEffect( + CommandContext, + Effect.sync(() => makeContext_()) + ) + ) + + const [result, exec_] = asResult(theHandler) + // probably could be nice to use a namespaced, computable wait key instead not unlike query invalidation? + // ["Something.Update", { id }] for instance + const exec = options?.disableSharedWaiting + ? exec_ + : Effect + .fnUntraced(function*(...args: Args) { + registerWait(id) + return yield* exec_(...args) + }, Effect.onExit(() => Effect.sync(() => unregisterWait(id)))) + + const waiting = options?.disableSharedWaiting + ? computed(() => result.value.waiting) + : computed(() => result.value.waiting || (waitState.value[id] ?? 0) > 0) + + const handle = Object.assign((...args: Args) => { + // we capture the call site stack here + const limit = Error.stackTraceLimit + Error.stackTraceLimit = 2 + const errorCall = new Error() + Error.stackTraceLimit = limit + + let cache: false | string = false + const captureStackTrace = () => { + // in case of an error, we want to append the definition stack to the call site stack, + // so we can see where the handler was defined too + + if (cache !== false) { + return cache + } + if (errorCall.stack) { + const stackDef = errorDef!.stack!.trim().split("\n") + const stackCall = errorCall.stack.trim().split("\n") + let endStackDef = stackDef.slice(2).join("\n").trim() + if (!endStackDef.includes(`(`)) { + endStackDef = endStackDef.replace(/at (.*)/, "at ($1)") + } + let endStackCall = stackCall.slice(2).join("\n").trim() + if (!endStackCall.includes(`(`)) { + endStackCall = endStackCall.replace(/at (.*)/, "at ($1)") + } + cache = `${endStackDef}\n${endStackCall}` + return cache + } + } + + const command = currentState.pipe(Effect.flatMap((state) => + Effect.withSpan( + exec(...args), + id, + { + captureStackTrace, + attributes: { + input: args, + state, + action: initialContext.action, + label: initialContext.label, + id: initialContext.id, + i18nKey: initialContext.i18nKey + } + } + ) + )) + + return this.runFork(command) + }, { action, label }) + + return reactive({ + /** static */ + id, + + /** the base i18n key, based on id by default. static */ + i18nKey: initialContext.i18nKey, + /** the `action.` namespace based on i18nKey.. static */ + namespace: initialContext.namespace, + + /** easy generate namespaced 18n keys, based on namespace. static */ + namespaced: initialContext.namespaced, + + /** reactive */ + result, + /** reactive */ + waiting, + /** reactive */ + action, + /** reactive */ + label, + /** reactive */ + state, + + handle + }) + }, + { id } + ) + } + + // /** @experimental */ + // takeOver: + // (command: Commander.CommandOut) => + // (...args: Args) => { + // // we capture the call site stack here + // const limit = Error.stackTraceLimit + // Error.stackTraceLimit = 2 + // const errorCall = new Error() + // const localErrorDef = new Error() + // Error.stackTraceLimit = limit + + // // TODO + // const errorDef = localErrorDef + + // let cache: false | string = false + // const captureStackTrace = () => { + // // in case of an error, we want to append the definition stack to the call site stack, + // // so we can see where the handler was defined too + + // if (cache !== false) { + // return cache + // } + // if (errorCall.stack) { + // const stackDef = errorDef.stack!.trim().split("\n") + // const stackCall = errorCall.stack.trim().split("\n") + // let endStackDef = stackDef.slice(2).join("\n").trim() + // if (!endStackDef.includes(`(`)) { + // endStackDef = endStackDef.replace(/at (.*)/, "at ($1)") + // } + // let endStackCall = stackCall.slice(2).join("\n").trim() + // if (!endStackCall.includes(`(`)) { + // endStackCall = endStackCall.replace(/at (.*)/, "at ($1)") + // } + // cache = `${endStackDef}\n${endStackCall}` + // return cache + // } + // } + + // return Effect.gen(function*() { + // const ctx = yield* CommandContext + // ctx.action = command.action + // return yield* command.exec(...args).pipe( + // Effect.flatten, + // Effect.withSpan( + // command.action, + // { captureStackTrace } + // ) + // ) + // }) + // }, + + /** + * Define a Command for handling user actions with built-in error reporting and state management. + * + * @param id The internal identifier for the action. Used as a tracing span and to lookup + * the user-facing name via internationalization (`action.${id}`). + * @param options Optional configuration for internationalization and state. + * @param options.i18nCustomKey Custom i18n key to use instead of `id` (e.g., for grouping similar actions) + * @param options.state Optional reactive state object (or function returning one) that is + * made available to the command effects and can be used for i18n interpolation. + * The state is captured at the start of each command execution and remains stable throughout. + * @returns A function that executes the command when called (e.g., directly in `@click` handlers). + * Built-in error reporting handles failures automatically. + * + * **Effect Context**: Effects have access to the `CommandContext` service, which provides + * the user-facing action name. + * + * **Returned Properties**: + * - `action`: User-facing action name from intl messages (useful for button labels) + * - `result`: The command result state + * - `waiting`: Boolean indicating if the command is in progress (shorthand for `result.waiting`) + * - `handle`: Function to execute the command + * - `exec`: The raw Effect that will be executed when calling `handle` (for advanced use cases) + * - `i18nKey`, `namespace`, `namespaced`: Helpers for internationalization keys + * + * **User Feedback**: Use the `withDefaultToast` helper for status notifications, or render + * the `result` inline for custom UI feedback. + */ + fn = < + const Id extends string, + const State extends IntlRecord = IntlRecord, + const I18nKey extends string = Id + >( + id: Id | { id: Id }, + options?: FnOptions + ): Commander.Gen & Commander.NonGen & { + state: Context.Tag<`Commander.Command.${Id}.state`, State> + } => + Object.assign( + ( + fn: any, + ...combinators: any[] + ): any => { + // we capture the definition stack here, so we can append it to later stack traces + const limit = Error.stackTraceLimit + Error.stackTraceLimit = 2 + const errorDef = new Error() + Error.stackTraceLimit = limit + + return this.makeCommand(id, options, errorDef)( + Effect.fnUntraced( + // fnUntraced only supports generators as first arg, so we convert to generator if needed + isGeneratorFunction(fn) ? fn : function*(...args) { + return yield* fn(...args) + }, + ...combinators as [any] + ) as any + ) + }, + makeBaseInfo(typeof id === "string" ? id : id.id, options), + { + state: Context.GenericTag<`Commander.Command.${Id}.state`, State>( + `Commander.Command.${typeof id === "string" ? id : id.id}.state` + ) + } + ) + + /** @experimental */ + alt2: < + const Id extends string, + MutArgs extends Array, + MutA, + MutE, + MutR, + const I18nKey extends string = Id, + State extends IntlRecord | undefined = undefined + >( + id: + | Id + | { id: Id; mutate: (...args: MutArgs) => Effect.Effect } + | ((...args: MutArgs) => Effect.Effect) & { id: Id }, + options?: FnOptions + ) => + & Commander.CommandContextLocal + & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( + handler: ( + ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal & { + // todo: only if we passed in one + mutate: (...args: MutArgs) => Effect.Effect + } + ) => (...args: Args) => Effect.Effect + ) => Commander.CommandOut) = ( + _id, + options? + ) => { + const isObject = typeof _id === "object" || typeof _id === "function" + const id = isObject ? _id.id : _id + const baseInfo = makeBaseInfo(id, options) + const idCmd = this.makeCommand(id, options) + // TODO: implement proper tracing stack + return Object.assign((cb: any) => + idCmd(cb( + Object.assign( + (fn: any, ...combinators: any[]) => + Effect.fnUntraced( + // fnUntraced only supports generators as first arg, so we convert to generator if needed + isGeneratorFunction(fn) ? fn : function*(...args) { + return yield* fn(...args) + }, + ...combinators as [any] + ), + baseInfo, + isObject + ? { mutate: "mutate" in _id ? _id.mutate : typeof _id === "function" ? _id : undefined } + : {} + ) + )), baseInfo) as any + } + + /** @experimental */ + alt = this.makeCommand as unknown as < + const Id extends string, + const I18nKey extends string = Id, + State extends IntlRecord | undefined = undefined + >( + id: Id, + customI18nKey?: I18nKey + ) => + & Commander.CommandContextLocal + & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( + handler: (...args: Args) => Effect.Effect + ) => Commander.CommandOut) + + /** + * Define a Command for handling user actions with built-in error reporting and state management. + * + * @param mutation The mutation function to take the identifier and initial handler from. Used as a tracing span and to lookup + * the user-facing name via internationalization (`action.${id}`). + * @param options Optional configuration for internationalization and state. + * @param options.i18nCustomKey Custom i18n key to use instead of `id` (e.g., for grouping similar actions) + * @param options.state Optional reactive state object (or function returning one) that is + * made available to the command effects and can be used for i18n interpolation. + * The state is captured at the start of each command execution and remains stable throughout. + * @returns A function that executes the command when called (e.g., directly in `@click` handlers). + * Built-in error reporting handles failures automatically. + * + * **Effect Context**: Effects have access to the `CommandContext` service, which provides + * the user-facing action name. + * + * **Returned Properties**: + * - `action`: User-facing action name from intl messages (useful for button labels) + * - `result`: The command result state + * - `waiting`: Boolean indicating if the command is in progress (shorthand for `result.waiting`) + * - `handle`: Function to execute the command + * - `exec`: The raw Effect that will be executed when calling `handle` (for advanced use cases) + * - `i18nKey`, `namespace`, `namespaced`: Helpers for internationalization keys + * + * **User Feedback**: Use the `withDefaultToast` helper for status notifications, or render + * the `result` inline for custom UI feedback. + */ + wrap = < + const Id extends string, + Args extends Array, + A, + E, + R, + const State extends IntlRecord = IntlRecord, + I18nKey extends string = Id + >( + mutation: + | { mutate: (...args: Args) => Effect.Effect; id: Id } + | ((...args: Args) => Effect.Effect) & { id: Id }, + options?: FnOptions + ): Commander.CommanderWrap => + Object.assign( + ( + ...combinators: any[] + ): any => { + // we capture the definition stack here, so we can append it to later stack traces + const limit = Error.stackTraceLimit + Error.stackTraceLimit = 2 + const errorDef = new Error() + Error.stackTraceLimit = limit + + const mutate = "mutate" in mutation ? mutation.mutate : mutation + + return this.makeCommand(mutation.id, options, errorDef)( + Effect.fnUntraced( + // fnUntraced only supports generators as first arg, so we convert to generator if needed + isGeneratorFunction(mutate) ? mutate : function*(...args: Args) { + return yield* mutate(...args) + }, + ...combinators as [any] + ) as any + ) + }, + makeBaseInfo(mutation.id, options), + { + state: Context.GenericTag<`Commander.Command.${Id}.state`, State>( + `Commander.Command.${mutation.id}.state` + ) + } + ) +} + +// @effect-diagnostics-next-line missingEffectServiceDependency:off +export class Commander extends Effect.Service()("Commander", { + dependencies: [WithToast.Default, Confirm.Default], + effect: Effect.gen(function*() { + const i18n = yield* I18n + return (rt: Runtime.Runtime) => new CommanderImpl(rt, i18n) + }) +}) {} From 016876b93ffc60767dd3e4c59ae225d995db5775 Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Tue, 14 Oct 2025 09:25:42 +0200 Subject: [PATCH 2/6] prep --- packages/vue/src/experimental/commander2.ts | 617 ++++++++++---------- 1 file changed, 324 insertions(+), 293 deletions(-) diff --git a/packages/vue/src/experimental/commander2.ts b/packages/vue/src/experimental/commander2.ts index 21e6464673..c85b741fb4 100644 --- a/packages/vue/src/experimental/commander2.ts +++ b/packages/vue/src/experimental/commander2.ts @@ -34,13 +34,11 @@ type FnOptionsInternal = { state?: IntlRecord | undefined } -export type EmitWithCallback = (event: Event, value: A, onDone: () => void) => void - -export declare namespace Commander { +export declare namespace Commander2 { export type CommanderBase = - & Commander.Gen - & Commander.NonGen - & Commander.CommandContextLocal + & Gen + & NonGen + & CommandContextLocal & { state: Context.Tag<`Commander.Command.${Id}.state`, State> } @@ -92,7 +90,7 @@ export declare namespace Commander { } export interface CommandOut< - Args extends Array, + Arg, A, E, R, @@ -103,35 +101,41 @@ export declare namespace Commander { new(): {} /** click handlers */ - handle: ((...args: Args) => RuntimeFiber, never>) & { + handle: ((arg: Arg) => RuntimeFiber, never>) & { /** @deprecated don't exist */ - effect: (...args: Args) => Effect.Effect + effect: (arg: Arg) => Effect.Effect } // // TODO: if we keep them, it would probably be nicer as an option api, deciding the return value like in Atom? // /** @experimental */ - // compose: (...args: Args) => Effect.Effect, R> + // compose: (arg: Arg) => Effect.Effect, R> // /** @experimental */ - // compose2: (...args: Args) => Effect.Effect + // compose2: (arg: Arg) => Effect.Effect // /** // * @experimental // * captures the current span and returns an Effect that when run will execute the command // */ - // handleEffect: (...args: Args) => Effect.Effect, never>> + // handleEffect: (arg: Arg) => Effect.Effect, never>> // /** // * @experimental // */ - // exec: (...args: Args) => Effect.Effect, never, Exclude> + // exec: (arg: Arg) => Effect.Effect, never, Exclude> + } + + export interface CommandContextLocal2 + extends CommandContextLocal + { + state: State } type CommandOutHelper< - Args extends Array, + Arg, Eff extends Effect.Effect, Id extends string, I18nKey extends string, State extends IntlRecord | undefined > = CommandOut< - Args, + Arg, Effect.Effect.Success, Effect.Effect.Error, Effect.Effect.Context, @@ -144,11 +148,11 @@ export declare namespace Commander { < Eff extends YieldWrap>, AEff, - Args extends Array + Arg >( - body: (...args: Args) => Generator + body: (arg: Arg) => Generator ): CommandOut< - Args, + Arg, AEff, [Eff] extends [never] ? never : [Eff] extends [YieldWrap>] ? E @@ -163,10 +167,10 @@ export declare namespace Commander { < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -177,17 +181,18 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A - ): CommandOutHelper + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -198,19 +203,20 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B, C extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -221,21 +227,22 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B, C, D extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -246,23 +253,24 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B, C, D, E extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -273,17 +281,18 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B, C, @@ -291,7 +300,7 @@ export declare namespace Commander { E, F extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -302,18 +311,19 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B, C, @@ -322,7 +332,7 @@ export declare namespace Commander { F, G extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -333,19 +343,20 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B, C, @@ -355,7 +366,7 @@ export declare namespace Commander { G, H extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -366,20 +377,21 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, + Arg, A, B, C, @@ -390,7 +402,7 @@ export declare namespace Commander { H, I extends Effect.Effect >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -401,70 +413,71 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H, - i: (_: H, ...args: NoInfer) => I - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I + ): CommandOutHelper } export type NonGen = { < Eff extends Effect.Effect, - Args extends Array + Arg >( - body: (...args: Args) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, B, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, B, C, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, B, C, D, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -472,15 +485,15 @@ export declare namespace Commander { C, D, E, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -489,16 +502,16 @@ export declare namespace Commander { D, E, F, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -508,17 +521,17 @@ export declare namespace Commander { E, F, G, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -529,18 +542,18 @@ export declare namespace Commander { F, G, H, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -552,33 +565,33 @@ export declare namespace Commander { G, H, I, - Args extends Array + Arg >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => I, - i: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper } export type GenWrap< RT, Id extends string, I18nKey extends string, - Args extends Array, + Arg, AEff, EEff, REff, State extends IntlRecord | undefined > = { (): Exclude extends never ? CommandOut< - Args, + Arg, AEff, EEff, REff, @@ -596,9 +609,10 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A - ): CommandOutHelper + ): CommandOutHelper < A, B extends Effect.Effect @@ -609,10 +623,11 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B + ): CommandOutHelper < A, B, @@ -624,11 +639,12 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C + ): CommandOutHelper < A, B, @@ -641,12 +657,13 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D + ): CommandOutHelper < A, B, @@ -660,13 +677,14 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E + ): CommandOutHelper < A, B, @@ -681,14 +699,15 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F + ): CommandOutHelper < A, B, @@ -704,15 +723,16 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G + ): CommandOutHelper >( a: ( _: Effect.Effect< @@ -720,16 +740,17 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H + ): CommandOutHelper >( a: ( _: Effect.Effect< @@ -737,34 +758,35 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H, - i: (_: H, ...args: NoInfer) => I - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I + ): CommandOutHelper } export type NonGenWrap< RT, Id extends string, I18nKey extends string, - Args extends Array, + Arg, AEff, EEff, REff, State extends IntlRecord | undefined > = { - (): Exclude extends never ? CommandOutHelper, Id, I18nKey, State> + (): Exclude extends never ? CommandOutHelper, Id, I18nKey, State> : MissingDependencies & {} < Eff extends Effect.Effect, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -772,13 +794,14 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => Eff - ): CommandOutHelper + ): CommandOutHelper < Eff extends Effect.Effect, B, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -786,15 +809,16 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, C, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -802,17 +826,18 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, C, D, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -820,19 +845,20 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, C, D, E, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -840,13 +866,14 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -854,7 +881,7 @@ export declare namespace Commander { D, E, F, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -862,14 +889,15 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -878,7 +906,7 @@ export declare namespace Commander { E, F, G, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -886,15 +914,16 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -904,7 +933,7 @@ export declare namespace Commander { F, G, H, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -912,16 +941,17 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -932,7 +962,7 @@ export declare namespace Commander { G, H, I, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -940,17 +970,18 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => I, - i: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper } } @@ -1508,7 +1539,7 @@ export class CommanderImpl { >( id: Id | { id: Id }, options?: FnOptions - ): Commander.Gen & Commander.NonGen & { + ): Commander2.Gen & Commander2.NonGen & { state: Context.Tag<`Commander.Command.${Id}.state`, State> } => Object.assign( @@ -1556,15 +1587,15 @@ export class CommanderImpl { | ((...args: MutArgs) => Effect.Effect) & { id: Id }, options?: FnOptions ) => - & Commander.CommandContextLocal + & Commander2.CommandContextLocal & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( handler: ( - ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal & { + ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander2.CommandContextLocal & { // todo: only if we passed in one mutate: (...args: MutArgs) => Effect.Effect } ) => (...args: Args) => Effect.Effect - ) => Commander.CommandOut) = ( + ) => Commander2.CommandOut) = ( _id, options? ) => { @@ -1601,10 +1632,10 @@ export class CommanderImpl { id: Id, customI18nKey?: I18nKey ) => - & Commander.CommandContextLocal + & Commander2.CommandContextLocal & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( handler: (...args: Args) => Effect.Effect - ) => Commander.CommandOut) + ) => Commander2.CommandOut) /** * Define a Command for handling user actions with built-in error reporting and state management. @@ -1646,7 +1677,7 @@ export class CommanderImpl { | { mutate: (...args: Args) => Effect.Effect; id: Id } | ((...args: Args) => Effect.Effect) & { id: Id }, options?: FnOptions - ): Commander.CommanderWrap => + ): Commander2.CommanderWrap => Object.assign( ( ...combinators: any[] From 18223c3277d28a8b167176246459aa9693ed768b Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Tue, 14 Oct 2025 09:36:24 +0200 Subject: [PATCH 3/6] progress --- packages/vue/src/experimental/commander2.ts | 46 ++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/vue/src/experimental/commander2.ts b/packages/vue/src/experimental/commander2.ts index c85b741fb4..b3bd7cb844 100644 --- a/packages/vue/src/experimental/commander2.ts +++ b/packages/vue/src/experimental/commander2.ts @@ -51,7 +51,7 @@ export declare namespace Commander2 { Id extends string, I18nCustomKey extends string, State extends IntlRecord | undefined, - I extends any[], + I, A, E, R @@ -1284,8 +1284,8 @@ export class CommanderImpl { const state = getStateValues(options) return Object.assign( - , A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( - handler: (...args: Args) => Effect.Effect + ( + handler: (arg: Arg, ctx: Commander2.CommandContextLocal2) => Effect.Effect ) => { // we capture the definition stack here, so we can append it to later stack traces const limit = Error.stackTraceLimit @@ -1363,7 +1363,7 @@ export class CommanderImpl { const exec = options?.disableSharedWaiting ? exec_ : Effect - .fnUntraced(function*(...args: Args) { + .fnUntraced(function*(...args: [any, any]) { registerWait(id) return yield* exec_(...args) }, Effect.onExit(() => Effect.sync(() => unregisterWait(id)))) @@ -1372,7 +1372,7 @@ export class CommanderImpl { ? computed(() => result.value.waiting) : computed(() => result.value.waiting || (waitState.value[id] ?? 0) > 0) - const handle = Object.assign((...args: Args) => { + const handle = Object.assign((arg: Arg) => { // we capture the call site stack here const limit = Error.stackTraceLimit Error.stackTraceLimit = 2 @@ -1405,12 +1405,12 @@ export class CommanderImpl { const command = currentState.pipe(Effect.flatMap((state) => Effect.withSpan( - exec(...args), + exec(arg, { ...context.value, state } as any), id, { captureStackTrace, attributes: { - input: args, + input: arg, state, action: initialContext.action, label: initialContext.label, @@ -1574,7 +1574,7 @@ export class CommanderImpl { /** @experimental */ alt2: < const Id extends string, - MutArgs extends Array, + MutArg, MutA, MutE, MutR, @@ -1583,19 +1583,19 @@ export class CommanderImpl { >( id: | Id - | { id: Id; mutate: (...args: MutArgs) => Effect.Effect } - | ((...args: MutArgs) => Effect.Effect) & { id: Id }, + | { id: Id; mutate: (arg: MutArg) => Effect.Effect } + | ((arg: MutArg) => Effect.Effect) & { id: Id }, options?: FnOptions ) => & Commander2.CommandContextLocal - & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( + & (( handler: ( ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander2.CommandContextLocal & { // todo: only if we passed in one - mutate: (...args: MutArgs) => Effect.Effect + mutate: (arg: Arg) => Effect.Effect } - ) => (...args: Args) => Effect.Effect - ) => Commander2.CommandOut) = ( + ) => (arg: Arg, ctx: Commander2.CommandContextLocal2) => Effect.Effect + ) => Commander2.CommandOut) = ( _id, options? ) => { @@ -1633,9 +1633,9 @@ export class CommanderImpl { customI18nKey?: I18nKey ) => & Commander2.CommandContextLocal - & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( - handler: (...args: Args) => Effect.Effect - ) => Commander2.CommandOut) + & (( + handler: (arg: Arg, ctx: Commander2.CommandContextLocal2) => Effect.Effect + ) => Commander2.CommandOut) /** * Define a Command for handling user actions with built-in error reporting and state management. @@ -1666,7 +1666,7 @@ export class CommanderImpl { */ wrap = < const Id extends string, - Args extends Array, + Arg, A, E, R, @@ -1674,10 +1674,10 @@ export class CommanderImpl { I18nKey extends string = Id >( mutation: - | { mutate: (...args: Args) => Effect.Effect; id: Id } - | ((...args: Args) => Effect.Effect) & { id: Id }, + | { mutate: (arg: Arg) => Effect.Effect; id: Id } + | ((arg: Arg) => Effect.Effect) & { id: Id }, options?: FnOptions - ): Commander2.CommanderWrap => + ): Commander2.CommanderWrap => Object.assign( ( ...combinators: any[] @@ -1693,8 +1693,8 @@ export class CommanderImpl { return this.makeCommand(mutation.id, options, errorDef)( Effect.fnUntraced( // fnUntraced only supports generators as first arg, so we convert to generator if needed - isGeneratorFunction(mutate) ? mutate : function*(...args: Args) { - return yield* mutate(...args) + isGeneratorFunction(mutate) ? mutate : function*(arg: Arg) { + return yield* mutate(arg) }, ...combinators as [any] ) as any From 46e3280c8f77f2c9599d08d02a479b3badc030e3 Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Tue, 14 Oct 2025 09:56:49 +0200 Subject: [PATCH 4/6] update test setup --- package.json | 1 + pnpm-lock.yaml | 3 +++ vite.config.base.ts | 4 +++- vitest.setup.ts | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 vitest.setup.ts diff --git a/package.json b/package.json index 48a94db980..8233016f46 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "@effect/language-service": "0.41.1", "@effect/platform": "^0.92.0", "@effect/platform-node": "^0.98.0", + "@effect/vitest": "^0.26.0", "@tsconfig/strictest": "^2.0.6", "@types/lodash": "^4.17.20", "@types/node": "~24.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0a9d9ac49..c82f17bf9e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,6 +67,9 @@ importers: '@effect/platform-node': specifier: ^0.98.0 version: 0.98.0(@effect/cluster@0.46.4(75de7a998cf2258bdcd42684c0598ed2))(@effect/platform@0.92.0(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)))(@effect/rpc@0.71.0(@effect/platform@0.92.0(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)))(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)))(@effect/sql@0.46.0(@effect/experimental@0.56.0(@effect/platform@0.92.0(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)))(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)))(@effect/platform@0.92.0(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)))(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)))(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a)) + '@effect/vitest': + specifier: ^0.26.0 + version: 0.26.0(effect@3.18.0(patch_hash=43c3b64130695b34e77e33c4bce41699657064974a32b770f14bbeefe69bf30a))(vitest@3.2.4(@types/node@24.6.0)(jsdom@27.0.0(postcss@8.5.6))(sass@1.93.2)(terser@5.44.0)(tsx@4.20.6)(yaml@2.8.1)) '@tsconfig/strictest': specifier: ^2.0.6 version: 2.0.6 diff --git a/vite.config.base.ts b/vite.config.base.ts index 223b137861..7586a0d532 100644 --- a/vite.config.base.ts +++ b/vite.config.base.ts @@ -12,6 +12,7 @@ import fs from "fs" // ] // }) + export default function makeConfig(dirName?: string) { const prefix = path.resolve(__dirname, "packages") const packages = fs.readdirSync(prefix).map(f => prefix + "/" + f).filter(f => fs.lstatSync(f).isDirectory() ) @@ -21,7 +22,8 @@ export default function makeConfig(dirName?: string) { test: { include: ["./test/**/*.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], reporters: "verbose", - globals: true + globals: true, + setupFiles: [path.join(__dirname, "vitest.setup.ts")], }, resolve: { alias: packages.map(pkg => ({ pkg, json: pkg + "/package.json"})).filter(_ => fs.existsSync(_.json)).reduce((acc, { pkg, json}) => { diff --git a/vitest.setup.ts b/vitest.setup.ts new file mode 100644 index 0000000000..7c3c6dccbc --- /dev/null +++ b/vitest.setup.ts @@ -0,0 +1,3 @@ +import { addEqualityTesters } from "@effect/vitest" + +addEqualityTesters() \ No newline at end of file From 21f74682689abf70f3562896e984d03e046d832f Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Tue, 14 Oct 2025 10:03:05 +0200 Subject: [PATCH 5/6] commander2 --- .changeset/huge-bobcats-greet.md | 5 ++ packages/vue/package.json | 4 ++ packages/vue/src/experimental/commander2.ts | 66 +++++++++---------- .../vue/src/experimental/makeUseCommand.ts | 4 +- packages/vue/src/makeClient.ts | 3 +- packages/vue/test/Mutation.test.ts | 39 ++++++----- packages/vue/test/stubs.ts | 6 +- 7 files changed, 73 insertions(+), 54 deletions(-) create mode 100644 .changeset/huge-bobcats-greet.md diff --git a/.changeset/huge-bobcats-greet.md b/.changeset/huge-bobcats-greet.md new file mode 100644 index 0000000000..a19d21933c --- /dev/null +++ b/.changeset/huge-bobcats-greet.md @@ -0,0 +1,5 @@ +--- +"@effect-app/vue": minor +--- + +introduce Commander2, which is unary and passes context as second arg. diff --git a/packages/vue/package.json b/packages/vue/package.json index f02e1beab3..2684f85f20 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -54,6 +54,10 @@ "types": "./dist/experimental/commander.d.ts", "default": "./dist/experimental/commander.js" }, + "./experimental/commander2": { + "types": "./dist/experimental/commander2.d.ts", + "default": "./dist/experimental/commander2.js" + }, "./experimental/confirm": { "types": "./dist/experimental/confirm.d.ts", "default": "./dist/experimental/confirm.js" diff --git a/packages/vue/src/experimental/commander2.ts b/packages/vue/src/experimental/commander2.ts index b3bd7cb844..ef57b98a2a 100644 --- a/packages/vue/src/experimental/commander2.ts +++ b/packages/vue/src/experimental/commander2.ts @@ -148,7 +148,7 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg + Arg = void >( body: (arg: Arg) => Generator ): CommandOut< @@ -167,8 +167,8 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, - A extends Effect.Effect + A extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -188,9 +188,9 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, - B extends Effect.Effect + B extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -211,10 +211,10 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, B, - C extends Effect.Effect + C extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -236,11 +236,11 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, B, C, - D extends Effect.Effect + D extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -263,12 +263,12 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, B, C, D, - E extends Effect.Effect + E extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -292,13 +292,13 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, B, C, D, E, - F extends Effect.Effect + F extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -323,14 +323,14 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, B, C, D, E, F, - G extends Effect.Effect + G extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -356,7 +356,6 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, B, C, @@ -364,7 +363,8 @@ export declare namespace Commander2 { E, F, G, - H extends Effect.Effect + H extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -391,7 +391,6 @@ export declare namespace Commander2 { < Eff extends YieldWrap>, AEff, - Arg, A, B, C, @@ -400,7 +399,8 @@ export declare namespace Commander2 { F, G, H, - I extends Effect.Effect + I extends Effect.Effect, + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( @@ -430,14 +430,14 @@ export declare namespace Commander2 { export type NonGen = { < Eff extends Effect.Effect, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => Eff ): CommandOutHelper < Eff extends Effect.Effect, A, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff @@ -446,7 +446,7 @@ export declare namespace Commander2 { Eff extends Effect.Effect, A, B, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -457,7 +457,7 @@ export declare namespace Commander2 { A, B, C, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -470,7 +470,7 @@ export declare namespace Commander2 { B, C, D, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -485,7 +485,7 @@ export declare namespace Commander2 { C, D, E, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -502,7 +502,7 @@ export declare namespace Commander2 { D, E, F, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -521,7 +521,7 @@ export declare namespace Commander2 { E, F, G, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -542,7 +542,7 @@ export declare namespace Commander2 { F, G, H, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -565,7 +565,7 @@ export declare namespace Commander2 { G, H, I, - Arg + Arg = void >( body: (arg: Arg, ctx: CommandContextLocal2) => A, a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, @@ -1571,7 +1571,7 @@ export class CommanderImpl { } ) - /** @experimental */ + /** @experimental @deprecated */ alt2: < const Id extends string, MutArg, @@ -1588,7 +1588,7 @@ export class CommanderImpl { options?: FnOptions ) => & Commander2.CommandContextLocal - & (( + & (( handler: ( ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander2.CommandContextLocal & { // todo: only if we passed in one @@ -1633,7 +1633,7 @@ export class CommanderImpl { customI18nKey?: I18nKey ) => & Commander2.CommandContextLocal - & (( + & (( handler: (arg: Arg, ctx: Commander2.CommandContextLocal2) => Effect.Effect ) => Commander2.CommandOut) @@ -1710,7 +1710,7 @@ export class CommanderImpl { } // @effect-diagnostics-next-line missingEffectServiceDependency:off -export class Commander extends Effect.Service()("Commander", { +export class Commander2 extends Effect.Service()("Commander2", { dependencies: [WithToast.Default, Confirm.Default], effect: Effect.gen(function*() { const i18n = yield* I18n diff --git a/packages/vue/src/experimental/makeUseCommand.ts b/packages/vue/src/experimental/makeUseCommand.ts index afbb2cd026..7a955ee092 100644 --- a/packages/vue/src/experimental/makeUseCommand.ts +++ b/packages/vue/src/experimental/makeUseCommand.ts @@ -1,5 +1,5 @@ import { Effect } from "effect-app" -import { Commander, type CommanderImpl, CommanderStatic } from "./commander.js" +import { Commander2, type CommanderImpl, CommanderStatic } from "./commander2.js" type X = X @@ -10,7 +10,7 @@ export interface CommanderResolved } export const makeUseCommand = Effect.fnUntraced(function*() { - const cmndr = yield* Commander + const cmndr = yield* Commander2 const runtime = yield* Effect.runtime() const comm = cmndr(runtime) diff --git a/packages/vue/src/makeClient.ts b/packages/vue/src/makeClient.ts index 0a74e374cd..3b6efadfb2 100644 --- a/packages/vue/src/makeClient.ts +++ b/packages/vue/src/makeClient.ts @@ -14,6 +14,7 @@ import { type RuntimeFiber } from "effect/Fiber" import { computed, type ComputedRef, onBeforeUnmount, type Ref, ref, watch, type WatchSource } from "vue" import { reportMessage } from "./errorReporter.js" import { type Commander, CommanderStatic } from "./experimental/commander.js" +import { type Commander2 } from "./experimental/commander2.js" import { I18n } from "./experimental/intl.js" import { type CommanderResolved, makeUseCommand } from "./experimental/makeUseCommand.js" import { Toast } from "./experimental/toast.js" @@ -1247,7 +1248,7 @@ export class QueryImpl { const managedRuntimeRt = (mrt: ManagedRuntime.ManagedRuntime) => mrt.runSync(Effect.runtime()) type Base = I18n | Toast -type Mix = ApiClientFactory | Commander | LegacyMutation | Base +type Mix = ApiClientFactory | Commander2 | LegacyMutation | Base export const makeClient = ( // global, but only accessible after startup has completed getBaseMrt: () => ManagedRuntime.ManagedRuntime, diff --git a/packages/vue/test/Mutation.test.ts b/packages/vue/test/Mutation.test.ts index 153ddcd937..bf352e35ec 100644 --- a/packages/vue/test/Mutation.test.ts +++ b/packages/vue/test/Mutation.test.ts @@ -24,10 +24,10 @@ describe("alt2", () => { const someMutation = { id: "Test Action", - mutate: (() => {}) as unknown as (a: number, b: string) => Effect.Effect + mutate: (() => {}) as unknown as (a: number) => Effect.Effect } as const const someMutation2 = Object.assign( - (() => {}) as unknown as (a: number, b: string) => Effect.Effect, + (() => {}) as unknown as (a: number) => Effect.Effect, { id: "Test Action" } as const @@ -252,16 +252,19 @@ it.live("can receive and use input", () => let executed = false const command = Command.fn("Test Action")( - function*(input1: number, input2: string) { + function*(input1: number, input2) { expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action") return { input1, input2 } }, Effect.tap(() => executed = true) ) - const r = yield* unwrap(command.handle(1, "2")) + const r = yield* unwrap(command.handle(1)) - expect(r).toEqual({ input1: 1, input2: "2" }) // to confirm that the initial function has ran and received input. + expect(r.input1).toBe(1) // to confirm that the initial function has ran and received input. + const { handle, result, waiting, ...rest } = command + const ctx = { ...rest, state: undefined } + expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx)) expect(executed).toBe(true) // to confirm that the combinators have ran. })) @@ -547,19 +550,25 @@ it.live("can receive and use input with alt", () => let executed = false - const command = Command.alt("Test Action")( - Effect.fnUntraced( - function*(input1: number, input2: string) { - expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action") + const command = Command.alt("Test Action")((input1: number, input2) => + Effect + .gen( + function*() { + expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action") - return { input1, input2 } - }, - Effect.tap(() => executed = true) - ) + return { input1, input2 } + } + ) + .pipe( + Effect.tap(() => executed = true) + ) ) - const r = yield* unwrap(command.handle(1, "2")) + const r = yield* unwrap(command.handle(1)) - expect(r).toEqual({ input1: 1, input2: "2" }) // to confirm that the initial function has ran and received input. + const { handle, result, waiting, ...rest } = command + const ctx = { ...rest, state: undefined } + expect(r.input1).toBe(1) + expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx)) // to confirm that the initial function has ran and received input. expect(executed).toBe(true) // to confirm that the combinators have ran. })) diff --git a/packages/vue/test/stubs.ts b/packages/vue/test/stubs.ts index 988dde8712..b354c4ab0a 100644 --- a/packages/vue/test/stubs.ts +++ b/packages/vue/test/stubs.ts @@ -6,7 +6,7 @@ import { Effect, Layer, ManagedRuntime, Option, S } from "effect-app" import { ApiClientFactory, makeRpcClient } from "effect-app/client" import { RpcContextMap } from "effect-app/rpc" import { ref } from "vue" -import { Commander } from "../src/experimental/commander.js" +import { Commander2 } from "../src/experimental/commander2.js" import { I18n } from "../src/experimental/intl.js" import { makeUseCommand } from "../src/experimental/makeUseCommand.js" import * as Toast from "../src/experimental/toast.js" @@ -83,7 +83,7 @@ export const useExperimental = ( ) => { const FakeIntlLayer = fakeIntlLayer(options?.messages) const FakeToastLayer = fakeToastLayer(options?.toasts) - const CommanderLayer = Commander.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) + const CommanderLayer = Commander2.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) const WithToastLayer = WithToast.Default.pipe(Layer.provide(FakeToastLayer)) const layers = Layer.mergeAll(CommanderLayer, WithToastLayer, FakeToastLayer, FakeIntlLayer) @@ -110,7 +110,7 @@ export const useClient = ( ) => { const FakeIntlLayer = fakeIntlLayer(options?.messages) const FakeToastLayer = fakeToastLayer(options?.toasts) - const CommanderLayer = Commander.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) + const CommanderLayer = Commander2.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) const WithToastLayer = WithToast.Default.pipe(Layer.provide(FakeToastLayer)) const api = ApiClientFactory.layer({ url: "bogus", headers: Option.none() }).pipe( Layer.provide(FetchHttpClient.layer) From 8fc7fa54bdc6d2a985e0a0f83dde6354f3397f16 Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Tue, 14 Oct 2025 10:06:04 +0200 Subject: [PATCH 6/6] just replace the original Commander. --- .changeset/huge-bobcats-greet.md | 2 +- packages/vue/src/experimental/commander.ts | 665 ++++--- packages/vue/src/experimental/commander2.ts | 1719 ----------------- .../vue/src/experimental/makeUseCommand.ts | 4 +- packages/vue/src/makeClient.ts | 3 +- packages/vue/test/stubs.ts | 6 +- 6 files changed, 356 insertions(+), 2043 deletions(-) delete mode 100644 packages/vue/src/experimental/commander2.ts diff --git a/.changeset/huge-bobcats-greet.md b/.changeset/huge-bobcats-greet.md index a19d21933c..1d06304ea3 100644 --- a/.changeset/huge-bobcats-greet.md +++ b/.changeset/huge-bobcats-greet.md @@ -2,4 +2,4 @@ "@effect-app/vue": minor --- -introduce Commander2, which is unary and passes context as second arg. +Change Commander to be unary and pass Context as second arg. \ No newline at end of file diff --git a/packages/vue/src/experimental/commander.ts b/packages/vue/src/experimental/commander.ts index 10718fa818..382967f33b 100644 --- a/packages/vue/src/experimental/commander.ts +++ b/packages/vue/src/experimental/commander.ts @@ -93,9 +93,9 @@ export const wrapEmit = ( export declare namespace Commander { export type CommanderBase = - & Commander.Gen - & Commander.NonGen - & Commander.CommandContextLocal + & Gen + & NonGen + & CommandContextLocal & { state: Context.Tag<`Commander.Command.${Id}.state`, State> } @@ -108,7 +108,7 @@ export declare namespace Commander { Id extends string, I18nCustomKey extends string, State extends IntlRecord | undefined, - I extends any[], + I, A, E, R @@ -147,7 +147,7 @@ export declare namespace Commander { } export interface CommandOut< - Args extends Array, + Arg, A, E, R, @@ -158,35 +158,41 @@ export declare namespace Commander { new(): {} /** click handlers */ - handle: ((...args: Args) => RuntimeFiber, never>) & { + handle: ((arg: Arg) => RuntimeFiber, never>) & { /** @deprecated don't exist */ - effect: (...args: Args) => Effect.Effect + effect: (arg: Arg) => Effect.Effect } // // TODO: if we keep them, it would probably be nicer as an option api, deciding the return value like in Atom? // /** @experimental */ - // compose: (...args: Args) => Effect.Effect, R> + // compose: (arg: Arg) => Effect.Effect, R> // /** @experimental */ - // compose2: (...args: Args) => Effect.Effect + // compose2: (arg: Arg) => Effect.Effect // /** // * @experimental // * captures the current span and returns an Effect that when run will execute the command // */ - // handleEffect: (...args: Args) => Effect.Effect, never>> + // handleEffect: (arg: Arg) => Effect.Effect, never>> // /** // * @experimental // */ - // exec: (...args: Args) => Effect.Effect, never, Exclude> + // exec: (arg: Arg) => Effect.Effect, never, Exclude> + } + + export interface CommandContextLocal2 + extends CommandContextLocal + { + state: State } type CommandOutHelper< - Args extends Array, + Arg, Eff extends Effect.Effect, Id extends string, I18nKey extends string, State extends IntlRecord | undefined > = CommandOut< - Args, + Arg, Effect.Effect.Success, Effect.Effect.Error, Effect.Effect.Context, @@ -199,11 +205,11 @@ export declare namespace Commander { < Eff extends YieldWrap>, AEff, - Args extends Array + Arg = void >( - body: (...args: Args) => Generator + body: (arg: Arg) => Generator ): CommandOut< - Args, + Arg, AEff, [Eff] extends [never] ? never : [Eff] extends [YieldWrap>] ? E @@ -218,10 +224,10 @@ export declare namespace Commander { < Eff extends YieldWrap>, AEff, - Args extends Array, - A extends Effect.Effect + A extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -232,17 +238,18 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A - ): CommandOutHelper + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, - B extends Effect.Effect + B extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -253,19 +260,20 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, B, - C extends Effect.Effect + C extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -276,21 +284,22 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, B, C, - D extends Effect.Effect + D extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -301,23 +310,24 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, B, C, D, - E extends Effect.Effect + E extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -328,25 +338,26 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, B, C, D, E, - F extends Effect.Effect + F extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -357,27 +368,28 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, B, C, D, E, F, - G extends Effect.Effect + G extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -388,19 +400,19 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, B, C, @@ -408,9 +420,10 @@ export declare namespace Commander { E, F, G, - H extends Effect.Effect + H extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -421,20 +434,20 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H + ): CommandOutHelper < Eff extends YieldWrap>, AEff, - Args extends Array, A, B, C, @@ -443,9 +456,10 @@ export declare namespace Commander { F, G, H, - I extends Effect.Effect + I extends Effect.Effect, + Arg = void >( - body: (...args: Args) => Generator, + body: (arg: Arg, ctx: CommandContextLocal2) => Generator, a: ( _: Effect.Effect< AEff, @@ -456,70 +470,71 @@ export declare namespace Commander { : [Eff] extends [YieldWrap>] ? R : never >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H, - i: (_: H, ...args: NoInfer) => I - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I + ): CommandOutHelper } export type NonGen = { < Eff extends Effect.Effect, - Args extends Array + Arg = void >( - body: (...args: Args) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, B, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, B, C, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, B, C, D, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -527,15 +542,15 @@ export declare namespace Commander { C, D, E, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -544,16 +559,16 @@ export declare namespace Commander { D, E, F, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -563,17 +578,17 @@ export declare namespace Commander { E, F, G, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -584,18 +599,18 @@ export declare namespace Commander { F, G, H, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, A, @@ -607,33 +622,33 @@ export declare namespace Commander { G, H, I, - Args extends Array + Arg = void >( - body: (...args: Args) => A, - a: (_: A, ...args: NoInfer) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => I, - i: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + body: (arg: Arg, ctx: CommandContextLocal2) => A, + a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper } export type GenWrap< RT, Id extends string, I18nKey extends string, - Args extends Array, + Arg, AEff, EEff, REff, State extends IntlRecord | undefined > = { (): Exclude extends never ? CommandOut< - Args, + Arg, AEff, EEff, REff, @@ -651,9 +666,10 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A - ): CommandOutHelper + ): CommandOutHelper < A, B extends Effect.Effect @@ -664,10 +680,11 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B + ): CommandOutHelper < A, B, @@ -679,11 +696,12 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C + ): CommandOutHelper < A, B, @@ -696,12 +714,13 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D + ): CommandOutHelper < A, B, @@ -715,13 +734,14 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E + ): CommandOutHelper < A, B, @@ -736,14 +756,15 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F + ): CommandOutHelper < A, B, @@ -759,15 +780,16 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G + ): CommandOutHelper >( a: ( _: Effect.Effect< @@ -775,16 +797,17 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H + ): CommandOutHelper >( a: ( _: Effect.Effect< @@ -792,34 +815,35 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => A, - b: (_: A, ...args: NoInfer) => B, - c: (_: B, ...args: NoInfer) => C, - d: (_: C, ...args: NoInfer) => D, - e: (_: D, ...args: NoInfer) => E, - f: (_: E, ...args: NoInfer) => F, - g: (_: F, ...args: NoInfer) => G, - h: (_: G, ...args: NoInfer) => H, - i: (_: H, ...args: NoInfer) => I - ): CommandOutHelper + b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, + c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I + ): CommandOutHelper } export type NonGenWrap< RT, Id extends string, I18nKey extends string, - Args extends Array, + Arg, AEff, EEff, REff, State extends IntlRecord | undefined > = { - (): Exclude extends never ? CommandOutHelper, Id, I18nKey, State> + (): Exclude extends never ? CommandOutHelper, Id, I18nKey, State> : MissingDependencies & {} < Eff extends Effect.Effect, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -827,13 +851,14 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => Eff - ): CommandOutHelper + ): CommandOutHelper < Eff extends Effect.Effect, B, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -841,15 +866,16 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, C, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -857,17 +883,18 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, C, D, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -875,19 +902,20 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, C, D, E, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -895,13 +923,14 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -909,7 +938,7 @@ export declare namespace Commander { D, E, F, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -917,14 +946,15 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -933,7 +963,7 @@ export declare namespace Commander { E, F, G, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -941,15 +971,16 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -959,7 +990,7 @@ export declare namespace Commander { F, G, H, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -967,16 +998,17 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper < Eff extends Effect.Effect, B, @@ -987,7 +1019,7 @@ export declare namespace Commander { G, H, I, - Args extends Array + Arg >( a: ( _: Effect.Effect< @@ -995,17 +1027,18 @@ export declare namespace Commander { EEff, REff >, - ...args: NoInfer + arg: NoInfer, + ctx: CommandContextLocal2, NoInfer, NoInfer> ) => B, - b: (_: B, ...args: NoInfer) => C, - c: (_: C, ...args: NoInfer) => D, - d: (_: D, ...args: NoInfer) => E, - e: (_: E, ...args: NoInfer) => F, - f: (_: F, ...args: NoInfer) => G, - g: (_: G, ...args: NoInfer) => H, - h: (_: H, ...args: NoInfer) => I, - i: (_: H, ...args: NoInfer) => Eff - ): CommandOutHelper + b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, + c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, + d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, + e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, + f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, + g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, + h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I, + i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff + ): CommandOutHelper } } @@ -1308,8 +1341,8 @@ export class CommanderImpl { const state = getStateValues(options) return Object.assign( - , A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( - handler: (...args: Args) => Effect.Effect + ( + handler: (arg: Arg, ctx: Commander.CommandContextLocal2) => Effect.Effect ) => { // we capture the definition stack here, so we can append it to later stack traces const limit = Error.stackTraceLimit @@ -1387,7 +1420,7 @@ export class CommanderImpl { const exec = options?.disableSharedWaiting ? exec_ : Effect - .fnUntraced(function*(...args: Args) { + .fnUntraced(function*(...args: [any, any]) { registerWait(id) return yield* exec_(...args) }, Effect.onExit(() => Effect.sync(() => unregisterWait(id)))) @@ -1396,7 +1429,7 @@ export class CommanderImpl { ? computed(() => result.value.waiting) : computed(() => result.value.waiting || (waitState.value[id] ?? 0) > 0) - const handle = Object.assign((...args: Args) => { + const handle = Object.assign((arg: Arg) => { // we capture the call site stack here const limit = Error.stackTraceLimit Error.stackTraceLimit = 2 @@ -1429,12 +1462,12 @@ export class CommanderImpl { const command = currentState.pipe(Effect.flatMap((state) => Effect.withSpan( - exec(...args), + exec(arg, { ...context.value, state } as any), id, { captureStackTrace, attributes: { - input: args, + input: arg, state, action: initialContext.action, label: initialContext.label, @@ -1595,10 +1628,10 @@ export class CommanderImpl { } ) - /** @experimental */ + /** @experimental @deprecated */ alt2: < const Id extends string, - MutArgs extends Array, + MutArg, MutA, MutE, MutR, @@ -1607,19 +1640,19 @@ export class CommanderImpl { >( id: | Id - | { id: Id; mutate: (...args: MutArgs) => Effect.Effect } - | ((...args: MutArgs) => Effect.Effect) & { id: Id }, + | { id: Id; mutate: (arg: MutArg) => Effect.Effect } + | ((arg: MutArg) => Effect.Effect) & { id: Id }, options?: FnOptions ) => & Commander.CommandContextLocal - & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( + & (( handler: ( ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal & { // todo: only if we passed in one - mutate: (...args: MutArgs) => Effect.Effect + mutate: (arg: Arg) => Effect.Effect } - ) => (...args: Args) => Effect.Effect - ) => Commander.CommandOut) = ( + ) => (arg: Arg, ctx: Commander.CommandContextLocal2) => Effect.Effect + ) => Commander.CommandOut) = ( _id, options? ) => { @@ -1657,9 +1690,9 @@ export class CommanderImpl { customI18nKey?: I18nKey ) => & Commander.CommandContextLocal - & (, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>( - handler: (...args: Args) => Effect.Effect - ) => Commander.CommandOut) + & (( + handler: (arg: Arg, ctx: Commander.CommandContextLocal2) => Effect.Effect + ) => Commander.CommandOut) /** * Define a Command for handling user actions with built-in error reporting and state management. @@ -1690,7 +1723,7 @@ export class CommanderImpl { */ wrap = < const Id extends string, - Args extends Array, + Arg, A, E, R, @@ -1698,10 +1731,10 @@ export class CommanderImpl { I18nKey extends string = Id >( mutation: - | { mutate: (...args: Args) => Effect.Effect; id: Id } - | ((...args: Args) => Effect.Effect) & { id: Id }, + | { mutate: (arg: Arg) => Effect.Effect; id: Id } + | ((arg: Arg) => Effect.Effect) & { id: Id }, options?: FnOptions - ): Commander.CommanderWrap => + ): Commander.CommanderWrap => Object.assign( ( ...combinators: any[] @@ -1717,8 +1750,8 @@ export class CommanderImpl { return this.makeCommand(mutation.id, options, errorDef)( Effect.fnUntraced( // fnUntraced only supports generators as first arg, so we convert to generator if needed - isGeneratorFunction(mutate) ? mutate : function*(...args: Args) { - return yield* mutate(...args) + isGeneratorFunction(mutate) ? mutate : function*(arg: Arg) { + return yield* mutate(arg) }, ...combinators as [any] ) as any diff --git a/packages/vue/src/experimental/commander2.ts b/packages/vue/src/experimental/commander2.ts deleted file mode 100644 index ef57b98a2a..0000000000 --- a/packages/vue/src/experimental/commander2.ts +++ /dev/null @@ -1,1719 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { asResult, type MissingDependencies, reportRuntimeError } from "@effect-app/vue" -import { reportMessage } from "@effect-app/vue/errorReporter" -import { type Result } from "@effect-atom/atom/Result" -import { Cause, Context, Effect, type Exit, flow, Match, Option, Runtime, S } from "effect-app" -import { SupportedErrors } from "effect-app/client" -import { OperationFailure, OperationSuccess } from "effect-app/Operations" -import { wrapEffect } from "effect-app/utils" -import { id, type RuntimeFiber } from "effect/Fiber" -import { type NoInfer } from "effect/Types" -import { isGeneratorFunction, type YieldWrap } from "effect/Utils" -import { type FormatXMLElementFn, type PrimitiveType } from "intl-messageformat" -import { computed, type ComputedRef, reactive, ref } from "vue" -import { CommandContext } from "./commander.js" -import { Confirm } from "./confirm.js" -import { I18n } from "./intl.js" -import { WithToast } from "./withToast.js" - -type IntlRecord = Record> -type FnOptions = { - i18nCustomKey?: I18nCustomKey - /** - * passed to the i18n formatMessage calls so you can use it in translation messagee - * including the Command `action` string. - * Automatically wrapped with Computed if just a thunk. - * provided as Command.state tag, so you can access it in the function. - */ - state?: ComputedRef | (() => State) - disableSharedWaiting?: boolean -} - -type FnOptionsInternal = { - i18nCustomKey?: I18nCustomKey | undefined - state?: IntlRecord | undefined -} - -export declare namespace Commander2 { - export type CommanderBase = - & Gen - & NonGen - & CommandContextLocal - & { - state: Context.Tag<`Commander.Command.${Id}.state`, State> - } - - export type CommanderFn = - CommanderBase - - export type CommanderWrap< - RT, - Id extends string, - I18nCustomKey extends string, - State extends IntlRecord | undefined, - I, - A, - E, - R - > = - & CommandContextLocal - & GenWrap - & NonGenWrap - & { - state: Context.Tag<`Commander.Command.${Id}.state`, State> - } - - export interface CommandContextLocal { - id: Id - i18nKey: I18nKey - namespace: `action.${I18nKey}` - namespaced: (k: K) => `action.${I18nKey}.${K}` - } - - export interface CommandProps< - A, - E, - Id extends string, - I18nKey extends string, - State extends IntlRecord | undefined - > extends CommandContextLocal { - /** reactive */ - action: string - /** reactive */ - label: string - /** reactive */ - result: Result - /** reactive */ - waiting: boolean - /** reactive */ - state: ComputedRef - } - - export interface CommandOut< - Arg, - A, - E, - R, - Id extends string, - I18nKey extends string, - State extends IntlRecord | undefined - > extends CommandProps { - new(): {} - - /** click handlers */ - handle: ((arg: Arg) => RuntimeFiber, never>) & { - /** @deprecated don't exist */ - effect: (arg: Arg) => Effect.Effect - } - - // // TODO: if we keep them, it would probably be nicer as an option api, deciding the return value like in Atom? - // /** @experimental */ - // compose: (arg: Arg) => Effect.Effect, R> - // /** @experimental */ - // compose2: (arg: Arg) => Effect.Effect - // /** - // * @experimental - // * captures the current span and returns an Effect that when run will execute the command - // */ - // handleEffect: (arg: Arg) => Effect.Effect, never>> - // /** - // * @experimental - // */ - // exec: (arg: Arg) => Effect.Effect, never, Exclude> - } - - export interface CommandContextLocal2 - extends CommandContextLocal - { - state: State - } - - type CommandOutHelper< - Arg, - Eff extends Effect.Effect, - Id extends string, - I18nKey extends string, - State extends IntlRecord | undefined - > = CommandOut< - Arg, - Effect.Effect.Success, - Effect.Effect.Error, - Effect.Effect.Context, - Id, - I18nKey, - State - > - - export type Gen = { - < - Eff extends YieldWrap>, - AEff, - Arg = void - >( - body: (arg: Arg) => Generator - ): CommandOut< - Arg, - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never, - Id, - I18nKey, - State - > - < - Eff extends YieldWrap>, - AEff, - A extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B, - C extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B, - C, - D extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B, - C, - D, - E extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B, - C, - D, - E, - F extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B, - C, - D, - E, - F, - G extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B, - C, - D, - E, - F, - G, - H extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H - ): CommandOutHelper - < - Eff extends YieldWrap>, - AEff, - A, - B, - C, - D, - E, - F, - G, - H, - I extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Generator, - a: ( - _: Effect.Effect< - AEff, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? E - : never, - [Eff] extends [never] ? never - : [Eff] extends [YieldWrap>] ? R - : never - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, - i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I - ): CommandOutHelper - } - - export type NonGen = { - < - Eff extends Effect.Effect, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - C, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - C, - D, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - C, - D, - E, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - C, - D, - E, - F, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - C, - D, - E, - F, - G, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - C, - D, - E, - F, - G, - H, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, - h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - A, - B, - C, - D, - E, - F, - G, - H, - I, - Arg = void - >( - body: (arg: Arg, ctx: CommandContextLocal2) => A, - a: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, - h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I, - i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - } - - export type GenWrap< - RT, - Id extends string, - I18nKey extends string, - Arg, - AEff, - EEff, - REff, - State extends IntlRecord | undefined - > = { - (): Exclude extends never ? CommandOut< - Arg, - AEff, - EEff, - REff, - Id, - I18nKey, - State - > - : MissingDependencies & {} - < - A extends Effect.Effect - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A - ): CommandOutHelper - < - A, - B extends Effect.Effect - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B - ): CommandOutHelper - < - A, - B, - C extends Effect.Effect - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C - ): CommandOutHelper - < - A, - B, - C, - D extends Effect.Effect - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D - ): CommandOutHelper - < - A, - B, - C, - D, - E extends Effect.Effect - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E - ): CommandOutHelper - < - A, - B, - C, - D, - E, - F extends Effect.Effect - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F - ): CommandOutHelper - < - A, - B, - C, - D, - E, - F, - G extends Effect.Effect - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G - ): CommandOutHelper - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H - ): CommandOutHelper - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => A, - b: (_: A, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => B, - c: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - d: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - e: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - f: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - g: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - h: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, - i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I - ): CommandOutHelper - } - - export type NonGenWrap< - RT, - Id extends string, - I18nKey extends string, - Arg, - AEff, - EEff, - REff, - State extends IntlRecord | undefined - > = { - (): Exclude extends never ? CommandOutHelper, Id, I18nKey, State> - : MissingDependencies & {} - < - Eff extends Effect.Effect, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - C, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - C, - D, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - C, - D, - E, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - C, - D, - E, - F, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - C, - D, - E, - F, - G, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - C, - D, - E, - F, - G, - H, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, - h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - < - Eff extends Effect.Effect, - B, - C, - D, - E, - F, - G, - H, - I, - Arg - >( - a: ( - _: Effect.Effect< - AEff, - EEff, - REff - >, - arg: NoInfer, - ctx: CommandContextLocal2, NoInfer, NoInfer> - ) => B, - b: (_: B, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => C, - c: (_: C, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => D, - d: (_: D, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => E, - e: (_: E, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => F, - f: (_: F, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => G, - g: (_: G, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => H, - h: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => I, - i: (_: H, arg: NoInfer, ctx: CommandContextLocal2, NoInfer, NoInfer>) => Eff - ): CommandOutHelper - } -} - -type ErrorRenderer = (e: E, action: string, ...args: Args) => string | undefined - -const renderErrorMaker = I18n.use( - ({ intl }) => - (action: string, errorRenderer?: ErrorRenderer) => - (e: E, ...args: Args): string => { - if (errorRenderer) { - const m = errorRenderer(e, action, ...args) - if (m !== undefined) { - return m - } - } - if (!S.is(SupportedErrors)(e) && !S.ParseResult.isParseError(e)) { - if (typeof e === "object" && e !== null) { - if ("message" in e) { - return `${e.message}` - } - if ("_tag" in e) { - return `${e._tag}` - } - } - return "" - } - const e2: SupportedErrors | S.ParseResult.ParseError = e - return Match.value(e2).pipe( - Match.tags({ - NotFoundError: (e) => { - return intl.formatMessage({ id: "handle.not_found" }, { type: e.type, id: e.id }) - }, - ParseError: (e) => { - console.warn(e.toString()) - return intl.formatMessage({ id: "validation.failed" }) - } - }), - Match.orElse((e) => `${e.message ?? e._tag ?? e}`) - ) - } -) - -const defaultFailureMessageHandler = , AME, AMR>( - actionMaker: - | string - | ((o: Option.Option, ...args: Args) => string) - | ((o: Option.Option, ...args: Args) => Effect.Effect), - errorRenderer?: ErrorRenderer -) => - Effect.fnUntraced(function*(o: Option.Option, ...args: Args) { - const action = yield* wrapEffect(actionMaker)(o, ...args) - const { intl } = yield* I18n - const renderError = yield* renderErrorMaker - - return Option.match(o, { - onNone: () => - intl.formatMessage( - { id: "handle.unexpected_error2" }, - { - action, - error: "" // TODO consider again Cause.pretty(cause), // will be reported to Sentry/Otel anyway.. and we shouldn't bother users with error dumps? - } - ), - onSome: (e) => - S.is(OperationFailure)(e) - ? { - level: "warn" as const, - message: intl.formatMessage( - { id: "handle.with_warnings" }, - { action } - ) + e.message - ? "\n" + e.message - : "" - } - : `${ - intl.formatMessage( - { id: "handle.with_errors" }, - { action } - ) - }:\n` + renderError(action, errorRenderer)(e, ...args) - }) - }) - -export const CommanderStatic = { - /** Version of @see confirmOrInterrupt that automatically includes the action name in the default messages */ - confirmOrInterrupt: Effect.fnUntraced(function*( - message: string | undefined = undefined - ) { - const context = yield* CommandContext - const { intl } = yield* I18n - - yield* Confirm.confirmOrInterrupt( - message - ?? intl.formatMessage( - { id: "handle.confirmation" }, - { action: context.action } - ) - ) - }), - /** Version of @see confirm that automatically includes the action name in the default messages */ - confirm: Effect.fnUntraced(function*( - message: string | undefined = undefined - ) { - const context = yield* CommandContext - const { intl } = yield* I18n - return yield* Confirm.confirm( - message - ?? intl.formatMessage( - { id: "handle.confirmation" }, - { action: context.action } - ) - ) - }), - updateAction: - >(update: (currentActionId: string, ...args: Args) => string) => - (_: Effect.Effect, ...input: Args) => - Effect.updateService( - _, - CommandContext, - (c) => ({ ...c, action: update(c.action, ...input) }) - ), - defaultFailureMessageHandler, - renderError: renderErrorMaker, - /** - * Version of withDefaultToast that automatically includes the action name in the default messages and uses intl. - * uses the Command id as i18n namespace. `action.{id}` is the main action name, - * and `action.{id}.waiting`, `action.{id}.success`, `action.{id}.failure` can be used to override the default messages for the respective states. - * - * the computed `state` provided to the Command can be used for interpolation in the i18n messages. (the state is captured at the start of each command execution and remains stable throughout) - * - * Note: if you provide `onWaiting` or `onSuccess` as `null`, no toast will be shown for that state. - * If you provide a string or function, it will be used instead of the i18n message. - * If you provide an `errorRenderer`, it will be used to render errors in the failure message. - */ - withDefaultToast: >( - options?: { - /** - * if true, previous toasts with this key will be replaced - */ - stableToastId?: undefined | true | string | ((id: string, ...args: Args) => true | string | undefined) - errorRenderer?: ErrorRenderer - onWaiting?: null | undefined | string | ((id: string, ...args: Args) => string | null | undefined) - onSuccess?: null | undefined | string | ((a: A, action: string, ...args: Args) => string | null | undefined) - } - ) => - ( - self: Effect.Effect, - ...args: Args - ) => - Effect.gen(function*() { - const cc = yield* CommandContext - const { intl } = yield* I18n - const withToast = yield* WithToast - const customWaiting = cc.namespaced("waiting") - const hasCustomWaiting = !!intl.messages[customWaiting] - const customSuccess = cc.namespaced("success") - const hasCustomSuccess = !!intl.messages[customSuccess] - const customFailure = cc.namespaced("failure") - const hasCustomFailure = !!intl.messages[customFailure] - const stableToastId = options?.stableToastId - ? typeof options.stableToastId === "string" - ? options.stableToastId - : typeof options.stableToastId === "boolean" - ? cc.id - : typeof options.stableToastId === "function" - ? (...args: Args) => { - const r = (options.stableToastId as any)(id, ...args) - if (typeof r === "string") return r - if (r === true) return cc.id - return undefined - } - : undefined - : undefined - return yield* self.pipe( - (_) => - withToast({ - onWaiting: options?.onWaiting === null ? null : hasCustomWaiting - ? intl.formatMessage({ - id: customWaiting - }, cc.state) - : intl.formatMessage( - { id: "handle.waiting" }, - { action: cc.action } - ), - onSuccess: options?.onSuccess === null - ? null - : (a, ..._args) => - hasCustomSuccess - ? intl.formatMessage( - { id: customSuccess }, - cc.state - ) - : (intl.formatMessage({ id: "handle.success" }, { action: cc.action }) - + (S.is(OperationSuccess)(a) && a.message ? "\n" + a.message : "")), - onFailure: defaultFailureMessageHandler( - hasCustomFailure ? intl.formatMessage({ id: customFailure }, cc.state) : cc.action, - options?.errorRenderer - ), - stableToastId - })(_, ...args) - ) - }) -} - -const makeBaseInfo = ( - id: Id, - options?: Pick, "i18nCustomKey"> -) => { - if (!id) throw new Error("must specify an id") - const i18nKey: I18nKey = options?.i18nCustomKey ?? id as unknown as I18nKey - - const namespace = `action.${i18nKey}` as const - - const context = { - id, - i18nKey, - namespace, - namespaced: (k: K) => `${namespace}.${k}` as const - } - - return context -} - -const waitState = ref>({}) -const registerWait = (id: string) => { - // console.debug("register wait", id) - waitState.value[id] = waitState.value[id] ? waitState.value[id] + 1 : 1 -} -const unregisterWait = (id: string) => { - // console.debug("unregister wait", id) - if (waitState.value[id]) { - waitState.value[id] = waitState.value[id] - 1 - if (waitState.value[id] <= 0) { - delete waitState.value[id] - } - } -} - -const getStateValues = ( - options?: FnOptions -): ComputedRef => { - const state_ = options?.state - const state = !state_ ? computed(() => undefined as State) : typeof state_ === "function" - ? computed(state_) - : state_ - return state -} - -// class preserves JSDoc throughout.. -export class CommanderImpl { - private runFork: ( - effect: Effect.Effect, - options?: Runtime.RunForkOptions - ) => RuntimeFiber - - constructor(private readonly rt: Runtime.Runtime, private readonly intl: I18n) { - this.runFork = Runtime.runFork(this.rt) - } - - readonly makeContext = ( - id: Id, - options?: FnOptionsInternal - ) => { - if (!id) throw new Error("must specify an id") - const i18nKey: I18nKey = options?.i18nCustomKey ?? id as unknown as I18nKey - - const namespace = `action.${i18nKey}` as const - - // must remain stable through out single call - const action = this.intl.formatMessage({ - id: namespace, - defaultMessage: id - }, { ...options?.state, _isLabel: false }) - - const label = this.intl.formatMessage({ - id: namespace, - defaultMessage: id - }, { ...options?.state, _isLabel: true }) - - const context = CommandContext.of({ - ...makeBaseInfo(id, options), - action, - label, - state: options?.state - }) - - return context - } - - readonly makeCommand = < - const Id extends string, - const State extends IntlRecord | undefined, - const I18nKey extends string = Id - >( - id_: Id | { id: Id }, - options?: FnOptions, - errorDef?: Error - ) => { - const id = typeof id_ === "string" ? id_ : id_.id - const state = getStateValues(options) - - return Object.assign( - ( - handler: (arg: Arg, ctx: Commander2.CommandContextLocal2) => Effect.Effect - ) => { - // we capture the definition stack here, so we can append it to later stack traces - const limit = Error.stackTraceLimit - Error.stackTraceLimit = 2 - const localErrorDef = new Error() - Error.stackTraceLimit = limit - if (!errorDef) { - errorDef = localErrorDef - } - - const key = `Commander.Command.${id}.state` as const - const stateTag = Context.GenericTag(key) - - const makeContext_ = () => this.makeContext(id, { ...options, state: state?.value }) - const initialContext = makeContext_() - const context = computed(() => makeContext_()) - const action = computed(() => context.value.action) - const label = computed(() => context.value.label) - - const errorReporter = (self: Effect.Effect) => - self.pipe( - Effect.tapErrorCause( - Effect.fnUntraced(function*(cause) { - if (Cause.isInterruptedOnly(cause)) { - console.info(`Interrupted while trying to ${id}`) - return - } - - const fail = Cause.failureOption(cause) - if (Option.isSome(fail)) { - // if (fail.value._tag === "SuppressErrors") { - // console.info( - // `Suppressed error trying to ${action}`, - // fail.value, - // ) - // return - // } - const message = `Failure trying to ${id}` - yield* reportMessage(message, { - action: id, - error: fail.value - }) - return - } - - const context = yield* CommandContext - const extra = { - action: context.action, - message: `Unexpected Error trying to ${id}` - } - yield* reportRuntimeError(cause, extra) - }, Effect.uninterruptible) - ) - ) - - const currentState = Effect.sync(() => state.value) - - const theHandler = flow( - handler, - errorReporter, - // all must be within the Effect.fn to fit within the Span - Effect.provideServiceEffect( - stateTag, - currentState - ), - Effect.provideServiceEffect( - CommandContext, - Effect.sync(() => makeContext_()) - ) - ) - - const [result, exec_] = asResult(theHandler) - // probably could be nice to use a namespaced, computable wait key instead not unlike query invalidation? - // ["Something.Update", { id }] for instance - const exec = options?.disableSharedWaiting - ? exec_ - : Effect - .fnUntraced(function*(...args: [any, any]) { - registerWait(id) - return yield* exec_(...args) - }, Effect.onExit(() => Effect.sync(() => unregisterWait(id)))) - - const waiting = options?.disableSharedWaiting - ? computed(() => result.value.waiting) - : computed(() => result.value.waiting || (waitState.value[id] ?? 0) > 0) - - const handle = Object.assign((arg: Arg) => { - // we capture the call site stack here - const limit = Error.stackTraceLimit - Error.stackTraceLimit = 2 - const errorCall = new Error() - Error.stackTraceLimit = limit - - let cache: false | string = false - const captureStackTrace = () => { - // in case of an error, we want to append the definition stack to the call site stack, - // so we can see where the handler was defined too - - if (cache !== false) { - return cache - } - if (errorCall.stack) { - const stackDef = errorDef!.stack!.trim().split("\n") - const stackCall = errorCall.stack.trim().split("\n") - let endStackDef = stackDef.slice(2).join("\n").trim() - if (!endStackDef.includes(`(`)) { - endStackDef = endStackDef.replace(/at (.*)/, "at ($1)") - } - let endStackCall = stackCall.slice(2).join("\n").trim() - if (!endStackCall.includes(`(`)) { - endStackCall = endStackCall.replace(/at (.*)/, "at ($1)") - } - cache = `${endStackDef}\n${endStackCall}` - return cache - } - } - - const command = currentState.pipe(Effect.flatMap((state) => - Effect.withSpan( - exec(arg, { ...context.value, state } as any), - id, - { - captureStackTrace, - attributes: { - input: arg, - state, - action: initialContext.action, - label: initialContext.label, - id: initialContext.id, - i18nKey: initialContext.i18nKey - } - } - ) - )) - - return this.runFork(command) - }, { action, label }) - - return reactive({ - /** static */ - id, - - /** the base i18n key, based on id by default. static */ - i18nKey: initialContext.i18nKey, - /** the `action.` namespace based on i18nKey.. static */ - namespace: initialContext.namespace, - - /** easy generate namespaced 18n keys, based on namespace. static */ - namespaced: initialContext.namespaced, - - /** reactive */ - result, - /** reactive */ - waiting, - /** reactive */ - action, - /** reactive */ - label, - /** reactive */ - state, - - handle - }) - }, - { id } - ) - } - - // /** @experimental */ - // takeOver: - // (command: Commander.CommandOut) => - // (...args: Args) => { - // // we capture the call site stack here - // const limit = Error.stackTraceLimit - // Error.stackTraceLimit = 2 - // const errorCall = new Error() - // const localErrorDef = new Error() - // Error.stackTraceLimit = limit - - // // TODO - // const errorDef = localErrorDef - - // let cache: false | string = false - // const captureStackTrace = () => { - // // in case of an error, we want to append the definition stack to the call site stack, - // // so we can see where the handler was defined too - - // if (cache !== false) { - // return cache - // } - // if (errorCall.stack) { - // const stackDef = errorDef.stack!.trim().split("\n") - // const stackCall = errorCall.stack.trim().split("\n") - // let endStackDef = stackDef.slice(2).join("\n").trim() - // if (!endStackDef.includes(`(`)) { - // endStackDef = endStackDef.replace(/at (.*)/, "at ($1)") - // } - // let endStackCall = stackCall.slice(2).join("\n").trim() - // if (!endStackCall.includes(`(`)) { - // endStackCall = endStackCall.replace(/at (.*)/, "at ($1)") - // } - // cache = `${endStackDef}\n${endStackCall}` - // return cache - // } - // } - - // return Effect.gen(function*() { - // const ctx = yield* CommandContext - // ctx.action = command.action - // return yield* command.exec(...args).pipe( - // Effect.flatten, - // Effect.withSpan( - // command.action, - // { captureStackTrace } - // ) - // ) - // }) - // }, - - /** - * Define a Command for handling user actions with built-in error reporting and state management. - * - * @param id The internal identifier for the action. Used as a tracing span and to lookup - * the user-facing name via internationalization (`action.${id}`). - * @param options Optional configuration for internationalization and state. - * @param options.i18nCustomKey Custom i18n key to use instead of `id` (e.g., for grouping similar actions) - * @param options.state Optional reactive state object (or function returning one) that is - * made available to the command effects and can be used for i18n interpolation. - * The state is captured at the start of each command execution and remains stable throughout. - * @returns A function that executes the command when called (e.g., directly in `@click` handlers). - * Built-in error reporting handles failures automatically. - * - * **Effect Context**: Effects have access to the `CommandContext` service, which provides - * the user-facing action name. - * - * **Returned Properties**: - * - `action`: User-facing action name from intl messages (useful for button labels) - * - `result`: The command result state - * - `waiting`: Boolean indicating if the command is in progress (shorthand for `result.waiting`) - * - `handle`: Function to execute the command - * - `exec`: The raw Effect that will be executed when calling `handle` (for advanced use cases) - * - `i18nKey`, `namespace`, `namespaced`: Helpers for internationalization keys - * - * **User Feedback**: Use the `withDefaultToast` helper for status notifications, or render - * the `result` inline for custom UI feedback. - */ - fn = < - const Id extends string, - const State extends IntlRecord = IntlRecord, - const I18nKey extends string = Id - >( - id: Id | { id: Id }, - options?: FnOptions - ): Commander2.Gen & Commander2.NonGen & { - state: Context.Tag<`Commander.Command.${Id}.state`, State> - } => - Object.assign( - ( - fn: any, - ...combinators: any[] - ): any => { - // we capture the definition stack here, so we can append it to later stack traces - const limit = Error.stackTraceLimit - Error.stackTraceLimit = 2 - const errorDef = new Error() - Error.stackTraceLimit = limit - - return this.makeCommand(id, options, errorDef)( - Effect.fnUntraced( - // fnUntraced only supports generators as first arg, so we convert to generator if needed - isGeneratorFunction(fn) ? fn : function*(...args) { - return yield* fn(...args) - }, - ...combinators as [any] - ) as any - ) - }, - makeBaseInfo(typeof id === "string" ? id : id.id, options), - { - state: Context.GenericTag<`Commander.Command.${Id}.state`, State>( - `Commander.Command.${typeof id === "string" ? id : id.id}.state` - ) - } - ) - - /** @experimental @deprecated */ - alt2: < - const Id extends string, - MutArg, - MutA, - MutE, - MutR, - const I18nKey extends string = Id, - State extends IntlRecord | undefined = undefined - >( - id: - | Id - | { id: Id; mutate: (arg: MutArg) => Effect.Effect } - | ((arg: MutArg) => Effect.Effect) & { id: Id }, - options?: FnOptions - ) => - & Commander2.CommandContextLocal - & (( - handler: ( - ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander2.CommandContextLocal & { - // todo: only if we passed in one - mutate: (arg: Arg) => Effect.Effect - } - ) => (arg: Arg, ctx: Commander2.CommandContextLocal2) => Effect.Effect - ) => Commander2.CommandOut) = ( - _id, - options? - ) => { - const isObject = typeof _id === "object" || typeof _id === "function" - const id = isObject ? _id.id : _id - const baseInfo = makeBaseInfo(id, options) - const idCmd = this.makeCommand(id, options) - // TODO: implement proper tracing stack - return Object.assign((cb: any) => - idCmd(cb( - Object.assign( - (fn: any, ...combinators: any[]) => - Effect.fnUntraced( - // fnUntraced only supports generators as first arg, so we convert to generator if needed - isGeneratorFunction(fn) ? fn : function*(...args) { - return yield* fn(...args) - }, - ...combinators as [any] - ), - baseInfo, - isObject - ? { mutate: "mutate" in _id ? _id.mutate : typeof _id === "function" ? _id : undefined } - : {} - ) - )), baseInfo) as any - } - - /** @experimental */ - alt = this.makeCommand as unknown as < - const Id extends string, - const I18nKey extends string = Id, - State extends IntlRecord | undefined = undefined - >( - id: Id, - customI18nKey?: I18nKey - ) => - & Commander2.CommandContextLocal - & (( - handler: (arg: Arg, ctx: Commander2.CommandContextLocal2) => Effect.Effect - ) => Commander2.CommandOut) - - /** - * Define a Command for handling user actions with built-in error reporting and state management. - * - * @param mutation The mutation function to take the identifier and initial handler from. Used as a tracing span and to lookup - * the user-facing name via internationalization (`action.${id}`). - * @param options Optional configuration for internationalization and state. - * @param options.i18nCustomKey Custom i18n key to use instead of `id` (e.g., for grouping similar actions) - * @param options.state Optional reactive state object (or function returning one) that is - * made available to the command effects and can be used for i18n interpolation. - * The state is captured at the start of each command execution and remains stable throughout. - * @returns A function that executes the command when called (e.g., directly in `@click` handlers). - * Built-in error reporting handles failures automatically. - * - * **Effect Context**: Effects have access to the `CommandContext` service, which provides - * the user-facing action name. - * - * **Returned Properties**: - * - `action`: User-facing action name from intl messages (useful for button labels) - * - `result`: The command result state - * - `waiting`: Boolean indicating if the command is in progress (shorthand for `result.waiting`) - * - `handle`: Function to execute the command - * - `exec`: The raw Effect that will be executed when calling `handle` (for advanced use cases) - * - `i18nKey`, `namespace`, `namespaced`: Helpers for internationalization keys - * - * **User Feedback**: Use the `withDefaultToast` helper for status notifications, or render - * the `result` inline for custom UI feedback. - */ - wrap = < - const Id extends string, - Arg, - A, - E, - R, - const State extends IntlRecord = IntlRecord, - I18nKey extends string = Id - >( - mutation: - | { mutate: (arg: Arg) => Effect.Effect; id: Id } - | ((arg: Arg) => Effect.Effect) & { id: Id }, - options?: FnOptions - ): Commander2.CommanderWrap => - Object.assign( - ( - ...combinators: any[] - ): any => { - // we capture the definition stack here, so we can append it to later stack traces - const limit = Error.stackTraceLimit - Error.stackTraceLimit = 2 - const errorDef = new Error() - Error.stackTraceLimit = limit - - const mutate = "mutate" in mutation ? mutation.mutate : mutation - - return this.makeCommand(mutation.id, options, errorDef)( - Effect.fnUntraced( - // fnUntraced only supports generators as first arg, so we convert to generator if needed - isGeneratorFunction(mutate) ? mutate : function*(arg: Arg) { - return yield* mutate(arg) - }, - ...combinators as [any] - ) as any - ) - }, - makeBaseInfo(mutation.id, options), - { - state: Context.GenericTag<`Commander.Command.${Id}.state`, State>( - `Commander.Command.${mutation.id}.state` - ) - } - ) -} - -// @effect-diagnostics-next-line missingEffectServiceDependency:off -export class Commander2 extends Effect.Service()("Commander2", { - dependencies: [WithToast.Default, Confirm.Default], - effect: Effect.gen(function*() { - const i18n = yield* I18n - return (rt: Runtime.Runtime) => new CommanderImpl(rt, i18n) - }) -}) {} diff --git a/packages/vue/src/experimental/makeUseCommand.ts b/packages/vue/src/experimental/makeUseCommand.ts index 7a955ee092..afbb2cd026 100644 --- a/packages/vue/src/experimental/makeUseCommand.ts +++ b/packages/vue/src/experimental/makeUseCommand.ts @@ -1,5 +1,5 @@ import { Effect } from "effect-app" -import { Commander2, type CommanderImpl, CommanderStatic } from "./commander2.js" +import { Commander, type CommanderImpl, CommanderStatic } from "./commander.js" type X = X @@ -10,7 +10,7 @@ export interface CommanderResolved } export const makeUseCommand = Effect.fnUntraced(function*() { - const cmndr = yield* Commander2 + const cmndr = yield* Commander const runtime = yield* Effect.runtime() const comm = cmndr(runtime) diff --git a/packages/vue/src/makeClient.ts b/packages/vue/src/makeClient.ts index 3b6efadfb2..0a74e374cd 100644 --- a/packages/vue/src/makeClient.ts +++ b/packages/vue/src/makeClient.ts @@ -14,7 +14,6 @@ import { type RuntimeFiber } from "effect/Fiber" import { computed, type ComputedRef, onBeforeUnmount, type Ref, ref, watch, type WatchSource } from "vue" import { reportMessage } from "./errorReporter.js" import { type Commander, CommanderStatic } from "./experimental/commander.js" -import { type Commander2 } from "./experimental/commander2.js" import { I18n } from "./experimental/intl.js" import { type CommanderResolved, makeUseCommand } from "./experimental/makeUseCommand.js" import { Toast } from "./experimental/toast.js" @@ -1248,7 +1247,7 @@ export class QueryImpl { const managedRuntimeRt = (mrt: ManagedRuntime.ManagedRuntime) => mrt.runSync(Effect.runtime()) type Base = I18n | Toast -type Mix = ApiClientFactory | Commander2 | LegacyMutation | Base +type Mix = ApiClientFactory | Commander | LegacyMutation | Base export const makeClient = ( // global, but only accessible after startup has completed getBaseMrt: () => ManagedRuntime.ManagedRuntime, diff --git a/packages/vue/test/stubs.ts b/packages/vue/test/stubs.ts index b354c4ab0a..988dde8712 100644 --- a/packages/vue/test/stubs.ts +++ b/packages/vue/test/stubs.ts @@ -6,7 +6,7 @@ import { Effect, Layer, ManagedRuntime, Option, S } from "effect-app" import { ApiClientFactory, makeRpcClient } from "effect-app/client" import { RpcContextMap } from "effect-app/rpc" import { ref } from "vue" -import { Commander2 } from "../src/experimental/commander2.js" +import { Commander } from "../src/experimental/commander.js" import { I18n } from "../src/experimental/intl.js" import { makeUseCommand } from "../src/experimental/makeUseCommand.js" import * as Toast from "../src/experimental/toast.js" @@ -83,7 +83,7 @@ export const useExperimental = ( ) => { const FakeIntlLayer = fakeIntlLayer(options?.messages) const FakeToastLayer = fakeToastLayer(options?.toasts) - const CommanderLayer = Commander2.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) + const CommanderLayer = Commander.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) const WithToastLayer = WithToast.Default.pipe(Layer.provide(FakeToastLayer)) const layers = Layer.mergeAll(CommanderLayer, WithToastLayer, FakeToastLayer, FakeIntlLayer) @@ -110,7 +110,7 @@ export const useClient = ( ) => { const FakeIntlLayer = fakeIntlLayer(options?.messages) const FakeToastLayer = fakeToastLayer(options?.toasts) - const CommanderLayer = Commander2.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) + const CommanderLayer = Commander.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer])) const WithToastLayer = WithToast.Default.pipe(Layer.provide(FakeToastLayer)) const api = ApiClientFactory.layer({ url: "bogus", headers: Option.none() }).pipe( Layer.provide(FetchHttpClient.layer)