@ic-reactor/react 3.13.0 → 4.0.0-beta.2

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 (174) hide show
  1. package/README.md +237 -787
  2. package/dist/index.d.ts +260 -16
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +471 -23
  5. package/dist/index.js.map +1 -1
  6. package/llms.txt +82 -278
  7. package/package.json +11 -39
  8. package/src/index.tsx +612 -0
  9. package/dist/auth/auth-client-compat.d.ts +0 -122
  10. package/dist/auth/auth-client-compat.d.ts.map +0 -1
  11. package/dist/auth/auth-client-compat.js +0 -162
  12. package/dist/auth/auth-client-compat.js.map +0 -1
  13. package/dist/auth/authentication-manager.d.ts +0 -405
  14. package/dist/auth/authentication-manager.d.ts.map +0 -1
  15. package/dist/auth/authentication-manager.js +0 -1537
  16. package/dist/auth/authentication-manager.js.map +0 -1
  17. package/dist/auth/constants.d.ts +0 -24
  18. package/dist/auth/constants.d.ts.map +0 -1
  19. package/dist/auth/constants.js +0 -24
  20. package/dist/auth/constants.js.map +0 -1
  21. package/dist/auth/createIdentityAttributeHooks.d.ts +0 -14
  22. package/dist/auth/createIdentityAttributeHooks.d.ts.map +0 -1
  23. package/dist/auth/createIdentityAttributeHooks.js +0 -122
  24. package/dist/auth/createIdentityAttributeHooks.js.map +0 -1
  25. package/dist/auth/identity-attributes-manager.d.ts +0 -27
  26. package/dist/auth/identity-attributes-manager.d.ts.map +0 -1
  27. package/dist/auth/identity-attributes-manager.js +0 -191
  28. package/dist/auth/identity-attributes-manager.js.map +0 -1
  29. package/dist/auth/identity-attributes.d.ts +0 -19
  30. package/dist/auth/identity-attributes.d.ts.map +0 -1
  31. package/dist/auth/identity-attributes.js +0 -227
  32. package/dist/auth/identity-attributes.js.map +0 -1
  33. package/dist/auth/index.d.ts +0 -8
  34. package/dist/auth/index.d.ts.map +0 -1
  35. package/dist/auth/index.js +0 -8
  36. package/dist/auth/index.js.map +0 -1
  37. package/dist/auth/local-ii-probe.d.ts +0 -57
  38. package/dist/auth/local-ii-probe.d.ts.map +0 -1
  39. package/dist/auth/local-ii-probe.js +0 -121
  40. package/dist/auth/local-ii-probe.js.map +0 -1
  41. package/dist/auth/types.d.ts +0 -222
  42. package/dist/auth/types.d.ts.map +0 -1
  43. package/dist/auth/types.js +0 -2
  44. package/dist/auth/types.js.map +0 -1
  45. package/dist/createActorHooks.d.ts +0 -41
  46. package/dist/createActorHooks.d.ts.map +0 -1
  47. package/dist/createActorHooks.js +0 -17
  48. package/dist/createActorHooks.js.map +0 -1
  49. package/dist/createInfiniteQuery.d.ts +0 -185
  50. package/dist/createInfiniteQuery.d.ts.map +0 -1
  51. package/dist/createInfiniteQuery.js +0 -198
  52. package/dist/createInfiniteQuery.js.map +0 -1
  53. package/dist/createMutation.d.ts +0 -33
  54. package/dist/createMutation.d.ts.map +0 -1
  55. package/dist/createMutation.js +0 -199
  56. package/dist/createMutation.js.map +0 -1
  57. package/dist/createQuery.d.ts +0 -63
  58. package/dist/createQuery.d.ts.map +0 -1
  59. package/dist/createQuery.js +0 -204
  60. package/dist/createQuery.js.map +0 -1
  61. package/dist/createReactorProvider.d.ts +0 -158
  62. package/dist/createReactorProvider.d.ts.map +0 -1
  63. package/dist/createReactorProvider.js +0 -256
  64. package/dist/createReactorProvider.js.map +0 -1
  65. package/dist/createSuspenseInfiniteQuery.d.ts +0 -154
  66. package/dist/createSuspenseInfiniteQuery.d.ts.map +0 -1
  67. package/dist/createSuspenseInfiniteQuery.js +0 -209
  68. package/dist/createSuspenseInfiniteQuery.js.map +0 -1
  69. package/dist/createSuspenseQuery.d.ts +0 -46
  70. package/dist/createSuspenseQuery.d.ts.map +0 -1
  71. package/dist/createSuspenseQuery.js +0 -158
  72. package/dist/createSuspenseQuery.js.map +0 -1
  73. package/dist/defineDisplayReactor.d.ts +0 -43
  74. package/dist/defineDisplayReactor.d.ts.map +0 -1
  75. package/dist/defineDisplayReactor.js +0 -42
  76. package/dist/defineDisplayReactor.js.map +0 -1
  77. package/dist/defineReactor.d.ts +0 -99
  78. package/dist/defineReactor.d.ts.map +0 -1
  79. package/dist/defineReactor.js +0 -15
  80. package/dist/defineReactor.js.map +0 -1
  81. package/dist/defineReactorShared.d.ts +0 -84
  82. package/dist/defineReactorShared.d.ts.map +0 -1
  83. package/dist/defineReactorShared.js +0 -139
  84. package/dist/defineReactorShared.js.map +0 -1
  85. package/dist/hooks/createAuthHooks.d.ts +0 -50
  86. package/dist/hooks/createAuthHooks.d.ts.map +0 -1
  87. package/dist/hooks/createAuthHooks.js +0 -291
  88. package/dist/hooks/createAuthHooks.js.map +0 -1
  89. package/dist/hooks/index.d.ts +0 -21
  90. package/dist/hooks/index.d.ts.map +0 -1
  91. package/dist/hooks/index.js +0 -24
  92. package/dist/hooks/index.js.map +0 -1
  93. package/dist/hooks/useActorInfiniteQuery.d.ts +0 -67
  94. package/dist/hooks/useActorInfiniteQuery.d.ts.map +0 -1
  95. package/dist/hooks/useActorInfiniteQuery.js +0 -89
  96. package/dist/hooks/useActorInfiniteQuery.js.map +0 -1
  97. package/dist/hooks/useActorMethod.d.ts +0 -148
  98. package/dist/hooks/useActorMethod.d.ts.map +0 -1
  99. package/dist/hooks/useActorMethod.js +0 -394
  100. package/dist/hooks/useActorMethod.js.map +0 -1
  101. package/dist/hooks/useActorMutation.d.ts +0 -51
  102. package/dist/hooks/useActorMutation.d.ts.map +0 -1
  103. package/dist/hooks/useActorMutation.js +0 -70
  104. package/dist/hooks/useActorMutation.js.map +0 -1
  105. package/dist/hooks/useActorQuery.d.ts +0 -45
  106. package/dist/hooks/useActorQuery.d.ts.map +0 -1
  107. package/dist/hooks/useActorQuery.js +0 -67
  108. package/dist/hooks/useActorQuery.js.map +0 -1
  109. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +0 -51
  110. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +0 -1
  111. package/dist/hooks/useActorSuspenseInfiniteQuery.js +0 -76
  112. package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +0 -1
  113. package/dist/hooks/useActorSuspenseQuery.d.ts +0 -32
  114. package/dist/hooks/useActorSuspenseQuery.d.ts.map +0 -1
  115. package/dist/hooks/useActorSuspenseQuery.js +0 -58
  116. package/dist/hooks/useActorSuspenseQuery.js.map +0 -1
  117. package/dist/ownedAuthentication.d.ts +0 -52
  118. package/dist/ownedAuthentication.d.ts.map +0 -1
  119. package/dist/ownedAuthentication.js +0 -49
  120. package/dist/ownedAuthentication.js.map +0 -1
  121. package/dist/server.d.ts +0 -21
  122. package/dist/server.d.ts.map +0 -1
  123. package/dist/server.js +0 -23
  124. package/dist/server.js.map +0 -1
  125. package/dist/testing.d.ts +0 -19
  126. package/dist/testing.d.ts.map +0 -1
  127. package/dist/testing.js +0 -19
  128. package/dist/testing.js.map +0 -1
  129. package/dist/types.d.ts +0 -671
  130. package/dist/types.d.ts.map +0 -1
  131. package/dist/types.js +0 -5
  132. package/dist/types.js.map +0 -1
  133. package/dist/utils.d.ts +0 -207
  134. package/dist/utils.d.ts.map +0 -1
  135. package/dist/utils.js +0 -405
  136. package/dist/utils.js.map +0 -1
  137. package/dist/validation.d.ts +0 -136
  138. package/dist/validation.d.ts.map +0 -1
  139. package/dist/validation.js +0 -144
  140. package/dist/validation.js.map +0 -1
  141. package/src/auth/auth-client-compat.ts +0 -273
  142. package/src/auth/authentication-manager.ts +0 -1682
  143. package/src/auth/constants.ts +0 -32
  144. package/src/auth/createIdentityAttributeHooks.ts +0 -169
  145. package/src/auth/identity-attributes-manager.ts +0 -226
  146. package/src/auth/identity-attributes.ts +0 -345
  147. package/src/auth/index.ts +0 -7
  148. package/src/auth/local-ii-probe.ts +0 -173
  149. package/src/auth/types.ts +0 -243
  150. package/src/createActorHooks.ts +0 -208
  151. package/src/createInfiniteQuery.ts +0 -670
  152. package/src/createMutation.ts +0 -324
  153. package/src/createQuery.ts +0 -369
  154. package/src/createReactorProvider.ts +0 -365
  155. package/src/createSuspenseInfiniteQuery.ts +0 -651
  156. package/src/createSuspenseQuery.ts +0 -304
  157. package/src/defineDisplayReactor.ts +0 -62
  158. package/src/defineReactor.ts +0 -142
  159. package/src/defineReactorShared.ts +0 -268
  160. package/src/hooks/createAuthHooks.ts +0 -371
  161. package/src/hooks/index.ts +0 -103
  162. package/src/hooks/useActorInfiniteQuery.ts +0 -278
  163. package/src/hooks/useActorMethod.ts +0 -710
  164. package/src/hooks/useActorMutation.ts +0 -205
  165. package/src/hooks/useActorQuery.ts +0 -157
  166. package/src/hooks/useActorSuspenseInfiniteQuery.ts +0 -248
  167. package/src/hooks/useActorSuspenseQuery.ts +0 -147
  168. package/src/index.ts +0 -31
  169. package/src/ownedAuthentication.ts +0 -81
  170. package/src/server.ts +0 -23
  171. package/src/testing.ts +0 -18
  172. package/src/types.ts +0 -948
  173. package/src/utils.ts +0 -505
  174. package/src/validation.ts +0 -226
package/dist/index.d.ts CHANGED
@@ -1,17 +1,261 @@
1
- export * from "@ic-reactor/core";
2
- export * from "./hooks/index.js";
3
- export * from "./validation.js";
4
- export * from "./createActorHooks.js";
5
- export * from "./defineReactor.js";
6
- export * from "./defineDisplayReactor.js";
7
- export * from "./createReactorProvider.js";
8
- export * from "./createQuery.js";
9
- export * from "./createSuspenseQuery.js";
10
- export * from "./createInfiniteQuery.js";
11
- export * from "./createSuspenseInfiniteQuery.js";
12
- export * from "./createMutation.js";
13
- export * from "./auth/index.js";
14
- export * from "./types.js";
15
- export { skipToken } from "@tanstack/react-query";
16
- export type { SkipToken } from "@tanstack/react-query";
1
+ /**
2
+ * `@ic-reactor/react` 4: the `'use client'` bindings over `@ic-reactor/core`.
3
+ *
4
+ * A provider that gives a tree one client ({@link ReactorProvider}), a hook
5
+ * that reads it ({@link useClient}), and one that follows who is signed in
6
+ * ({@link useAuth}). Nothing here wraps `useQuery` or `useMutation`: an app
7
+ * calls TanStack Query's own hooks with the options the client builds. The
8
+ * package never re-exports `@ic-reactor/core`, so every name has one import
9
+ * path.
10
+ *
11
+ * The directive above makes this module a client boundary, so a framework
12
+ * that renders on a server (Next.js's App Router, for one) loads it as client
13
+ * code. A Server Component still cannot pass `ReactorProvider` its `client`
14
+ * prop, a function, across that boundary: render the provider from a client
15
+ * module of the app, which a Server Component then renders around its page.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ import type { AuthState, Client } from "@ic-reactor/core";
20
+ import { type ReactElement, type ReactNode } from "react";
21
+ /** Props of {@link ReactorProvider}. */
22
+ export interface ReactorProviderProps {
23
+ /**
24
+ * Returns the client of this tree. Either it creates one, such as
25
+ * `() => createClient({ network: "ic", auth: () => new AuthClient() })`, and
26
+ * the provider owns that client and disposes it when it unmounts; or it
27
+ * returns a client the app created before, at module scope, as
28
+ * `() => client`, and the provider borrows it and never disposes it.
29
+ *
30
+ * A factory, not a client, so that the provider decides when it runs: once
31
+ * per mounted provider, never per render. Give it no work beyond creating or
32
+ * returning the client (`createClient` does none until the client is used):
33
+ * React may call it twice in development and keep one result.
34
+ *
35
+ * Only the factory of the first render is used. A different function on a
36
+ * later render does not rebuild the client; to replace it, remount the
37
+ * provider by giving it another `key`.
38
+ */
39
+ readonly client: () => Client;
40
+ /** The tree that reads the client with {@link useClient} and {@link useAuth}. */
41
+ readonly children: ReactNode;
42
+ }
43
+ /**
44
+ * Gives a tree one client: it gets it from `client` once, on the first
45
+ * render, makes it available to {@link useClient} and {@link useAuth}, renders
46
+ * TanStack Query's `QueryClientProvider` around the children with the
47
+ * client's `QueryClient`, and, if its factory created the client, disposes it
48
+ * when it unmounts.
49
+ *
50
+ * Put it at the root of the part of the app that calls canisters, in a
51
+ * client module (the examples below). On a server it renders inside the
52
+ * request, so a factory that creates the client runs once per request and no
53
+ * cache or caller is shared between two users, which a client at module scope
54
+ * would be.
55
+ *
56
+ * Who disposes the client depends on when it was created, not on where the
57
+ * factory is written. A client the factory call creates belongs to the
58
+ * provider. A client created before the call, such as one at module scope that
59
+ * code outside React uses too, is borrowed: the provider never disposes it,
60
+ * however many times it mounts and unmounts, and the app ends it with
61
+ * `client.dispose()` if it ever needs to. A factory that creates the shared
62
+ * client lazily on its first call (`() => (client ??= createClient(...))`)
63
+ * hands that first provider ownership, and the provider disposes it on
64
+ * unmount. It can also lose the client before any unmount: when React throws
65
+ * away the render that created it (see below), the client stays registered
66
+ * for disposal at collection until the next render gets it back from the
67
+ * factory, so a garbage collection while the fallback shows disposes the
68
+ * client the retry then mounts. Create a shared client eagerly instead. In
69
+ * development, a provider whose factory hands back a client that an earlier
70
+ * factory call created and no provider has committed yet, as a lazily shared
71
+ * factory does, logs a warning (under `StrictMode`, on its first render), and
72
+ * a provider that is given a borrowed client which is already disposed logs an
73
+ * error.
74
+ *
75
+ * Disposal is safe in React's development double-mount (`StrictMode` mounts,
76
+ * unmounts and mounts every component again at once): the cleanup only
77
+ * schedules the disposal for the next macrotask, and the second mount cancels
78
+ * it, so a client in use is never disposed. An unmount that is not followed
79
+ * by a mount disposes an owned client exactly once.
80
+ *
81
+ * React runs no cleanup for a render it throws away before committing it: the
82
+ * first render of a provider below a Suspense boundary that suspends, or the
83
+ * `useState` initializer call that `StrictMode` drops in development. An owned
84
+ * client built for such a render, whose auth a child's {@link useAuth} may
85
+ * already have built, is disposed once that render's state is garbage
86
+ * collected, through a `FinalizationRegistry`. That is later than an unmount
87
+ * would dispose it, at a moment no code chooses, but it is disposed, auth and
88
+ * listeners with it. A client that the factory returns again, or that a
89
+ * provider commits, is taken off the registry, whoever owns it. A runtime
90
+ * without `FinalizationRegistry` never disposes such a client, and a server
91
+ * never registers one: it builds no auth there, and the rest of the request
92
+ * still uses it.
93
+ *
94
+ * React also runs the effects of a subtree again when it shows a hidden
95
+ * `Activity` once more, and that can be long after they were cleaned up. If an
96
+ * owned client was disposed meanwhile, the provider builds another from the
97
+ * same factory, because a disposed client cannot call, sign in or cache any
98
+ * more. The cost is that hiding a provider inside an `Activity` drops its
99
+ * cache: disposing clears the `QueryClient`, and the client built on the next
100
+ * show starts empty. React cannot tell a hidden subtree from an unmounted one
101
+ * in the cleanup, so there is no way to keep it. To keep a cache across
102
+ * hiding, render the provider above the `Activity`, not inside it, or give it
103
+ * a borrowed client, which is never disposed.
104
+ *
105
+ * @example
106
+ * A client per provider, owned and disposed by it (on a server, one per
107
+ * request):
108
+ * ```tsx
109
+ * "use client"
110
+ *
111
+ * import { createClient } from "@ic-reactor/core"
112
+ * import { ReactorProvider } from "@ic-reactor/react"
113
+ * import { AuthClient } from "@icp-sdk/auth/client"
114
+ * import type { ReactNode } from "react"
115
+ *
116
+ * export function Providers({ children }: { children: ReactNode }) {
117
+ * return (
118
+ * <ReactorProvider
119
+ * client={() =>
120
+ * createClient({ network: "ic", auth: () => new AuthClient() })
121
+ * }
122
+ * >
123
+ * {children}
124
+ * </ReactorProvider>
125
+ * )
126
+ * }
127
+ * ```
128
+ *
129
+ * @example
130
+ * One client per tab, created at module scope and used outside React too.
131
+ * The provider borrows it and never disposes it (browser-only: on a server a
132
+ * module-scope client is shared by every request):
133
+ * ```tsx
134
+ * "use client"
135
+ *
136
+ * import { createClient } from "@ic-reactor/core"
137
+ * import { ReactorProvider } from "@ic-reactor/react"
138
+ * import { AuthClient } from "@icp-sdk/auth/client"
139
+ * import type { ReactNode } from "react"
140
+ *
141
+ * export const client = createClient({
142
+ * network: "ic",
143
+ * auth: () => new AuthClient(),
144
+ * })
145
+ *
146
+ * export function Providers({ children }: { children: ReactNode }) {
147
+ * return <ReactorProvider client={() => client}>{children}</ReactorProvider>
148
+ * }
149
+ * ```
150
+ */
151
+ export declare function ReactorProvider({ client: build, children, }: ReactorProviderProps): ReactElement;
152
+ /**
153
+ * The client of the nearest {@link ReactorProvider}: the one object that
154
+ * builds canister handles and query options, and that signs users in and out.
155
+ *
156
+ * Call it in the body of each component that builds keys or options, on
157
+ * every render, and build them from what it returns there, never from a
158
+ * client held at module scope: they are built for the caller this render
159
+ * shows. Do not keep what it returns past the render: while a page hydrates
160
+ * it is a view for the anonymous caller, and a view never moves on. An effect
161
+ * or a callback that uses it closes over its render's value and lists it in
162
+ * its dependencies (`react-hooks/exhaustive-deps`), so that it runs again with
163
+ * the client after hydrating. Kept from the hydrating render anywhere else
164
+ * (`useState(client)`, `useRef(client)`, a `useMemo` or `useCallback` with
165
+ * `[]`, a module variable), it stays that view: the component shows the
166
+ * anonymous caller's data, a read it starts while the user is signed in is
167
+ * cancelled, and a write through it still signs as the live caller. Nothing
168
+ * warns about it. A nested {@link ReactorProvider} given it
169
+ * (`client={() => client}`) holds the client the view was made over.
170
+ * It follows the client's caller with `useSyncExternalStore`, so a
171
+ * component that calls it renders again when the caller changes (a sign-in, a
172
+ * switch of account, a sign-out) and never otherwise: a change of status that
173
+ * leaves the caller as it is (a session that expired, or one signed in
174
+ * elsewhere, both call as the anonymous principal) renders nothing. In the
175
+ * steady state it returns the provider's client object itself.
176
+ *
177
+ * On a server, and while a page hydrates, the caller is the anonymous one, as
178
+ * for {@link useAuth}. In a browser that holds a session, the hydrating render
179
+ * gets a view of the client for the anonymous caller: its `queryKey`,
180
+ * `queryOptions`, `caller()` and `authState()` are the anonymous caller's, so
181
+ * the page finds what the server prefetched and dehydrated and matches its
182
+ * HTML; everything else (canisters, `mutationOptions`, `signIn`, `signOut`,
183
+ * the `QueryClient`) is the client's own, and a write signs as the caller
184
+ * current when it runs. Right after hydrating, React renders the component
185
+ * again with the client itself, for the user: a read with none of the user's
186
+ * data yet shows its loading state, and a `useSuspenseQuery` read its
187
+ * boundary's fallback, until that data arrives. A client built with
188
+ * `identity` keeps its caller for good and is always returned as it is.
189
+ *
190
+ * Three consequences of that move on a signed-in reload:
191
+ *
192
+ * - A Suspense boundary that is still dehydrated below a component that
193
+ * renders with the caller (this hook or {@link useAuth}), because its lazy
194
+ * code is still loading or its streamed HTML has not arrived, is rendered
195
+ * on the client when that component moves on: it shows its fallback
196
+ * instead of the server's HTML, and React 18 reports a recoverable error.
197
+ * Its data is still the user's. A `useAuth()` component also moves on in a
198
+ * tab whose session expired or is signed in elsewhere. Render such a boundary where no component
199
+ * that renders with the caller sits above it, or pass it in as `children`,
200
+ * which a component's own update does not render again.
201
+ * - A read the hydrating render built may still run once (TanStack Query
202
+ * refetches stale data on mount, and an effect may fetch with the view's
203
+ * options). It is cancelled before anything is sent. A key that holds data
204
+ * keeps it as it was, and a fetch of it resolves with that data. A key with
205
+ * none fails (`kind` `"cancelled"`, `code` `"caller_changed"`) until the
206
+ * anonymous caller is current again: the hydrating render's own reads never
207
+ * show that, but a listener of
208
+ * `client.queryClient.getQueryCache().subscribe()` (the client takes no
209
+ * `QueryCache` of yours), an effect that awaits the fetch and, for a
210
+ * `useSuspenseQuery` read the server rendered without dehydrating its
211
+ * data, React's `onRecoverableError` (as the reported error's `cause` on
212
+ * React 19) see it, so ignore `kind` `"cancelled"` there.
213
+ * - Put a Suspense boundary above every component that reads with
214
+ * `useSuspenseQuery`, on React 18 and 19 alike. The move is a synchronous
215
+ * update, which such a read suspends until the user's data arrives. With a
216
+ * boundary above, the boundary shows its fallback, then the user's data,
217
+ * and the rest of the page responds meanwhile. With none, React 18 refuses
218
+ * the update ("A component suspended while responding to synchronous
219
+ * input") and unmounts the root, so a signed-in reload renders nothing.
220
+ * React 19 keeps the server's HTML on screen, but until the user's data
221
+ * arrives, however long the read and its retries take, a click or any other
222
+ * update outside a transition commits nothing, and neither does a
223
+ * transition that renders the reading component again.
224
+ *
225
+ * @throws Error outside a `ReactorProvider`, naming it.
226
+ */
227
+ export declare function useClient(): Client;
228
+ /**
229
+ * Who calls, and how to change it: the client's {@link AuthState} (`status`
230
+ * and `principal`) with `signIn` and `signOut` forwarded to the client.
231
+ *
232
+ * It follows the client with `useSyncExternalStore`, so a component renders
233
+ * again once per change of status or principal and never otherwise (a renewed
234
+ * delegation, or a parent that renders, does not). The object it returns is
235
+ * the same until the state changes, so it is safe in a dependency array or
236
+ * as a prop of a memoized child.
237
+ *
238
+ * On a server, and while a page hydrates, the state is `anonymous`: the
239
+ * server has no session, and rendering the browser's would not match the
240
+ * server's HTML. A browser whose state is another one (signed in, or a session
241
+ * that expired or is signed in elsewhere) renders the component again with its
242
+ * own state right after hydration; an anonymous one does not, and keeps the
243
+ * object. A component that reads `status` before then should show the same
244
+ * thing signed out and while the session is read. Whenever it moves on after
245
+ * hydrating (a signed-in reload, or a session that expired or is signed in
246
+ * elsewhere), it renders a Suspense boundary still dehydrated below it on the
247
+ * client, as for {@link useClient}.
248
+ *
249
+ * `signIn` and `signOut` reject like {@link Client.signIn} and
250
+ * {@link Client.signOut}: on a client built with `identity`, which has no
251
+ * sign-in, and on a server.
252
+ *
253
+ * @throws Error outside a {@link ReactorProvider}.
254
+ */
255
+ export declare function useAuth(): AuthState & {
256
+ /** Signs in through the client's auth, passing `options` on. */
257
+ signIn(options?: unknown): Promise<void>;
258
+ /** Signs out through the client's auth. */
259
+ signOut(options?: unknown): Promise<void>;
260
+ };
17
261
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAGhC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,iBAAiB,CAAA;AAG/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qBAAqB,CAAA;AAEnC,cAAc,iBAAiB,CAAA;AAE/B,cAAc,YAAY,CAAA;AAK1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzD,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAwNd,wCAAwC;AACxC,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,MAAM,CAAA;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2GG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EAAE,KAAK,EACb,QAAQ,GACT,EAAE,oBAAoB,GAAG,YAAY,CAmDrC;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAclC;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,OAAO,IAAI,SAAS,GAAG;IACrC,gEAAgE;IAChE,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,2CAA2C;IAC3C,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1C,CAsBA"}