@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/CHANGELOG.md +15 -0
- package/dist/commander.d.ts +8 -8
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +7 -7
- package/dist/confirm.d.ts +2 -2
- package/dist/confirm.d.ts.map +1 -1
- package/dist/confirm.js +3 -3
- package/dist/intl.d.ts +2 -2
- package/dist/intl.d.ts.map +1 -1
- package/dist/intl.js +4 -4
- package/dist/makeClient.d.ts +6 -6
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +3 -3
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +1 -1
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/toast.d.ts +3 -3
- package/dist/toast.d.ts.map +1 -1
- package/dist/toast.js +5 -5
- package/dist/withToast.d.ts +2 -2
- package/dist/withToast.d.ts.map +1 -1
- package/dist/withToast.js +3 -3
- package/package.json +2 -2
- package/src/commander.ts +11 -11
- package/src/confirm.ts +2 -2
- package/src/intl.ts +3 -3
- package/src/makeClient.ts +5 -5
- package/src/query.ts +2 -2
- package/src/runtime.ts +3 -3
- package/src/toast.ts +4 -4
- package/src/withToast.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
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.
|
|
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
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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 =
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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
|
|
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 {
|
|
2
|
-
import { proxify } from "effect-app/
|
|
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(
|
|
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,
|
|
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: () =>
|
|
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
|
|
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: () =>
|
|
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: () =>
|
|
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
|
|
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: () =>
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
2
|
-
import { proxify } from "effect-app/
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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>(
|