@trpc/react-query 10.0.0-alpha-exp-suspense-2022-11-07-23-41-14.8

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -0
  3. package/dist/createHooksInternal-9f58b9a0.mjs +414 -0
  4. package/dist/createHooksInternal-bf3d6e79.js +422 -0
  5. package/dist/createTRPCReact.d.ts +42 -0
  6. package/dist/createTRPCReact.d.ts.map +1 -0
  7. package/dist/getArrayQueryKey-5ab807a3.js +21 -0
  8. package/dist/getArrayQueryKey-e56d8d64.mjs +19 -0
  9. package/dist/index.d.ts +4 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +58 -0
  12. package/dist/index.mjs +47 -0
  13. package/dist/internals/context.d.ts +102 -0
  14. package/dist/internals/context.d.ts.map +1 -0
  15. package/dist/internals/getArrayQueryKey.d.ts +9 -0
  16. package/dist/internals/getArrayQueryKey.d.ts.map +1 -0
  17. package/dist/internals/getQueryKey.d.ts +6 -0
  18. package/dist/internals/getQueryKey.d.ts.map +1 -0
  19. package/dist/interop.d.ts +11 -0
  20. package/dist/interop.d.ts.map +1 -0
  21. package/dist/queryClient-358a9a75.js +9 -0
  22. package/dist/queryClient-4d766c0c.mjs +7 -0
  23. package/dist/shared/hooks/createHooksInternal.d.ts +123 -0
  24. package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -0
  25. package/dist/shared/index.d.ts +7 -0
  26. package/dist/shared/index.d.ts.map +1 -0
  27. package/dist/shared/index.js +18 -0
  28. package/dist/shared/index.mjs +7 -0
  29. package/dist/shared/proxy/decorationProxy.d.ts +8 -0
  30. package/dist/shared/proxy/decorationProxy.d.ts.map +1 -0
  31. package/dist/shared/proxy/utilsProxy.d.ts +79 -0
  32. package/dist/shared/proxy/utilsProxy.d.ts.map +1 -0
  33. package/dist/shared/queryClient.d.ts +16 -0
  34. package/dist/shared/queryClient.d.ts.map +1 -0
  35. package/dist/shared/types.d.ts +37 -0
  36. package/dist/shared/types.d.ts.map +1 -0
  37. package/dist/ssg/index.d.ts +5 -0
  38. package/dist/ssg/index.d.ts.map +1 -0
  39. package/dist/ssg/index.js +126 -0
  40. package/dist/ssg/index.mjs +121 -0
  41. package/dist/ssg/ssg.d.ts +23 -0
  42. package/dist/ssg/ssg.d.ts.map +1 -0
  43. package/dist/ssg/ssgProxy.d.ts +36 -0
  44. package/dist/ssg/ssgProxy.d.ts.map +1 -0
  45. package/package.json +80 -0
  46. package/shared/index.d.ts +1 -0
  47. package/shared/index.js +1 -0
  48. package/src/createTRPCReact.tsx +215 -0
  49. package/src/index.ts +4 -0
  50. package/src/internals/context.tsx +247 -0
  51. package/src/internals/getArrayQueryKey.test.ts +41 -0
  52. package/src/internals/getArrayQueryKey.ts +18 -0
  53. package/src/internals/getQueryKey.ts +10 -0
  54. package/src/interop.ts +29 -0
  55. package/src/shared/hooks/createHooksInternal.tsx +684 -0
  56. package/src/shared/index.ts +9 -0
  57. package/src/shared/proxy/decorationProxy.ts +43 -0
  58. package/src/shared/proxy/utilsProxy.ts +260 -0
  59. package/src/shared/queryClient.ts +20 -0
  60. package/src/shared/types.ts +38 -0
  61. package/src/ssg/index.ts +4 -0
  62. package/src/ssg/ssg.ts +138 -0
  63. package/src/ssg/ssgProxy.ts +105 -0
  64. package/ssg/index.d.ts +1 -0
  65. package/ssg/index.js +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) <year> <author>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ <p align="center">
2
+ <a href="https://trpc.io/"><img src="../../www/static/img/logo-text.svg" alt="tRPC" height="130"/></a>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <strong>End-to-end typesafe APIs made easy</strong>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <img src="https://assets.trpc.io/www/v10/preview-dark.gif" alt="Demo" />
11
+ </p>
12
+
13
+ # `@trpc/react`
14
+
15
+ > Connect a tRPC server to React.
16
+
17
+ ## Documentation
18
+
19
+ Full documentation for `@trpc/react-query` can be found [here](https://trpc.io/docs/react-queries)
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ # npm
25
+ npm install @trpc/react-query@next @tanstack/react-query
26
+
27
+ # Yarn
28
+ yarn add @trpc/react-query@next @tanstack/react-query
29
+
30
+ # pnpm
31
+ pnpm add @trpc/react-query@next @tanstack/react-query
32
+ ```
33
+
34
+ ## Basic Example
35
+
36
+ Create a utils file that exports tRPC hooks and providers.
37
+
38
+ ```ts
39
+ import { createReactQueryHooks, createTRPCReact } from '@trpc/react-query';
40
+ import type { AppRouter } from './server';
41
+
42
+ export const trpc = createTRPCReact<AppRouter>();
43
+ ```
44
+
45
+ Use the provider to connect to your API.
46
+
47
+ ```ts
48
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
49
+ import React from 'react';
50
+ import { useState } from 'react';
51
+ import { trpc } from '~/utils/trpc';
52
+
53
+ export function App() {
54
+ const [queryClient] = useState(() => new QueryClient());
55
+ const [trpcClient] = useState(() =>
56
+ trpc.createClient({
57
+ url: 'http://localhost:5000/trpc',
58
+ }),
59
+ );
60
+ return (
61
+ <trpc.Provider client={trpcClient} queryClient={queryClient}>
62
+ <QueryClientProvider client={queryClient}>
63
+ {/* Your app here */}
64
+ </QueryClientProvider>
65
+ </trpc.Provider>
66
+ );
67
+ }
68
+ ```
69
+
70
+ Now in any component, you can query your API using the proxy exported from the utils file.
71
+
72
+ ```ts
73
+ import { proxy } from '~/utils/trpc';
74
+
75
+ export function Hello() {
76
+ const { data, error, status } = proxy.greeting.useQuery({ name: 'tRPC' });
77
+
78
+ if (error) {
79
+ return <p>{error.message}</p>;
80
+ }
81
+
82
+ if (status !== 'success') {
83
+ return <p>Loading...</p>;
84
+ }
85
+
86
+ return <div>{data && <p>{data.greeting}</p>}</div>;
87
+ }
88
+ ```
@@ -0,0 +1,414 @@
1
+ import { createRecursiveProxy, createFlatProxy } from '@trpc/server/shared';
2
+ import { createTRPCClientProxy, createTRPCClient } from '@trpc/client';
3
+ import { useQuery, useQueryClient, useMutation, hashQueryKey, useInfiniteQuery } from '@tanstack/react-query';
4
+ import React, { createContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';
5
+ import { g as getArrayQueryKey } from './getArrayQueryKey-e56d8d64.mjs';
6
+
7
+ /**
8
+ * We treat `undefined` as an input the same as omitting an `input`
9
+ * https://github.com/trpc/trpc/issues/2290
10
+ */ function getQueryKey(path, input) {
11
+ return input === undefined ? [
12
+ path
13
+ ] : [
14
+ path,
15
+ input
16
+ ];
17
+ }
18
+
19
+ /**
20
+ * Create proxy for decorating procedures
21
+ * @internal
22
+ */ function createReactProxyDecoration(name, hooks) {
23
+ return createRecursiveProxy((opts)=>{
24
+ const args = opts.args;
25
+ const pathCopy = [
26
+ name,
27
+ ...opts.path
28
+ ];
29
+ // The last arg is for instance `.useMutation` or `.useQuery()`
30
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
31
+ const lastArg = pathCopy.pop();
32
+ // The `path` ends up being something like `post.byId`
33
+ const path = pathCopy.join('.');
34
+ if (lastArg === 'useMutation') {
35
+ return hooks[lastArg](path, ...args);
36
+ }
37
+ const [input, ...rest] = args;
38
+ const queryKey = getQueryKey(path, input);
39
+ if (lastArg.startsWith('useSuspense')) {
40
+ const opts1 = rest[0] || {};
41
+ const fn = lastArg === 'useSuspenseQuery' ? 'useQuery' : 'useInfiniteQuery';
42
+ return hooks[fn](queryKey, {
43
+ ...opts1,
44
+ suspense: true,
45
+ enabled: true
46
+ });
47
+ }
48
+ return hooks[lastArg](queryKey, ...rest);
49
+ });
50
+ }
51
+
52
+ const contextProps = [
53
+ 'client',
54
+ 'ssrContext',
55
+ 'ssrState',
56
+ 'abortOnUnmount'
57
+ ];
58
+ const TRPCContext = /*#__PURE__*/ createContext(null);
59
+
60
+ /**
61
+ * @internal
62
+ */ function createReactQueryUtilsProxy(context) {
63
+ return createFlatProxy((key)=>{
64
+ const contextName = key;
65
+ if (contextName === 'client') {
66
+ return createTRPCClientProxy(context.client);
67
+ }
68
+ if (contextProps.includes(contextName)) {
69
+ return context[contextName];
70
+ }
71
+ return createRecursiveProxy(({ path , args })=>{
72
+ const pathCopy = [
73
+ key,
74
+ ...path
75
+ ];
76
+ const utilName = pathCopy.pop();
77
+ const fullPath = pathCopy.join('.');
78
+ const getOpts = (name)=>{
79
+ if ([
80
+ 'setData',
81
+ 'setInfiniteData'
82
+ ].includes(name)) {
83
+ const [input, updater, ...rest] = args;
84
+ const queryKey = getQueryKey(fullPath, input);
85
+ return {
86
+ queryKey,
87
+ updater,
88
+ rest
89
+ };
90
+ }
91
+ const [input1, ...rest1] = args;
92
+ const queryKey1 = getQueryKey(fullPath, input1);
93
+ return {
94
+ queryKey: queryKey1,
95
+ rest: rest1
96
+ };
97
+ };
98
+ const { queryKey , rest , updater } = getOpts(utilName);
99
+ const contextMap = {
100
+ fetch: ()=>context.fetchQuery(queryKey, ...rest),
101
+ fetchInfinite: ()=>context.fetchInfiniteQuery(queryKey, ...rest),
102
+ prefetch: ()=>context.prefetchQuery(queryKey, ...rest),
103
+ prefetchInfinite: ()=>context.prefetchInfiniteQuery(queryKey, ...rest),
104
+ invalidate: ()=>context.invalidateQueries(queryKey, ...rest),
105
+ refetch: ()=>context.refetchQueries(queryKey, ...rest),
106
+ cancel: ()=>context.cancelQuery(queryKey, ...rest),
107
+ setData: ()=>context.setQueryData(queryKey, updater, ...rest),
108
+ setInfiniteData: ()=>context.setInfiniteQueryData(queryKey, updater, ...rest),
109
+ getData: ()=>context.getQueryData(queryKey),
110
+ getInfiniteData: ()=>context.getInfiniteQueryData(queryKey)
111
+ };
112
+ return contextMap[utilName]();
113
+ });
114
+ });
115
+ }
116
+
117
+ function getClientArgs(pathAndInput, opts) {
118
+ const [path, input] = pathAndInput;
119
+ return [
120
+ path,
121
+ input,
122
+ opts?.trpc
123
+ ];
124
+ }
125
+ /**
126
+ * Makes a stable reference of the `trpc` prop
127
+ */ function useHookResult(value) {
128
+ const ref = useRef(value);
129
+ ref.current.path = value.path;
130
+ return ref.current;
131
+ }
132
+ /**
133
+ * Create strongly typed react hooks
134
+ * @internal
135
+ */ function createHooksInternal(config) {
136
+ const mutationSuccessOverride = config?.unstable_overrides?.useMutation?.onSuccess ?? ((options)=>options.originalFn());
137
+ const Context = config?.context ?? TRPCContext;
138
+ const ReactQueryContext = config?.reactQueryContext;
139
+ const createClient = (opts)=>{
140
+ return createTRPCClient(opts);
141
+ };
142
+ const TRPCProvider = (props)=>{
143
+ const { abortOnUnmount =false , client , queryClient , ssrContext } = props;
144
+ const [ssrState, setSSRState] = useState(props.ssrState ?? false);
145
+ useEffect(()=>{
146
+ // Only updating state to `mounted` if we are using SSR.
147
+ // This makes it so we don't have an unnecessary re-render when opting out of SSR.
148
+ setSSRState((state)=>state ? 'mounted' : false);
149
+ }, []);
150
+ return /*#__PURE__*/ React.createElement(Context.Provider, {
151
+ value: {
152
+ abortOnUnmount,
153
+ queryClient,
154
+ client,
155
+ ssrContext: ssrContext || null,
156
+ ssrState,
157
+ fetchQuery: useCallback((pathAndInput, opts)=>{
158
+ return queryClient.fetchQuery(getArrayQueryKey(pathAndInput), ()=>client.query(...getClientArgs(pathAndInput, opts)), opts);
159
+ }, [
160
+ client,
161
+ queryClient
162
+ ]),
163
+ fetchInfiniteQuery: useCallback((pathAndInput, opts)=>{
164
+ return queryClient.fetchInfiniteQuery(getArrayQueryKey(pathAndInput), ({ pageParam })=>{
165
+ const [path, input] = pathAndInput;
166
+ const actualInput = {
167
+ ...input,
168
+ cursor: pageParam
169
+ };
170
+ return client.query(...getClientArgs([
171
+ path,
172
+ actualInput
173
+ ], opts));
174
+ }, opts);
175
+ }, [
176
+ client,
177
+ queryClient
178
+ ]),
179
+ prefetchQuery: useCallback((pathAndInput, opts)=>{
180
+ return queryClient.prefetchQuery(getArrayQueryKey(pathAndInput), ()=>client.query(...getClientArgs(pathAndInput, opts)), opts);
181
+ }, [
182
+ client,
183
+ queryClient
184
+ ]),
185
+ prefetchInfiniteQuery: useCallback((pathAndInput, opts)=>{
186
+ return queryClient.prefetchInfiniteQuery(getArrayQueryKey(pathAndInput), ({ pageParam })=>{
187
+ const [path, input] = pathAndInput;
188
+ const actualInput = {
189
+ ...input,
190
+ cursor: pageParam
191
+ };
192
+ return client.query(...getClientArgs([
193
+ path,
194
+ actualInput
195
+ ], opts));
196
+ }, opts);
197
+ }, [
198
+ client,
199
+ queryClient
200
+ ]),
201
+ invalidateQueries: useCallback((...args)=>{
202
+ const [queryKey, ...rest] = args;
203
+ return queryClient.invalidateQueries(getArrayQueryKey(queryKey), ...rest);
204
+ }, [
205
+ queryClient
206
+ ]),
207
+ refetchQueries: useCallback((...args)=>{
208
+ const [queryKey, ...rest] = args;
209
+ return queryClient.refetchQueries(getArrayQueryKey(queryKey), ...rest);
210
+ }, [
211
+ queryClient
212
+ ]),
213
+ cancelQuery: useCallback((pathAndInput)=>{
214
+ return queryClient.cancelQueries(getArrayQueryKey(pathAndInput));
215
+ }, [
216
+ queryClient
217
+ ]),
218
+ setQueryData: useCallback((...args)=>{
219
+ const [queryKey, ...rest] = args;
220
+ return queryClient.setQueryData(getArrayQueryKey(queryKey), ...rest);
221
+ }, [
222
+ queryClient
223
+ ]),
224
+ getQueryData: useCallback((...args)=>{
225
+ const [queryKey, ...rest] = args;
226
+ return queryClient.getQueryData(getArrayQueryKey(queryKey), ...rest);
227
+ }, [
228
+ queryClient
229
+ ]),
230
+ setInfiniteQueryData: useCallback((...args)=>{
231
+ const [queryKey, ...rest] = args;
232
+ return queryClient.setQueryData(getArrayQueryKey(queryKey), ...rest);
233
+ }, [
234
+ queryClient
235
+ ]),
236
+ getInfiniteQueryData: useCallback((...args)=>{
237
+ const [queryKey, ...rest] = args;
238
+ return queryClient.getQueryData(getArrayQueryKey(queryKey), ...rest);
239
+ }, [
240
+ queryClient
241
+ ])
242
+ }
243
+ }, props.children);
244
+ };
245
+ function useContext() {
246
+ return React.useContext(Context);
247
+ }
248
+ /**
249
+ * Hack to make sure errors return `status`='error` when doing SSR
250
+ * @link https://github.com/trpc/trpc/pull/1645
251
+ */ function useSSRQueryOptionsIfNeeded(pathAndInput, opts) {
252
+ const { queryClient , ssrState } = useContext();
253
+ return ssrState && ssrState !== 'mounted' && queryClient.getQueryCache().find(getArrayQueryKey(pathAndInput))?.state.status === 'error' ? {
254
+ retryOnMount: false,
255
+ ...opts
256
+ } : opts;
257
+ }
258
+ function useQuery$1(pathAndInput, opts) {
259
+ const { abortOnUnmount , client , ssrState , queryClient , prefetchQuery } = useContext();
260
+ if (typeof window === 'undefined' && ssrState === 'prepass' && opts?.trpc?.ssr !== false && opts?.enabled !== false && !queryClient.getQueryCache().find(getArrayQueryKey(pathAndInput))) {
261
+ void prefetchQuery(pathAndInput, opts);
262
+ }
263
+ const ssrOpts = useSSRQueryOptionsIfNeeded(pathAndInput, opts);
264
+ // request option should take priority over global
265
+ const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
266
+ const hook = useQuery(getArrayQueryKey(pathAndInput), (queryFunctionContext)=>{
267
+ const actualOpts = {
268
+ ...ssrOpts,
269
+ trpc: {
270
+ ...ssrOpts?.trpc,
271
+ ...shouldAbortOnUnmount ? {
272
+ signal: queryFunctionContext.signal
273
+ } : {}
274
+ }
275
+ };
276
+ return client.query(...getClientArgs(pathAndInput, actualOpts));
277
+ }, {
278
+ context: ReactQueryContext,
279
+ ...ssrOpts
280
+ });
281
+ hook.trpc = useHookResult({
282
+ path: pathAndInput[0]
283
+ });
284
+ return hook;
285
+ }
286
+ function useMutation$1(path, opts) {
287
+ const { client } = useContext();
288
+ const queryClient = useQueryClient({
289
+ context: ReactQueryContext
290
+ });
291
+ const hook = useMutation((input)=>{
292
+ const actualPath = Array.isArray(path) ? path[0] : path;
293
+ return client.mutation(...getClientArgs([
294
+ actualPath,
295
+ input
296
+ ], opts));
297
+ }, {
298
+ context: ReactQueryContext,
299
+ ...opts,
300
+ onSuccess (...args) {
301
+ const originalFn = ()=>opts?.onSuccess?.(...args);
302
+ return mutationSuccessOverride({
303
+ originalFn,
304
+ queryClient
305
+ });
306
+ }
307
+ });
308
+ hook.trpc = useHookResult({
309
+ path: Array.isArray(path) ? path[0] : path
310
+ });
311
+ return hook;
312
+ }
313
+ /* istanbul ignore next */ /**
314
+ * ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
315
+ * **Experimental.** API might change without major version bump
316
+ * ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠
317
+ */ function useSubscription(pathAndInput, opts) {
318
+ const enabled = opts?.enabled ?? true;
319
+ const queryKey = hashQueryKey(pathAndInput);
320
+ const { client } = useContext();
321
+ return useEffect(()=>{
322
+ if (!enabled) {
323
+ return;
324
+ }
325
+ const [path, input] = pathAndInput;
326
+ let isStopped = false;
327
+ const subscription = client.subscription(path, input ?? undefined, {
328
+ onStarted: ()=>{
329
+ if (!isStopped) {
330
+ opts.onStarted?.();
331
+ }
332
+ },
333
+ onData: (data)=>{
334
+ if (!isStopped) {
335
+ opts.onData(data);
336
+ }
337
+ },
338
+ onError: (err)=>{
339
+ if (!isStopped) {
340
+ opts.onError?.(err);
341
+ }
342
+ }
343
+ });
344
+ return ()=>{
345
+ isStopped = true;
346
+ subscription.unsubscribe();
347
+ };
348
+ // eslint-disable-next-line react-hooks/exhaustive-deps
349
+ }, [
350
+ queryKey,
351
+ enabled
352
+ ]);
353
+ }
354
+ function useInfiniteQuery$1(pathAndInput, opts) {
355
+ const [path, input] = pathAndInput;
356
+ const { client , ssrState , prefetchInfiniteQuery , queryClient , abortOnUnmount , } = useContext();
357
+ if (typeof window === 'undefined' && ssrState === 'prepass' && opts?.trpc?.ssr !== false && opts?.enabled !== false && !queryClient.getQueryCache().find(getArrayQueryKey(pathAndInput))) {
358
+ void prefetchInfiniteQuery(pathAndInput, opts);
359
+ }
360
+ const ssrOpts = useSSRQueryOptionsIfNeeded(pathAndInput, opts);
361
+ // request option should take priority over global
362
+ const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? abortOnUnmount;
363
+ const hook = useInfiniteQuery(getArrayQueryKey(pathAndInput), (queryFunctionContext)=>{
364
+ const actualOpts = {
365
+ ...ssrOpts,
366
+ trpc: {
367
+ ...ssrOpts?.trpc,
368
+ ...shouldAbortOnUnmount ? {
369
+ signal: queryFunctionContext.signal
370
+ } : {}
371
+ }
372
+ };
373
+ const actualInput = {
374
+ ...input ?? {},
375
+ cursor: queryFunctionContext.pageParam
376
+ };
377
+ return client.query(...getClientArgs([
378
+ path,
379
+ actualInput
380
+ ], actualOpts));
381
+ }, {
382
+ context: ReactQueryContext,
383
+ ...ssrOpts
384
+ });
385
+ hook.trpc = useHookResult({
386
+ path
387
+ });
388
+ return hook;
389
+ }
390
+ const useDehydratedState = (client, trpcState)=>{
391
+ const transformed = useMemo(()=>{
392
+ if (!trpcState) {
393
+ return trpcState;
394
+ }
395
+ return client.runtime.transformer.deserialize(trpcState);
396
+ }, [
397
+ trpcState,
398
+ client
399
+ ]);
400
+ return transformed;
401
+ };
402
+ return {
403
+ Provider: TRPCProvider,
404
+ createClient,
405
+ useContext,
406
+ useQuery: useQuery$1,
407
+ useMutation: useMutation$1,
408
+ useSubscription,
409
+ useDehydratedState,
410
+ useInfiniteQuery: useInfiniteQuery$1
411
+ };
412
+ }
413
+
414
+ export { createReactQueryUtilsProxy as a, createReactProxyDecoration as b, createHooksInternal as c };