@effect-app/vue 4.0.0-beta.190 → 4.0.0-beta.191
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 +2 -2
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +4 -4
- package/dist/form.d.ts +2 -2
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +1 -1
- package/dist/query.d.ts +3 -3
- package/dist/query.d.ts.map +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/withToast.d.ts +1 -1
- package/package.json +5 -7
- package/src/commander.ts +5 -5
- package/src/form.ts +1 -1
- package/src/query.ts +5 -5
- package/src/runtime.ts +3 -3
- package/test/Mutation.test.ts +71 -12
- package/test/dist/stubs.d.ts +6 -2
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/dist/stubs.js +26 -7
- package/test/makeClient.test.ts +1 -1
- package/test/streamFn.test.ts +33 -14
- package/test/stubs.ts +27 -6
- package/eslint.config.mjs +0 -24
package/test/stubs.ts
CHANGED
|
@@ -28,6 +28,16 @@ const fakeToastLayer = (toasts: any[] = []) =>
|
|
|
28
28
|
toasts.splice(idx, 1)
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
const scheduleAutoDismiss = (toast: any, timeout: number | undefined) => {
|
|
32
|
+
// Treat Infinity / undefined as "stays until explicitly replaced/dismissed".
|
|
33
|
+
// Node's setTimeout silently clamps Infinity to 1ms which would otherwise
|
|
34
|
+
// cause the toast to disappear before assertions can observe it.
|
|
35
|
+
if (timeout === undefined || !Number.isFinite(timeout)) return
|
|
36
|
+
toast.timeoutId = setTimeout(() => {
|
|
37
|
+
const i = toasts.indexOf(toast)
|
|
38
|
+
if (i > -1) toasts.splice(i, 1)
|
|
39
|
+
}, timeout)
|
|
40
|
+
}
|
|
31
41
|
const fakeToast =
|
|
32
42
|
(type: "error" | "warning" | "success" | "info") => (message: string, options?: Toast.ToastOpts) => {
|
|
33
43
|
const id = options?.id ?? Math.random().toString(36).substring(2, 15)
|
|
@@ -39,15 +49,11 @@ const fakeToastLayer = (toasts: any[] = []) =>
|
|
|
39
49
|
const toast = toasts[idx]
|
|
40
50
|
clearTimeout(toast.timeoutId)
|
|
41
51
|
Object.assign(toast, { type, message, options })
|
|
42
|
-
toast
|
|
43
|
-
toasts.splice(idx, 1)
|
|
44
|
-
}, options?.timeout ?? 3000)
|
|
52
|
+
scheduleAutoDismiss(toast, options?.timeout ?? 3000)
|
|
45
53
|
} else {
|
|
46
54
|
const toast: any = { id, type, message, options }
|
|
47
|
-
toast.timeoutId = setTimeout(() => {
|
|
48
|
-
toasts.splice(idx, 1)
|
|
49
|
-
}, options?.timeout ?? 3000)
|
|
50
55
|
toasts.push(toast)
|
|
56
|
+
scheduleAutoDismiss(toast, options?.timeout ?? 3000)
|
|
51
57
|
}
|
|
52
58
|
return id
|
|
53
59
|
}
|
|
@@ -94,6 +100,21 @@ export const useExperimental = (
|
|
|
94
100
|
return Effect.runSync(makeUseCommand<WithToast | Toast.Toast | I18n>(Layer.empty).pipe(Effect.provide(layers)))
|
|
95
101
|
}
|
|
96
102
|
|
|
103
|
+
// Effect-returning variant: keeps the caller's runtime context (e.g. a TestClock
|
|
104
|
+
// provided by `it.effect`) so virtual-time advances reach the runtime captured
|
|
105
|
+
// inside Commander.
|
|
106
|
+
export const useExperimentalE = (
|
|
107
|
+
options?: { messages?: Record<string, string> | Record<string, MessageFormatElement[]>; toasts: any[] }
|
|
108
|
+
) => {
|
|
109
|
+
const FakeIntlLayer = fakeIntlLayer(options?.messages)
|
|
110
|
+
const FakeToastLayer = fakeToastLayer(options?.toasts)
|
|
111
|
+
const CommanderLayer = Commander.Default.pipe(Layer.provide([FakeIntlLayer, FakeToastLayer]))
|
|
112
|
+
const WithToastLayer = WithToast.Default.pipe(Layer.provide(FakeToastLayer))
|
|
113
|
+
const layers = Layer.mergeAll(CommanderLayer, WithToastLayer, FakeToastLayer, FakeIntlLayer)
|
|
114
|
+
|
|
115
|
+
return makeUseCommand<WithToast | Toast.Toast | I18n>(Layer.empty).pipe(Effect.provide(layers))
|
|
116
|
+
}
|
|
117
|
+
|
|
97
118
|
export class RequestContextMap extends RpcContextMap.makeMap({}) {}
|
|
98
119
|
export const { TaggedRequestFor } = makeRpcClient(RequestContextMap)
|
|
99
120
|
|
package/eslint.config.mjs
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { augmentedConfig } from "@effect-app/eslint-shared-config/eslint.base.config"
|
|
2
|
-
import path from "node:path"
|
|
3
|
-
import { fileURLToPath } from "node:url"
|
|
4
|
-
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
6
|
-
const __dirname = path.dirname(__filename)
|
|
7
|
-
|
|
8
|
-
export default [
|
|
9
|
-
...augmentedConfig(__dirname, false),
|
|
10
|
-
{
|
|
11
|
-
ignores: [
|
|
12
|
-
"**/*.js",
|
|
13
|
-
"**/*.jsx",
|
|
14
|
-
"**/*.d.ts",
|
|
15
|
-
"node_modules/"
|
|
16
|
-
]
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
rules: {
|
|
20
|
-
"@typescript-eslint/no-empty-interface": "off",
|
|
21
|
-
"@typescript-eslint/no-explicit-any": "warn"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
]
|