@effect-app/vue 4.0.0-beta.6 → 4.0.0-beta.61

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +392 -0
  2. package/dist/{experimental/commander.d.ts → commander.d.ts} +12 -13
  3. package/dist/commander.d.ts.map +1 -0
  4. package/dist/commander.js +556 -0
  5. package/dist/{experimental/confirm.d.ts → confirm.d.ts} +2 -2
  6. package/dist/confirm.d.ts.map +1 -0
  7. package/dist/confirm.js +28 -0
  8. package/dist/form.d.ts +9 -0
  9. package/dist/form.d.ts.map +1 -1
  10. package/dist/form.js +38 -9
  11. package/dist/{experimental/intl.d.ts → intl.d.ts} +4 -4
  12. package/dist/intl.d.ts.map +1 -0
  13. package/dist/intl.js +5 -0
  14. package/dist/makeClient.d.ts +13 -12
  15. package/dist/makeClient.d.ts.map +1 -1
  16. package/dist/makeClient.js +11 -10
  17. package/dist/{experimental/makeUseCommand.d.ts → makeUseCommand.d.ts} +1 -1
  18. package/dist/makeUseCommand.d.ts.map +1 -0
  19. package/dist/makeUseCommand.js +13 -0
  20. package/dist/mutate.d.ts +1 -1
  21. package/dist/mutate.d.ts.map +1 -1
  22. package/dist/mutate.js +2 -2
  23. package/dist/query.d.ts +10 -14
  24. package/dist/query.d.ts.map +1 -1
  25. package/dist/query.js +23 -23
  26. package/dist/runtime.d.ts +3 -0
  27. package/dist/runtime.d.ts.map +1 -1
  28. package/dist/runtime.js +14 -2
  29. package/dist/{experimental/toast.d.ts → toast.d.ts} +3 -3
  30. package/dist/toast.d.ts.map +1 -0
  31. package/dist/toast.js +41 -0
  32. package/dist/{experimental/withToast.d.ts → withToast.d.ts} +2 -2
  33. package/dist/withToast.d.ts.map +1 -0
  34. package/dist/withToast.js +45 -0
  35. package/package.json +43 -43
  36. package/src/{experimental/commander.ts → commander.ts} +14 -16
  37. package/src/{experimental/confirm.ts → confirm.ts} +2 -2
  38. package/src/form.ts +46 -8
  39. package/src/intl.ts +9 -0
  40. package/src/makeClient.ts +17 -13
  41. package/src/mutate.ts +1 -1
  42. package/src/query.ts +44 -45
  43. package/src/runtime.ts +24 -1
  44. package/src/{experimental/toast.ts → toast.ts} +4 -4
  45. package/src/{experimental/withToast.ts → withToast.ts} +2 -2
  46. package/test/Mutation.test.ts +1 -1
  47. package/test/dist/form.test.d.ts.map +1 -1
  48. package/test/dist/stubs.d.ts +43 -59
  49. package/test/dist/stubs.d.ts.map +1 -1
  50. package/test/dist/stubs.js +8 -8
  51. package/test/form-validation-errors.test.ts +23 -19
  52. package/test/form.test.ts +20 -2
  53. package/test/stubs.ts +7 -7
  54. package/tsconfig.json +0 -1
  55. package/dist/experimental/commander.d.ts.map +0 -1
  56. package/dist/experimental/commander.js +0 -558
  57. package/dist/experimental/confirm.d.ts.map +0 -1
  58. package/dist/experimental/confirm.js +0 -28
  59. package/dist/experimental/intl.d.ts.map +0 -1
  60. package/dist/experimental/intl.js +0 -5
  61. package/dist/experimental/makeUseCommand.d.ts.map +0 -1
  62. package/dist/experimental/makeUseCommand.js +0 -13
  63. package/dist/experimental/toast.d.ts.map +0 -1
  64. package/dist/experimental/toast.js +0 -41
  65. package/dist/experimental/withToast.d.ts.map +0 -1
  66. package/dist/experimental/withToast.js +0 -45
  67. package/src/experimental/intl.ts +0 -9
  68. /package/src/{experimental/makeUseCommand.ts → makeUseCommand.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { Effect, ServiceMap } from "effect-app";
1
+ import { Context, Effect } from "effect-app";
2
2
  export type ToastId = string | number;
3
3
  export type ToastOpts = {
4
4
  id?: ToastId;
@@ -15,7 +15,7 @@ export type UseToast = () => {
15
15
  info: (this: void, message: string, options?: ToastOpts) => ToastId;
16
16
  dismiss: (this: void, id: ToastId) => void;
17
17
  };
18
- declare const CurrentToastId_base: ServiceMap.OpaqueClass<CurrentToastId, "CurrentToastId", {
18
+ declare const CurrentToastId_base: Context.OpaqueClass<CurrentToastId, "CurrentToastId", {
19
19
  toastId: ToastId;
20
20
  }>;
21
21
  export declare class CurrentToastId extends CurrentToastId_base {
@@ -28,7 +28,7 @@ export declare const wrap: (toast: ReturnType<UseToast>) => {
28
28
  warning: (message: string, options?: ToastOptsInternal) => Effect.Effect<ToastId, never, never>;
29
29
  dismiss: (toastId: ToastId) => Effect.Effect<void, never, never>;
30
30
  };
31
- declare const Toast_base: ServiceMap.OpaqueClass<Toast, "Toast", {
31
+ declare const Toast_base: Context.OpaqueClass<Toast, "Toast", {
32
32
  error: (message: string, options?: ToastOptsInternal) => Effect.Effect<ToastId, never, never>;
33
33
  info: (message: string, options?: ToastOptsInternal) => Effect.Effect<ToastId, never, never>;
34
34
  success: (message: string, options?: ToastOptsInternal) => Effect.Effect<ToastId, never, never>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../src/toast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAU,MAAM,YAAY,CAAA;AAGpD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AACrC,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAC1D,MAAM,MAAM,iBAAiB,GAAG;IAAE,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzE,MAAM,MAAM,QAAQ,GAAG,MAAM;IAC3B,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAA;IACpE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAA;IACtE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAA;IACtE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,KAAK,OAAO,CAAA;IACnE,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,KAAK,IAAI,CAAA;CAC3C,CAAA;;aAE6E,OAAO;;AAArF,qBAAa,cAAe,SAAQ,mBAAwE;CAAG;AAE/G,+FAA+F;AAC/F,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,CAAC,QAAQ,CAAC;qBAE3B,MAAM,YAAY,iBAAiB;oBAAnC,MAAM,YAAY,iBAAiB;uBAAnC,MAAM,YAAY,iBAAiB;uBAAnC,MAAM,YAAY,iBAAiB;uBAmBjC,OAAO;CAE7B,CAAA;;qBArBoB,MAAM,YAAY,iBAAiB;oBAAnC,MAAM,YAAY,iBAAiB;uBAAnC,MAAM,YAAY,iBAAiB;uBAAnC,MAAM,YAAY,iBAAiB;uBAmBjC,OAAO;;;;;;;;AAI9B,qBAAa,KACX,SAAQ,UAAoG;CAE7G"}
package/dist/toast.js ADDED
@@ -0,0 +1,41 @@
1
+ import { Context, Effect, Option } from "effect-app";
2
+ import { proxify } from "effect-app/Context";
3
+ export class CurrentToastId extends Context.Opaque()("CurrentToastId") {
4
+ }
5
+ /** fallback to CurrentToastId when available unless id is explicitly set to a value or null */
6
+ export const wrap = (toast) => {
7
+ const wrap = (toastHandler) => {
8
+ return (message, options) => Effect.serviceOption(CurrentToastId).pipe(Effect.flatMap((currentToast) => Effect.sync(() => {
9
+ const { id: _id, ...rest } = options ?? {};
10
+ const id = _id !== undefined
11
+ ? _id ?? undefined
12
+ : Option.getOrUndefined(Option.map(currentToast, (_) => _.toastId));
13
+ // when id is undefined, we may end up with no toast at all..
14
+ return toastHandler(message, id !== undefined ? { ...rest, id } : rest);
15
+ })));
16
+ };
17
+ return {
18
+ error: wrap(toast.error),
19
+ info: wrap(toast.info),
20
+ success: wrap(toast.success),
21
+ warning: wrap(toast.warning),
22
+ dismiss: (toastId) => Effect.sync(() => toast.dismiss(toastId))
23
+ };
24
+ };
25
+ export class Toast extends proxify(Context.Opaque()("Toast"))() {
26
+ }
27
+ // const a = Layer.effect(Toast, Effect.sync(() => Toast.of(null as any)))
28
+ // const A = Toast.of({
29
+ // error: () => Effect.succeed(null as any),
30
+ // info: () => Effect.succeed(null as any),
31
+ // success: () => Effect.succeed(null as any),
32
+ // warning: () => Effect.succeed(null as any),
33
+ // dismiss: () => Effect.succeed(null as any)
34
+ // })
35
+ // const b = Toast.info("test")
36
+ // const a2 = Toast.use((_) => _.error("test"))
37
+ // const b2 = Effect.gen(function*() {
38
+ // const toast = yield* Toast
39
+ // toast.error("test")
40
+ // })
41
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9hc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdG9hc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxFQUFFLE1BQU0sWUFBWSxDQUFBO0FBQ3BELE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQTtBQWM1QyxNQUFNLE9BQU8sY0FBZSxTQUFRLE9BQU8sQ0FBQyxNQUFNLEVBQXdDLENBQUMsZ0JBQWdCLENBQUM7Q0FBRztBQUUvRywrRkFBK0Y7QUFDL0YsTUFBTSxDQUFDLE1BQU0sSUFBSSxHQUFHLENBQUMsS0FBMkIsRUFBRSxFQUFFO0lBQ2xELE1BQU0sSUFBSSxHQUFHLENBQUMsWUFBK0QsRUFBRSxFQUFFO1FBQy9FLE9BQU8sQ0FBQyxPQUFlLEVBQUUsT0FBMkIsRUFBRSxFQUFFLENBQ3REL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BQyxPQUFnQixFQUFFLEVBQUUsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7S0FDekUsQ0FBQTtBQUNILENBQUMsQ0FBQTtBQUVELE1BQU0sT0FBTyxLQUNYLFNBQVEsT0FBTyxDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQWtDLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBa0M7Q0FFN0c7QUFFRCwwRUFBMEU7QUFFMUUsdUJBQXVCO0FBQ3ZCLDhDQUE4QztBQUM5Qyw2Q0FBNkM7QUFDN0MsZ0RBQWdEO0FBQ2hELGdEQUFnRDtBQUNoRCwrQ0FBK0M7QUFDL0MsS0FBSztBQUVMLCtCQUErQjtBQUUvQiwrQ0FBK0M7QUFFL0Msc0NBQXNDO0FBQ3RDLCtCQUErQjtBQUMvQix3QkFBd0I7QUFDeEIsS0FBSyJ9
@@ -1,4 +1,4 @@
1
- import { Effect, Layer, type Option, ServiceMap } from "effect-app";
1
+ import { Context, Effect, Layer, type Option } from "effect-app";
2
2
  import { Toast } from "./toast.js";
3
3
  export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, SucR, ErrR> {
4
4
  stableToastId?: undefined | string | ((...args: Args) => string | undefined);
@@ -13,7 +13,7 @@ export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, S
13
13
  message: string;
14
14
  }, never, ErrR>);
15
15
  }
16
- declare const WithToast_base: ServiceMap.ServiceClass<WithToast, "WithToast", <A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(options: ToastOptions<A, E, Args, WaiR, SucR, ErrR>) => (self: Effect.Effect<A, E, R>, ...args: Args) => Effect.Effect<A, E, R | WaiR | SucR | ErrR>> & {
16
+ declare const WithToast_base: Context.ServiceClass<WithToast, "WithToast", <A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(options: ToastOptions<A, E, Args, WaiR, SucR, ErrR>) => (self: Effect.Effect<A, E, R>, ...args: Args) => Effect.Effect<A, E, R | WaiR | SucR | ErrR>> & {
17
17
  readonly make: Effect.Effect<(<A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(options: ToastOptions<A, E, Args, WaiR, SucR, ErrR>) => (self: Effect.Effect<A, E, R>, ...args: Args) => Effect.Effect<A, E, R | WaiR | SucR | ErrR>), never, Toast>;
18
18
  };
19
19
  export declare class WithToast extends WithToast_base {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withToast.d.ts","sourceRoot":"","sources":["../src/withToast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAA;AAEvE,OAAO,EAAkB,KAAK,EAAE,MAAM,YAAY,CAAA;AAElD,MAAM,WAAW,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,SAAS,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IACvF,aAAa,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,EACL,MAAM,GACN,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC,GAClC,IAAI,GACJ,CAAC,CACD,GAAG,IAAI,EAAE,IAAI,KACV,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;IACjD,SAAS,EACL,MAAM,GACN,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC,GACxC,IAAI,GACJ,CAAC,CACD,CAA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AI,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,EACtG,SAAS,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAClD,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,CACb;CAC/F"}
@@ -0,0 +1,45 @@
1
+ import { Cause, Context, Effect, Layer } from "effect-app";
2
+ import { wrapEffect } from "effect-app/utils";
3
+ import { CurrentToastId, Toast } from "./toast.js";
4
+ // @effect-diagnostics-next-line missingEffectServiceDependency:off
5
+ export class WithToast extends Context.Service()("WithToast", {
6
+ make: Effect.gen(function* () {
7
+ const toast = yield* Toast;
8
+ return (options) => Effect.fnUntraced(function* (self, ...args) {
9
+ const baseTimeout = options.timeout ?? 3_000;
10
+ const stableToastId = typeof options.stableToastId === "function"
11
+ ? options.stableToastId(...args)
12
+ : options.stableToastId;
13
+ const t = yield* wrapEffect(options.onWaiting)(...args);
14
+ const toastId = t === null ? stableToastId : yield* toast.info(t, { id: stableToastId ?? null } // TODO: timeout forever?
15
+ );
16
+ return yield* self.pipe(Effect.tap(Effect.fnUntraced(function* (a) {
17
+ const t = yield* wrapEffect(options.onSuccess)(a, ...args);
18
+ if (t === null) {
19
+ return;
20
+ }
21
+ yield* toast.success(t, toastId !== undefined ? { id: toastId, timeout: baseTimeout } : { timeout: baseTimeout });
22
+ })), Effect.tapCause(Effect.fnUntraced(function* (cause) {
23
+ yield* Effect.logDebug("WithToast - caught error cause: " + Cause.squash(cause), Cause.hasInterruptsOnly(cause), cause);
24
+ if (Cause.hasInterruptsOnly(cause)) {
25
+ if (toastId)
26
+ yield* toast.dismiss(toastId);
27
+ return;
28
+ }
29
+ const t = yield* wrapEffect(options.onFailure)(Cause.findErrorOption(cause), ...args);
30
+ const opts = { timeout: baseTimeout * 2 };
31
+ if (typeof t === "object") {
32
+ return t.level === "warn"
33
+ ? yield* toast.warning(t.message, toastId !== undefined ? { ...opts, id: toastId } : opts)
34
+ : yield* toast.error(t.message, toastId !== undefined ? { ...opts, id: toastId } : opts);
35
+ }
36
+ yield* toast.error(t, toastId !== undefined ? { ...opts, id: toastId } : opts);
37
+ }, Effect.uninterruptible)), toastId !== undefined ? Effect.provideService(CurrentToastId, CurrentToastId.of({ toastId })) : (_) => _);
38
+ });
39
+ })
40
+ }) {
41
+ static DefaultWithoutDependencies = Layer.effect(this, this.make);
42
+ static Default = this.DefaultWithoutDependencies;
43
+ static handle = (options) => (self, ...args) => this.use((_) => _(options)(self, ...args));
44
+ }
45
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2l0aFRvYXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3dpdGhUb2FzdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFlLE1BQU0sWUFBWSxDQUFBO0FBQ3ZFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQTtBQUM3QyxPQUFPLEVBQUUsY0FBYyxFQUFFLEtBQUssRUFBRSxNQUFNLFlBQVksQ0FBQTtBQWdDbEQsbUVBQW1FO0FBQ25FLE1BQU0sT0FBTyxTQUFVLFNBQVEsT0FBTyxDQUFDLE9BQU8sRUFBYSxDQUFDLFdBQVcsRUFBRTtJQUN2RSxJQUFJLEVBQUUsTUFBTSxDQUFDLEdBQUcsQ0FBQ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FPLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQ3pHLENBQUE7UUFDSCxDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQztDQUNILENBQUM7SUFDQSxNQUFNLENBQVUsMEJBQTBCLEdBQUcsS0FBSyxDQUFDLE1BQU0sQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQzFFLE1BQU0sQ0FBVSxPQUFPLEdBQUcsSUFBSSxDQUFDLDBCQUEwQixDQUFBO0lBRXpELE1BQU0sQ0FBVSxNQUFNLEdBQUcsQ0FDdkIsT0FBbUQsRUFDdUQsRUFBRSxDQUM5RyxDQUFDLElBQUksRUFBRSxHQUFHLElBQUksRUFBRSxFQUFFLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQyxDQUFrQyxPQUFPLENBQUMsQ0FBQyxJQUFJLEVBQUUsR0FBRyxJQUFJLENBQUMsQ0FBQyxDQUFBIn0=
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
2
  "name": "@effect-app/vue",
3
- "version": "4.0.0-beta.6",
3
+ "version": "4.0.0-beta.61",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/effect-ts-app/libs/tree/main/packages/vue",
7
7
  "dependencies": {
8
- "@formatjs/intl": "^4.1.2",
9
- "@tanstack/query-core": "5.83.1",
10
- "@tanstack/vue-query": "5.83.1",
8
+ "@formatjs/intl": "^4.1.5",
9
+ "@tanstack/query-core": "5.96.2",
10
+ "@tanstack/vue-query": "5.96.2",
11
11
  "@vueuse/core": "^14.2.1",
12
12
  "change-case": "^5.4.4",
13
13
  "query-string": "^9.3.1",
14
- "effect-app": "4.0.0-beta.6"
14
+ "effect-app": "4.0.0-beta.61"
15
15
  },
16
16
  "peerDependencies": {
17
- "@effect/atom-vue": "^4.0.0-beta.25",
18
- "@effect/platform-browser": "^4.0.0-beta.25",
19
- "@sentry/browser": "^10.40.0",
20
- "effect": "^4.0.0-beta.25",
21
- "vue": "^3.5.29"
17
+ "@effect/atom-vue": "^4.0.0-beta.43",
18
+ "@effect/platform-browser": "^4.0.0-beta.43",
19
+ "@sentry/browser": "^10.47.0",
20
+ "effect": "^4.0.0-beta.43",
21
+ "vue": "^3.5.32"
22
22
  },
23
23
  "devDependencies": {
24
- "@effect/vitest": "^4.0.0-beta.25",
25
- "@formatjs/icu-messageformat-parser": "^3.5.1",
26
- "@types/node": "25.3.3",
27
- "@vitejs/plugin-vue": "^6.0.4",
28
- "intl-messageformat": "^11.1.2",
24
+ "@effect/vitest": "^4.0.0-beta.43",
25
+ "@formatjs/icu-messageformat-parser": "^3.5.3",
26
+ "@types/node": "25.5.2",
27
+ "@vitejs/plugin-vue": "^6.0.5",
28
+ "intl-messageformat": "^11.2.0",
29
29
  "json5": "^2.2.3",
30
- "typescript": "~5.9.3",
31
- "vite": "^7.3.1",
32
- "vitest": "^4.0.18",
33
- "@effect-app/eslint-shared-config": "0.5.7-beta.1"
30
+ "typescript": "~6.0.2",
31
+ "vite": "^8.0.6",
32
+ "vitest": "^4.1.3",
33
+ "@effect-app/eslint-shared-config": "0.5.7-beta.7"
34
34
  },
35
35
  "typesVersions": {
36
36
  "*": {
@@ -44,38 +44,26 @@
44
44
  "types": "./dist/index.d.ts",
45
45
  "default": "./dist/index.js"
46
46
  },
47
+ "./commander": {
48
+ "types": "./dist/commander.d.ts",
49
+ "default": "./dist/commander.js"
50
+ },
51
+ "./confirm": {
52
+ "types": "./dist/confirm.d.ts",
53
+ "default": "./dist/confirm.js"
54
+ },
47
55
  "./errorReporter": {
48
56
  "types": "./dist/errorReporter.d.ts",
49
57
  "default": "./dist/errorReporter.js"
50
58
  },
51
- "./experimental/commander": {
52
- "types": "./dist/experimental/commander.d.ts",
53
- "default": "./dist/experimental/commander.js"
54
- },
55
- "./experimental/confirm": {
56
- "types": "./dist/experimental/confirm.d.ts",
57
- "default": "./dist/experimental/confirm.js"
58
- },
59
- "./experimental/intl": {
60
- "types": "./dist/experimental/intl.d.ts",
61
- "default": "./dist/experimental/intl.js"
62
- },
63
- "./experimental/makeUseCommand": {
64
- "types": "./dist/experimental/makeUseCommand.d.ts",
65
- "default": "./dist/experimental/makeUseCommand.js"
66
- },
67
- "./experimental/toast": {
68
- "types": "./dist/experimental/toast.d.ts",
69
- "default": "./dist/experimental/toast.js"
70
- },
71
- "./experimental/withToast": {
72
- "types": "./dist/experimental/withToast.d.ts",
73
- "default": "./dist/experimental/withToast.js"
74
- },
75
59
  "./form": {
76
60
  "types": "./dist/form.d.ts",
77
61
  "default": "./dist/form.js"
78
62
  },
63
+ "./intl": {
64
+ "types": "./dist/intl.d.ts",
65
+ "default": "./dist/intl.js"
66
+ },
79
67
  "./lib": {
80
68
  "types": "./dist/lib.d.ts",
81
69
  "default": "./dist/lib.js"
@@ -92,6 +80,10 @@
92
80
  "types": "./dist/makeIntl.d.ts",
93
81
  "default": "./dist/makeIntl.js"
94
82
  },
83
+ "./makeUseCommand": {
84
+ "types": "./dist/makeUseCommand.d.ts",
85
+ "default": "./dist/makeUseCommand.js"
86
+ },
95
87
  "./mutate": {
96
88
  "types": "./dist/mutate.d.ts",
97
89
  "default": "./dist/mutate.js"
@@ -107,6 +99,14 @@
107
99
  "./runtime": {
108
100
  "types": "./dist/runtime.d.ts",
109
101
  "default": "./dist/runtime.js"
102
+ },
103
+ "./toast": {
104
+ "types": "./dist/toast.d.ts",
105
+ "default": "./dist/toast.js"
106
+ },
107
+ "./withToast": {
108
+ "types": "./dist/withToast.d.ts",
109
+ "default": "./dist/withToast.js"
110
110
  }
111
111
  },
112
112
  "gitHead": "bd8e27eea3eff97db8739d577d67e7336c078d28",
@@ -1,12 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { asResult, type MissingDependencies, reportRuntimeError } from "@effect-app/vue"
3
3
  import { reportMessage } from "@effect-app/vue/errorReporter"
4
- import { type AsyncResult } from "effect/unstable/reactivity/AsyncResult"
5
- import { Cause, Effect, type Exit, type Fiber, flow, Layer, Match, MutableHashMap, Option, Predicate, S, ServiceMap } from "effect-app"
4
+ import { Cause, Context, Effect, type Exit, type Fiber, flow, Layer, Match, MutableHashMap, Option, Predicate, S } from "effect-app"
6
5
  import { SupportedErrors } from "effect-app/client"
7
6
  import { OperationFailure, OperationSuccess } from "effect-app/Operations"
8
- import { wrapEffect } from "effect-app/utils"
9
- import { isGeneratorFunction } from "effect/Utils"
7
+ import { isGeneratorFunction, wrapEffect } from "effect-app/utils"
8
+ import { type AsyncResult } from "effect/unstable/reactivity/AsyncResult"
10
9
  import { type FormatXMLElementFn, type PrimitiveType } from "intl-messageformat"
11
10
  import { computed, type ComputedRef, reactive, ref } from "vue"
12
11
  import { Confirm } from "./confirm.js"
@@ -67,7 +66,7 @@ export const DefaultIntl = {
67
66
  }
68
67
  }
69
68
 
70
- export class CommandContext extends ServiceMap.Service<CommandContext, {
69
+ export class CommandContext extends Context.Service<CommandContext, {
71
70
  id: string
72
71
  i18nKey: string
73
72
  action: string
@@ -97,7 +96,7 @@ export declare namespace Commander {
97
96
  & NonGen<RT, Id, I18nKey, State>
98
97
  & CommandContextLocal<Id, I18nKey>
99
98
  & {
100
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>
99
+ state: Context.Service<`Commander.Command.${Id}.state`, State>
101
100
  }
102
101
 
103
102
  export type CommanderFn<RT, Id extends string, I18nKey extends string, State extends IntlRecord | undefined> =
@@ -117,7 +116,7 @@ export declare namespace Commander {
117
116
  & GenWrap<RT, Id, I18nCustomKey, I, A, E, R, State>
118
117
  & NonGenWrap<RT, Id, I18nCustomKey, I, A, E, R, State>
119
118
  & {
120
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>
119
+ state: Context.Service<`Commander.Command.${Id}.state`, State>
121
120
  }
122
121
 
123
122
  export interface CommandContextLocal<Id extends string, I18nKey extends string> {
@@ -1324,7 +1323,7 @@ const getStateValues = <const Id extends string, const I18nKey extends string, S
1324
1323
  // class preserves JSDoc throughout..
1325
1324
  export class CommanderImpl<RT, RTHooks> {
1326
1325
  constructor(
1327
- private readonly rt: ServiceMap.ServiceMap<RT>,
1326
+ private readonly rt: Context.Context<RT>,
1328
1327
  private readonly intl: I18n,
1329
1328
  private readonly hooks: Layer.Layer<RTHooks, never, RT>
1330
1329
  ) {
@@ -1386,7 +1385,7 @@ export class CommanderImpl<RT, RTHooks> {
1386
1385
  }
1387
1386
 
1388
1387
  const key = `Commander.Command.${id}.state` as const
1389
- const stateTag = ServiceMap.Service<typeof key, State>(key)
1388
+ const stateTag = Context.Service<typeof key, State>(key)
1390
1389
 
1391
1390
  const makeContext_ = () => this.makeContext(id, { ...options, state: state?.value })
1392
1391
  const initialContext = makeContext_()
@@ -1655,7 +1654,7 @@ export class CommanderImpl<RT, RTHooks> {
1655
1654
  id: Id | { id: Id },
1656
1655
  options?: FnOptions<Id, I18nKey, State>
1657
1656
  ): Commander.Gen<RT | RTHooks, Id, I18nKey, State> & Commander.NonGen<RT | RTHooks, Id, I18nKey, State> & {
1658
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>
1657
+ state: Context.Service<`Commander.Command.${Id}.state`, State>
1659
1658
  } =>
1660
1659
  Object.assign(
1661
1660
  (
@@ -1680,13 +1679,13 @@ export class CommanderImpl<RT, RTHooks> {
1680
1679
  },
1681
1680
  makeBaseInfo(typeof id === "string" ? id : id.id, options),
1682
1681
  {
1683
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>(
1682
+ state: Context.Service<`Commander.Command.${Id}.state`, State>(
1684
1683
  `Commander.Command.${typeof id === "string" ? id : id.id}.state`
1685
1684
  )
1686
1685
  }
1687
1686
  )
1688
1687
 
1689
- /** @experimental @deprecated */
1688
+ /** @deprecated */
1690
1689
  alt2: <
1691
1690
  const Id extends string,
1692
1691
  MutArg,
@@ -1738,7 +1737,6 @@ export class CommanderImpl<RT, RTHooks> {
1738
1737
  )), baseInfo) as any
1739
1738
  }
1740
1739
 
1741
- /** @experimental */
1742
1740
  alt = this.makeCommand as unknown as <
1743
1741
  const Id extends string,
1744
1742
  const I18nKey extends string = Id,
@@ -1816,7 +1814,7 @@ export class CommanderImpl<RT, RTHooks> {
1816
1814
  },
1817
1815
  makeBaseInfo(mutation.id, options),
1818
1816
  {
1819
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>(
1817
+ state: Context.Service<`Commander.Command.${Id}.state`, State>(
1820
1818
  `Commander.Command.${mutation.id}.state`
1821
1819
  )
1822
1820
  }
@@ -1824,10 +1822,10 @@ export class CommanderImpl<RT, RTHooks> {
1824
1822
  }
1825
1823
 
1826
1824
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
1827
- export class Commander extends ServiceMap.Service<Commander>()("Commander", {
1825
+ export class Commander extends Context.Service<Commander>()("Commander", {
1828
1826
  make: Effect.gen(function*() {
1829
1827
  const i18n = yield* I18n
1830
- return <RT, RTHooks>(rt: ServiceMap.ServiceMap<RT>, rtHooks: Layer.Layer<RTHooks, never, RT>) =>
1828
+ return <RT, RTHooks>(rt: Context.Context<RT>, rtHooks: Layer.Layer<RTHooks, never, RT>) =>
1831
1829
  new CommanderImpl(rt, i18n, rtHooks)
1832
1830
  })
1833
1831
  }) {
@@ -1,8 +1,8 @@
1
- import { Effect, Layer, ServiceMap } from "effect-app"
1
+ import { Context, Effect, Layer } from "effect-app"
2
2
  import { I18n } from "./intl.js"
3
3
 
4
4
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
5
- export class Confirm extends ServiceMap.Service<Confirm>()("Confirm", {
5
+ export class Confirm extends Context.Service<Confirm>()("Confirm", {
6
6
  make: Effect.gen(function*() {
7
7
  const { intl } = yield* I18n
8
8
 
package/src/form.ts CHANGED
@@ -22,6 +22,7 @@ function getObjectsAST(ast: S.AST.AST): S.AST.Objects | null {
22
22
  return null
23
23
  }
24
24
 
25
+ /** @deprecated Use OmegaForm instead */
25
26
  export function convertIn(v: string | null, type?: "text" | "float" | "int") {
26
27
  return v === null ? "" : type === "text" ? v : `${v}`
27
28
  }
@@ -30,8 +31,10 @@ export function convertIn(v: string | null, type?: "text" | "float" | "int") {
30
31
  * Makes sure our international number format is converted to js int/float format.
31
32
  * Right now assumes . for thousands and , for decimal.
32
33
  */
34
+ /** @deprecated Use OmegaForm instead */
33
35
  export const prepareNumberForLocale = (v: string) => v.replace(/\./g, "").replace(/,/g, ".")
34
36
 
37
+ /** @deprecated Use OmegaForm instead */
35
38
  export function convertOutInt(v: string, type?: "text" | "float" | "int") {
36
39
  v = v == null ? v : v.trim()
37
40
  const c = v === ""
@@ -49,6 +52,7 @@ export function convertOutInt(v: string, type?: "text" | "float" | "int") {
49
52
  return c
50
53
  }
51
54
 
55
+ /** @deprecated Use OmegaForm instead */
52
56
  export function convertOut(v: string, set: (v: {} | null) => void, type?: "text" | "float" | "int") {
53
57
  return set(convertOutInt(v, type))
54
58
  }
@@ -143,10 +147,18 @@ function handlePropertySignature(
143
147
  const typeLiteral = getObjectsAST(ps.type)
144
148
 
145
149
  const tagPropertySignature = typeLiteral?.propertySignatures.find((_) => _.name === "_tag")
146
- const tagLiteral = tagPropertySignature
147
- && S.AST.isLiteral(tagPropertySignature.type)
148
- && typeof tagPropertySignature.type.literal === "string"
149
- ? tagPropertySignature.type.literal
150
+ // unwrap single-element Union to Literal (S.Struct({ _tag: S.Literal("x") }) wraps as Union([Literal("x")]))
151
+ const tagType = tagPropertySignature
152
+ ? S.AST.isUnion(tagPropertySignature.type)
153
+ && tagPropertySignature.type.types.length === 1
154
+ && S.AST.isLiteral(tagPropertySignature.type.types[0]!)
155
+ ? tagPropertySignature.type.types[0]
156
+ : tagPropertySignature.type
157
+ : undefined
158
+ const tagLiteral = tagType
159
+ && S.AST.isLiteral(tagType)
160
+ && typeof tagType.literal === "string"
161
+ ? tagType.literal
150
162
  : void 0
151
163
 
152
164
  const toRet = handlePropertySignature(ps)
@@ -189,6 +201,7 @@ function handlePropertySignature(
189
201
  }
190
202
  }
191
203
 
204
+ /** @deprecated Use OmegaForm instead */
192
205
  export function buildFieldInfoFromFields<
193
206
  From extends Record<PropertyKey, any>,
194
207
  To extends Record<PropertyKey, any>
@@ -198,6 +211,7 @@ export function buildFieldInfoFromFields<
198
211
  return buildFieldInfoFromFieldsRoot(schema).fields
199
212
  }
200
213
 
214
+ /** @deprecated Use OmegaForm instead */
201
215
  export function buildFieldInfoFromFieldsRoot<
202
216
  From extends Record<PropertyKey, any>,
203
217
  To extends Record<PropertyKey, any>,
@@ -235,7 +249,9 @@ abstract class PhantomTypeParameter<
235
249
 
236
250
  const defaultIntl = createIntl({ locale: "en" })
237
251
 
252
+ /** @deprecated Use OmegaForm instead */
238
253
  export const translate = ref<IntlFormatters["formatMessage"]>(defaultIntl.formatMessage)
254
+ /** @deprecated Use OmegaForm instead */
239
255
  export const customSchemaErrors = ref<Map<S.AST.AST | string, (message: string, e: unknown, v: unknown) => string>>(
240
256
  new Map()
241
257
  )
@@ -269,7 +285,7 @@ function buildFieldInfo(
269
285
  }
270
286
 
271
287
  // parse specific error types for better translation support
272
- const integerMatch = err.match(/Expected.*integer.*actual\s+(.+)/i)
288
+ const integerMatch = err.match(/Expected.*integer.*(?:actual|got)\s+([^)]+)/i)
273
289
  if (integerMatch) {
274
290
  return translate.value(
275
291
  { defaultMessage: "Expected an integer, actual {actualValue}", id: "validation.integer.expected" },
@@ -277,7 +293,7 @@ function buildFieldInfo(
277
293
  )
278
294
  }
279
295
 
280
- const numberMatch = err.match(/Expected.*number.*actual\s+(.+)/i)
296
+ const numberMatch = err.match(/Expected.*number.*(?:actual|got)\s+([^)]+)/i)
281
297
  if (numberMatch) {
282
298
  return translate.value(
283
299
  { defaultMessage: "Expected a number, actual {actualValue}", id: "validation.number.expected" },
@@ -398,6 +414,7 @@ function buildFieldInfo(
398
414
  return info as any
399
415
  }
400
416
 
417
+ /** @deprecated Use OmegaForm instead */
401
418
  export function getMetadataFromSchema(
402
419
  ast: S.AST.AST
403
420
  ): {
@@ -411,6 +428,27 @@ export function getMetadataFromSchema(
411
428
  required: boolean
412
429
  description?: string
413
430
  } {
431
+ const findJsonSchemaType = (
432
+ schema: any,
433
+ target: "number" | "integer"
434
+ ): boolean => {
435
+ if (!schema || typeof schema !== "object") {
436
+ return false
437
+ }
438
+
439
+ if (schema.type === target) {
440
+ return true
441
+ }
442
+
443
+ if (Array.isArray(schema.type) && schema.type.includes(target)) {
444
+ return true
445
+ }
446
+
447
+ return ["anyOf", "oneOf", "allOf"].some((key) =>
448
+ Array.isArray(schema[key]) && schema[key].some((member: any) => findJsonSchemaType(member, target))
449
+ )
450
+ }
451
+
414
452
  const nullable = S.AST.isUnion(ast) && ast.types.includes(S.Null.ast)
415
453
  const realSelf = nullable && S.AST.isUnion(ast)
416
454
  ? ast.types.filter((_) => _ !== S.Null.ast)[0]!
@@ -440,8 +478,8 @@ export function getMetadataFromSchema(
440
478
  // "title": "Int"
441
479
  // }
442
480
  // }
443
- const isNumber = jschema.type === "number" || jschema.type === "integer"
444
- const isInt = jschema.type === "integer"
481
+ const isInt = findJsonSchemaType(jschema, "integer")
482
+ const isNumber = isInt || findJsonSchemaType(jschema, "number")
445
483
  return {
446
484
  type: isInt ? "int" as const : isNumber ? "float" as const : "text" as const,
447
485
  minimum: jschema.minimum,
package/src/intl.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Context } from "effect-app"
2
+ import { proxify } from "effect-app/Context"
3
+ import { type MakeIntlReturn } from "./makeIntl.js"
4
+
5
+ export class I18n extends proxify(Context.Opaque<I18n, ReturnType<MakeIntlReturn<string>["useIntl"]>>()("I18n"))<
6
+ I18n,
7
+ ReturnType<MakeIntlReturn<string>["useIntl"]>
8
+ >() {
9
+ }