@shivaedev/react 0.31.1 → 0.33.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 (122) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +80 -25
  3. package/dist/adapters/Forbidden.d.ts +10 -0
  4. package/dist/adapters/Forbidden.d.ts.map +1 -0
  5. package/dist/adapters/Forbidden.js +6 -0
  6. package/dist/adapters/Forbidden.js.map +1 -0
  7. package/dist/adapters/loadQuery.js +1 -1
  8. package/dist/adapters/loadQuery.js.map +1 -1
  9. package/dist/{client → adapters}/permissionBoundary.d.ts +3 -0
  10. package/dist/adapters/permissionBoundary.d.ts.map +1 -0
  11. package/dist/{client → adapters}/permissionBoundary.js +2 -2
  12. package/dist/adapters/permissionBoundary.js.map +1 -0
  13. package/dist/{permissionGuard.d.ts → adapters/permissionGuard.d.ts} +4 -3
  14. package/dist/adapters/permissionGuard.d.ts.map +1 -0
  15. package/dist/{permissionGuard.js → adapters/permissionGuard.js} +5 -5
  16. package/dist/adapters/permissionGuard.js.map +1 -0
  17. package/dist/{internal → adapters}/queryHandoff.d.ts.map +1 -1
  18. package/dist/{internal → adapters}/queryHandoff.js.map +1 -1
  19. package/dist/{queryRoute.d.ts → adapters/queryRoute.d.ts} +13 -7
  20. package/dist/adapters/queryRoute.d.ts.map +1 -0
  21. package/dist/adapters/queryRoute.js +21 -0
  22. package/dist/adapters/queryRoute.js.map +1 -0
  23. package/dist/adapters/queryRouteFailure.d.ts +10 -0
  24. package/dist/adapters/queryRouteFailure.d.ts.map +1 -0
  25. package/dist/adapters/queryRouteFailure.js +13 -0
  26. package/dist/adapters/queryRouteFailure.js.map +1 -0
  27. package/dist/adapters/screenPending.d.ts.map +1 -0
  28. package/dist/adapters/screenPending.js.map +1 -0
  29. package/dist/{internal → adapters}/useLoaderHandoff.d.ts.map +1 -1
  30. package/dist/{internal → adapters}/useLoaderHandoff.js.map +1 -1
  31. package/dist/adapters/useQueryRetry.d.ts +3 -0
  32. package/dist/adapters/useQueryRetry.d.ts.map +1 -0
  33. package/dist/adapters/useQueryRetry.js +10 -0
  34. package/dist/adapters/useQueryRetry.js.map +1 -0
  35. package/dist/client/adapters/SessionGeneration.d.ts +1 -1
  36. package/dist/client/adapters/SessionGeneration.d.ts.map +1 -1
  37. package/dist/client/adapters/SessionGeneration.js +2 -1
  38. package/dist/client/adapters/SessionGeneration.js.map +1 -1
  39. package/dist/client/adapters/useLiveWindow.d.ts +4 -0
  40. package/dist/client/adapters/useLiveWindow.d.ts.map +1 -0
  41. package/dist/client/adapters/useLiveWindow.js +16 -0
  42. package/dist/client/adapters/useLiveWindow.js.map +1 -0
  43. package/dist/client/adapters/useSignOut.d.ts.map +1 -0
  44. package/dist/client/{useSignOut.js → adapters/useSignOut.js} +1 -1
  45. package/dist/client/adapters/useSignOut.js.map +1 -0
  46. package/dist/client/authSession.d.ts +7 -3
  47. package/dist/client/authSession.d.ts.map +1 -1
  48. package/dist/client/authSession.js +20 -3
  49. package/dist/client/authSession.js.map +1 -1
  50. package/dist/client/create.d.ts.map +1 -1
  51. package/dist/client/create.js +7 -4
  52. package/dist/client/create.js.map +1 -1
  53. package/dist/client/editor.js +3 -3
  54. package/dist/client/editor.js.map +1 -1
  55. package/dist/client/mountLive.d.ts +3 -3
  56. package/dist/client/mountLive.d.ts.map +1 -1
  57. package/dist/client/mountLive.js +7 -4
  58. package/dist/client/mountLive.js.map +1 -1
  59. package/dist/client/resultState.d.ts.map +1 -1
  60. package/dist/client/resultState.js +3 -10
  61. package/dist/client/resultState.js.map +1 -1
  62. package/dist/client/saveState.d.ts +1 -1
  63. package/dist/client/saveState.d.ts.map +1 -1
  64. package/dist/client/saveState.js +1 -1
  65. package/dist/client/saveState.js.map +1 -1
  66. package/dist/client/useLoaderQuery.js +1 -1
  67. package/dist/client/useLoaderQuery.js.map +1 -1
  68. package/dist/internal/registerLiveWindow.d.ts +5 -0
  69. package/dist/internal/registerLiveWindow.d.ts.map +1 -0
  70. package/dist/internal/registerLiveWindow.js +31 -0
  71. package/dist/internal/registerLiveWindow.js.map +1 -0
  72. package/dist/permissions.d.ts +11 -6
  73. package/dist/permissions.d.ts.map +1 -1
  74. package/dist/permissions.js +5 -1
  75. package/dist/permissions.js.map +1 -1
  76. package/dist/submission.d.ts +1 -0
  77. package/dist/submission.d.ts.map +1 -1
  78. package/dist/submission.js +1 -0
  79. package/dist/submission.js.map +1 -1
  80. package/package.json +14 -14
  81. package/src/adapters/Forbidden.ts +26 -0
  82. package/src/adapters/loadQuery.ts +1 -1
  83. package/src/{client → adapters}/permissionBoundary.ts +2 -2
  84. package/src/{permissionGuard.ts → adapters/permissionGuard.ts} +6 -5
  85. package/src/adapters/queryRoute.ts +46 -0
  86. package/src/adapters/queryRouteFailure.ts +21 -0
  87. package/src/adapters/useQueryRetry.ts +10 -0
  88. package/src/client/adapters/SessionGeneration.ts +4 -2
  89. package/src/client/adapters/useLiveWindow.ts +17 -0
  90. package/src/client/{useSignOut.ts → adapters/useSignOut.ts} +1 -1
  91. package/src/client/authSession.ts +32 -6
  92. package/src/client/create.ts +10 -4
  93. package/src/client/editor.ts +3 -3
  94. package/src/client/mountLive.ts +8 -6
  95. package/src/client/resultState.ts +3 -10
  96. package/src/client/saveState.ts +2 -2
  97. package/src/client/useLoaderQuery.ts +1 -1
  98. package/src/internal/registerLiveWindow.ts +41 -0
  99. package/src/permissions.ts +6 -6
  100. package/src/submission.ts +2 -0
  101. package/dist/client/permissionBoundary.d.ts.map +0 -1
  102. package/dist/client/permissionBoundary.js.map +0 -1
  103. package/dist/client/screenPending.d.ts.map +0 -1
  104. package/dist/client/screenPending.js.map +0 -1
  105. package/dist/client/useSignOut.d.ts.map +0 -1
  106. package/dist/client/useSignOut.js.map +0 -1
  107. package/dist/permissionGuard.d.ts.map +0 -1
  108. package/dist/permissionGuard.js.map +0 -1
  109. package/dist/queryRoute.d.ts.map +0 -1
  110. package/dist/queryRoute.js +0 -21
  111. package/dist/queryRoute.js.map +0 -1
  112. package/src/queryRoute.ts +0 -35
  113. /package/dist/{internal → adapters}/queryHandoff.d.ts +0 -0
  114. /package/dist/{internal → adapters}/queryHandoff.js +0 -0
  115. /package/dist/{client → adapters}/screenPending.d.ts +0 -0
  116. /package/dist/{client → adapters}/screenPending.js +0 -0
  117. /package/dist/{internal → adapters}/useLoaderHandoff.d.ts +0 -0
  118. /package/dist/{internal → adapters}/useLoaderHandoff.js +0 -0
  119. /package/dist/client/{useSignOut.d.ts → adapters/useSignOut.d.ts} +0 -0
  120. /package/src/{internal → adapters}/queryHandoff.ts +0 -0
  121. /package/src/{client → adapters}/screenPending.ts +0 -0
  122. /package/src/{internal → adapters}/useLoaderHandoff.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.33.0 - 2026-11-02
4
+
5
+ ### Added
6
+
7
+ - Form and React submission configurations accept a `savedValues` mapping to normalize a successful submission against its captured baseline while retaining later field edits.
8
+ - Return a `useRetry` hook from `queryRoute` so a route's error component can refresh its query and render a successful result without rebuilding the query or replacing the surrounding shell.
9
+ - Accept optional `redirects.signedOut` and `redirects.refused` callbacks for native typed TanStack redirects. Signed-out redirects can preserve the full return location with `signInSearch`; refused reads handle both `Forbidden` and `QueryReadDenied`.
10
+
11
+ ### Fixed
12
+
13
+ - Editors preserve newer received baselines when an earlier save completes, and merge normalized saved fields without erasing later edits.
14
+ - Create forms retain optional keys removed while a submission is in flight when resetting their inputs.
15
+ - Keep live coalescing overrides owned by each query reader, so removing a reader restores the remaining reader's override. Clearing a session's live coalescing override restores the binding's original window.
16
+
17
+ ### Breaking
18
+
19
+ - Direct callers of `@shivaedev/react/client/mountLive.ts` now run `mountLive(client, window)` as an Effect requiring `AtomRegistry.AtomRegistry`, instead of passing the registry as its first argument. Provide the registry with `Effect.provideService(AtomRegistry.AtomRegistry, registry)` and call the returned cleanup when the reader unmounts.
20
+ - Direct calls to the loader returned by `queryRoute` now require `location` alongside `abortController`, context, deps and params. Pass the native TanStack loader context, or add the requested location to a custom loader invocation.
21
+
22
+ ## 0.32.0 - 2026-11-01
23
+
24
+ ### Added
25
+
26
+ - React exposes an Effect `PermissionSession` schema alongside its inferred session type, using access's shared permission codec.
27
+ - React session reads expose typed permission grants while preserving provider fields.
28
+ - React supplies `Forbidden` with a router link back to an allowed route, and `PermissionBoundaryError` for route failures inside the router.
29
+ - Identity's `betterAuthMount` accepts `onPasswordReset`, an Effect callback that runs with the host's context and composes after Better Auth's native reset callback.
30
+ - React's `permissionGuard` accepts `hidden: true` to render TanStack Router's not-found page when a signed-in viewer lacks a required permission.
31
+
32
+ ### Breaking
33
+
34
+ - React's `authSession` now requires a nullable session with a `user` object and validates its permission grants. Use `authQuery` for reads of other payload shapes; remove application session permission decoders when using `authSession`.
35
+ - `PermissionSession` is now a schema-derived type. Extend it with an intersection or an application interface rather than module augmentation.
36
+
3
37
  ## 0.31.1 - 2026-11-01
4
38
 
5
39
  ### Changed
package/README.md CHANGED
@@ -571,7 +571,7 @@ With native `RpcClient.layerProtocolHttp` and `FetchHttpClient.layer` as the bro
571
571
 
572
572
  #### Route loaders with TanStack Router
573
573
 
574
- TanStack Router owns routes, navigation, search validation, loader data and screen components. Spread `queryRoute(buildQuery)` from `@shivaedev/react/queryRoute.ts` into `createRoute` to derive loader dependencies from validated search and load a contract query atom in the router context’s registry. A `NotFound` instance from `@shivaedev/errors/taxonomy.ts` or a `QueryReadDenied` refusal enters TanStack's not-found handling with the original rejection in the not-found component's `data` prop, preserving its message. One root `notFoundComponent` can show that message for all query routes; a route's own `notFoundComponent` takes precedence. Other typed failures reach `errorComponent` unchanged. The atom runs through its native RPC runtime and shares its execution with React. The factory receives `{ context, params, search }`: `context` is the loader’s router context, including parent `beforeLoad` contributions. Annotate it with `typeof root.types.allContext` (or the parent route’s `types.allContext`) to keep client and viewer access checked against the route’s declaration.
574
+ TanStack Router owns routes, navigation, search validation, loader data and screen components. Spread `queryRoute(buildQuery)` from `@shivaedev/react/adapters/queryRoute.ts` into `createRoute` to derive loader dependencies from validated search and load a contract query atom in the router context’s registry. A `NotFound` instance from `@shivaedev/errors/taxonomy.ts` or a `QueryReadDenied` refusal enters TanStack's not-found handling with the original rejection in the not-found component's `data` prop, preserving its message. One root `notFoundComponent` can show that message for all query routes; a route's own `notFoundComponent` takes precedence. Other typed failures reach `errorComponent` unchanged. The atom runs through its native RPC runtime and shares its execution with React. The factory receives `{ context, params, search }`: `context` is the loader’s router context, including parent `beforeLoad` contributions. Annotate it with `typeof root.types.allContext` (or the parent route’s `types.allContext`) to keep client and viewer access checked against the route’s declaration.
575
575
 
576
576
  This example assumes an application-owned `api.get.query({ id, page })` returning `{ id, title }`, with declared `NotFound` and `NoteMissing` rejections:
577
577
 
@@ -583,7 +583,7 @@ import { Effect, Option, Predicate, Schema } from "effect";
583
583
  import type { ReactNode } from "react";
584
584
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
585
585
  import { NotFound } from "@shivaedev/errors/taxonomy.ts";
586
- import { queryRoute } from "@shivaedev/react/queryRoute.ts";
586
+ import { queryRoute } from "@shivaedev/react/adapters/queryRoute.ts";
587
587
  import { useLoaderQuery } from "@shivaedev/react/client/useLoaderQuery.ts";
588
588
  import { api } from "./notes-client.ts";
589
589
 
@@ -597,13 +597,15 @@ const Search = Schema.Struct({
597
597
  Schema.withDecodingDefaultKey(Effect.succeed(1)),
598
598
  ),
599
599
  });
600
+ const noteQuery = queryRoute(
601
+ ({ context, params, search }: { context: typeof root.types.allContext; params: { id: string }; search: typeof Search.Type }) =>
602
+ context.api.get.query({ id: params.id, page: search.page }),
603
+ );
600
604
  const note = createRoute({
601
605
  getParentRoute: () => root,
602
606
  path: "/notes/$id",
603
607
  validateSearch: Schema.toStandardSchemaV1(Search),
604
- ...queryRoute(({ context, params, search }: { context: typeof root.types.allContext; params: { id: string }; search: typeof Search.Type }) =>
605
- context.api.get.query({ id: params.id, page: search.page }),
606
- ),
608
+ ...noteQuery,
607
609
  component: Note,
608
610
  errorComponent: Failure,
609
611
  });
@@ -634,7 +636,15 @@ function Note() {
634
636
  return <h1>{query.data.title}</h1>;
635
637
  }
636
638
  function Failure({ error }: ErrorComponentProps) {
637
- return <p role="alert">{Predicate.isTagged(error, "NoteMissing") ? "Note missing" : "Could not load"}</p>;
639
+ const retry = noteQuery.useRetry();
640
+ return (
641
+ <>
642
+ <p role="alert">{Predicate.isTagged(error, "NoteMissing") ? "Note missing" : "Could not load"}</p>
643
+ <button type="button" onClick={() => void retry()}>
644
+ Retry
645
+ </button>
646
+ </>
647
+ );
638
648
  }
639
649
  function SharedNotFound({ data }: NotFoundRouteProps) {
640
650
  return <h1>{Schema.is(NotFound)(data) ? data.message : "Page not found"}</h1>;
@@ -652,6 +662,25 @@ export function App() {
652
662
 
653
663
  `validateSearch` stays native: `Schema.toStandardSchemaV1(Search)` supplies TanStack’s search input and output types. The schema defaults a missing or invalid page to `1`. The query callback names its params and schema output type because TypeScript cannot infer them backward through an object spread. Changing search changes the loader dependencies and queries the new payload. Keep `params`, `validateSearch`, `component` and `errorComponent` on the route, with an optional `notFoundComponent` to override the shared screen; options after the spread can override its `loaderDeps` or `loader`.
654
664
 
665
+ Keep the result of `queryRoute` to call its `useRetry()` hook inside that route's error component. The returned callback refreshes the query using the current match's params, decoded search dependencies and context, then invalidates that match. A successful retry renders the route again without replacing the surrounding shell or its draft inputs.
666
+
667
+ For redirects, supply `redirects.signedOut` and `redirects.refused` in the optional second argument. The signed-out callback handles the shared `Unauthorized` rejection; the refusal callback handles `Forbidden` and `QueryReadDenied`. Use TanStack's typed `redirect` with a registered router (or an explicit router type), and `signInSearch` to carry the requested path, search and fragment into sign-in's `returnTo`. Destinations and UI remain application choices:
668
+
669
+ ```ts
670
+ import { redirect } from "@tanstack/react-router";
671
+ import { queryRoute } from "@shivaedev/react/adapters/queryRoute.ts";
672
+ import { signInSearch } from "@shivaedev/react/signInSearch.ts";
673
+
674
+ const noteQuery = queryRoute(buildQuery, {
675
+ redirects: {
676
+ signedOut: (location) => redirect({ to: "/sign-in", search: signInSearch(location) }),
677
+ refused: () => redirect({ to: "/no-access" }),
678
+ },
679
+ });
680
+ ```
681
+
682
+ Without the corresponding callback, failures retain their normal error or not-found handling. `NotFound` continues to use the not-found screen even when refusal redirects are configured.
683
+
655
684
  For a loader that coordinates more work, use `loadQuery(registry, atom, loaderContext)` from `@shivaedev/react/adapters/loadQuery.ts` directly. It reads the atom in the supplied registry and throws typed failures unchanged, including `NotFound`; the loader decides how to handle them.
656
685
 
657
686
  `defaultPendingMs: Infinity` keeps the current route's data visible during navigation; the shell reads TanStack's `isLoading` to display pending state. The new route commits when its loader settles. This is TanStack's pending policy, separate from `useQuery`'s retained display. The loader and the component share one query execution even when the route delays mounting for 650 ms, beyond the registry’s idle window: the first render has the loaded value and the RPC handler runs once.
@@ -668,22 +697,26 @@ Permissions come from the session payload's `user.permissions`, populated by `@s
668
697
 
669
698
  Declare a route's requirement in TanStack's native `staticData`: `signedIn: true` admits any signed-in viewer, and `permission` requires a specific grant. Routes that declare neither stay public. Install `permissionGuard` once as the root route's `beforeLoad`; it checks all matched routes before their loaders run, including requirements on parents. Signed-out visitors go to the app's `signIn` path with the full requested location in the `returnTo` search field. A signed-in session without a required grant throws the shared `Forbidden` failure. A signed-in-only parent does not bypass a child's permission requirement.
670
699
 
700
+ Set `permissionGuard({ session, signIn, hidden: true })` to hide refused routes from signed-in members. The guard throws TanStack's native not-found result, renders the app's `notFoundComponent` at the requested URL and prevents the route's loader from running. Signed-out visitors still go to sign-in with their return location; sessions with the required grant still enter the route.
701
+
671
702
  ```tsx
672
703
  import { RegistryContext } from "@effect/atom-react";
673
- import { createRootRouteWithContext, createRoute, createRouter, RouterProvider } from "@tanstack/react-router";
704
+ import { createRootRouteWithContext, createRoute, createRouter, Link, RouterProvider, useRouter } from "@tanstack/react-router";
705
+ import type { ReactNode } from "react";
674
706
  import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
675
707
  import { permission } from "@shivaedev/access/permission.ts";
676
- import { PermissionBoundary, useCan } from "@shivaedev/react/client/permissionBoundary.ts";
708
+ import { Forbidden } from "@shivaedev/react/adapters/Forbidden.ts";
709
+ import { PermissionBoundary, PermissionBoundaryError, useCan } from "@shivaedev/react/adapters/permissionBoundary.ts";
677
710
  import { useLoaderQuery } from "@shivaedev/react/client/useLoaderQuery.ts";
678
- import { permissionGuard } from "@shivaedev/react/permissionGuard.ts";
711
+ import { permissionGuard } from "@shivaedev/react/adapters/permissionGuard.ts";
679
712
  import { can, type PermissionSession } from "@shivaedev/react/permissions.ts";
680
- import { queryRoute } from "@shivaedev/react/queryRoute.ts";
713
+ import { queryRoute } from "@shivaedev/react/adapters/queryRoute.ts";
681
714
  import { api, registry } from "./notes-client.ts";
682
715
  import { auth, SignIn } from "./auth.tsx";
683
716
 
684
717
  const ReadNotes = permission("notes.read");
685
- const root = createRootRouteWithContext<{ registry: AtomRegistry.AtomRegistry; api: typeof api }>()({
686
- beforeLoad: permissionGuard({ session: () => auth.session, signIn: "/login" }),
718
+ const root = createRootRouteWithContext<{ registry: AtomRegistry.AtomRegistry; api: typeof api; session: PermissionSession | undefined }>()({
719
+ beforeLoad: ({ context, ...route }) => permissionGuard({ session: () => context.session, signIn: "/login" })(route),
687
720
  });
688
721
  const profile = createRoute({
689
722
  getParentRoute: () => root,
@@ -715,7 +748,9 @@ const login = createRoute({
715
748
  },
716
749
  });
717
750
  const router = createRouter({
718
- context: { registry, api },
751
+ context: { registry, api, session: auth.session },
752
+ InnerWrap: PermissionShell,
753
+ defaultErrorComponent: PermissionBoundaryError,
719
754
  routeTree: root.addChildren([profile, note, login]),
720
755
  disableGlobalCatchBoundary: true,
721
756
  });
@@ -725,23 +760,43 @@ function Controls() {
725
760
  return can(ReadNotes) ? <button type="button">Read notes</button> : null;
726
761
  }
727
762
 
728
- export function App({ session }: { readonly session: PermissionSession | undefined }) {
763
+ function PermissionShell({ children }: { readonly children: ReactNode }): ReactNode {
764
+ const session = useRouter<typeof router>().options.context?.session;
729
765
  return (
730
- <PermissionBoundary session={session} fallback={<h1>Permission denied</h1>}>
731
- <RegistryContext.Provider value={registry}>
732
- <Controls />
733
- <RouterProvider router={router} />
734
- </RegistryContext.Provider>
766
+ <PermissionBoundary session={session} fallback={<NoAccess />}>
767
+ <Controls />
768
+ {children}
735
769
  </PermissionBoundary>
736
770
  );
737
771
  }
738
772
 
773
+ function NoAccess(): ReactNode {
774
+ return (
775
+ <>
776
+ <Forbidden to="/profile" backLabel="Back to profile" />
777
+ <Link to="/login">Use another account</Link>
778
+ </>
779
+ );
780
+ }
781
+
782
+ export function App({ session }: { readonly session: PermissionSession | undefined }) {
783
+ return (
784
+ <RegistryContext.Provider value={registry}>
785
+ <RouterProvider router={router} context={{ session }} />
786
+ </RegistryContext.Provider>
787
+ );
788
+ }
789
+
739
790
  const showNotes = can(auth.session, ReadNotes);
740
791
  ```
741
792
 
742
- `auth` owns the current session and passes it to `App`; `SignIn` updates that session before invoking `onSignedIn`. Use the session's registry for router context and React, as with other query routes. Importing `permissionGuard` augments TanStack's `StaticDataRouteOption`; route options and their inference remain native.
793
+ `auth` owns the current session and passes it to `App`; `SignIn` updates that session before invoking `onSignedIn`. Use the session's registry for router context and React, as with other query routes. Importing `permissionGuard` augments TanStack's `StaticDataRouteOption`; route options and their inference remain native. The guard returns `void` explicitly, so `beforeLoad` needs no return annotation, including when it reads the session from route context.
794
+
795
+ `InnerWrap` puts `PermissionBoundary` inside the router. Its fallback can render `Link` and read route context. Set `defaultErrorComponent: PermissionBoundaryError` so route and loader failures reach the boundary's fallback while TanStack keeps its navigation controller mounted. This lets a refused viewer follow the fallback link without reloading the page. Keep `disableGlobalCatchBoundary: true`; other errors propagate to an enclosing application boundary. A route-specific `errorComponent` owns any failures it consumes.
796
+
797
+ `Forbidden` from `@shivaedev/react/adapters/Forbidden.ts` supplies the no-access heading, explanation and a router link. Set `to` to a route the viewer may open. Optional `title`, `children`, `backLabel` and `className` let the application choose wording and layout. The default heading is “Permission denied” and the link says “Go back”.
743
798
 
744
- `PermissionBoundary` renders the app's one fallback at the denied URL for a refused route, a loader's `Forbidden`, or a `useQuery`/`useLoaderQuery` result containing the shared `Forbidden` class. Other errors propagate to an enclosing error boundary. Set TanStack's `disableGlobalCatchBoundary: true` and leave permission failures to this boundary; a route-specific `errorComponent` that consumes an error owns its rendering instead. Without a permission boundary, query failures keep their normal typed state. Like a React error boundary, remount it to clear a caught failure.
799
+ `PermissionBoundary` also catches component query failures containing the shared `Forbidden` class. Without a boundary, query failures keep their normal typed state. TanStack resets route failures when the viewer navigates away; remount a boundary to clear a failure it catches outside the route error path.
745
800
 
746
801
  #### Better Auth actions
747
802
 
@@ -775,7 +830,7 @@ const onSubmit = (credentials: { email: string; password: string }) => signIn(cr
775
830
 
776
831
  `authCall` returns a function from input to `Effect<A, AuthFailure>`. It uses the same failure codes and successful data as `authAction`.
777
832
 
778
- Use `authSession` from `@shivaedev/react/client/authSession.ts` for the application's Better Auth session. It returns a native `atom` for `useQuery` and a `refresh` Effect that refreshes that same atom and waits through its loading state. Supply Better Auth's public `getSession` call with `disableCookieCache: true` so a mutation reads current user data:
833
+ Use `authSession` from `@shivaedev/react/client/authSession.ts` for the application's Better Auth session. It returns a native `atom` for `useQuery` and a `refresh` Effect that refreshes that same atom and waits through its loading state. Both expose typed `user.permissions` alongside the provider's existing session and user fields, using the `PermissionSession` schema from `@shivaedev/react/permissions.ts`. Applications do not decode `get-session` themselves. Missing grants stay optional; malformed grants fail with `AuthUnavailable`. The reader must return a nullable session with a `user` object; use `authQuery` for other payload shapes. Supply Better Auth's public `getSession` call with `disableCookieCache: true` so a mutation reads current user data:
779
834
 
780
835
  ```tsx
781
836
  import { Effect } from "effect";
@@ -808,7 +863,7 @@ The example uses `Option` from `effect` and the application's Better Auth client
808
863
 
809
864
  For other Better Auth reads, `authQuery` from `@shivaedev/react/client/authQuery.ts` creates an input-keyed query atom family. Call `authQuery((input, signal) => authClient.getSession({ query: input, fetchOptions: { signal } }))` with an explicitly typed input, then render its atom with `useQuery`. Releasing a pending read interrupts its Effect and aborts the supplied signal.
810
865
 
811
- For an explicit sign-out in a TanStack route, use `useSignOut(signOut, { signIn: "/sign-in" })` from `@shivaedev/react/client/useSignOut.ts` in place of `useAction`. It exposes the same state and a `dispatch()` handler. The hook records sign-out intent before the request and navigates to sign-in after success. Repeated clicks while pending share one request and follow-up. Unmounting the component or disposing its registry stops the follow-up navigation. If a session refresh replaces the component before the response, the replacement session’s route policy owns navigation to sign-in. `permissionGuard` and `signInSearch(location)` omit `returnTo` for that intent, including when the auth owner's session refresh reruns guards first. Use `signInSearch` for module sign-in links too; ordinary visits retain the full requested location. Applications do not need history markers or Better Auth completion timing hooks.
866
+ For an explicit sign-out in a TanStack route, use `useSignOut(signOut, { signIn: "/sign-in" })` from `@shivaedev/react/client/adapters/useSignOut.ts` in place of `useAction`. It exposes the same state and a `dispatch()` handler. The hook records sign-out intent before the request and navigates to sign-in after success. Repeated clicks while pending share one request and follow-up. Unmounting the component or disposing its registry stops the follow-up navigation. If a session refresh replaces the component before the response, the replacement session’s route policy owns navigation to sign-in. `permissionGuard` and `signInSearch(location)` omit `returnTo` for that intent, including when the auth owner's session refresh reruns guards first. Use `signInSearch` for module sign-in links too; ordinary visits retain the full requested location. Applications do not need history markers or Better Auth completion timing hooks.
812
867
 
813
868
  ### 3. Every day
814
869
 
@@ -966,7 +1021,7 @@ screenStories.it("shows the route failure", [], async () => {
966
1021
 
967
1022
  Story kits can acquire `captureReactWarnings` from `@shivaedev/test-story/client/react.ts` in their `create` effect with `const warnings = yield* captureReactWarnings`. The scope owns the capture and restores `console.error` when it closes, including after a failed story. Pass `warnings.onCaughtError` to `render` to capture boundary errors, or `warnings.expectCaughtError(predicate)` to exclude a declared error. Both handlers silence caught errors; the capture also silences and records `console.error` calls. `warnings.read()` returns `{ consoleErrors, caughtErrors }`, with each console call's arguments and the unexpected caught errors. It asserts nothing, leaving the story spec to state its expectation. The Vitest guard uses the same capture mechanism and additionally checks that every declared error occurred.
968
1023
 
969
- A screen kit tells its screen driver when the screen has finished its work with `screenPending({ router })` from `@shivaedev/react/client/screenPending.ts`. The Effect reads the `AtomRegistry` from its environment and returns a function that reports `true` while a native `AsyncResult` that something still reads is waiting, or while the optional TanStack router loads a route, and `false` otherwise. A result left waiting by a component that has unmounted does not count, even while the registry's idle window keeps its atom. Each call reads the registry and router at that moment, so pass it as the driver's `pending` option instead of listing the screen's queries by hand:
1024
+ A screen kit tells its screen driver when the screen has finished its work with `screenPending({ router })` from `@shivaedev/react/adapters/screenPending.ts`. The Effect reads the `AtomRegistry` from its environment and returns a function that reports `true` while a native `AsyncResult` that something still reads is waiting, or while the optional TanStack router loads a route, and `false` otherwise. A result left waiting by a component that has unmounted does not count, even while the registry's idle window keeps its atom. Each call reads the registry and router at that moment, so pass it as the driver's `pending` option instead of listing the screen's queries by hand:
970
1025
 
971
1026
  ```ts
972
1027
  const pending = yield* screenPending({ router }).pipe(Effect.provideService(AtomRegistry.AtomRegistry, view.registry));
@@ -1003,7 +1058,7 @@ pnpm add @shivaedev/react @effect/atom-react effect react
1003
1058
  pnpm add @shivaedev/form
1004
1059
  ```
1005
1060
 
1006
- Add the optional router peer when using `queryRoute`, `loadQuery`, `permissionGuard`, `PermissionBoundary` or `useSignOut`:
1061
+ Add the optional router peer when using `queryRoute`, `loadQuery`, `permissionGuard`, `PermissionBoundary`, `PermissionBoundaryError`, `Forbidden` or `useSignOut`:
1007
1062
 
1008
1063
  ```sh
1009
1064
  pnpm add @tanstack/react-router
@@ -0,0 +1,10 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ForbiddenProps {
3
+ readonly backLabel?: string;
4
+ readonly children?: ReactNode;
5
+ readonly className?: string;
6
+ readonly title?: string;
7
+ readonly to: string;
8
+ }
9
+ export declare function Forbidden({ to, title, children, backLabel, className, }: ForbiddenProps): ReactNode;
10
+ //# sourceMappingURL=Forbidden.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Forbidden.d.ts","sourceRoot":"","sources":["../../src/adapters/Forbidden.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,EACzB,EAAE,EACF,KAA2B,EAC3B,QAAiD,EACjD,SAAqB,EACrB,SAAS,GACT,EAAE,cAAc,GAAG,SAAS,CAQ5B"}
@@ -0,0 +1,6 @@
1
+ import { Link } from "@tanstack/react-router";
2
+ import { createElement } from "react";
3
+ export function Forbidden({ to, title = "Permission denied", children = "You do not have access to this page.", backLabel = "Go back", className, }) {
4
+ return createElement("main", { className }, createElement("h1", null, title), createElement("p", null, children), createElement(Link, { to }, backLabel));
5
+ }
6
+ //# sourceMappingURL=Forbidden.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Forbidden.js","sourceRoot":"","sources":["../../src/adapters/Forbidden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAUtD,MAAM,UAAU,SAAS,CAAC,EACzB,EAAE,EACF,KAAK,GAAG,mBAAmB,EAC3B,QAAQ,GAAG,sCAAsC,EACjD,SAAS,GAAG,SAAS,EACrB,SAAS,GACO;IAChB,OAAO,aAAa,CACnB,MAAM,EACN,EAAE,SAAS,EAAE,EACb,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAChC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,EAClC,aAAa,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,CACtC,CAAC;AACH,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { Effect } from "effect";
2
2
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
3
- import { keepLoaderQuery } from "#internal/queryHandoff.ts";
4
3
  import { recheckUnauthorized } from "#internal/sessionRecheck.ts";
4
+ import { keepLoaderQuery } from "./queryHandoff.js";
5
5
  export async function loadQuery(registry, atom, { abortController }) {
6
6
  const { signal } = abortController;
7
7
  const handoff = keepLoaderQuery(registry, atom, signal);
@@ -1 +1 @@
1
- {"version":3,"file":"loadQuery.js","sourceRoot":"","sources":["../../src/adapters/loadQuery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,QAAmC,EACnC,IAA8C,EAC9C,EAAE,eAAe,EAA4C;IAE7D,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;IACnC,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACxD,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACtI,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CA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AI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,MAAM,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACpD,MAAM,MAAM,CAAC,OAAO,CAAC;QACtB,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACvE,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC;YAC7B,MAAM,QAAQ,CAAC;QAChB,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;YAAS,CAAC;QACV,OAAO,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;AACF,CAAC"}
@@ -7,5 +7,8 @@ export interface PermissionBoundaryProps {
7
7
  readonly session: PermissionSession | null | undefined;
8
8
  }
9
9
  export declare function useCan(): (permission: Permission) => boolean;
10
+ export declare function PermissionBoundaryError({ error }: {
11
+ readonly error: unknown;
12
+ }): ReactNode;
10
13
  export declare function PermissionBoundary({ children, fallback, session }: PermissionBoundaryProps): ReactNode;
11
14
  //# sourceMappingURL=permissionBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionBoundary.d.ts","sourceRoot":"","sources":["../../src/adapters/permissionBoundary.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EAAO,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;CACvD;AAED,wBAAgB,MAAM,IAAI,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAG5D;AAED,wBAAgB,uBAAuB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAMzF;AAED,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,uBAAuB,GAAG,SAAS,CAMtG"}
@@ -7,7 +7,7 @@ export function useCan() {
7
7
  const context = useContext(PermissionContext);
8
8
  return (permission) => can(context?.session, permission);
9
9
  }
10
- function PermissionFailure({ error }) {
10
+ export function PermissionBoundaryError({ error }) {
11
11
  const context = useContext(PermissionContext);
12
12
  if (!isForbidden(error)) {
13
13
  throw error;
@@ -15,6 +15,6 @@ function PermissionFailure({ error }) {
15
15
  return context?.fallback;
16
16
  }
17
17
  export function PermissionBoundary({ children, fallback, session }) {
18
- return createElement(PermissionContext.Provider, { value: { fallback, session } }, createElement(CatchBoundary, { children, errorComponent: PermissionFailure, getResetKey: () => "permission" }));
18
+ return createElement(PermissionContext.Provider, { value: { fallback, session } }, createElement(CatchBoundary, { children, errorComponent: PermissionBoundaryError, getResetKey: () => "permission" }));
19
19
  }
20
20
  //# sourceMappingURL=permissionBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionBoundary.js","sourceRoot":"","sources":["../../src/adapters/permissionBoundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,GAAG,EAA0B,MAAM,iBAAiB,CAAC;AAQ9D,MAAM,UAAU,MAAM;IACrB,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,EAAE,KAAK,EAA+B;IAC7E,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,CAAC;IACb,CAAC;IACD,OAAO,OAAO,EAAE,QAAQ,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAA2B;IAC1F,OAAO,aAAa,CACnB,iBAAiB,CAAC,QAAQ,EAC1B,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAChC,aAAa,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,uBAAuB,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CACpH,CAAC;AACH,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { Permission } from "@shivaedev/access/permission.ts";
2
- import { type PermissionSession } from "./permissions.ts";
3
- import { type SignInLocation } from "./signInSearch.ts";
2
+ import { type PermissionSession } from "#permissions.ts";
3
+ import { type SignInLocation } from "#signInSearch.ts";
4
4
  declare module "@tanstack/react-router" {
5
5
  interface StaticDataRouteOption {
6
6
  readonly permission?: Permission;
@@ -8,6 +8,7 @@ declare module "@tanstack/react-router" {
8
8
  }
9
9
  }
10
10
  export interface PermissionGuardOptions {
11
+ readonly hidden?: boolean;
11
12
  readonly session: () => PermissionSession | null | undefined;
12
13
  readonly signIn: string;
13
14
  }
@@ -20,5 +21,5 @@ export interface PermissionGuardContext {
20
21
  };
21
22
  }[];
22
23
  }
23
- export declare function permissionGuard({ session, signIn }: PermissionGuardOptions): (context: PermissionGuardContext) => void;
24
+ export declare function permissionGuard({ session, signIn, hidden }: PermissionGuardOptions): (context: PermissionGuardContext) => void;
24
25
  //# sourceMappingURL=permissionGuard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionGuard.d.ts","sourceRoot":"","sources":["../../src/adapters/permissionGuard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAO,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,kBAAkB,CAAC;AAErE,OAAO,QAAQ,wBAAwB,CAAC;IACvC,UAAU,qBAAqB;QAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;QACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;KAC5B;CACD;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,iBAAiB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS;QAAE,QAAQ,CAAC,UAAU,EAAE;YAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;YAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;CACxH;AAED,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAc,EAAE,EAAE,sBAAsB,GAAG,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAgBtI"}
@@ -1,8 +1,8 @@
1
- import { redirect } from "@tanstack/react-router";
1
+ import { notFound, redirect } from "@tanstack/react-router";
2
2
  import { forbidden } from "@shivaedev/access/refusal.ts";
3
- import { can } from "./permissions.js";
4
- import { signInSearch } from "./signInSearch.js";
5
- export function permissionGuard({ session, signIn }) {
3
+ import { can } from "#permissions.ts";
4
+ import { signInSearch } from "#signInSearch.ts";
5
+ export function permissionGuard({ session, signIn, hidden = false }) {
6
6
  return ({ matches, location }) => {
7
7
  const required = matches.flatMap((match) => (match.staticData.permission === undefined ? [] : [match.staticData.permission]));
8
8
  if (required.length === 0 && !matches.some((match) => match.staticData.signedIn === true)) {
@@ -14,7 +14,7 @@ export function permissionGuard({ session, signIn }) {
14
14
  }
15
15
  for (const permission of required) {
16
16
  if (!can(current, permission)) {
17
- throw forbidden(permission);
17
+ throw hidden ? notFound() : forbidden(permission);
18
18
  }
19
19
  }
20
20
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissionGuard.js","sourceRoot":"","sources":["../../src/adapters/permissionGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,GAAG,EAA0B,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAuB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoBrE,MAAM,UAAU,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,EAA0B;IAC1F,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS,CAAC,C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AAO,CAAC,GAAG,IAAI,CAIrG;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAO3H"}
1
+ {"version":3,"file":"queryHandoff.d.ts","sourceRoot":"","sources":["../../src/adapters/queryHandoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAUpE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW;;;EAiCjH;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAIrG;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAO3H"}
@@ -1 +1 @@
1
- {"version":3,"file":"queryHandoff.js","sourceRoot":"","sources":["../../src/internal/queryHandoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAS/C,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAwE,CAAC;AAErG,MAAM,UAAU,eAAe,CAAC,QAAmC,EAAE,IAAwB,EAAE,MAAmB;IACjH,IAAI,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QACtB,QAAQ,C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AAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAmC,EAAE,IAAwB;IAC9F,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/D,OAAO,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;AACF,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAmC,EAAE,IAAwB;IAC/F,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/D,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC,KAAK,CAAC;QACtB,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC"}
@@ -1,17 +1,21 @@
1
- import { type LoaderFnContext } from "@tanstack/react-router";
1
+ import type { LoaderFnContext } from "@tanstack/react-router";
2
2
  import type * as AsyncResult from "effect/reactivity/AsyncResult";
3
3
  import type * as Atom from "effect/reactivity/Atom";
4
4
  import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
5
+ import { type QueryRouteRedirects } from "./queryRouteFailure.ts";
6
+ interface QueryRouteInput<TParams, TSearch, TContext> {
7
+ readonly context: TContext;
8
+ readonly params: TParams;
9
+ readonly search: TSearch;
10
+ }
5
11
  export declare function queryRoute<TParams extends object, TSearch extends object, A, E, TContext extends {
6
12
  readonly registry: AtomRegistry.AtomRegistry;
7
13
  } = {
8
14
  readonly registry: AtomRegistry.AtomRegistry;
9
- }>(query: (route: {
10
- readonly params: TParams;
11
- readonly search: TSearch;
12
- readonly context: TContext;
13
- }) => Atom.Atom<AsyncResult.AsyncResult<A, E>>): {
14
- loader: (context: Pick<LoaderFnContext, "abortController"> & {
15
+ }>(query: (route: QueryRouteInput<TParams, TSearch, TContext>) => Atom.Atom<AsyncResult.AsyncResult<A, E>>, options?: {
16
+ readonly redirects?: QueryRouteRedirects;
17
+ }): {
18
+ loader: (context: Pick<LoaderFnContext, "abortController" | "location"> & {
15
19
  readonly context: TContext;
16
20
  readonly deps: TSearch;
17
21
  readonly params: TParams;
@@ -19,5 +23,7 @@ export declare function queryRoute<TParams extends object, TSearch extends objec
19
23
  loaderDeps: ({ search }: {
20
24
  readonly search: TSearch;
21
25
  }) => TSearch;
26
+ useRetry: () => () => Promise<void>;
22
27
  };
28
+ export {};
23
29
  //# sourceMappingURL=queryRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryRoute.d.ts","sourceRoot":"","sources":["../../src/adapters/queryRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,wBAAwB,CAAC;AAGrF,UAAU,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ;IACnD,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,UAAU,CACzB,OAAO,SAAS,MAAM,EACtB,OAAO,SAAS,MAAM,EACtB,CAAC,EACD,CAAC,EACD,QAAQ,SAAS;IAAE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,CAAA;CAAE,EAEpH,KAAK,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACvG,OAAO,GAAE;IAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAA;CAAO;IAGzD,MAAM,YACI,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,UAAU,CAAC,GAAG;QAChE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;KACzB,KACC,OAAO,CAAC,CAAC,CAAC;IAOb,UAAU,eAAe;QAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;KAAE;IACrD,QAAQ;EAMT"}
@@ -0,0 +1,21 @@
1
+ import { loadQuery } from "./loadQuery.js";
2
+ import { queryRouteFailure } from "./queryRouteFailure.js";
3
+ import { useQueryRetry } from "./useQueryRetry.js";
4
+ export function queryRoute(query, options = {}) {
5
+ return {
6
+ loader: async (context) => {
7
+ try {
8
+ return await loadQuery(context.context.registry, query({ context: context.context, params: context.params, search: context.deps }), context);
9
+ }
10
+ catch (error) {
11
+ throw queryRouteFailure(error, context.location, options.redirects);
12
+ }
13
+ },
14
+ loaderDeps: ({ search }) => search,
15
+ useRetry: () => useQueryRetry((match) => {
16
+ const { context, params, loaderDeps } = match;
17
+ context.registry.refresh(query({ context, params, search: loaderDeps }));
18
+ }),
19
+ };
20
+ }
21
+ //# sourceMappingURL=queryRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryRoute.js","sourceRoot":"","sources":["../../src/adapters/queryRoute.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAA4B,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQnD,MAAM,UAAU,UAAU,CAOzB,KAAuG,EACvG,OAAO,GAAiD,EAAE;IAE1D,OAAO;QACN,MAAM,EAAE,KAAK,EACZ,OAIC,EACY,EAAE;YACf,IAAI,CAAC;gBACJ,OAAO,MAAM,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;YAC9I,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;YACrE,CAAC;QACF,CAAC;QACD,UAAU,EAAE,CAAC,EAAE,MAAM,EAAgC,EAAE,EAAE,CAAC,MAAM;QAChE,QAAQ,EAAE,GAAG,EAAE,CACd,aAAa,CAAC,CAAC,KAAK,EAAE,EAAE;YACvB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAgE,KAAK,CAAC;YAC3G,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC;KACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { SignInLocation } from "#signInSearch.ts";
2
+ export type QueryRouteRedirect = Response & {
3
+ readonly options: object;
4
+ };
5
+ export interface QueryRouteRedirects {
6
+ readonly refused?: () => QueryRouteRedirect;
7
+ readonly signedOut?: (location: SignInLocation) => QueryRouteRedirect;
8
+ }
9
+ export declare function queryRouteFailure(error: unknown, location: SignInLocation, redirects: QueryRouteRedirects | undefined): unknown;
10
+ //# sourceMappingURL=queryRouteFailure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryRouteFailure.d.ts","sourceRoot":"","sources":["../../src/adapters/queryRouteFailure.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,kBAAkB,CAAC;IAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,kBAAkB,CAAC;CACtE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAQ/H"}
@@ -0,0 +1,13 @@
1
+ import { notFound } from "@tanstack/react-router";
2
+ import { Predicate } from "effect";
3
+ import { isForbidden, isNotFound, isUnauthorized } from "@shivaedev/errors/taxonomy.ts";
4
+ export function queryRouteFailure(error, location, redirects) {
5
+ if (isUnauthorized(error) && redirects?.signedOut) {
6
+ return redirects.signedOut(location);
7
+ }
8
+ if ((isForbidden(error) || Predicate.isTagged(error, "QueryReadDenied")) && redirects?.refused) {
9
+ return redirects.refused();
10
+ }
11
+ return isNotFound(error) || Predicate.isTagged(error, "QueryReadDenied") ? notFound({ data: error }) : error;
12
+ }
13
+ //# sourceMappingURL=queryRouteFailure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryRouteFailure.js","sourceRoot":"","sources":["../../src/adapters/queryRouteFailure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAUxF,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAE,QAAwB,EAAE,SAA0C;IACrH,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,SAAS,EAAE,SAAS,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,IAAI,SAAS,EAAE,OAAO,EAAE,CAAC;QAChG,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9G,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screenPending.d.ts","sourceRoot":"","sources":["../../src/adapters/screenPending.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACxC;AAED,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,GAAE,oBAAyB,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,YAAY,CAAC,CAKnI"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"screenPending.js","sourceRoot":"","sources":["../../src/adapters/screenPending.ts"],"names":[],"mappings":"AACA,OAAO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EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAC5F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLoaderHandoff.d.ts","sourceRoot":"","sources":["../../src/internal/useLoaderHandoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAIpE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAcpG"}
1
+ {"version":3,"file":"useLoaderHandoff.d.ts","sourceRoot":"","sources":["../../src/adapters/useLoaderHandoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAIpE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAcpG"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLoaderHandoff.js","sourceRoot":"","sources":["../../src/internal/useLoaderHandoff.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,QAAmC,EAA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C,IAAI,KAAK,IAAI,EAAE,CAAC;QACvF,MAAM,OAAO,GAAG,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACnD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,OAAO,CAAC;QACf,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type AnyRouteMatch } from "@tanstack/react-router";
2
+ export declare function useQueryRetry(refresh: (match: AnyRouteMatch) => void): () => Promise<void>;
3
+ //# sourceMappingURL=useQueryRetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQueryRetry.d.ts","sourceRoot":"","sources":["../../src/adapters/useQueryRetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,wBAAwB,CAAC;AAEjF,wBAAgB,aAAa,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAO1F"}
@@ -0,0 +1,10 @@
1
+ import { useMatch, useRouter } from "@tanstack/react-router";
2
+ export function useQueryRetry(refresh) {
3
+ const router = useRouter();
4
+ const match = useMatch({ strict: false });
5
+ return () => {
6
+ refresh(match);
7
+ return router.invalidate({ filter: (candidate) => candidate.id === match.id });
8
+ };
9
+ }
10
+ //# sourceMappingURL=useQueryRetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQueryRetry.js","sourceRoot":"","sources":["../../src/adapters/useQueryRetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEjF,MAAM,UAAU,aAAa,CAAC,OAAuC;IACpE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1C,OAAO,GAAG,EAAE;QACX,OAAO,CAAC,KAAK,CAAC,CAAC;QACf,OAAO,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAChF,CAAC,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { Duration } from "effect";
1
+ import { type Duration } from "effect";
2
2
  import * as AtomRegistry from "effect/reactivity/AtomRegistry";
3
3
  import { type ReactNode } from "react";
4
4
  interface SessionGenerationProps<TSession, TClient> {
@@ -1 +1 @@
1
- {"version":3,"file":"SessionGeneration.d.ts","sourceRoot":"","sources":["../../../src/client/adapters/SessionGeneration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAiD3E,UAAU,sBAAsB,CAAC,QAAQ,EAAE,OAAO;IACjD,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,SAAS,CAAC;IAClD,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,YAAY,KAAK,OAAO,CAAC;IACtF,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,KAAK,GAAG,SAAS,CAAC;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;CAC3B;AACD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,EACpD,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,kBAAkB,GAClB,EAAE,sBAAsB,CAAC,QAAQ,E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