@trpc/react-query 11.18.1-canary.9 → 11.19.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.
- package/dist/getQueryKey-4D2iXfB-.cjs +193 -0
- package/dist/getQueryKey-B1x5Ak4F.mjs +132 -0
- package/dist/getQueryKey-B1x5Ak4F.mjs.map +1 -0
- package/dist/{getQueryKey.d-CruH3ncI.d.mts → getQueryKey-Bw7DtJ4y.d.cts} +21 -46
- package/dist/getQueryKey-Bw7DtJ4y.d.cts.map +1 -0
- package/dist/{getQueryKey.d-C_PnqPni.d.cts → getQueryKey-Cgg9jecL.d.mts} +21 -46
- package/dist/getQueryKey-Cgg9jecL.d.mts.map +1 -0
- package/dist/index.cjs +16 -17
- package/dist/index.d.cts +3 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -10
- package/dist/index.mjs.map +1 -1
- package/dist/rsc.cjs +49 -17
- package/dist/rsc.d.cts +3 -5
- package/dist/rsc.d.cts.map +1 -1
- package/dist/rsc.d.mts +3 -5
- package/dist/rsc.d.mts.map +1 -1
- package/dist/rsc.mjs +43 -12
- package/dist/rsc.mjs.map +1 -1
- package/dist/server/index.cjs +30 -35
- package/dist/server/index.d.cts +3 -5
- package/dist/server/index.d.cts.map +1 -1
- package/dist/server/index.d.mts +3 -5
- package/dist/server/index.d.mts.map +1 -1
- package/dist/server/index.mjs +20 -25
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.cjs +3 -4
- package/dist/shared/index.d.cts +2 -2
- package/dist/shared/index.d.mts +2 -2
- package/dist/shared/index.mjs +2 -4
- package/dist/{shared-Dt4RsQVp.cjs → shared-BhNi4Oqs.cjs} +210 -237
- package/dist/{shared-JtnEvJvB.mjs → shared-DhkLzxq7.mjs} +131 -160
- package/dist/shared-DhkLzxq7.mjs.map +1 -0
- package/package.json +11 -11
- package/src/createTRPCReact.tsx +1 -2
- package/src/index.ts +1 -0
- package/src/internals/context.tsx +10 -4
- package/src/internals/getQueryKey.ts +1 -3
- package/src/internals/useQueries.ts +9 -3
- package/src/shared/hooks/createHooksInternal.tsx +0 -1
- package/src/shared/hooks/types.ts +37 -20
- package/src/shared/types.ts +31 -12
- package/src/utils/createUtilityFunctions.ts +2 -2
- package/dist/getQueryKey-BY58RNzP.mjs +0 -196
- package/dist/getQueryKey-BY58RNzP.mjs.map +0 -1
- package/dist/getQueryKey-PyKLS56S.cjs +0 -242
- package/dist/getQueryKey.d-C_PnqPni.d.cts.map +0 -1
- package/dist/getQueryKey.d-CruH3ncI.d.mts.map +0 -1
- package/dist/shared-JtnEvJvB.mjs.map +0 -1
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as _objectSpread2, i as getQueryKeyInternal, n as getMutationKeyInternal } from "./getQueryKey-B1x5Ak4F.mjs";
|
|
2
2
|
import { TRPCUntypedClient, createTRPCClient, createTRPCClientProxy, getUntypedClient } from "@trpc/client";
|
|
3
3
|
import { QueryClient, hashKey, infiniteQueryOptions, queryOptions, skipToken, useInfiniteQuery, useMutation, usePrefetchInfiniteQuery, usePrefetchQuery, useQueries, useQuery, useSuspenseInfiniteQuery, useSuspenseQueries, useSuspenseQuery } from "@tanstack/react-query";
|
|
4
4
|
import { createFlatProxy, createRecursiveProxy, isAsyncIterable } from "@trpc/server/unstable-core-do-not-import";
|
|
5
|
-
import * as React$2 from "react";
|
|
6
|
-
import * as React$1 from "react";
|
|
7
5
|
import * as React from "react";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
-
|
|
10
6
|
//#region src/shared/proxy/decorationProxy.ts
|
|
11
7
|
/**
|
|
12
8
|
* Create proxy for decorating procedures
|
|
@@ -24,7 +20,6 @@ function createReactDecoration(hooks) {
|
|
|
24
20
|
return hooks[lastArg](pathCopy, input, opts);
|
|
25
21
|
});
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
//#endregion
|
|
29
24
|
//#region src/internals/context.tsx
|
|
30
25
|
var _React$createContext;
|
|
@@ -34,8 +29,7 @@ const contextProps = [
|
|
|
34
29
|
"ssrState",
|
|
35
30
|
"abortOnUnmount"
|
|
36
31
|
];
|
|
37
|
-
const TRPCContext = (_React$createContext = React
|
|
38
|
-
|
|
32
|
+
const TRPCContext = (_React$createContext = React.createContext) === null || _React$createContext === void 0 ? void 0 : _React$createContext.call(React, null);
|
|
39
33
|
//#endregion
|
|
40
34
|
//#region src/shared/proxy/utilsProxy.ts
|
|
41
35
|
const getQueryType = (utilName) => {
|
|
@@ -72,9 +66,12 @@ function createRecursiveUtilsProxy(context) {
|
|
|
72
66
|
const input = args.shift();
|
|
73
67
|
const queryType = getQueryType(utilName);
|
|
74
68
|
const queryKey = getQueryKeyInternal(path, input, queryType);
|
|
75
|
-
|
|
69
|
+
return {
|
|
76
70
|
infiniteQueryOptions: () => context.infiniteQueryOptions(path, queryKey, args[0]),
|
|
77
71
|
queryOptions: () => context.queryOptions(path, queryKey, ...args),
|
|
72
|
+
/**
|
|
73
|
+
* DecorateQueryProcedure
|
|
74
|
+
*/
|
|
78
75
|
fetch: () => context.fetchQuery(queryKey, ...args),
|
|
79
76
|
fetchInfinite: () => context.fetchInfiniteQuery(queryKey, args[0]),
|
|
80
77
|
prefetch: () => context.prefetchQuery(queryKey, ...args),
|
|
@@ -93,11 +90,13 @@ function createRecursiveUtilsProxy(context) {
|
|
|
93
90
|
},
|
|
94
91
|
getData: () => context.getQueryData(queryKey),
|
|
95
92
|
getInfiniteData: () => context.getInfiniteQueryData(queryKey),
|
|
93
|
+
/**
|
|
94
|
+
* DecorateMutationProcedure
|
|
95
|
+
*/
|
|
96
96
|
setMutationDefaults: () => context.setMutationDefaults(getMutationKeyInternal(path), input),
|
|
97
97
|
getMutationDefaults: () => context.getMutationDefaults(getMutationKeyInternal(path)),
|
|
98
98
|
isMutating: () => context.isMutating({ mutationKey: getMutationKeyInternal(path) })
|
|
99
|
-
};
|
|
100
|
-
return contextMap[utilName]();
|
|
99
|
+
}[utilName]();
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
/**
|
|
@@ -119,10 +118,8 @@ function createReactQueryUtils(context) {
|
|
|
119
118
|
function createQueryUtilsProxy(context) {
|
|
120
119
|
return createRecursiveUtilsProxy(context);
|
|
121
120
|
}
|
|
122
|
-
|
|
123
121
|
//#endregion
|
|
124
122
|
//#region src/shared/proxy/useQueriesProxy.ts
|
|
125
|
-
var import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
|
|
126
123
|
/**
|
|
127
124
|
* Create proxy for `useQueries` options
|
|
128
125
|
* @internal
|
|
@@ -133,19 +130,16 @@ function createUseQueries(client) {
|
|
|
133
130
|
const arrayPath = opts.path;
|
|
134
131
|
const dotPath = arrayPath.join(".");
|
|
135
132
|
const [input, _opts] = opts.args;
|
|
136
|
-
|
|
133
|
+
return _objectSpread2({
|
|
137
134
|
queryKey: getQueryKeyInternal(arrayPath, input, "query"),
|
|
138
135
|
queryFn: () => {
|
|
139
136
|
return untypedClient.query(dotPath, input, _opts === null || _opts === void 0 ? void 0 : _opts.trpc);
|
|
140
137
|
}
|
|
141
138
|
}, _opts);
|
|
142
|
-
return options;
|
|
143
139
|
});
|
|
144
140
|
}
|
|
145
|
-
|
|
146
141
|
//#endregion
|
|
147
142
|
//#region src/internals/getClientArgs.ts
|
|
148
|
-
var import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
|
|
149
143
|
/**
|
|
150
144
|
* @internal
|
|
151
145
|
*/
|
|
@@ -155,7 +149,7 @@ function getClientArgs(queryKey, opts, infiniteParams) {
|
|
|
155
149
|
let input = (_queryKey$ = queryKey[1]) === null || _queryKey$ === void 0 ? void 0 : _queryKey$.input;
|
|
156
150
|
if (infiniteParams) {
|
|
157
151
|
var _input;
|
|
158
|
-
input = (
|
|
152
|
+
input = _objectSpread2(_objectSpread2(_objectSpread2({}, (_input = input) !== null && _input !== void 0 ? _input : {}), infiniteParams.pageParam ? { cursor: infiniteParams.pageParam } : {}), {}, { direction: infiniteParams.direction });
|
|
159
153
|
}
|
|
160
154
|
return [
|
|
161
155
|
path.join("."),
|
|
@@ -163,74 +157,66 @@ function getClientArgs(queryKey, opts, infiniteParams) {
|
|
|
163
157
|
opts === null || opts === void 0 ? void 0 : opts.trpc
|
|
164
158
|
];
|
|
165
159
|
}
|
|
166
|
-
|
|
167
160
|
//#endregion
|
|
168
|
-
//#region
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
t = "@@asyncIterator", o = "@@iterator";
|
|
176
|
-
}
|
|
177
|
-
throw new TypeError("Object is not async iterable");
|
|
161
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/asyncIterator.js
|
|
162
|
+
function _asyncIterator(r) {
|
|
163
|
+
var n, t, o, e = 2;
|
|
164
|
+
for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
|
|
165
|
+
if (t && null != (n = r[t])) return n.call(r);
|
|
166
|
+
if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
|
167
|
+
t = "@@asyncIterator", o = "@@iterator";
|
|
178
168
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
this.s = r$1, this.n = r$1.next;
|
|
192
|
-
}, AsyncFromSyncIterator.prototype = {
|
|
193
|
-
s: null,
|
|
194
|
-
n: null,
|
|
195
|
-
next: function next() {
|
|
196
|
-
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
197
|
-
},
|
|
198
|
-
"return": function _return(r$1) {
|
|
199
|
-
var n = this.s["return"];
|
|
200
|
-
return void 0 === n ? Promise.resolve({
|
|
201
|
-
value: r$1,
|
|
202
|
-
done: !0
|
|
203
|
-
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
204
|
-
},
|
|
205
|
-
"throw": function _throw(r$1) {
|
|
206
|
-
var n = this.s["return"];
|
|
207
|
-
return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
208
|
-
}
|
|
209
|
-
}, new AsyncFromSyncIterator(r);
|
|
169
|
+
throw new TypeError("Object is not async iterable");
|
|
170
|
+
}
|
|
171
|
+
function AsyncFromSyncIterator(r) {
|
|
172
|
+
function AsyncFromSyncIteratorContinuation(r) {
|
|
173
|
+
if (Object(r) !== r) return Promise.reject(/* @__PURE__ */ new TypeError(r + " is not an object."));
|
|
174
|
+
var n = r.done;
|
|
175
|
+
return Promise.resolve(r.value).then(function(r) {
|
|
176
|
+
return {
|
|
177
|
+
value: r,
|
|
178
|
+
done: n
|
|
179
|
+
};
|
|
180
|
+
});
|
|
210
181
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
182
|
+
return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) {
|
|
183
|
+
this.s = r, this.n = r.next;
|
|
184
|
+
}, AsyncFromSyncIterator.prototype = {
|
|
185
|
+
s: null,
|
|
186
|
+
n: null,
|
|
187
|
+
next: function next() {
|
|
188
|
+
return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
|
189
|
+
},
|
|
190
|
+
"return": function _return(r) {
|
|
191
|
+
var n = this.s["return"];
|
|
192
|
+
return void 0 === n ? Promise.resolve({
|
|
193
|
+
value: r,
|
|
194
|
+
done: !0
|
|
195
|
+
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
196
|
+
},
|
|
197
|
+
"throw": function _throw(r) {
|
|
198
|
+
var n = this.s["return"];
|
|
199
|
+
return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
|
200
|
+
}
|
|
201
|
+
}, new AsyncFromSyncIterator(r);
|
|
202
|
+
}
|
|
214
203
|
//#endregion
|
|
215
204
|
//#region src/internals/trpcResult.ts
|
|
216
|
-
var import_asyncIterator = __toESM(require_asyncIterator(), 1);
|
|
217
205
|
function createTRPCOptionsResult(value) {
|
|
218
|
-
|
|
219
|
-
return { path };
|
|
206
|
+
return { path: value.path.join(".") };
|
|
220
207
|
}
|
|
221
208
|
/**
|
|
222
209
|
* Makes a stable reference of the `trpc` prop
|
|
223
210
|
*/
|
|
224
211
|
function useHookResult(value) {
|
|
225
212
|
const result = createTRPCOptionsResult(value);
|
|
226
|
-
return React
|
|
213
|
+
return React.useMemo(() => result, [result]);
|
|
227
214
|
}
|
|
228
215
|
/**
|
|
229
216
|
* @internal
|
|
230
217
|
*/
|
|
231
218
|
async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
|
|
232
|
-
const
|
|
233
|
-
const query = queryCache.build(queryClient, { queryKey });
|
|
219
|
+
const query = queryClient.getQueryCache().build(queryClient, { queryKey });
|
|
234
220
|
query.setState({
|
|
235
221
|
data: [],
|
|
236
222
|
status: "success"
|
|
@@ -240,12 +226,10 @@ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey)
|
|
|
240
226
|
var _didIteratorError = false;
|
|
241
227
|
var _iteratorError;
|
|
242
228
|
try {
|
|
243
|
-
for (var _iterator = (
|
|
229
|
+
for (var _iterator = _asyncIterator(asyncIterable), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
|
|
244
230
|
const value = _step.value;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
query.setState({ data: [...aggregate] });
|
|
248
|
-
}
|
|
231
|
+
aggregate.push(value);
|
|
232
|
+
query.setState({ data: [...aggregate] });
|
|
249
233
|
}
|
|
250
234
|
} catch (err) {
|
|
251
235
|
_didIteratorError = true;
|
|
@@ -259,10 +243,8 @@ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey)
|
|
|
259
243
|
}
|
|
260
244
|
return aggregate;
|
|
261
245
|
}
|
|
262
|
-
|
|
263
246
|
//#endregion
|
|
264
247
|
//#region src/utils/createUtilityFunctions.ts
|
|
265
|
-
var import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
|
|
266
248
|
/**
|
|
267
249
|
* Creates a set of utility functions that can be used to interact with `react-query`
|
|
268
250
|
* @param opts the `TRPCClient` and `QueryClient` to use
|
|
@@ -273,93 +255,92 @@ function createUtilityFunctions(opts) {
|
|
|
273
255
|
const { client, queryClient } = opts;
|
|
274
256
|
const untypedClient = client instanceof TRPCUntypedClient ? client : getUntypedClient(client);
|
|
275
257
|
return {
|
|
276
|
-
infiniteQueryOptions: (path, queryKey, opts
|
|
258
|
+
infiniteQueryOptions: (path, queryKey, opts) => {
|
|
277
259
|
var _queryKey$, _ref;
|
|
278
260
|
const inputIsSkipToken = ((_queryKey$ = queryKey[1]) === null || _queryKey$ === void 0 ? void 0 : _queryKey$.input) === skipToken;
|
|
279
261
|
const queryFn = async (queryFnContext) => {
|
|
280
262
|
var _opts$trpc;
|
|
281
|
-
const actualOpts = (
|
|
282
|
-
|
|
263
|
+
const actualOpts = _objectSpread2(_objectSpread2({}, opts), {}, { trpc: _objectSpread2(_objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), (opts === null || opts === void 0 || (_opts$trpc = opts.trpc) === null || _opts$trpc === void 0 ? void 0 : _opts$trpc.abortOnUnmount) ? { signal: queryFnContext.signal } : { signal: null }) });
|
|
264
|
+
return await untypedClient.query(...getClientArgs(queryKey, actualOpts, {
|
|
283
265
|
direction: queryFnContext.direction,
|
|
284
266
|
pageParam: queryFnContext.pageParam
|
|
285
267
|
}));
|
|
286
|
-
return result;
|
|
287
268
|
};
|
|
288
|
-
return Object.assign(infiniteQueryOptions((
|
|
289
|
-
initialData: opts
|
|
269
|
+
return Object.assign(infiniteQueryOptions(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
270
|
+
initialData: opts === null || opts === void 0 ? void 0 : opts.initialData,
|
|
290
271
|
queryKey,
|
|
291
272
|
queryFn: inputIsSkipToken ? skipToken : queryFn,
|
|
292
|
-
initialPageParam: (_ref = opts
|
|
273
|
+
initialPageParam: (_ref = opts === null || opts === void 0 ? void 0 : opts.initialCursor) !== null && _ref !== void 0 ? _ref : null
|
|
293
274
|
})), { trpc: createTRPCOptionsResult({ path }) });
|
|
294
275
|
},
|
|
295
|
-
queryOptions: (path, queryKey, opts
|
|
276
|
+
queryOptions: (path, queryKey, opts) => {
|
|
296
277
|
var _queryKey$2;
|
|
297
278
|
const inputIsSkipToken = ((_queryKey$2 = queryKey[1]) === null || _queryKey$2 === void 0 ? void 0 : _queryKey$2.input) === skipToken;
|
|
298
279
|
const queryFn = async (queryFnContext) => {
|
|
299
280
|
var _opts$trpc2;
|
|
300
|
-
const actualOpts = (
|
|
281
|
+
const actualOpts = _objectSpread2(_objectSpread2({}, opts), {}, { trpc: _objectSpread2(_objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), (opts === null || opts === void 0 || (_opts$trpc2 = opts.trpc) === null || _opts$trpc2 === void 0 ? void 0 : _opts$trpc2.abortOnUnmount) ? { signal: queryFnContext.signal } : { signal: null }) });
|
|
301
282
|
const result = await untypedClient.query(...getClientArgs(queryKey, actualOpts));
|
|
302
283
|
if (isAsyncIterable(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey);
|
|
303
284
|
return result;
|
|
304
285
|
};
|
|
305
|
-
return Object.assign(queryOptions((
|
|
306
|
-
initialData: opts
|
|
286
|
+
return Object.assign(queryOptions(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
287
|
+
initialData: opts === null || opts === void 0 ? void 0 : opts.initialData,
|
|
307
288
|
queryKey,
|
|
308
289
|
queryFn: inputIsSkipToken ? skipToken : queryFn
|
|
309
290
|
})), { trpc: createTRPCOptionsResult({ path }) });
|
|
310
291
|
},
|
|
311
|
-
fetchQuery: (queryKey, opts
|
|
312
|
-
return queryClient.fetchQuery((
|
|
292
|
+
fetchQuery: (queryKey, opts) => {
|
|
293
|
+
return queryClient.fetchQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
313
294
|
queryKey,
|
|
314
|
-
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts
|
|
295
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts))
|
|
315
296
|
}));
|
|
316
297
|
},
|
|
317
|
-
fetchInfiniteQuery: (queryKey, opts
|
|
298
|
+
fetchInfiniteQuery: (queryKey, opts) => {
|
|
318
299
|
var _opts$initialCursor;
|
|
319
|
-
return queryClient.fetchInfiniteQuery((
|
|
300
|
+
return queryClient.fetchInfiniteQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
320
301
|
queryKey,
|
|
321
302
|
queryFn: ({ pageParam, direction }) => {
|
|
322
|
-
return untypedClient.query(...getClientArgs(queryKey, opts
|
|
303
|
+
return untypedClient.query(...getClientArgs(queryKey, opts, {
|
|
323
304
|
pageParam,
|
|
324
305
|
direction
|
|
325
306
|
}));
|
|
326
307
|
},
|
|
327
|
-
initialPageParam: (_opts$initialCursor = opts
|
|
308
|
+
initialPageParam: (_opts$initialCursor = opts === null || opts === void 0 ? void 0 : opts.initialCursor) !== null && _opts$initialCursor !== void 0 ? _opts$initialCursor : null
|
|
328
309
|
}));
|
|
329
310
|
},
|
|
330
|
-
prefetchQuery: (queryKey, opts
|
|
331
|
-
return queryClient.prefetchQuery((
|
|
311
|
+
prefetchQuery: (queryKey, opts) => {
|
|
312
|
+
return queryClient.prefetchQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
332
313
|
queryKey,
|
|
333
|
-
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts
|
|
314
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts))
|
|
334
315
|
}));
|
|
335
316
|
},
|
|
336
|
-
prefetchInfiniteQuery: (queryKey, opts
|
|
317
|
+
prefetchInfiniteQuery: (queryKey, opts) => {
|
|
337
318
|
var _opts$initialCursor2;
|
|
338
|
-
return queryClient.prefetchInfiniteQuery((
|
|
319
|
+
return queryClient.prefetchInfiniteQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
339
320
|
queryKey,
|
|
340
321
|
queryFn: ({ pageParam, direction }) => {
|
|
341
|
-
return untypedClient.query(...getClientArgs(queryKey, opts
|
|
322
|
+
return untypedClient.query(...getClientArgs(queryKey, opts, {
|
|
342
323
|
pageParam,
|
|
343
324
|
direction
|
|
344
325
|
}));
|
|
345
326
|
},
|
|
346
|
-
initialPageParam: (_opts$initialCursor2 = opts
|
|
327
|
+
initialPageParam: (_opts$initialCursor2 = opts === null || opts === void 0 ? void 0 : opts.initialCursor) !== null && _opts$initialCursor2 !== void 0 ? _opts$initialCursor2 : null
|
|
347
328
|
}));
|
|
348
329
|
},
|
|
349
|
-
ensureQueryData: (queryKey, opts
|
|
350
|
-
return queryClient.ensureQueryData((
|
|
330
|
+
ensureQueryData: (queryKey, opts) => {
|
|
331
|
+
return queryClient.ensureQueryData(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
351
332
|
queryKey,
|
|
352
|
-
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts
|
|
333
|
+
queryFn: () => untypedClient.query(...getClientArgs(queryKey, opts))
|
|
353
334
|
}));
|
|
354
335
|
},
|
|
355
336
|
invalidateQueries: (queryKey, filters, options) => {
|
|
356
|
-
return queryClient.invalidateQueries((
|
|
337
|
+
return queryClient.invalidateQueries(_objectSpread2(_objectSpread2({}, filters), {}, { queryKey }), options);
|
|
357
338
|
},
|
|
358
339
|
resetQueries: (queryKey, filters, options) => {
|
|
359
|
-
return queryClient.resetQueries((
|
|
340
|
+
return queryClient.resetQueries(_objectSpread2(_objectSpread2({}, filters), {}, { queryKey }), options);
|
|
360
341
|
},
|
|
361
342
|
refetchQueries: (queryKey, filters, options) => {
|
|
362
|
-
return queryClient.refetchQueries((
|
|
343
|
+
return queryClient.refetchQueries(_objectSpread2(_objectSpread2({}, filters), {}, { queryKey }), options);
|
|
363
344
|
},
|
|
364
345
|
cancelQuery: (queryKey, options) => {
|
|
365
346
|
return queryClient.cancelQueries({ queryKey }, options);
|
|
@@ -368,7 +349,7 @@ function createUtilityFunctions(opts) {
|
|
|
368
349
|
return queryClient.setQueryData(queryKey, updater, options);
|
|
369
350
|
},
|
|
370
351
|
setQueriesData: (queryKey, filters, updater, options) => {
|
|
371
|
-
return queryClient.setQueriesData((
|
|
352
|
+
return queryClient.setQueriesData(_objectSpread2(_objectSpread2({}, filters), {}, { queryKey }), updater, options);
|
|
372
353
|
},
|
|
373
354
|
getQueryData: (queryKey) => {
|
|
374
355
|
return queryClient.getQueryData(queryKey);
|
|
@@ -390,27 +371,24 @@ function createUtilityFunctions(opts) {
|
|
|
390
371
|
return queryClient.getMutationDefaults(mutationKey);
|
|
391
372
|
},
|
|
392
373
|
isMutating: (filters) => {
|
|
393
|
-
return queryClient.isMutating((
|
|
374
|
+
return queryClient.isMutating(_objectSpread2(_objectSpread2({}, filters), {}, { exact: true }));
|
|
394
375
|
}
|
|
395
376
|
};
|
|
396
377
|
}
|
|
397
|
-
|
|
398
378
|
//#endregion
|
|
399
379
|
//#region src/shared/hooks/createHooksInternal.tsx
|
|
400
|
-
var import_objectSpread2 = __toESM(require_objectSpread2());
|
|
401
380
|
const trackResult = (result, onTrackResult) => {
|
|
402
|
-
|
|
381
|
+
return new Proxy(result, { get(target, prop) {
|
|
403
382
|
onTrackResult(prop);
|
|
404
383
|
return target[prop];
|
|
405
384
|
} });
|
|
406
|
-
return trackedResult;
|
|
407
385
|
};
|
|
408
386
|
/**
|
|
409
387
|
* @internal
|
|
410
388
|
*/
|
|
411
389
|
function createRootHooks(config) {
|
|
412
390
|
var _config$overrides$use, _config$overrides, _config$context;
|
|
413
|
-
const mutationSuccessOverride = (_config$overrides$use = config === null || config === void 0 || (_config$overrides = config.overrides) === null || _config$overrides === void 0 || (_config$overrides = _config$overrides.useMutation) === null || _config$overrides === void 0 ? void 0 : _config$overrides.onSuccess) !== null && _config$overrides$use !== void 0 ? _config$overrides$use : (options) => options.originalFn();
|
|
391
|
+
const mutationSuccessOverride = (_config$overrides$use = config === null || config === void 0 || (_config$overrides = config.overrides) === null || _config$overrides === void 0 || (_config$overrides = _config$overrides.useMutation) === null || _config$overrides === void 0 ? void 0 : _config$overrides.onSuccess) !== null && _config$overrides$use !== void 0 ? _config$overrides$use : ((options) => options.originalFn());
|
|
414
392
|
const Context = (_config$context = config === null || config === void 0 ? void 0 : config.context) !== null && _config$context !== void 0 ? _config$context : TRPCContext;
|
|
415
393
|
const createClient = createTRPCClient;
|
|
416
394
|
const TRPCProvider = (props) => {
|
|
@@ -422,7 +400,7 @@ function createRootHooks(config) {
|
|
|
422
400
|
client,
|
|
423
401
|
queryClient
|
|
424
402
|
}), [client, queryClient]);
|
|
425
|
-
const contextValue = React.useMemo(() => (
|
|
403
|
+
const contextValue = React.useMemo(() => _objectSpread2({
|
|
426
404
|
abortOnUnmount,
|
|
427
405
|
queryClient,
|
|
428
406
|
client,
|
|
@@ -439,10 +417,7 @@ function createRootHooks(config) {
|
|
|
439
417
|
React.useEffect(() => {
|
|
440
418
|
setSSRState((state) => state ? "mounted" : false);
|
|
441
419
|
}, []);
|
|
442
|
-
return /* @__PURE__ */
|
|
443
|
-
value: contextValue,
|
|
444
|
-
children: props.children
|
|
445
|
-
});
|
|
420
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value: contextValue }, props.children);
|
|
446
421
|
};
|
|
447
422
|
function useContext() {
|
|
448
423
|
const context = React.useContext(Context);
|
|
@@ -456,22 +431,21 @@ function createRootHooks(config) {
|
|
|
456
431
|
function useSSRQueryOptionsIfNeeded(queryKey, opts) {
|
|
457
432
|
var _queryClient$getQuery;
|
|
458
433
|
const { queryClient, ssrState } = useContext();
|
|
459
|
-
return ssrState && ssrState !== "mounted" && ((_queryClient$getQuery = queryClient.getQueryCache().find({ queryKey })) === null || _queryClient$getQuery === void 0 ? void 0 : _queryClient$getQuery.state.status) === "error" ? (
|
|
434
|
+
return ssrState && ssrState !== "mounted" && ((_queryClient$getQuery = queryClient.getQueryCache().find({ queryKey })) === null || _queryClient$getQuery === void 0 ? void 0 : _queryClient$getQuery.state.status) === "error" ? _objectSpread2({ retryOnMount: false }, opts) : opts;
|
|
460
435
|
}
|
|
461
436
|
function useQuery$1(path, input, opts) {
|
|
462
437
|
var _opts$trpc, _opts$enabled, _ref, _opts$trpc$abortOnUnm, _opts$trpc2;
|
|
463
|
-
const
|
|
464
|
-
const { abortOnUnmount, client, ssrState, queryClient, prefetchQuery } = context;
|
|
438
|
+
const { abortOnUnmount, client, ssrState, queryClient, prefetchQuery } = useContext();
|
|
465
439
|
const queryKey = getQueryKeyInternal(path, input, "query");
|
|
466
440
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
467
441
|
const isInputSkipToken = input === skipToken;
|
|
468
442
|
if (typeof window === "undefined" && ssrState === "prepass" && (opts === null || opts === void 0 || (_opts$trpc = opts.trpc) === null || _opts$trpc === void 0 ? void 0 : _opts$trpc.ssr) !== false && ((_opts$enabled = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled !== void 0 ? _opts$enabled : defaultOpts === null || defaultOpts === void 0 ? void 0 : defaultOpts.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({ queryKey })) prefetchQuery(queryKey, opts);
|
|
469
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, (
|
|
443
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, _objectSpread2(_objectSpread2({}, defaultOpts), opts));
|
|
470
444
|
const shouldAbortOnUnmount = (_ref = (_opts$trpc$abortOnUnm = opts === null || opts === void 0 || (_opts$trpc2 = opts.trpc) === null || _opts$trpc2 === void 0 ? void 0 : _opts$trpc2.abortOnUnmount) !== null && _opts$trpc$abortOnUnm !== void 0 ? _opts$trpc$abortOnUnm : config === null || config === void 0 ? void 0 : config.abortOnUnmount) !== null && _ref !== void 0 ? _ref : abortOnUnmount;
|
|
471
|
-
const hook = useQuery((
|
|
445
|
+
const hook = useQuery(_objectSpread2(_objectSpread2({}, ssrOpts), {}, {
|
|
472
446
|
queryKey,
|
|
473
447
|
queryFn: isInputSkipToken ? input : async (queryFunctionContext) => {
|
|
474
|
-
const actualOpts = (
|
|
448
|
+
const actualOpts = _objectSpread2(_objectSpread2({}, ssrOpts), {}, { trpc: _objectSpread2(_objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : { signal: null }) });
|
|
475
449
|
const result = await client.query(...getClientArgs(queryKey, actualOpts));
|
|
476
450
|
if (isAsyncIterable(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey);
|
|
477
451
|
return result;
|
|
@@ -486,10 +460,10 @@ function createRootHooks(config) {
|
|
|
486
460
|
const queryKey = getQueryKeyInternal(path, input, "query");
|
|
487
461
|
const isInputSkipToken = input === skipToken;
|
|
488
462
|
const shouldAbortOnUnmount = (_ref2 = (_opts$trpc$abortOnUnm2 = opts === null || opts === void 0 || (_opts$trpc3 = opts.trpc) === null || _opts$trpc3 === void 0 ? void 0 : _opts$trpc3.abortOnUnmount) !== null && _opts$trpc$abortOnUnm2 !== void 0 ? _opts$trpc$abortOnUnm2 : config === null || config === void 0 ? void 0 : config.abortOnUnmount) !== null && _ref2 !== void 0 ? _ref2 : context.abortOnUnmount;
|
|
489
|
-
usePrefetchQuery((
|
|
463
|
+
usePrefetchQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
490
464
|
queryKey,
|
|
491
465
|
queryFn: isInputSkipToken ? input : (queryFunctionContext) => {
|
|
492
|
-
const actualOpts = { trpc: (
|
|
466
|
+
const actualOpts = { trpc: _objectSpread2(_objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : {}) };
|
|
493
467
|
return context.client.query(...getClientArgs(queryKey, actualOpts));
|
|
494
468
|
}
|
|
495
469
|
}));
|
|
@@ -499,10 +473,10 @@ function createRootHooks(config) {
|
|
|
499
473
|
const context = useContext();
|
|
500
474
|
const queryKey = getQueryKeyInternal(path, input, "query");
|
|
501
475
|
const shouldAbortOnUnmount = (_ref3 = (_opts$trpc$abortOnUnm3 = opts === null || opts === void 0 || (_opts$trpc4 = opts.trpc) === null || _opts$trpc4 === void 0 ? void 0 : _opts$trpc4.abortOnUnmount) !== null && _opts$trpc$abortOnUnm3 !== void 0 ? _opts$trpc$abortOnUnm3 : config === null || config === void 0 ? void 0 : config.abortOnUnmount) !== null && _ref3 !== void 0 ? _ref3 : context.abortOnUnmount;
|
|
502
|
-
const hook = useSuspenseQuery((
|
|
476
|
+
const hook = useSuspenseQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
503
477
|
queryKey,
|
|
504
478
|
queryFn: (queryFunctionContext) => {
|
|
505
|
-
const actualOpts = (
|
|
479
|
+
const actualOpts = _objectSpread2(_objectSpread2({}, opts), {}, { trpc: _objectSpread2(_objectSpread2({}, opts === null || opts === void 0 ? void 0 : opts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : { signal: null }) });
|
|
506
480
|
return context.client.query(...getClientArgs(queryKey, actualOpts));
|
|
507
481
|
}
|
|
508
482
|
}), context.queryClient);
|
|
@@ -513,7 +487,7 @@ function createRootHooks(config) {
|
|
|
513
487
|
const { client, queryClient } = useContext();
|
|
514
488
|
const mutationKey = getMutationKeyInternal(path);
|
|
515
489
|
const defaultOpts = queryClient.defaultMutationOptions(queryClient.getMutationDefaults(mutationKey));
|
|
516
|
-
const hook = useMutation((
|
|
490
|
+
const hook = useMutation(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
517
491
|
mutationKey,
|
|
518
492
|
mutationFn: (input) => {
|
|
519
493
|
return client.mutation(...getClientArgs([path, { input }], opts));
|
|
@@ -554,7 +528,7 @@ function createRootHooks(config) {
|
|
|
554
528
|
React.useEffect(() => {
|
|
555
529
|
optsRef.current = opts;
|
|
556
530
|
});
|
|
557
|
-
const [trackedProps] = React.useState(new Set([]));
|
|
531
|
+
const [trackedProps] = React.useState(/* @__PURE__ */ new Set([]));
|
|
558
532
|
const addTrackedProp = React.useCallback((key) => {
|
|
559
533
|
trackedProps.add(key);
|
|
560
534
|
}, [trackedProps]);
|
|
@@ -573,15 +547,15 @@ function createRootHooks(config) {
|
|
|
573
547
|
var _currentSubscriptionR;
|
|
574
548
|
(_currentSubscriptionR = currentSubscriptionRef.current) === null || _currentSubscriptionR === void 0 || _currentSubscriptionR.unsubscribe();
|
|
575
549
|
if (!enabled) {
|
|
576
|
-
updateState(() => (
|
|
550
|
+
updateState(() => _objectSpread2(_objectSpread2({}, initialStateIdle), {}, { reset }));
|
|
577
551
|
return;
|
|
578
552
|
}
|
|
579
|
-
updateState(() => (
|
|
553
|
+
updateState(() => _objectSpread2(_objectSpread2({}, initialStateConnecting), {}, { reset }));
|
|
580
554
|
const subscription = client.subscription(path.join("."), input !== null && input !== void 0 ? input : void 0, {
|
|
581
555
|
onStarted: () => {
|
|
582
556
|
var _optsRef$current$onSt, _optsRef$current;
|
|
583
557
|
(_optsRef$current$onSt = (_optsRef$current = optsRef.current).onStarted) === null || _optsRef$current$onSt === void 0 || _optsRef$current$onSt.call(_optsRef$current);
|
|
584
|
-
updateState((prev) => (
|
|
558
|
+
updateState((prev) => _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
585
559
|
status: "pending",
|
|
586
560
|
error: null
|
|
587
561
|
}));
|
|
@@ -589,7 +563,7 @@ function createRootHooks(config) {
|
|
|
589
563
|
onData: (data) => {
|
|
590
564
|
var _optsRef$current$onDa, _optsRef$current2;
|
|
591
565
|
(_optsRef$current$onDa = (_optsRef$current2 = optsRef.current).onData) === null || _optsRef$current$onDa === void 0 || _optsRef$current$onDa.call(_optsRef$current2, data);
|
|
592
|
-
updateState((prev) => (
|
|
566
|
+
updateState((prev) => _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
593
567
|
status: "pending",
|
|
594
568
|
data,
|
|
595
569
|
error: null
|
|
@@ -598,7 +572,7 @@ function createRootHooks(config) {
|
|
|
598
572
|
onError: (error) => {
|
|
599
573
|
var _optsRef$current$onEr, _optsRef$current3;
|
|
600
574
|
(_optsRef$current$onEr = (_optsRef$current3 = optsRef.current).onError) === null || _optsRef$current$onEr === void 0 || _optsRef$current$onEr.call(_optsRef$current3, error);
|
|
601
|
-
updateState((prev) => (
|
|
575
|
+
updateState((prev) => _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
602
576
|
status: "error",
|
|
603
577
|
error
|
|
604
578
|
}));
|
|
@@ -606,12 +580,12 @@ function createRootHooks(config) {
|
|
|
606
580
|
onConnectionStateChange: (result) => {
|
|
607
581
|
updateState((prev) => {
|
|
608
582
|
switch (result.state) {
|
|
609
|
-
case "idle": return (
|
|
583
|
+
case "idle": return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
610
584
|
status: result.state,
|
|
611
585
|
error: null,
|
|
612
586
|
data: void 0
|
|
613
587
|
});
|
|
614
|
-
case "connecting": return (
|
|
588
|
+
case "connecting": return _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
615
589
|
error: result.error,
|
|
616
590
|
status: result.state
|
|
617
591
|
});
|
|
@@ -622,7 +596,7 @@ function createRootHooks(config) {
|
|
|
622
596
|
onComplete: () => {
|
|
623
597
|
var _optsRef$current$onCo, _optsRef$current4;
|
|
624
598
|
(_optsRef$current$onCo = (_optsRef$current4 = optsRef.current).onComplete) === null || _optsRef$current$onCo === void 0 || _optsRef$current$onCo.call(_optsRef$current4);
|
|
625
|
-
updateState((prev) => (
|
|
599
|
+
updateState((prev) => _objectSpread2(_objectSpread2({}, prev), {}, {
|
|
626
600
|
status: "idle",
|
|
627
601
|
error: null,
|
|
628
602
|
data: void 0
|
|
@@ -643,7 +617,7 @@ function createRootHooks(config) {
|
|
|
643
617
|
(_currentSubscriptionR2 = currentSubscriptionRef.current) === null || _currentSubscriptionR2 === void 0 || _currentSubscriptionR2.unsubscribe();
|
|
644
618
|
};
|
|
645
619
|
}, [reset]);
|
|
646
|
-
const resultRef = React.useRef(enabled ? (
|
|
620
|
+
const resultRef = React.useRef(enabled ? _objectSpread2(_objectSpread2({}, initialStateConnecting), {}, { reset }) : _objectSpread2(_objectSpread2({}, initialStateIdle), {}, { reset }));
|
|
647
621
|
const [state, setState] = React.useState(trackResult(resultRef.current, addTrackedProp));
|
|
648
622
|
return state;
|
|
649
623
|
}
|
|
@@ -653,16 +627,16 @@ function createRootHooks(config) {
|
|
|
653
627
|
const queryKey = getQueryKeyInternal(path, input, "infinite");
|
|
654
628
|
const defaultOpts = queryClient.getQueryDefaults(queryKey);
|
|
655
629
|
const isInputSkipToken = input === skipToken;
|
|
656
|
-
if (typeof window === "undefined" && ssrState === "prepass" && (opts === null || opts === void 0 || (_opts$trpc5 = opts.trpc) === null || _opts$trpc5 === void 0 ? void 0 : _opts$trpc5.ssr) !== false && ((_opts$enabled3 = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled3 !== void 0 ? _opts$enabled3 : defaultOpts === null || defaultOpts === void 0 ? void 0 : defaultOpts.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({ queryKey })) prefetchInfiniteQuery(queryKey, (
|
|
657
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, (
|
|
630
|
+
if (typeof window === "undefined" && ssrState === "prepass" && (opts === null || opts === void 0 || (_opts$trpc5 = opts.trpc) === null || _opts$trpc5 === void 0 ? void 0 : _opts$trpc5.ssr) !== false && ((_opts$enabled3 = opts === null || opts === void 0 ? void 0 : opts.enabled) !== null && _opts$enabled3 !== void 0 ? _opts$enabled3 : defaultOpts === null || defaultOpts === void 0 ? void 0 : defaultOpts.enabled) !== false && !isInputSkipToken && !queryClient.getQueryCache().find({ queryKey })) prefetchInfiniteQuery(queryKey, _objectSpread2(_objectSpread2({}, defaultOpts), opts));
|
|
631
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, _objectSpread2(_objectSpread2({}, defaultOpts), opts));
|
|
658
632
|
const shouldAbortOnUnmount = (_opts$trpc$abortOnUnm4 = opts === null || opts === void 0 || (_opts$trpc6 = opts.trpc) === null || _opts$trpc6 === void 0 ? void 0 : _opts$trpc6.abortOnUnmount) !== null && _opts$trpc$abortOnUnm4 !== void 0 ? _opts$trpc$abortOnUnm4 : abortOnUnmount;
|
|
659
|
-
const hook = useInfiniteQuery((
|
|
633
|
+
const hook = useInfiniteQuery(_objectSpread2(_objectSpread2({}, ssrOpts), {}, {
|
|
660
634
|
initialPageParam: (_opts$initialCursor = opts.initialCursor) !== null && _opts$initialCursor !== void 0 ? _opts$initialCursor : null,
|
|
661
635
|
persister: opts.persister,
|
|
662
636
|
queryKey,
|
|
663
637
|
queryFn: isInputSkipToken ? input : (queryFunctionContext) => {
|
|
664
638
|
var _queryFunctionContext;
|
|
665
|
-
const actualOpts = (
|
|
639
|
+
const actualOpts = _objectSpread2(_objectSpread2({}, ssrOpts), {}, { trpc: _objectSpread2(_objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : { signal: null }) });
|
|
666
640
|
return client.query(...getClientArgs(queryKey, actualOpts, {
|
|
667
641
|
pageParam: (_queryFunctionContext = queryFunctionContext.pageParam) !== null && _queryFunctionContext !== void 0 ? _queryFunctionContext : opts.initialCursor,
|
|
668
642
|
direction: queryFunctionContext.direction
|
|
@@ -678,14 +652,14 @@ function createRootHooks(config) {
|
|
|
678
652
|
const queryKey = getQueryKeyInternal(path, input, "infinite");
|
|
679
653
|
const defaultOpts = context.queryClient.getQueryDefaults(queryKey);
|
|
680
654
|
const isInputSkipToken = input === skipToken;
|
|
681
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, (
|
|
655
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, _objectSpread2(_objectSpread2({}, defaultOpts), opts));
|
|
682
656
|
const shouldAbortOnUnmount = (_opts$trpc$abortOnUnm5 = opts === null || opts === void 0 || (_opts$trpc7 = opts.trpc) === null || _opts$trpc7 === void 0 ? void 0 : _opts$trpc7.abortOnUnmount) !== null && _opts$trpc$abortOnUnm5 !== void 0 ? _opts$trpc$abortOnUnm5 : context.abortOnUnmount;
|
|
683
|
-
usePrefetchInfiniteQuery((
|
|
657
|
+
usePrefetchInfiniteQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
684
658
|
initialPageParam: (_opts$initialCursor2 = opts.initialCursor) !== null && _opts$initialCursor2 !== void 0 ? _opts$initialCursor2 : null,
|
|
685
659
|
queryKey,
|
|
686
660
|
queryFn: isInputSkipToken ? input : (queryFunctionContext) => {
|
|
687
661
|
var _queryFunctionContext2;
|
|
688
|
-
const actualOpts = (
|
|
662
|
+
const actualOpts = _objectSpread2(_objectSpread2({}, ssrOpts), {}, { trpc: _objectSpread2(_objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : {}) });
|
|
689
663
|
return context.client.query(...getClientArgs(queryKey, actualOpts, {
|
|
690
664
|
pageParam: (_queryFunctionContext2 = queryFunctionContext.pageParam) !== null && _queryFunctionContext2 !== void 0 ? _queryFunctionContext2 : opts.initialCursor,
|
|
691
665
|
direction: queryFunctionContext.direction
|
|
@@ -698,14 +672,14 @@ function createRootHooks(config) {
|
|
|
698
672
|
const context = useContext();
|
|
699
673
|
const queryKey = getQueryKeyInternal(path, input, "infinite");
|
|
700
674
|
const defaultOpts = context.queryClient.getQueryDefaults(queryKey);
|
|
701
|
-
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, (
|
|
675
|
+
const ssrOpts = useSSRQueryOptionsIfNeeded(queryKey, _objectSpread2(_objectSpread2({}, defaultOpts), opts));
|
|
702
676
|
const shouldAbortOnUnmount = (_opts$trpc$abortOnUnm6 = opts === null || opts === void 0 || (_opts$trpc8 = opts.trpc) === null || _opts$trpc8 === void 0 ? void 0 : _opts$trpc8.abortOnUnmount) !== null && _opts$trpc$abortOnUnm6 !== void 0 ? _opts$trpc$abortOnUnm6 : context.abortOnUnmount;
|
|
703
|
-
const hook = useSuspenseInfiniteQuery((
|
|
677
|
+
const hook = useSuspenseInfiniteQuery(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
704
678
|
initialPageParam: (_opts$initialCursor3 = opts.initialCursor) !== null && _opts$initialCursor3 !== void 0 ? _opts$initialCursor3 : null,
|
|
705
679
|
queryKey,
|
|
706
680
|
queryFn: (queryFunctionContext) => {
|
|
707
681
|
var _queryFunctionContext3;
|
|
708
|
-
const actualOpts = (
|
|
682
|
+
const actualOpts = _objectSpread2(_objectSpread2({}, ssrOpts), {}, { trpc: _objectSpread2(_objectSpread2({}, ssrOpts === null || ssrOpts === void 0 ? void 0 : ssrOpts.trpc), shouldAbortOnUnmount ? { signal: queryFunctionContext.signal } : {}) });
|
|
709
683
|
return context.client.query(...getClientArgs(queryKey, actualOpts, {
|
|
710
684
|
pageParam: (_queryFunctionContext3 = queryFunctionContext.pageParam) !== null && _queryFunctionContext3 !== void 0 ? _queryFunctionContext3 : opts.initialCursor,
|
|
711
685
|
direction: queryFunctionContext.direction
|
|
@@ -717,23 +691,21 @@ function createRootHooks(config) {
|
|
|
717
691
|
}
|
|
718
692
|
const useQueries$1 = (queriesCallback, options) => {
|
|
719
693
|
const { ssrState, queryClient, prefetchQuery, client } = useContext();
|
|
720
|
-
const
|
|
721
|
-
const queries = queriesCallback(proxy);
|
|
694
|
+
const queries = queriesCallback(createUseQueries(client));
|
|
722
695
|
if (typeof window === "undefined" && ssrState === "prepass") for (const query of queries) {
|
|
723
696
|
var _queryOption$trpc;
|
|
724
697
|
const queryOption = query;
|
|
725
698
|
if (((_queryOption$trpc = queryOption.trpc) === null || _queryOption$trpc === void 0 ? void 0 : _queryOption$trpc.ssr) !== false && !queryClient.getQueryCache().find({ queryKey: queryOption.queryKey })) prefetchQuery(queryOption.queryKey, queryOption);
|
|
726
699
|
}
|
|
727
700
|
return useQueries({
|
|
728
|
-
queries: queries.map((query) => (
|
|
701
|
+
queries: queries.map((query) => _objectSpread2(_objectSpread2({}, query), {}, { queryKey: query.queryKey })),
|
|
729
702
|
combine: options === null || options === void 0 ? void 0 : options.combine
|
|
730
703
|
}, queryClient);
|
|
731
704
|
};
|
|
732
705
|
const useSuspenseQueries$1 = (queriesCallback) => {
|
|
733
706
|
const { queryClient, client } = useContext();
|
|
734
|
-
const
|
|
735
|
-
const
|
|
736
|
-
const hook = useSuspenseQueries({ queries: queries.map((query) => (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, query), {}, {
|
|
707
|
+
const queries = queriesCallback(createUseQueries(client));
|
|
708
|
+
const hook = useSuspenseQueries({ queries: queries.map((query) => _objectSpread2(_objectSpread2({}, query), {}, {
|
|
737
709
|
queryFn: query.queryFn,
|
|
738
710
|
queryKey: query.queryKey
|
|
739
711
|
})) }, queryClient);
|
|
@@ -756,7 +728,6 @@ function createRootHooks(config) {
|
|
|
756
728
|
useSuspenseInfiniteQuery: useSuspenseInfiniteQuery$1
|
|
757
729
|
};
|
|
758
730
|
}
|
|
759
|
-
|
|
760
731
|
//#endregion
|
|
761
732
|
//#region src/shared/queryClient.ts
|
|
762
733
|
/**
|
|
@@ -766,7 +737,7 @@ const getQueryClient = (config) => {
|
|
|
766
737
|
var _config$queryClient;
|
|
767
738
|
return (_config$queryClient = config.queryClient) !== null && _config$queryClient !== void 0 ? _config$queryClient : new QueryClient(config.queryClientConfig);
|
|
768
739
|
};
|
|
769
|
-
|
|
770
740
|
//#endregion
|
|
771
|
-
export {
|
|
772
|
-
|
|
741
|
+
export { createUseQueries as a, getQueryType as c, createReactDecoration as d, getClientArgs as i, TRPCContext as l, createRootHooks as n, createQueryUtilsProxy as o, createUtilityFunctions as r, createReactQueryUtils as s, getQueryClient as t, contextProps as u };
|
|
742
|
+
|
|
743
|
+
//# sourceMappingURL=shared-DhkLzxq7.mjs.map
|