@effect-app/vue 4.0.0-beta.52 → 4.0.0-beta.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue",
3
- "version": "4.0.0-beta.52",
3
+ "version": "4.0.0-beta.54",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/effect-ts-app/libs/tree/main/packages/vue",
@@ -11,7 +11,7 @@
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.52"
14
+ "effect-app": "4.0.0-beta.54"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@effect/atom-vue": "^4.0.0-beta.43",
package/src/commander.ts CHANGED
@@ -1,7 +1,7 @@
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 { 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"
5
5
  import { SupportedErrors } from "effect-app/client"
6
6
  import { OperationFailure, OperationSuccess } from "effect-app/Operations"
7
7
  import { isGeneratorFunction, wrapEffect } from "effect-app/utils"
@@ -66,7 +66,7 @@ export const DefaultIntl = {
66
66
  }
67
67
  }
68
68
 
69
- export class CommandContext extends ServiceMap.Service<CommandContext, {
69
+ export class CommandContext extends Context.Service<CommandContext, {
70
70
  id: string
71
71
  i18nKey: string
72
72
  action: string
@@ -96,7 +96,7 @@ export declare namespace Commander {
96
96
  & NonGen<RT, Id, I18nKey, State>
97
97
  & CommandContextLocal<Id, I18nKey>
98
98
  & {
99
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>
99
+ state: Context.Service<`Commander.Command.${Id}.state`, State>
100
100
  }
101
101
 
102
102
  export type CommanderFn<RT, Id extends string, I18nKey extends string, State extends IntlRecord | undefined> =
@@ -116,7 +116,7 @@ export declare namespace Commander {
116
116
  & GenWrap<RT, Id, I18nCustomKey, I, A, E, R, State>
117
117
  & NonGenWrap<RT, Id, I18nCustomKey, I, A, E, R, State>
118
118
  & {
119
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>
119
+ state: Context.Service<`Commander.Command.${Id}.state`, State>
120
120
  }
121
121
 
122
122
  export interface CommandContextLocal<Id extends string, I18nKey extends string> {
@@ -1323,7 +1323,7 @@ const getStateValues = <const Id extends string, const I18nKey extends string, S
1323
1323
  // class preserves JSDoc throughout..
1324
1324
  export class CommanderImpl<RT, RTHooks> {
1325
1325
  constructor(
1326
- private readonly rt: ServiceMap.ServiceMap<RT>,
1326
+ private readonly rt: Context.Context<RT>,
1327
1327
  private readonly intl: I18n,
1328
1328
  private readonly hooks: Layer.Layer<RTHooks, never, RT>
1329
1329
  ) {
@@ -1385,7 +1385,7 @@ export class CommanderImpl<RT, RTHooks> {
1385
1385
  }
1386
1386
 
1387
1387
  const key = `Commander.Command.${id}.state` as const
1388
- const stateTag = ServiceMap.Service<typeof key, State>(key)
1388
+ const stateTag = Context.Service<typeof key, State>(key)
1389
1389
 
1390
1390
  const makeContext_ = () => this.makeContext(id, { ...options, state: state?.value })
1391
1391
  const initialContext = makeContext_()
@@ -1654,7 +1654,7 @@ export class CommanderImpl<RT, RTHooks> {
1654
1654
  id: Id | { id: Id },
1655
1655
  options?: FnOptions<Id, I18nKey, State>
1656
1656
  ): Commander.Gen<RT | RTHooks, Id, I18nKey, State> & Commander.NonGen<RT | RTHooks, Id, I18nKey, State> & {
1657
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>
1657
+ state: Context.Service<`Commander.Command.${Id}.state`, State>
1658
1658
  } =>
1659
1659
  Object.assign(
1660
1660
  (
@@ -1679,7 +1679,7 @@ export class CommanderImpl<RT, RTHooks> {
1679
1679
  },
1680
1680
  makeBaseInfo(typeof id === "string" ? id : id.id, options),
1681
1681
  {
1682
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>(
1682
+ state: Context.Service<`Commander.Command.${Id}.state`, State>(
1683
1683
  `Commander.Command.${typeof id === "string" ? id : id.id}.state`
1684
1684
  )
1685
1685
  }
@@ -1814,7 +1814,7 @@ export class CommanderImpl<RT, RTHooks> {
1814
1814
  },
1815
1815
  makeBaseInfo(mutation.id, options),
1816
1816
  {
1817
- state: ServiceMap.Service<`Commander.Command.${Id}.state`, State>(
1817
+ state: Context.Service<`Commander.Command.${Id}.state`, State>(
1818
1818
  `Commander.Command.${mutation.id}.state`
1819
1819
  )
1820
1820
  }
@@ -1822,10 +1822,10 @@ export class CommanderImpl<RT, RTHooks> {
1822
1822
  }
1823
1823
 
1824
1824
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
1825
- export class Commander extends ServiceMap.Service<Commander>()("Commander", {
1825
+ export class Commander extends Context.Service<Commander>()("Commander", {
1826
1826
  make: Effect.gen(function*() {
1827
1827
  const i18n = yield* I18n
1828
- 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>) =>
1829
1829
  new CommanderImpl(rt, i18n, rtHooks)
1830
1830
  })
1831
1831
  }) {
package/src/confirm.ts CHANGED
@@ -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/intl.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ServiceMap } from "effect-app"
2
- import { proxify } from "effect-app/ServiceMap"
1
+ import { Context } from "effect-app"
2
+ import { proxify } from "effect-app/Context"
3
3
  import { type MakeIntlReturn } from "./makeIntl.js"
4
4
 
5
- export class I18n extends proxify(ServiceMap.Opaque<I18n, ReturnType<MakeIntlReturn<string>["useIntl"]>>()("I18n"))<
5
+ export class I18n extends proxify(Context.Opaque<I18n, ReturnType<MakeIntlReturn<string>["useIntl"]>>()("I18n"))<
6
6
  I18n,
7
7
  ReturnType<MakeIntlReturn<string>["useIntl"]>
8
8
  >() {
package/src/makeClient.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import { type InvalidateOptions, type InvalidateQueryFilters, isCancelledError, type QueryObserverResult, type RefetchOptions, type UseQueryReturnType } from "@tanstack/vue-query"
3
3
  import { camelCase } from "change-case"
4
- import { Cause, Data, Effect, Exit, Layer, type ManagedRuntime, Match, Option, S, ServiceMap, Struct } from "effect-app"
4
+ import { Cause, Context, Data, Effect, Exit, Layer, type ManagedRuntime, Match, Option, S, Struct } from "effect-app"
5
5
  import { type ApiClientFactory, type Req } from "effect-app/client"
6
6
  import type { RequestHandler, RequestHandlers, RequestHandlerWithInput, Requests } from "effect-app/client/clientFor"
7
7
  import { ErrorSilenced, type SupportedErrors } from "effect-app/client/errors"
@@ -392,7 +392,7 @@ export const useMutationInt = (): typeof _useMutation => {
392
392
 
393
393
  export class LegacyMutationImpl<RT> {
394
394
  constructor(
395
- private readonly getRuntime: () => ServiceMap.ServiceMap<RT>,
395
+ private readonly getRuntime: () => Context.Context<RT>,
396
396
  private readonly toast: Toast,
397
397
  private readonly intl: I18n
398
398
  ) {}
@@ -1070,12 +1070,12 @@ export class LegacyMutationImpl<RT> {
1070
1070
  }
1071
1071
 
1072
1072
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
1073
- export class LegacyMutation extends ServiceMap.Service<LegacyMutation>()("LegacyMutation", {
1073
+ export class LegacyMutation extends Context.Service<LegacyMutation>()("LegacyMutation", {
1074
1074
  make: Effect.gen(function*() {
1075
1075
  const intl = yield* I18n
1076
1076
  const toast = yield* Toast
1077
1077
 
1078
- return <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => new LegacyMutationImpl(getRuntime, toast, intl)
1078
+ return <R>(getRuntime: () => Context.Context<R>) => new LegacyMutationImpl(getRuntime, toast, intl)
1079
1079
  })
1080
1080
  }) {
1081
1081
  static readonly DefaultWithoutDependencies = Layer.effect(this, this.make)
@@ -1085,7 +1085,7 @@ export class LegacyMutation extends ServiceMap.Service<LegacyMutation>()("Legacy
1085
1085
  export type ClientFrom<M extends Requests> = RequestHandlers<never, never, M, M["meta"]["moduleName"]>
1086
1086
 
1087
1087
  export class QueryImpl<R> {
1088
- constructor(readonly getRuntime: () => ServiceMap.ServiceMap<R>) {
1088
+ constructor(readonly getRuntime: () => Context.Context<R>) {
1089
1089
  this.useQuery = makeQuery(this.getRuntime)
1090
1090
  }
1091
1091
  /**
package/src/query.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable @typescript-eslint/no-unsafe-return */
4
4
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
5
5
  import { type DefaultError, type Enabled, type InitialDataFunction, type NonUndefinedGuard, type PlaceholderDataFunction, type QueryKey, type QueryObserverOptions, type QueryObserverResult, type RefetchOptions, useQuery as useTanstackQuery, useQueryClient, type UseQueryDefinedReturnType, type UseQueryReturnType } from "@tanstack/vue-query"
6
- import { Array, Cause, Effect, Option, S, type ServiceMap } from "effect-app"
6
+ import { Array, Cause, type Context, Effect, Option, S } from "effect-app"
7
7
  import { type Req } from "effect-app/client"
8
8
  import type { RequestHandler, RequestHandlerWithInput } from "effect-app/client/clientFor"
9
9
  import { ServiceUnavailableError } from "effect-app/client/errors"
@@ -83,7 +83,7 @@ export class KnownFiberFailure<E> extends Error {
83
83
  }
84
84
  }
85
85
 
86
- export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
86
+ export const makeQuery = <R>(getRuntime: () => Context.Context<R>) => {
87
87
  const useQuery_: {
88
88
  <I, A, E, Request extends Req, Name extends string>(
89
89
  q:
package/src/runtime.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Exit, flow, ManagedRuntime } from "effect"
2
2
  import { Effect, Layer, Logger } from "effect-app"
3
- import { type ServiceMap } from "effect-app/ServiceMap"
3
+ import { type Context } from "effect-app/Context"
4
4
  import { KnownFiberFailure } from "./query.js"
5
5
 
6
6
  export function makeAppRuntime<A, E>(layer: Layer.Layer<A, E>) {
@@ -33,7 +33,7 @@ export function initializeAsync<A, E>(layer: Layer.Layer<A, E, never>) {
33
33
  }
34
34
 
35
35
  // we wrap into KnownFiberFailure because we want to keep the full cause of the failure.
36
- export const makeRunPromise = <T>(services: ServiceMap<T>) =>
36
+ export const makeRunPromise = <T>(services: Context<T>) =>
37
37
  flow(Effect.runPromiseExitWith(services), (_) =>
38
38
  _.then(
39
39
  Exit.match({
@@ -42,7 +42,7 @@ export const makeRunPromise = <T>(services: ServiceMap<T>) =>
42
42
  })
43
43
  ))
44
44
 
45
- export const makeRunSync = <T>(services: ServiceMap<T>) =>
45
+ export const makeRunSync = <T>(services: Context<T>) =>
46
46
  flow(
47
47
  Effect.runSyncExitWith(services),
48
48
  Exit.match({
package/src/toast.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Effect, Option, ServiceMap } from "effect-app"
2
- import { proxify } from "effect-app/ServiceMap"
1
+ import { Context, Effect, Option } from "effect-app"
2
+ import { proxify } from "effect-app/Context"
3
3
 
4
4
  export type ToastId = string | number
5
5
  export type ToastOpts = { id?: ToastId; timeout?: number }
@@ -13,7 +13,7 @@ export type UseToast = () => {
13
13
  dismiss: (this: void, id: ToastId) => void
14
14
  }
15
15
 
16
- export class CurrentToastId extends ServiceMap.Opaque<CurrentToastId, { toastId: ToastId }>()("CurrentToastId") {}
16
+ export class CurrentToastId extends Context.Opaque<CurrentToastId, { toastId: ToastId }>()("CurrentToastId") {}
17
17
 
18
18
  /** fallback to CurrentToastId when available unless id is explicitly set to a value or null */
19
19
  export const wrap = (toast: ReturnType<UseToast>) => {
@@ -42,7 +42,7 @@ export const wrap = (toast: ReturnType<UseToast>) => {
42
42
  }
43
43
 
44
44
  export class Toast
45
- extends proxify(ServiceMap.Opaque<Toast, ReturnType<typeof wrap>>()("Toast"))<Toast, ReturnType<typeof wrap>>()
45
+ extends proxify(Context.Opaque<Toast, ReturnType<typeof wrap>>()("Toast"))<Toast, ReturnType<typeof wrap>>()
46
46
  {
47
47
  }
48
48
 
package/src/withToast.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Cause, Effect, Layer, type Option, ServiceMap } from "effect-app"
1
+ import { Cause, Context, Effect, Layer, type Option } from "effect-app"
2
2
  import { wrapEffect } from "effect-app/utils"
3
3
  import { CurrentToastId, Toast } from "./toast.js"
4
4
 
@@ -33,7 +33,7 @@ export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, S
33
33
  }
34
34
 
35
35
  // @effect-diagnostics-next-line missingEffectServiceDependency:off
36
- export class WithToast extends ServiceMap.Service<WithToast>()("WithToast", {
36
+ export class WithToast extends Context.Service<WithToast>()("WithToast", {
37
37
  make: Effect.gen(function*() {
38
38
  const toast = yield* Toast
39
39
  return <A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(