@effect-app/vue 2.77.2 → 2.77.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,24 @@
1
1
  import { Effect } from "effect-app"
2
- import { Commander, CommanderStatic } from "./commander.js"
2
+ import { Commander, type CommanderImpl, CommanderStatic } from "./commander.js"
3
3
 
4
4
  type X<X> = X
5
5
 
6
- // try to preserve JSDoc..
7
- export interface CommanderResolved extends X<typeof CommanderStatic> {
8
- alt: ReturnType<Commander["alt"]>
9
- fn: ReturnType<Commander["fn"]>
10
- wrap: ReturnType<Commander["wrap"]>
11
- alt2: ReturnType<Commander["alt2"]>
12
- withDefaultToast: typeof CommanderStatic.withDefaultToast
6
+ // helps retain JSDoc
7
+ export interface CommanderResolved<RT>
8
+ extends X<typeof CommanderStatic>, Pick<CommanderImpl<RT>, "fn" | "wrap" | "alt" | "alt2">
9
+ {
13
10
  }
14
11
 
15
12
  export const makeUseCommand = Effect.fnUntraced(function*<R = never>() {
16
13
  const cmndr = yield* Commander
17
14
  const runtime = yield* Effect.runtime<R>()
18
15
 
16
+ const comm = cmndr(runtime)
17
+
19
18
  const command = {
20
- ...cmndr,
21
- alt: cmndr.alt(runtime),
22
- fn: cmndr.fn(runtime),
23
- wrap: cmndr.wrap(runtime),
24
- alt2: cmndr.alt2(runtime),
19
+ ...comm,
25
20
  ...CommanderStatic
26
21
  }
27
22
 
28
- return command as CommanderResolved
23
+ return command as CommanderResolved<R>
29
24
  })
package/src/makeClient.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import * as Result from "@effect-atom/atom/Result"
3
3
  import { type InitialDataFunction, type InvalidateOptions, type InvalidateQueryFilters, isCancelledError, type QueryObserverResult, type RefetchOptions, type UseQueryReturnType } from "@tanstack/vue-query"
4
+ import { camelCase } from "change-case"
4
5
  import { Cause, Effect, Exit, type ManagedRuntime, Match, Option, Runtime, S, Struct } from "effect-app"
6
+ import { type ApiClientFactory } from "effect-app/client"
5
7
  import type { RequestHandler, RequestHandlers, RequestHandlerWithInput, Requests, TaggedRequestClassAny } from "effect-app/client/clientFor"
6
8
  import { ErrorSilenced, type SupportedErrors } from "effect-app/client/errors"
7
9
  import { constant, identity, pipe, tuple } from "effect-app/Function"
@@ -11,17 +13,15 @@ import { dropUndefinedT } from "effect-app/utils"
11
13
  import { type RuntimeFiber } from "effect/Fiber"
12
14
  import { computed, type ComputedRef, onBeforeUnmount, type Ref, ref, watch, type WatchSource } from "vue"
13
15
  import { reportMessage } from "./errorReporter.js"
14
- import { Commander, CommanderStatic } from "./experimental/commander.js"
16
+ import { type Commander, CommanderStatic } from "./experimental/commander.js"
15
17
  import { I18n } from "./experimental/intl.js"
18
+ import { type CommanderResolved, makeUseCommand } from "./experimental/makeUseCommand.js"
16
19
  import { Toast } from "./experimental/toast.js"
17
20
  import { buildFieldInfoFromFieldsRoot } from "./form.js"
18
21
  import { reportRuntimeError } from "./lib.js"
19
22
  import { asResult, makeMutation, type MutationOptions, type MutationOptionsBase, mutationResultToVue, type Res, useMakeMutation } from "./mutate.js"
20
23
  import { type CustomDefinedInitialQueryOptions, type CustomUndefinedInitialQueryOptions, type KnownFiberFailure, makeQuery } from "./query.js"
21
24
 
22
- import { camelCase } from "change-case"
23
- import { type ApiClientFactory } from "effect-app/client"
24
-
25
25
  const mapHandler = <A, E, R, I = void, A2 = A, E2 = E, R2 = R>(
26
26
  handler: Effect.Effect<A, E, R> | ((i: I) => Effect.Effect<A, E, R>),
27
27
  map: (self: Effect.Effect<A, E, R>, i: I) => Effect.Effect<A2, E2, R2>
@@ -1011,18 +1011,10 @@ export const makeClient = <RT>(
1011
1011
  getBaseMrt: () => ManagedRuntime.ManagedRuntime<RT | ApiClientFactory | Commander | LegacyMutation | Base, never>,
1012
1012
  clientFor_: ReturnType<typeof ApiClientFactory["makeFor"]>
1013
1013
  ) => {
1014
- const getRt = Effect.runtime<RT | ApiClientFactory | Commander | LegacyMutation | Base>()
1014
+ type R = RT | ApiClientFactory | Commander | LegacyMutation | Base
1015
+ const getRt = Effect.runtime<R>()
1015
1016
  const getBaseRt = () => managedRuntimeRt(getBaseMrt())
1016
- const makeCommand = Effect.gen(function*() {
1017
- const cmd = yield* Commander
1018
- const rt = yield* getRt
1019
- return {
1020
- fn: cmd.fn(rt),
1021
- wrap: cmd.wrap(rt),
1022
- alt: cmd.alt(rt),
1023
- alt2: cmd.alt2(rt)
1024
- }
1025
- })
1017
+ const makeCommand = makeUseCommand<R>()
1026
1018
  const makeMutation = Effect.gen(function*() {
1027
1019
  const mut = yield* LegacyMutation
1028
1020
 
@@ -1300,8 +1292,9 @@ export const makeClient = <RT>(
1300
1292
  useSuspenseQuery
1301
1293
  }
1302
1294
 
1303
- const Command = {
1295
+ const Command: CommanderResolved<RT> = {
1304
1296
  ...{
1297
+ // delay initialisation until first use...
1305
1298
  fn: (...args: [any]) => useCommand().fn(...args),
1306
1299
  wrap: (...args: [any]) => useCommand().wrap(...args),
1307
1300
  alt: (...args: [any]) => useCommand().alt(...args),
@@ -1,9 +1,11 @@
1
1
  import { type MessageFormatElement } from "@formatjs/icu-messageformat-parser";
2
2
  import { Layer } from "effect-app";
3
3
  import { I18n } from "../src/experimental/intl.js";
4
+ import * as Toast from "../src/experimental/toast.js";
5
+ import { WithToast } from "../src/experimental/withToast.js";
4
6
  export declare const fakeIntlLayer: (messages?: Record<string, string> | Record<string, MessageFormatElement[]>) => Layer.Layer<I18n, never, never>;
5
7
  export declare const useExperimental: (options?: {
6
8
  messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
7
9
  toasts: any[];
8
- }) => import("../src/experimental/makeUseCommand.js").CommanderResolved;
10
+ }) => import("../src/experimental/makeUseCommand.js").CommanderResolved<Toast.Toast | I18n | WithToast>;
9
11
  //# sourceMappingURL=stubs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../stubs.ts"],"names":[],"mapp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