functype-react 1.21.0 → 1.22.0

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 (82) hide show
  1. package/README.md +17 -20
  2. package/dist/TaskState-DWxGWqXf.d.ts +24 -0
  3. package/dist/async/TaskState.d.ts +2 -0
  4. package/dist/async/index.d.ts +9 -7
  5. package/dist/async/index.js +1 -1
  6. package/dist/async/index.js.map +1 -1
  7. package/dist/async/useTask.d.ts +24 -0
  8. package/dist/async/useTask.js +2 -0
  9. package/dist/async/useTask.js.map +1 -0
  10. package/dist/async/useTaskPromise.d.ts +14 -0
  11. package/dist/async/useTaskPromise.js +2 -0
  12. package/dist/async/useTaskPromise.js.map +1 -0
  13. package/dist/async/useTaskValue.d.ts +24 -0
  14. package/dist/async/useTaskValue.js +2 -0
  15. package/dist/async/useTaskValue.js.map +1 -0
  16. package/dist/{eq-CR56QmPb.d.ts → eq-CK6oQqWG.d.ts} +3 -1
  17. package/dist/forms/Validated.d.ts +2 -0
  18. package/dist/forms/Validated.js.map +1 -1
  19. package/dist/forms/useValidatedField.d.ts +2 -0
  20. package/dist/forms/useValidatedField.js.map +1 -1
  21. package/dist/forms/useValidatedForm.d.ts +2 -0
  22. package/dist/forms/useValidatedForm.js.map +1 -1
  23. package/dist/hooks/eq.d.ts +1 -1
  24. package/dist/hooks/eq.js.map +1 -1
  25. package/dist/hooks/index.d.ts +9 -9
  26. package/dist/hooks/useEither.d.ts +1 -1
  27. package/dist/hooks/useEither.js.map +1 -1
  28. package/dist/hooks/useList.d.ts +1 -1
  29. package/dist/hooks/useList.js.map +1 -1
  30. package/dist/hooks/useOption.d.ts +1 -1
  31. package/dist/hooks/useOption.js.map +1 -1
  32. package/dist/hooks/useStableCallback.d.ts +1 -1
  33. package/dist/hooks/useStableCallback.js.map +1 -1
  34. package/dist/hooks/useStableEffect.d.ts +1 -1
  35. package/dist/hooks/useStableEffect.js.map +1 -1
  36. package/dist/hooks/useStableMemo.d.ts +1 -1
  37. package/dist/hooks/useStableMemo.js.map +1 -1
  38. package/dist/hooks/useStableState.d.ts +1 -1
  39. package/dist/hooks/useStableState.js.map +1 -1
  40. package/dist/hooks/useTry.d.ts +1 -1
  41. package/dist/hooks/useTry.js.map +1 -1
  42. package/dist/{index-Dr09mq-A.d.ts → index-DjzwkXMF.d.ts} +9 -1
  43. package/dist/index.d.ts +10 -10
  44. package/dist/match/index.d.ts +1 -1
  45. package/dist/match/index.js +1 -1
  46. package/dist/match-CkGESkj9.js.map +1 -1
  47. package/dist/query/IOQueryError.d.ts +2 -0
  48. package/dist/query/IOQueryError.js.map +1 -1
  49. package/dist/query/ioQueryFn.d.ts +4 -3
  50. package/dist/query/ioQueryFn.js +1 -1
  51. package/dist/query/ioQueryFn.js.map +1 -1
  52. package/dist/query/queryState.d.ts +10 -8
  53. package/dist/query/queryState.js.map +1 -1
  54. package/dist/query/useIOMutation.d.ts +2 -0
  55. package/dist/query/useIOMutation.js.map +1 -1
  56. package/dist/query/useIOMutationState.d.ts +6 -4
  57. package/dist/query/useIOMutationState.js.map +1 -1
  58. package/dist/query/useIOQuery.d.ts +2 -0
  59. package/dist/query/useIOQuery.js.map +1 -1
  60. package/dist/query/useIOQueryState.d.ts +7 -5
  61. package/dist/query/useIOQueryState.js.map +1 -1
  62. package/dist/{useEither-D1Rn_tLR.d.ts → useEither-DyPW7OaA.d.ts} +3 -1
  63. package/dist/{useList-C_7X5OA_.d.ts → useList-B5Iox1xv.d.ts} +3 -1
  64. package/dist/{useOption-B8UyOh8h.d.ts → useOption-CXXNC1_S.d.ts} +3 -1
  65. package/dist/{useStableCallback-C5jd1hKf.d.ts → useStableCallback-CXQQOhl6.d.ts} +4 -2
  66. package/dist/{useStableEffect-BiDhoNpC.d.ts → useStableEffect-C-5NCd1T.d.ts} +4 -2
  67. package/dist/{useStableMemo-DCeNIpt5.d.ts → useStableMemo-PYyLBWwd.d.ts} +4 -2
  68. package/dist/{useStableState-BPVQ-XMX.d.ts → useStableState-fi6nURHS.d.ts} +4 -2
  69. package/dist/{useTry-ie1X0NiH.d.ts → useTry-B0HIcFFb.d.ts} +3 -1
  70. package/package.json +10 -10
  71. package/dist/AsyncState-DxKw9NF6.d.ts +0 -21
  72. package/dist/async/AsyncState.d.ts +0 -2
  73. package/dist/async/useIO.d.ts +0 -27
  74. package/dist/async/useIO.js +0 -2
  75. package/dist/async/useIO.js.map +0 -1
  76. package/dist/async/useIOPromise.d.ts +0 -15
  77. package/dist/async/useIOPromise.js +0 -2
  78. package/dist/async/useIOPromise.js.map +0 -1
  79. package/dist/async/useIOValue.d.ts +0 -24
  80. package/dist/async/useIOValue.js +0 -2
  81. package/dist/async/useIOValue.js.map +0 -1
  82. /package/dist/async/{AsyncState.js → TaskState.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype-react",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "React bindings for functype — ADT-aware hooks and exhaustive pattern matching components",
5
5
  "keywords": [
6
6
  "functype",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@tanstack/react-query": ">=5.0.0",
30
- "functype": ">=1.14.0",
30
+ "functype": ">=0.60.0",
31
31
  "react": ">=18.0.0 <20.0.0",
32
32
  "react-dom": ">=18.0.0 <20.0.0"
33
33
  },
@@ -40,20 +40,20 @@
40
40
  }
41
41
  },
42
42
  "devDependencies": {
43
- "@tanstack/react-query": "^5.104.5",
43
+ "@tanstack/react-query": "^5.104.1",
44
44
  "@testing-library/dom": "^10.4.2",
45
45
  "@testing-library/jest-dom": "^7.0.1",
46
46
  "@testing-library/react": "^16.3.3",
47
- "@types/node": "^24.19.2",
47
+ "@types/node": "^24.19.1",
48
48
  "@types/react": "^19.3.0",
49
49
  "@types/react-dom": "^19.3.0",
50
50
  "fast-check": "^4.10.2",
51
- "functype": "^1.21.0",
52
- "jsdom": "^30.1.3",
53
- "react": "^19.3.1",
54
- "react-dom": "^19.3.1",
55
- "ts-builds": "^4.0.0",
56
- "tsdown": "^0.23.2"
51
+ "functype": "^1.22.0",
52
+ "jsdom": "^30.1.1",
53
+ "react": "^19.3.0",
54
+ "react-dom": "^19.3.0",
55
+ "ts-builds": "^3.4.3",
56
+ "tsdown": "^0.23.0"
57
57
  },
58
58
  "type": "module",
59
59
  "main": "./dist/index.js",
@@ -1,21 +0,0 @@
1
- /**
2
- * Lifecycle state of an async operation managed by `useIO` (and the query hooks'
3
- * `toQueryState` / `useIOQueryState` projections).
4
- *
5
- * `Idle` is before the first run, `Pending` while it's in flight, then `Success` or
6
- * `Failure`. A cancelled run (unmount, or `deps` changing) never reaches `Failure`: its
7
- * result is discarded.
8
- */
9
- type AsyncState<E, A> = {
10
- readonly _tag: "Idle";
11
- } | {
12
- readonly _tag: "Pending";
13
- } | {
14
- readonly _tag: "Success";
15
- readonly value: A;
16
- } | {
17
- readonly _tag: "Failure";
18
- readonly error: E;
19
- };
20
- export { AsyncState as t };
21
- //# sourceMappingURL=AsyncState-DxKw9NF6.d.ts.map
@@ -1,2 +0,0 @@
1
- import { t as AsyncState } from "../AsyncState-DxKw9NF6.js";
2
- export { AsyncState };
@@ -1,27 +0,0 @@
1
- import { t as AsyncState } from "../AsyncState-DxKw9NF6.js";
2
- import { IO } from "functype/io";
3
- export type UseIOResult<E, A> = AsyncState<E, A> & {
4
- readonly isIdle: boolean;
5
- readonly isPending: boolean;
6
- readonly isSuccess: boolean;
7
- readonly isFailure: boolean;
8
- refetch: () => void;
9
- };
10
- /**
11
- * Runs an `IO<never, E, A>` tied to a component's lifecycle and returns its `AsyncState`,
12
- * plus boolean flags and a `refetch` trigger.
13
- *
14
- * - The factory receives an `AbortSignal` that aborts on unmount or when `deps` change.
15
- * The effect is cancelled with it: no further step runs once it fires. Also pass it to
16
- * `Http` / `IO.tryAsync` so an in-flight request aborts too.
17
- * - A cancelled run's result is discarded, so it never shows up as `Failure`.
18
- * - A typed failure becomes `Failure` with the effect's `E`.
19
- * - A defect (a bug: a throw inside the effect, or the factory throwing while building it)
20
- * is rethrown during render, so the nearest error boundary catches it, the way a bug in
21
- * any other component would surface.
22
- * - StrictMode-safe: the cleanup aborts the signal and discards any late result.
23
- *
24
- * @interop React reaches an error boundary only through a throw during render, so a defect is rethrown there.
25
- */
26
- export declare function useIO<E, A>(io: (signal: AbortSignal) => IO<never, E, A>, deps: ReadonlyArray<unknown>): UseIOResult<E, A>;
27
- //# sourceMappingURL=useIO.d.ts.map
@@ -1,2 +0,0 @@
1
- "use client";import{useCallback as e,useEffect as t,useReducer as n,useRef as r,useState as i}from"react";import{Try as a}from"functype";function o(e,t){return t.type===`PENDING`?{_tag:`Pending`}:t.type===`SUCCESS`?{_tag:`Success`,value:t.value}:{_tag:`Failure`,error:t.error}}function s(s,c){let[l,u]=n(o,{_tag:`Idle`}),[d,f]=i(void 0),[p,m]=n(e=>e+1,0),h=r(s);h.current=s,t(()=>{let e=new AbortController;u({type:`PENDING`});let t=t=>{e.signal.aborted||t.fold(e=>u({type:`FAILURE`,error:e}),e=>u({type:`SUCCESS`,value:e}),()=>f({value:/* @__PURE__ */ Error(`useIO: the effect interrupted itself`)}),e=>f({value:e}))};return a(()=>h.current(e.signal)).fold(e=>f({value:e}),n=>void n.runExit({signal:e.signal}).then(t)),()=>e.abort()},[...c,p]);let g=e(()=>m(),[]);if(d)throw d.value;return{...l,isIdle:l._tag===`Idle`,isPending:l._tag===`Pending`,isSuccess:l._tag===`Success`,isFailure:l._tag===`Failure`,refetch:g}}export{s as useIO};
2
- //# sourceMappingURL=useIO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIO.js","names":["reducer","action","useIO","state","dispatch","useReducer","defect","setDefect","useState","refetchTick","forceRefetch","n","ioRef","useRef","io","useEffect","controller","settle","exit","Try","thrown","effect","deps","refetch","useCallback"],"sources":["../../src/async/useIO.ts"],"sourcesContent":["\"use client\"\n\nimport { Try } from \"functype\"\nimport type { Exit, IO } from \"functype/io\"\nimport { useCallback, useEffect, useReducer, useRef, useState } from \"react\"\n\nimport type { AsyncState } from \"./AsyncState\"\n\ntype Action<E, A> =\n | { readonly type: \"PENDING\" }\n | { readonly type: \"SUCCESS\"; readonly value: A }\n | { readonly type: \"FAILURE\"; readonly error: E }\n\nfunction reducer<E, A>(_state: AsyncState<E, A>, action: Action<E, A>): AsyncState<E, A> {\n if (action.type === \"PENDING\") return { _tag: \"Pending\" }\n if (action.type === \"SUCCESS\") return { _tag: \"Success\", value: action.value }\n return { _tag: \"Failure\", error: action.error }\n}\n\nexport type UseIOResult<E, A> = AsyncState<E, A> & {\n readonly isIdle: boolean\n readonly isPending: boolean\n readonly isSuccess: boolean\n readonly isFailure: boolean\n refetch: () => void\n}\n\n/**\n * Runs an `IO<never, E, A>` tied to a component's lifecycle and returns its `AsyncState`,\n * plus boolean flags and a `refetch` trigger.\n *\n * - The factory receives an `AbortSignal` that aborts on unmount or when `deps` change.\n * The effect is cancelled with it: no further step runs once it fires. Also pass it to\n * `Http` / `IO.tryAsync` so an in-flight request aborts too.\n * - A cancelled run's result is discarded, so it never shows up as `Failure`.\n * - A typed failure becomes `Failure` with the effect's `E`.\n * - A defect (a bug: a throw inside the effect, or the factory throwing while building it)\n * is rethrown during render, so the nearest error boundary catches it, the way a bug in\n * any other component would surface.\n * - StrictMode-safe: the cleanup aborts the signal and discards any late result.\n *\n * @interop React reaches an error boundary only through a throw during render, so a defect is rethrown there.\n */\nexport function useIO<E, A>(\n io: (signal: AbortSignal) => IO<never, E, A>,\n deps: ReadonlyArray<unknown>,\n): UseIOResult<E, A> {\n const [state, dispatch] = useReducer(reducer<E, A>, { _tag: \"Idle\" })\n const [defect, setDefect] = useState<{ readonly value: unknown } | undefined>(undefined)\n const [refetchTick, forceRefetch] = useReducer((n: number) => n + 1, 0)\n const ioRef = useRef(io)\n ioRef.current = io\n\n useEffect(() => {\n const controller = new AbortController()\n dispatch({ type: \"PENDING\" })\n\n const settle = (exit: Exit<E, A>): void => {\n if (controller.signal.aborted) return\n exit.fold(\n (error) => dispatch({ type: \"FAILURE\", error }),\n (value) => dispatch({ type: \"SUCCESS\", value }),\n // Interrupted without an abort means the effect interrupted itself (IO.interrupt()):\n // there is no value and no E, so it is reported like a defect.\n () => setDefect({ value: new Error(\"useIO: the effect interrupted itself\") }),\n (defect) => setDefect({ value: defect }),\n )\n }\n\n // The factory is user code and can throw while building the effect; that's a defect too.\n Try(() => ioRef.current(controller.signal)).fold(\n (thrown) => setDefect({ value: thrown }),\n (effect) => void effect.runExit({ signal: controller.signal }).then(settle),\n )\n\n return () => controller.abort()\n }, [...deps, refetchTick])\n\n const refetch = useCallback(() => forceRefetch(), [])\n\n if (defect) throw defect.value\n\n return {\n ...state,\n isIdle: state._tag === \"Idle\",\n isPending: state._tag === \"Pending\",\n isSuccess: state._tag === \"Success\",\n isFailure: state._tag === \"Failure\",\n refetch,\n }\n}\n"],"mappings":"A,yIAaA,SAASA,EAAc,EAA0B,EAAwC,CAGvF,OAFIC,EAAO,OAAS,UAAkB,CAAE,KAAM,SAAU,EACpDA,EAAO,OAAS,UAAkB,CAAE,KAAM,UAAW,MAAOA,EAAO,KAAM,EACtE,CAAE,KAAM,UAAW,MAAOA,EAAO,KAAM,CAChD,CA0BA,SAAgBC,EACd,EACA,EACmB,CACnB,GAAM,CAACC,EAAOC,GAAYC,EAAWL,EAAe,CAAE,KAAM,MAAO,CAAC,EAC9D,CAACM,EAAQC,GAAaC,EAAkD,IAAA,EAAS,EACjF,CAACC,EAAaC,GAAgBL,EAAY,GAAcM,EAAI,EAAG,CAAC,EAChEC,EAAQC,EAAOC,CAAE,EACvB,EAAM,QAAUA,EAEhBC,MAAgB,CACd,IAAMC,EAAa,IAAI,gBACvBZ,EAAS,CAAE,KAAM,SAAU,CAAC,EAE5B,IAAMa,EAAU,GAA2B,CACrCD,EAAW,OAAO,SACtBE,EAAK,KACF,GAAUd,EAAS,CAAE,KAAM,UAAW,OAAM,CAAC,EAC7C,GAAUA,EAAS,CAAE,KAAM,UAAW,OAAM,CAAC,MAGxCG,EAAU,CAAE,MAAO,gBAAI,MAAM,sCAAsC,CAAE,CAAC,EAC3E,GAAWA,EAAU,CAAE,MAAOD,CAAO,CAAC,CACzC,CACF,EAQA,OALAa,MAAUP,EAAM,QAAQI,EAAW,MAAM,CAAC,CAAC,CAAC,KACzC,GAAWT,EAAU,CAAE,MAAOa,CAAO,CAAC,EACtC,GAAW,KAAKC,EAAO,QAAQ,CAAE,OAAQL,EAAW,MAAO,CAAC,CAAC,CAAC,KAAKC,CAAM,CAC5E,MAEaD,EAAW,MAAM,CAChC,EAAG,CAAC,GAAGM,EAAMb,CAAW,CAAC,EAEzB,IAAMc,EAAUC,MAAkBd,EAAa,EAAG,CAAC,CAAC,EAEpD,GAAIJ,EAAQ,MAAMA,EAAO,MAEzB,MAAO,CACL,GAAGH,EACH,OAAQA,EAAM,OAAS,OACvB,UAAWA,EAAM,OAAS,UAC1B,UAAWA,EAAM,OAAS,UAC1B,UAAWA,EAAM,OAAS,UAC1B,SACF,CACF,C"}
@@ -1,15 +0,0 @@
1
- import { Exit, IO } from "functype/io";
2
- /**
3
- * Starts an `IO<never, E, A>` and returns a `Promise<Exit<E, A>>` that is stable across
4
- * renders with the same `deps`. Intended for React 19's `use()`: a new promise on each
5
- * render would suspend forever.
6
- *
7
- * `Exit` keeps a typed failure, a defect and an interruption apart, so a consumer can tell
8
- * them apart; `useIOValue` does that for you.
9
- *
10
- * The factory is read through a ref, so the latest closure runs even if it isn't in `deps`.
11
- * Put in `deps` whatever changes the result. The factory receives an `AbortSignal` for
12
- * `Http` / `IO.tryAsync`; `useMemo` has no cleanup, so nothing aborts it on unmount.
13
- */
14
- export declare function useIOPromise<E, A>(io: (signal: AbortSignal) => IO<never, E, A>, deps: ReadonlyArray<unknown>): Promise<Exit<E, A>>;
15
- //# sourceMappingURL=useIOPromise.d.ts.map
@@ -1,2 +0,0 @@
1
- "use client";import{useMemo as e,useRef as t}from"react";function n(n,r){let i=t(n);return i.current=n,e(()=>{let e=new AbortController;return i.current(e.signal).runExit({signal:e.signal})},r)}export{n as useIOPromise};
2
- //# sourceMappingURL=useIOPromise.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIOPromise.js","names":["useIOPromise","ioRef","useRef","io","useMemo","controller","deps"],"sources":["../../src/async/useIOPromise.ts"],"sourcesContent":["\"use client\"\n\nimport type { Exit, IO } from \"functype/io\"\nimport { useMemo, useRef } from \"react\"\n\n/**\n * Starts an `IO<never, E, A>` and returns a `Promise<Exit<E, A>>` that is stable across\n * renders with the same `deps`. Intended for React 19's `use()`: a new promise on each\n * render would suspend forever.\n *\n * `Exit` keeps a typed failure, a defect and an interruption apart, so a consumer can tell\n * them apart; `useIOValue` does that for you.\n *\n * The factory is read through a ref, so the latest closure runs even if it isn't in `deps`.\n * Put in `deps` whatever changes the result. The factory receives an `AbortSignal` for\n * `Http` / `IO.tryAsync`; `useMemo` has no cleanup, so nothing aborts it on unmount.\n */\nexport function useIOPromise<E, A>(\n io: (signal: AbortSignal) => IO<never, E, A>,\n deps: ReadonlyArray<unknown>,\n): Promise<Exit<E, A>> {\n const ioRef = useRef(io)\n ioRef.current = io\n\n return useMemo(() => {\n const controller = new AbortController()\n return ioRef.current(controller.signal).runExit({ signal: controller.signal })\n }, deps)\n}\n"],"mappings":"A,yDAiBA,SAAgBA,EACd,EACA,EACqB,CACrB,IAAMC,EAAQC,EAAOC,CAAE,EAGvB,MAFA,GAAM,QAAUA,EAETC,MAAc,CACnB,IAAMC,EAAa,IAAI,gBACvB,OAAOJ,EAAM,QAAQI,EAAW,MAAM,CAAC,CAAC,QAAQ,CAAE,OAAQA,EAAW,MAAO,CAAC,CAC/E,EAAGC,CAAI,CACT,C"}
@@ -1,24 +0,0 @@
1
- import { IO } from "functype/io";
2
- /**
3
- * Suspense-aware variant of `useIO` for React 19+. Suspends while the effect is pending and
4
- * returns its value. On failure it throws the typed error; on a defect, the defect; on an
5
- * interruption, an `InterruptedError`. All three reach `<AsyncBoundary>` (or a hand-rolled
6
- * Suspense + ErrorBoundary pair).
7
- *
8
- * Invariants enforced by React 19:
9
- * 1. The promise must be stable across renders. `useIOPromise` memoizes by `deps`, so
10
- * passing the same deps yields the same promise.
11
- * 2. An ErrorBoundary must wrap the Suspense, never the reverse — otherwise Suspense will
12
- * catch the thrown error instead of the boundary.
13
- * 3. Do not call this on the server. Build the `IO` in a Client Component and call
14
- * `useIOValue` there.
15
- *
16
- * @interop React's `use()` reaches the nearest ErrorBoundary only through a throw, not an Either return.
17
- *
18
- * Testing note: React 19's `use()` does not unsuspend reliably under jsdom +
19
- * @testing-library/react. End-to-end tests of `useIOValue` + `<AsyncBoundary>` require a
20
- * real browser scheduler (Playwright); unit tests of `useIO` and `useIOPromise` cover the
21
- * plumbing.
22
- */
23
- export declare function useIOValue<E, A>(io: (signal: AbortSignal) => IO<never, E, A>, deps: ReadonlyArray<unknown>): A;
24
- //# sourceMappingURL=useIOValue.d.ts.map
@@ -1,2 +0,0 @@
1
- "use client";import{useIOPromise as e}from"./useIOPromise.js";import{use as t}from"react";import{InterruptedError as n}from"functype/io";function r(r,i){let a=t(e(r,i));if(a.isSuccess())return a.orThrow();throw a.isFailure()?a.toValue().error:a.isDie()?a.toValue().defect:new n}export{r as useIOValue};
2
- //# sourceMappingURL=useIOValue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useIOValue.js","names":["useIOValue","exit","use","useIOPromise","io","deps","InterruptedError"],"sources":["../../src/async/useIOValue.ts"],"sourcesContent":["\"use client\"\n\nimport { InterruptedError, type IO } from \"functype/io\"\nimport { use } from \"react\"\n\nimport { useIOPromise } from \"./useIOPromise\"\n\n/**\n * Suspense-aware variant of `useIO` for React 19+. Suspends while the effect is pending and\n * returns its value. On failure it throws the typed error; on a defect, the defect; on an\n * interruption, an `InterruptedError`. All three reach `<AsyncBoundary>` (or a hand-rolled\n * Suspense + ErrorBoundary pair).\n *\n * Invariants enforced by React 19:\n * 1. The promise must be stable across renders. `useIOPromise` memoizes by `deps`, so\n * passing the same deps yields the same promise.\n * 2. An ErrorBoundary must wrap the Suspense, never the reverse — otherwise Suspense will\n * catch the thrown error instead of the boundary.\n * 3. Do not call this on the server. Build the `IO` in a Client Component and call\n * `useIOValue` there.\n *\n * @interop React's `use()` reaches the nearest ErrorBoundary only through a throw, not an Either return.\n *\n * Testing note: React 19's `use()` does not unsuspend reliably under jsdom +\n * @testing-library/react. End-to-end tests of `useIOValue` + `<AsyncBoundary>` require a\n * real browser scheduler (Playwright); unit tests of `useIO` and `useIOPromise` cover the\n * plumbing.\n */\nexport function useIOValue<E, A>(io: (signal: AbortSignal) => IO<never, E, A>, deps: ReadonlyArray<unknown>): A {\n const exit = use(useIOPromise(io, deps))\n if (exit.isSuccess()) return exit.orThrow()\n if (exit.isFailure()) throw exit.toValue().error\n if (exit.isDie()) throw exit.toValue().defect\n throw new InterruptedError()\n}\n"],"mappings":"A,yIA4BA,SAAgBA,EAAiB,EAA8C,EAAiC,CAC9G,IAAMC,EAAOC,EAAIC,EAAaC,EAAIC,CAAI,CAAC,EACvC,GAAIJ,EAAK,UAAU,EAAG,OAAOA,EAAK,QAAQ,EAG1C,MAFIA,EAAK,UAAU,EAASA,EAAK,QAAQ,CAAC,CAAC,MACvCA,EAAK,MAAM,EAASA,EAAK,QAAQ,CAAC,CAAC,OACjC,IAAIK,CACZ,C"}
File without changes