@trpc/tanstack-react-query 11.18.1-canary.19 → 11.18.1-canary.30

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/index.mjs CHANGED
@@ -1,212 +1,141 @@
1
- import * as React$1 from "react";
2
1
  import * as React from "react";
3
2
  import { TRPCUntypedClient, getUntypedClient } from "@trpc/client";
4
3
  import { callTRPCProcedure, createTRPCRecursiveProxy } from "@trpc/server";
5
4
  import { hashKey, infiniteQueryOptions, queryOptions, skipToken } from "@tanstack/react-query";
6
5
  import { isAsyncIterable, isFunction, isObject, run } from "@trpc/server/unstable-core-do-not-import";
7
- import { jsx } from "react/jsx-runtime";
8
-
9
- //#region rolldown:runtime
10
- var __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __commonJS = (cb, mod) => function() {
17
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
- };
19
- var __copyProps = (to, from, except, desc) => {
20
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
- key = keys[i];
22
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
- get: ((k) => from[k]).bind(null, key),
24
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
- });
26
- }
27
- return to;
28
- };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
- value: mod,
31
- enumerable: true
32
- }) : target, mod));
33
-
34
- //#endregion
35
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
36
- var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
37
- function _typeof$2(o) {
38
- "@babel/helpers - typeof";
39
- return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
40
- return typeof o$1;
41
- } : function(o$1) {
42
- return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
43
- }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
44
- }
45
- module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
46
- } });
47
-
6
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
7
+ function _typeof(o) {
8
+ "@babel/helpers - typeof";
9
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
10
+ return typeof o;
11
+ } : function(o) {
12
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
13
+ }, _typeof(o);
14
+ }
48
15
  //#endregion
49
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
50
- var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
51
- var _typeof$1 = require_typeof()["default"];
52
- function toPrimitive$1(t, r) {
53
- if ("object" != _typeof$1(t) || !t) return t;
54
- var e = t[Symbol.toPrimitive];
55
- if (void 0 !== e) {
56
- var i = e.call(t, r || "default");
57
- if ("object" != _typeof$1(i)) return i;
58
- throw new TypeError("@@toPrimitive must return a primitive value.");
59
- }
60
- return ("string" === r ? String : Number)(t);
16
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
17
+ function toPrimitive(t, r) {
18
+ if ("object" != _typeof(t) || !t) return t;
19
+ var e = t[Symbol.toPrimitive];
20
+ if (void 0 !== e) {
21
+ var i = e.call(t, r || "default");
22
+ if ("object" != _typeof(i)) return i;
23
+ throw new TypeError("@@toPrimitive must return a primitive value.");
61
24
  }
62
- module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
63
- } });
64
-
25
+ return ("string" === r ? String : Number)(t);
26
+ }
65
27
  //#endregion
66
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
67
- var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
68
- var _typeof = require_typeof()["default"];
69
- var toPrimitive = require_toPrimitive();
70
- function toPropertyKey$1(t) {
71
- var i = toPrimitive(t, "string");
72
- return "symbol" == _typeof(i) ? i : i + "";
73
- }
74
- module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
75
- } });
76
-
28
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
29
+ function toPropertyKey(t) {
30
+ var i = toPrimitive(t, "string");
31
+ return "symbol" == _typeof(i) ? i : i + "";
32
+ }
77
33
  //#endregion
78
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
79
- var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
80
- var toPropertyKey = require_toPropertyKey();
81
- function _defineProperty(e, r, t) {
82
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
83
- value: t,
84
- enumerable: !0,
85
- configurable: !0,
86
- writable: !0
87
- }) : e[r] = t, e;
88
- }
89
- module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
90
- } });
91
-
34
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
35
+ function _defineProperty(e, r, t) {
36
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
37
+ value: t,
38
+ enumerable: !0,
39
+ configurable: !0,
40
+ writable: !0
41
+ }) : e[r] = t, e;
42
+ }
92
43
  //#endregion
93
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
94
- var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
95
- var defineProperty = require_defineProperty();
96
- function ownKeys(e, r) {
97
- var t = Object.keys(e);
98
- if (Object.getOwnPropertySymbols) {
99
- var o = Object.getOwnPropertySymbols(e);
100
- r && (o = o.filter(function(r$1) {
101
- return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
102
- })), t.push.apply(t, o);
103
- }
104
- return t;
44
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/objectSpread2.js
45
+ function ownKeys(e, r) {
46
+ var t = Object.keys(e);
47
+ if (Object.getOwnPropertySymbols) {
48
+ var o = Object.getOwnPropertySymbols(e);
49
+ r && (o = o.filter(function(r) {
50
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
51
+ })), t.push.apply(t, o);
105
52
  }
106
- function _objectSpread2(e) {
107
- for (var r = 1; r < arguments.length; r++) {
108
- var t = null != arguments[r] ? arguments[r] : {};
109
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
110
- defineProperty(e, r$1, t[r$1]);
111
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
112
- Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
113
- });
114
- }
115
- return e;
53
+ return t;
54
+ }
55
+ function _objectSpread2(e) {
56
+ for (var r = 1; r < arguments.length; r++) {
57
+ var t = null != arguments[r] ? arguments[r] : {};
58
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
59
+ _defineProperty(e, r, t[r]);
60
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
61
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
62
+ });
116
63
  }
117
- module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
118
- } });
119
-
64
+ return e;
65
+ }
120
66
  //#endregion
121
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js
122
- var require_asyncIterator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
123
- function _asyncIterator$1(r) {
124
- var n, t, o, e = 2;
125
- for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
126
- if (t && null != (n = r[t])) return n.call(r);
127
- if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
128
- t = "@@asyncIterator", o = "@@iterator";
129
- }
130
- throw new TypeError("Object is not async iterable");
67
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/asyncIterator.js
68
+ function _asyncIterator(r) {
69
+ var n, t, o, e = 2;
70
+ for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
71
+ if (t && null != (n = r[t])) return n.call(r);
72
+ if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
73
+ t = "@@asyncIterator", o = "@@iterator";
131
74
  }
132
- function AsyncFromSyncIterator(r) {
133
- function AsyncFromSyncIteratorContinuation(r$1) {
134
- if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
135
- var n = r$1.done;
136
- return Promise.resolve(r$1.value).then(function(r$2) {
137
- return {
138
- value: r$2,
139
- done: n
140
- };
141
- });
142
- }
143
- return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
144
- this.s = r$1, this.n = r$1.next;
145
- }, AsyncFromSyncIterator.prototype = {
146
- s: null,
147
- n: null,
148
- next: function next() {
149
- return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
150
- },
151
- "return": function _return(r$1) {
152
- var n = this.s["return"];
153
- return void 0 === n ? Promise.resolve({
154
- value: r$1,
155
- done: !0
156
- }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
157
- },
158
- "throw": function _throw(r$1) {
159
- var n = this.s["return"];
160
- return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
161
- }
162
- }, new AsyncFromSyncIterator(r);
75
+ throw new TypeError("Object is not async iterable");
76
+ }
77
+ function AsyncFromSyncIterator(r) {
78
+ function AsyncFromSyncIteratorContinuation(r) {
79
+ if (Object(r) !== r) return Promise.reject(/* @__PURE__ */ new TypeError(r + " is not an object."));
80
+ var n = r.done;
81
+ return Promise.resolve(r.value).then(function(r) {
82
+ return {
83
+ value: r,
84
+ done: n
85
+ };
86
+ });
163
87
  }
164
- module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
165
- } });
166
-
167
- //#endregion
168
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js
169
- var require_objectWithoutPropertiesLoose = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(exports, module) {
170
- function _objectWithoutPropertiesLoose(r, e) {
171
- if (null == r) return {};
172
- var t = {};
173
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
174
- if (e.includes(n)) continue;
175
- t[n] = r[n];
88
+ return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) {
89
+ this.s = r, this.n = r.next;
90
+ }, AsyncFromSyncIterator.prototype = {
91
+ s: null,
92
+ n: null,
93
+ next: function next() {
94
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
95
+ },
96
+ "return": function _return(r) {
97
+ var n = this.s["return"];
98
+ return void 0 === n ? Promise.resolve({
99
+ value: r,
100
+ done: !0
101
+ }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
102
+ },
103
+ "throw": function _throw(r) {
104
+ var n = this.s["return"];
105
+ return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
176
106
  }
177
- return t;
107
+ }, new AsyncFromSyncIterator(r);
108
+ }
109
+ //#endregion
110
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/objectWithoutPropertiesLoose.js
111
+ function _objectWithoutPropertiesLoose(r, e) {
112
+ if (null == r) return {};
113
+ var t = {};
114
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
115
+ if (e.includes(n)) continue;
116
+ t[n] = r[n];
178
117
  }
179
- module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
180
- } });
181
-
118
+ return t;
119
+ }
182
120
  //#endregion
183
- //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js
184
- var require_objectWithoutProperties = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(exports, module) {
185
- var objectWithoutPropertiesLoose = require_objectWithoutPropertiesLoose();
186
- function _objectWithoutProperties$1(e, t) {
187
- if (null == e) return {};
188
- var o, r, i = objectWithoutPropertiesLoose(e, t);
189
- if (Object.getOwnPropertySymbols) {
190
- var s = Object.getOwnPropertySymbols(e);
191
- for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
192
- }
193
- return i;
121
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/objectWithoutProperties.js
122
+ function _objectWithoutProperties(e, t) {
123
+ if (null == e) return {};
124
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
125
+ if (Object.getOwnPropertySymbols) {
126
+ var s = Object.getOwnPropertySymbols(e);
127
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
194
128
  }
195
- module.exports = _objectWithoutProperties$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
196
- } });
197
-
129
+ return i;
130
+ }
198
131
  //#endregion
199
132
  //#region src/internals/utils.ts
200
- var import_objectSpread2$5 = __toESM(require_objectSpread2(), 1);
201
- var import_asyncIterator = __toESM(require_asyncIterator(), 1);
202
- var import_objectWithoutProperties = __toESM(require_objectWithoutProperties(), 1);
203
133
  const _excluded = ["cursor", "direction"];
204
134
  /**
205
135
  * @internal
206
136
  */
207
137
  function createTRPCOptionsResult(value) {
208
- const path = value.path.join(".");
209
- return { path };
138
+ return { path: value.path.join(".") };
210
139
  }
211
140
  function isPrefixedQueryKey(queryKey) {
212
141
  return queryKey.length >= 3;
@@ -234,7 +163,7 @@ function getClientArgs(queryKey, opts, infiniteParams) {
234
163
  let input = (_queryKeyData$args = queryKeyData.args) === null || _queryKeyData$args === void 0 ? void 0 : _queryKeyData$args.input;
235
164
  if (infiniteParams) {
236
165
  var _queryKeyData$args$in, _queryKeyData$args2;
237
- input = (0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, (_queryKeyData$args$in = (_queryKeyData$args2 = queryKeyData.args) === null || _queryKeyData$args2 === void 0 ? void 0 : _queryKeyData$args2.input) !== null && _queryKeyData$args$in !== void 0 ? _queryKeyData$args$in : {}), infiniteParams.pageParam !== void 0 ? { cursor: infiniteParams.pageParam } : {}), {}, { direction: infiniteParams.direction });
166
+ input = _objectSpread2(_objectSpread2(_objectSpread2({}, (_queryKeyData$args$in = (_queryKeyData$args2 = queryKeyData.args) === null || _queryKeyData$args2 === void 0 ? void 0 : _queryKeyData$args2.input) !== null && _queryKeyData$args$in !== void 0 ? _queryKeyData$args$in : {}), infiniteParams.pageParam !== void 0 ? { cursor: infiniteParams.pageParam } : {}), {}, { direction: infiniteParams.direction });
238
167
  }
239
168
  return [
240
169
  queryKeyData.path.join("."),
@@ -246,8 +175,7 @@ function getClientArgs(queryKey, opts, infiniteParams) {
246
175
  * @internal
247
176
  */
248
177
  async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey) {
249
- const queryCache = queryClient.getQueryCache();
250
- const query = queryCache.build(queryClient, { queryKey });
178
+ const query = queryClient.getQueryCache().build(queryClient, { queryKey });
251
179
  query.setState({
252
180
  data: [],
253
181
  status: "success"
@@ -257,12 +185,10 @@ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey)
257
185
  var _didIteratorError = false;
258
186
  var _iteratorError;
259
187
  try {
260
- for (var _iterator = (0, import_asyncIterator.default)(asyncIterable), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
188
+ for (var _iterator = _asyncIterator(asyncIterable), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
261
189
  const value = _step.value;
262
- {
263
- aggregate.push(value);
264
- query.setState({ data: [...aggregate] });
265
- }
190
+ aggregate.push(value);
191
+ query.setState({ data: [...aggregate] });
266
192
  }
267
193
  } catch (err) {
268
194
  _didIteratorError = true;
@@ -289,13 +215,13 @@ function getQueryKeyInternal(opts) {
289
215
  const splitPath = opts.path.flatMap((part) => part.split("."));
290
216
  if (!input && type === "any") return splitPath.length ? [splitPath] : [];
291
217
  if (type === "infinite" && isObject(input) && ("direction" in input || "cursor" in input)) {
292
- const { cursor: _, direction: __ } = input, inputWithoutCursorAndDirection = (0, import_objectWithoutProperties.default)(input, _excluded);
218
+ const { cursor: _, direction: __ } = input;
293
219
  return [splitPath, {
294
- input: inputWithoutCursorAndDirection,
220
+ input: _objectWithoutProperties(input, _excluded),
295
221
  type: "infinite"
296
222
  }];
297
223
  }
298
- return [splitPath, (0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, typeof input !== "undefined" && input !== skipToken && { input }), type && type !== "any" && { type })];
224
+ return [splitPath, _objectSpread2(_objectSpread2({}, typeof input !== "undefined" && input !== skipToken && { input }), type && type !== "any" && { type })];
299
225
  });
300
226
  if (opts.prefix) key.unshift([opts.prefix]);
301
227
  return key;
@@ -314,33 +240,28 @@ function getMutationKeyInternal(opts) {
314
240
  function unwrapLazyArg(valueOrLazy) {
315
241
  return isFunction(valueOrLazy) ? valueOrLazy() : valueOrLazy;
316
242
  }
317
-
318
243
  //#endregion
319
244
  //#region src/internals/infiniteQueryOptions.ts
320
- var import_objectSpread2$4 = __toESM(require_objectSpread2());
321
245
  function trpcInfiniteQueryOptions(args) {
322
246
  var _opts$initialCursor;
323
247
  const { input, query, path, queryKey, opts } = args;
324
248
  const inputIsSkipToken = input === skipToken;
325
249
  const queryFn = async (queryFnContext) => {
326
250
  var _opts$trpc;
327
- const actualOpts = (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, { trpc: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, 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 }) });
328
- const result = await query(...getClientArgs(queryKey, actualOpts, {
251
+ 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 }) });
252
+ return await query(...getClientArgs(queryKey, actualOpts, {
329
253
  direction: queryFnContext.direction,
330
254
  pageParam: queryFnContext.pageParam
331
255
  }));
332
- return result;
333
256
  };
334
- return Object.assign(infiniteQueryOptions((0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts !== null && opts !== void 0 ? opts : {}), {}, {
257
+ return Object.assign(infiniteQueryOptions(_objectSpread2(_objectSpread2({}, opts !== null && opts !== void 0 ? opts : {}), {}, {
335
258
  queryKey,
336
259
  queryFn: inputIsSkipToken ? skipToken : queryFn,
337
260
  initialPageParam: (_opts$initialCursor = opts === null || opts === void 0 ? void 0 : opts.initialCursor) !== null && _opts$initialCursor !== void 0 ? _opts$initialCursor : input === null || input === void 0 ? void 0 : input.cursor
338
261
  })), { trpc: createTRPCOptionsResult({ path }) });
339
262
  }
340
-
341
263
  //#endregion
342
264
  //#region src/internals/mutationOptions.ts
343
- var import_objectSpread2$3 = __toESM(require_objectSpread2());
344
265
  /**
345
266
  * @internal
346
267
  */
@@ -353,19 +274,18 @@ function trpcMutationOptions(args) {
353
274
  prefix: (_opts$keyPrefix = opts === null || opts === void 0 ? void 0 : opts.keyPrefix) !== null && _opts$keyPrefix !== void 0 ? _opts$keyPrefix : prefix
354
275
  });
355
276
  const defaultOpts = queryClient.defaultMutationOptions(queryClient.getMutationDefaults(mutationKey));
356
- const mutationSuccessOverride = (_overrides$onSuccess = overrides === null || overrides === void 0 ? void 0 : overrides.onSuccess) !== null && _overrides$onSuccess !== void 0 ? _overrides$onSuccess : (options) => options.originalFn();
277
+ const mutationSuccessOverride = (_overrides$onSuccess = overrides === null || overrides === void 0 ? void 0 : overrides.onSuccess) !== null && _overrides$onSuccess !== void 0 ? _overrides$onSuccess : ((options) => options.originalFn());
357
278
  const mutationFn = async (input) => {
358
- const result = await mutate(...getClientArgs([...mutationKey, { input }], opts));
359
- return result;
279
+ return await mutate(...getClientArgs([...mutationKey, { input }], opts));
360
280
  };
361
- return (0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, opts), {}, {
281
+ return _objectSpread2(_objectSpread2({}, opts), {}, {
362
282
  mutationKey,
363
283
  mutationFn,
364
- onSuccess(...args$1) {
284
+ onSuccess(...args) {
365
285
  var _ref, _opts$meta;
366
286
  const originalFn = () => {
367
287
  var _opts$onSuccess, _opts$onSuccess2, _defaultOpts$onSucces;
368
- return (_opts$onSuccess = opts === null || opts === void 0 || (_opts$onSuccess2 = opts.onSuccess) === null || _opts$onSuccess2 === void 0 ? void 0 : _opts$onSuccess2.call(opts, ...args$1)) !== null && _opts$onSuccess !== void 0 ? _opts$onSuccess : defaultOpts === null || defaultOpts === void 0 || (_defaultOpts$onSucces = defaultOpts.onSuccess) === null || _defaultOpts$onSucces === void 0 ? void 0 : _defaultOpts$onSucces.call(defaultOpts, ...args$1);
288
+ return (_opts$onSuccess = opts === null || opts === void 0 || (_opts$onSuccess2 = opts.onSuccess) === null || _opts$onSuccess2 === void 0 ? void 0 : _opts$onSuccess2.call(opts, ...args)) !== null && _opts$onSuccess !== void 0 ? _opts$onSuccess : defaultOpts === null || defaultOpts === void 0 || (_defaultOpts$onSucces = defaultOpts.onSuccess) === null || _defaultOpts$onSucces === void 0 ? void 0 : _defaultOpts$onSucces.call(defaultOpts, ...args);
369
289
  };
370
290
  return mutationSuccessOverride({
371
291
  originalFn,
@@ -376,10 +296,8 @@ function trpcMutationOptions(args) {
376
296
  trpc: createTRPCOptionsResult({ path })
377
297
  });
378
298
  }
379
-
380
299
  //#endregion
381
300
  //#region src/internals/queryOptions.ts
382
- var import_objectSpread2$2 = __toESM(require_objectSpread2());
383
301
  /**
384
302
  * @internal
385
303
  */
@@ -389,21 +307,19 @@ function trpcQueryOptions(args) {
389
307
  const inputIsSkipToken = input === skipToken;
390
308
  const queryFn = async (queryFnContext) => {
391
309
  var _opts$trpc;
392
- const actualOpts = (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, opts), {}, { trpc: (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, 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 }) });
393
- const queryKey$1 = queryFnContext.queryKey;
394
- const result = await query(...getClientArgs(queryKey$1, actualOpts));
395
- if (isAsyncIterable(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey$1);
310
+ 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 }) });
311
+ const queryKey = queryFnContext.queryKey;
312
+ const result = await query(...getClientArgs(queryKey, actualOpts));
313
+ if (isAsyncIterable(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey);
396
314
  return result;
397
315
  };
398
- return Object.assign(queryOptions((0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, opts), {}, {
316
+ return Object.assign(queryOptions(_objectSpread2(_objectSpread2({}, opts), {}, {
399
317
  queryKey,
400
318
  queryFn: inputIsSkipToken ? skipToken : queryFn
401
319
  })), { trpc: createTRPCOptionsResult({ path }) });
402
320
  }
403
-
404
321
  //#endregion
405
322
  //#region src/internals/subscriptionOptions.ts
406
- var import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
407
323
  /**
408
324
  * @internal
409
325
  */
@@ -413,7 +329,7 @@ const trpcSubscriptionOptions = (args) => {
413
329
  const _subscribe = (innerOpts) => {
414
330
  return subscribe(path.join("."), input === skipToken ? void 0 : input, innerOpts);
415
331
  };
416
- return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {
332
+ return _objectSpread2(_objectSpread2({}, opts), {}, {
417
333
  enabled,
418
334
  subscribe: _subscribe,
419
335
  queryKey,
@@ -421,14 +337,14 @@ const trpcSubscriptionOptions = (args) => {
421
337
  });
422
338
  };
423
339
  function useSubscription(opts) {
424
- const optsRef = React$1.useRef(opts);
340
+ const optsRef = React.useRef(opts);
425
341
  optsRef.current = opts;
426
- const trackedProps = React$1.useRef(new Set([]));
427
- const addTrackedProp = React$1.useCallback((key) => {
342
+ const trackedProps = React.useRef(/* @__PURE__ */ new Set([]));
343
+ const addTrackedProp = React.useCallback((key) => {
428
344
  trackedProps.current.add(key);
429
345
  }, []);
430
- const currentSubscriptionRef = React$1.useRef(() => {});
431
- const reset = React$1.useCallback(() => {
346
+ const currentSubscriptionRef = React.useRef(() => {});
347
+ const reset = React.useCallback(() => {
432
348
  var _currentSubscriptionR;
433
349
  (_currentSubscriptionR = currentSubscriptionRef.current) === null || _currentSubscriptionR === void 0 || _currentSubscriptionR.call(currentSubscriptionRef);
434
350
  updateState(getInitialState);
@@ -437,7 +353,7 @@ function useSubscription(opts) {
437
353
  onStarted: () => {
438
354
  var _optsRef$current$onSt, _optsRef$current;
439
355
  (_optsRef$current$onSt = (_optsRef$current = optsRef.current).onStarted) === null || _optsRef$current$onSt === void 0 || _optsRef$current$onSt.call(_optsRef$current);
440
- updateState((prev) => (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
356
+ updateState((prev) => _objectSpread2(_objectSpread2({}, prev), {}, {
441
357
  status: "pending",
442
358
  error: null
443
359
  }));
@@ -445,7 +361,7 @@ function useSubscription(opts) {
445
361
  onData: (data) => {
446
362
  var _optsRef$current$onDa, _optsRef$current2;
447
363
  (_optsRef$current$onDa = (_optsRef$current2 = optsRef.current).onData) === null || _optsRef$current$onDa === void 0 || _optsRef$current$onDa.call(_optsRef$current2, data);
448
- updateState((prev) => (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
364
+ updateState((prev) => _objectSpread2(_objectSpread2({}, prev), {}, {
449
365
  status: "pending",
450
366
  data,
451
367
  error: null
@@ -454,7 +370,7 @@ function useSubscription(opts) {
454
370
  onError: (error) => {
455
371
  var _optsRef$current$onEr, _optsRef$current3;
456
372
  (_optsRef$current$onEr = (_optsRef$current3 = optsRef.current).onError) === null || _optsRef$current$onEr === void 0 || _optsRef$current$onEr.call(_optsRef$current3, error);
457
- updateState((prev) => (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
373
+ updateState((prev) => _objectSpread2(_objectSpread2({}, prev), {}, {
458
374
  status: "error",
459
375
  error
460
376
  }));
@@ -464,12 +380,12 @@ function useSubscription(opts) {
464
380
  (_optsRef$current$onCo = (_optsRef$current4 = optsRef.current).onConnectionStateChange) === null || _optsRef$current$onCo === void 0 || _optsRef$current$onCo.call(_optsRef$current4, result);
465
381
  updateState((prev) => {
466
382
  switch (result.state) {
467
- case "connecting": return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
383
+ case "connecting": return _objectSpread2(_objectSpread2({}, prev), {}, {
468
384
  status: "connecting",
469
385
  error: result.error
470
386
  });
471
387
  case "pending": return prev;
472
- case "idle": return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
388
+ case "idle": return _objectSpread2(_objectSpread2({}, prev), {}, {
473
389
  status: "idle",
474
390
  data: void 0,
475
391
  error: null
@@ -482,7 +398,7 @@ function useSubscription(opts) {
482
398
  subscription.unsubscribe();
483
399
  };
484
400
  }, [hashKey(opts.queryKey), opts.enabled]);
485
- const getInitialState = React$1.useCallback(() => {
401
+ const getInitialState = React.useCallback(() => {
486
402
  return opts.enabled ? {
487
403
  data: void 0,
488
404
  error: null,
@@ -495,10 +411,10 @@ function useSubscription(opts) {
495
411
  reset
496
412
  };
497
413
  }, [opts.enabled, reset]);
498
- const resultRef = React$1.useRef(getInitialState());
499
- const [state, setState] = React$1.useState(trackResult(resultRef, addTrackedProp));
414
+ const resultRef = React.useRef(getInitialState());
415
+ const [state, setState] = React.useState(trackResult(resultRef, addTrackedProp));
500
416
  state.reset = reset;
501
- const updateState = React$1.useCallback((callback) => {
417
+ const updateState = React.useCallback((callback) => {
502
418
  const prev = resultRef.current;
503
419
  const next = resultRef.current = callback(prev);
504
420
  let shouldUpdate = false;
@@ -508,7 +424,7 @@ function useSubscription(opts) {
508
424
  }
509
425
  if (shouldUpdate) setState(trackResult(resultRef, addTrackedProp));
510
426
  }, [addTrackedProp]);
511
- React$1.useEffect(() => {
427
+ React.useEffect(() => {
512
428
  if (!opts.enabled) return;
513
429
  reset();
514
430
  return () => {
@@ -519,16 +435,13 @@ function useSubscription(opts) {
519
435
  return state;
520
436
  }
521
437
  function trackResult(result, onTrackResult) {
522
- const trackedResult = new Proxy(result.current, { get(_target, prop) {
438
+ return new Proxy(result.current, { get(_target, prop) {
523
439
  onTrackResult(prop);
524
440
  return result.current[prop];
525
441
  } });
526
- return trackedResult;
527
442
  }
528
-
529
443
  //#endregion
530
444
  //#region src/internals/createOptionsProxy.ts
531
- var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
532
445
  /**
533
446
  * Create a typed proxy from your router types. Can also be used on the server.
534
447
  *
@@ -548,15 +461,14 @@ function createTRPCOptionsProxy(opts) {
548
461
  signal: void 0,
549
462
  batchIndex: 0
550
463
  }));
551
- const untypedClient = opts.client instanceof TRPCUntypedClient ? opts.client : getUntypedClient(opts.client);
552
- return untypedClient[type](path, input, trpcOpts);
464
+ return (opts.client instanceof TRPCUntypedClient ? opts.client : getUntypedClient(opts.client))[type](path, input, trpcOpts);
553
465
  };
554
466
  };
555
467
  return createTRPCRecursiveProxy(({ args, path: _path }) => {
556
468
  const path = [..._path];
557
469
  const utilName = path.pop();
558
470
  const [arg1, arg2] = args;
559
- const contextMap = {
471
+ return {
560
472
  "~types": void 0,
561
473
  pathKey: () => {
562
474
  return getQueryKeyInternal({
@@ -566,7 +478,7 @@ function createTRPCOptionsProxy(opts) {
566
478
  });
567
479
  },
568
480
  pathFilter: () => {
569
- return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, arg1), {}, { queryKey: getQueryKeyInternal({
481
+ return _objectSpread2(_objectSpread2({}, arg1), {}, { queryKey: getQueryKeyInternal({
570
482
  path,
571
483
  type: "any",
572
484
  prefix
@@ -596,7 +508,7 @@ function createTRPCOptionsProxy(opts) {
596
508
  });
597
509
  },
598
510
  queryFilter: () => {
599
- return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, arg2), {}, { queryKey: getQueryKeyInternal({
511
+ return _objectSpread2(_objectSpread2({}, arg2), {}, { queryKey: getQueryKeyInternal({
600
512
  path,
601
513
  input: arg1,
602
514
  type: "query",
@@ -627,7 +539,7 @@ function createTRPCOptionsProxy(opts) {
627
539
  });
628
540
  },
629
541
  infiniteQueryFilter: () => {
630
- return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, arg2), {}, { queryKey: getQueryKeyInternal({
542
+ return _objectSpread2(_objectSpread2({}, arg2), {}, { queryKey: getQueryKeyInternal({
631
543
  path,
632
544
  input: arg1,
633
545
  type: "infinite",
@@ -665,11 +577,9 @@ function createTRPCOptionsProxy(opts) {
665
577
  subscribe: callIt("subscription")
666
578
  });
667
579
  }
668
- };
669
- return contextMap[utilName]();
580
+ }[utilName]();
670
581
  });
671
582
  }
672
-
673
583
  //#endregion
674
584
  //#region src/internals/Context.tsx
675
585
  /**
@@ -690,13 +600,7 @@ function createTRPCContext() {
690
600
  props.queryClient,
691
601
  props.keyPrefix
692
602
  ]);
693
- return /* @__PURE__ */ jsx(TRPCClientContext.Provider, {
694
- value: props.trpcClient,
695
- children: /* @__PURE__ */ jsx(TRPCContext.Provider, {
696
- value,
697
- children: props.children
698
- })
699
- });
603
+ return /* @__PURE__ */ React.createElement(TRPCClientContext.Provider, { value: props.trpcClient }, /* @__PURE__ */ React.createElement(TRPCContext.Provider, { value }, props.children));
700
604
  };
701
605
  TRPCProvider.displayName = "TRPCProvider";
702
606
  function useTRPC() {
@@ -715,7 +619,7 @@ function createTRPCContext() {
715
619
  useTRPCClient
716
620
  };
717
621
  }
718
-
719
622
  //#endregion
720
623
  export { createTRPCContext, createTRPCOptionsProxy, useSubscription };
624
+
721
625
  //# sourceMappingURL=index.mjs.map