@trpc/tanstack-react-query 11.4.1 → 11.4.2-canary.1

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.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __copyProps = (to, from, except, desc) => {
9
12
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
13
  key = keys[i];
@@ -28,7 +31,175 @@ const __tanstack_react_query = __toESM(require("@tanstack/react-query"));
28
31
  const __trpc_server_unstable_core_do_not_import = __toESM(require("@trpc/server/unstable-core-do-not-import"));
29
32
  const react_jsx_runtime = __toESM(require("react/jsx-runtime"));
30
33
 
34
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
35
+ var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
36
+ function _typeof$2(o) {
37
+ "@babel/helpers - typeof";
38
+ return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
39
+ return typeof o$1;
40
+ } : function(o$1) {
41
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
42
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
43
+ }
44
+ module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
45
+ } });
46
+
47
+ //#endregion
48
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
49
+ var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
50
+ var _typeof$1 = require_typeof()["default"];
51
+ function toPrimitive$1(t, r) {
52
+ if ("object" != _typeof$1(t) || !t) return t;
53
+ var e = t[Symbol.toPrimitive];
54
+ if (void 0 !== e) {
55
+ var i = e.call(t, r || "default");
56
+ if ("object" != _typeof$1(i)) return i;
57
+ throw new TypeError("@@toPrimitive must return a primitive value.");
58
+ }
59
+ return ("string" === r ? String : Number)(t);
60
+ }
61
+ module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
62
+ } });
63
+
64
+ //#endregion
65
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
66
+ var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
67
+ var _typeof = require_typeof()["default"];
68
+ var toPrimitive = require_toPrimitive();
69
+ function toPropertyKey$1(t) {
70
+ var i = toPrimitive(t, "string");
71
+ return "symbol" == _typeof(i) ? i : i + "";
72
+ }
73
+ module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
74
+ } });
75
+
76
+ //#endregion
77
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
78
+ var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
79
+ var toPropertyKey = require_toPropertyKey();
80
+ function _defineProperty(e, r, t) {
81
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
82
+ value: t,
83
+ enumerable: !0,
84
+ configurable: !0,
85
+ writable: !0
86
+ }) : e[r] = t, e;
87
+ }
88
+ module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
89
+ } });
90
+
91
+ //#endregion
92
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
93
+ var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
94
+ var defineProperty = require_defineProperty();
95
+ function ownKeys(e, r) {
96
+ var t = Object.keys(e);
97
+ if (Object.getOwnPropertySymbols) {
98
+ var o = Object.getOwnPropertySymbols(e);
99
+ r && (o = o.filter(function(r$1) {
100
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
101
+ })), t.push.apply(t, o);
102
+ }
103
+ return t;
104
+ }
105
+ function _objectSpread2(e) {
106
+ for (var r = 1; r < arguments.length; r++) {
107
+ var t = null != arguments[r] ? arguments[r] : {};
108
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
109
+ defineProperty(e, r$1, t[r$1]);
110
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
111
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
112
+ });
113
+ }
114
+ return e;
115
+ }
116
+ module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
117
+ } });
118
+
119
+ //#endregion
120
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js
121
+ var require_asyncIterator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
122
+ function _asyncIterator$1(r) {
123
+ var n, t, o, e = 2;
124
+ for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
125
+ if (t && null != (n = r[t])) return n.call(r);
126
+ if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
127
+ t = "@@asyncIterator", o = "@@iterator";
128
+ }
129
+ throw new TypeError("Object is not async iterable");
130
+ }
131
+ function AsyncFromSyncIterator(r) {
132
+ function AsyncFromSyncIteratorContinuation(r$1) {
133
+ if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
134
+ var n = r$1.done;
135
+ return Promise.resolve(r$1.value).then(function(r$2) {
136
+ return {
137
+ value: r$2,
138
+ done: n
139
+ };
140
+ });
141
+ }
142
+ return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
143
+ this.s = r$1, this.n = r$1.next;
144
+ }, AsyncFromSyncIterator.prototype = {
145
+ s: null,
146
+ n: null,
147
+ next: function next() {
148
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
149
+ },
150
+ "return": function _return(r$1) {
151
+ var n = this.s["return"];
152
+ return void 0 === n ? Promise.resolve({
153
+ value: r$1,
154
+ done: !0
155
+ }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
156
+ },
157
+ "throw": function _throw(r$1) {
158
+ var n = this.s["return"];
159
+ return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
160
+ }
161
+ }, new AsyncFromSyncIterator(r);
162
+ }
163
+ module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
164
+ } });
165
+
166
+ //#endregion
167
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js
168
+ var require_objectWithoutPropertiesLoose = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(exports, module) {
169
+ function _objectWithoutPropertiesLoose(r, e) {
170
+ if (null == r) return {};
171
+ var t = {};
172
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
173
+ if (e.includes(n)) continue;
174
+ t[n] = r[n];
175
+ }
176
+ return t;
177
+ }
178
+ module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
179
+ } });
180
+
181
+ //#endregion
182
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js
183
+ var require_objectWithoutProperties = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(exports, module) {
184
+ var objectWithoutPropertiesLoose = require_objectWithoutPropertiesLoose();
185
+ function _objectWithoutProperties$1(e, t) {
186
+ if (null == e) return {};
187
+ var o, r, i = objectWithoutPropertiesLoose(e, t);
188
+ if (Object.getOwnPropertySymbols) {
189
+ var s = Object.getOwnPropertySymbols(e);
190
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
191
+ }
192
+ return i;
193
+ }
194
+ module.exports = _objectWithoutProperties$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
195
+ } });
196
+
197
+ //#endregion
31
198
  //#region src/internals/utils.ts
199
+ var import_objectSpread2$5 = __toESM(require_objectSpread2(), 1);
200
+ var import_asyncIterator = __toESM(require_asyncIterator(), 1);
201
+ var import_objectWithoutProperties = __toESM(require_objectWithoutProperties(), 1);
202
+ const _excluded = ["cursor", "direction"];
32
203
  /**
33
204
  * @internal
34
205
  */
@@ -40,17 +211,17 @@ function createTRPCOptionsResult(value) {
40
211
  * @internal
41
212
  */
42
213
  function getClientArgs(queryKey, opts, infiniteParams) {
214
+ var _queryKey$;
43
215
  const path = queryKey[0];
44
- let input = queryKey[1]?.input;
45
- if (infiniteParams) input = {
46
- ...input ?? {},
47
- ...infiniteParams.pageParam !== void 0 ? { cursor: infiniteParams.pageParam } : {},
48
- direction: infiniteParams.direction
49
- };
216
+ let input = (_queryKey$ = queryKey[1]) === null || _queryKey$ === void 0 ? void 0 : _queryKey$.input;
217
+ if (infiniteParams) {
218
+ var _input;
219
+ input = (0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, (_input = input) !== null && _input !== void 0 ? _input : {}), infiniteParams.pageParam !== void 0 ? { cursor: infiniteParams.pageParam } : {}), {}, { direction: infiniteParams.direction });
220
+ }
50
221
  return [
51
222
  path.join("."),
52
223
  input,
53
- opts?.trpc
224
+ opts === null || opts === void 0 ? void 0 : opts.trpc
54
225
  ];
55
226
  }
56
227
  /**
@@ -64,9 +235,26 @@ async function buildQueryFromAsyncIterable(asyncIterable, queryClient, queryKey)
64
235
  status: "success"
65
236
  });
66
237
  const aggregate = [];
67
- for await (const value of asyncIterable) {
68
- aggregate.push(value);
69
- query.setState({ data: [...aggregate] });
238
+ var _iteratorAbruptCompletion = false;
239
+ var _didIteratorError = false;
240
+ var _iteratorError;
241
+ try {
242
+ for (var _iterator = (0, import_asyncIterator.default)(asyncIterable), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
243
+ const value = _step.value;
244
+ {
245
+ aggregate.push(value);
246
+ query.setState({ data: [...aggregate] });
247
+ }
248
+ }
249
+ } catch (err) {
250
+ _didIteratorError = true;
251
+ _iteratorError = err;
252
+ } finally {
253
+ try {
254
+ if (_iteratorAbruptCompletion && _iterator.return != null) await _iterator.return();
255
+ } finally {
256
+ if (_didIteratorError) throw _iteratorError;
257
+ }
70
258
  }
71
259
  return aggregate;
72
260
  }
@@ -81,16 +269,13 @@ function getQueryKeyInternal(path, input, type) {
81
269
  const splitPath = path.flatMap((part) => part.split("."));
82
270
  if (!input && (!type || type === "any")) return splitPath.length ? [splitPath] : [];
83
271
  if (type === "infinite" && (0, __trpc_server_unstable_core_do_not_import.isObject)(input) && ("direction" in input || "cursor" in input)) {
84
- const { cursor: _, direction: __,...inputWithoutCursorAndDirection } = input;
272
+ const { cursor: _, direction: __ } = input, inputWithoutCursorAndDirection = (0, import_objectWithoutProperties.default)(input, _excluded);
85
273
  return [splitPath, {
86
274
  input: inputWithoutCursorAndDirection,
87
275
  type: "infinite"
88
276
  }];
89
277
  }
90
- return [splitPath, {
91
- ...typeof input !== "undefined" && input !== __tanstack_react_query.skipToken && { input },
92
- ...type && type !== "any" && { type }
93
- }];
278
+ return [splitPath, (0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, typeof input !== "undefined" && input !== __tanstack_react_query.skipToken && { input }), type && type !== "any" && { type })];
94
279
  }
95
280
  /**
96
281
  * @internal
@@ -108,64 +293,66 @@ function unwrapLazyArg(valueOrLazy) {
108
293
 
109
294
  //#endregion
110
295
  //#region src/internals/infiniteQueryOptions.ts
296
+ var import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
111
297
  function trpcInfiniteQueryOptions(args) {
298
+ var _opts$initialCursor;
112
299
  const { input, query, path, queryKey, opts } = args;
113
300
  const inputIsSkipToken = input === __tanstack_react_query.skipToken;
114
301
  const queryFn = async (queryFnContext) => {
115
- const actualOpts = {
116
- ...opts,
117
- trpc: {
118
- ...opts?.trpc,
119
- ...opts?.trpc?.abortOnUnmount ? { signal: queryFnContext.signal } : { signal: null }
120
- }
121
- };
302
+ var _opts$trpc;
303
+ 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 }) });
122
304
  const result = await query(...getClientArgs(queryKey, actualOpts, {
123
305
  direction: queryFnContext.direction,
124
306
  pageParam: queryFnContext.pageParam
125
307
  }));
126
308
  return result;
127
309
  };
128
- return Object.assign((0, __tanstack_react_query.infiniteQueryOptions)({
129
- ...opts,
310
+ return Object.assign((0, __tanstack_react_query.infiniteQueryOptions)((0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
130
311
  queryKey,
131
312
  queryFn: inputIsSkipToken ? __tanstack_react_query.skipToken : queryFn,
132
- initialPageParam: opts?.initialCursor ?? input?.cursor
133
- }), { trpc: createTRPCOptionsResult({ path }) });
313
+ 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
314
+ })), { trpc: createTRPCOptionsResult({ path }) });
134
315
  }
135
316
 
136
317
  //#endregion
137
318
  //#region src/internals/mutationOptions.ts
319
+ var import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
138
320
  /**
139
321
  * @internal
140
322
  */
141
323
  function trpcMutationOptions(args) {
324
+ var _overrides$onSuccess;
142
325
  const { mutate, path, opts, overrides } = args;
143
326
  const queryClient = unwrapLazyArg(args.queryClient);
144
327
  const mutationKey = getMutationKeyInternal(path);
145
328
  const defaultOpts = queryClient.defaultMutationOptions(queryClient.getMutationDefaults(mutationKey));
146
- const mutationSuccessOverride = overrides?.onSuccess ?? ((options) => options.originalFn());
329
+ const mutationSuccessOverride = (_overrides$onSuccess = overrides === null || overrides === void 0 ? void 0 : overrides.onSuccess) !== null && _overrides$onSuccess !== void 0 ? _overrides$onSuccess : (options) => options.originalFn();
147
330
  const mutationFn = async (input) => {
148
331
  const result = await mutate(...getClientArgs([path, { input }], opts));
149
332
  return result;
150
333
  };
151
- return {
152
- ...opts,
334
+ return (0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, opts), {}, {
153
335
  mutationKey,
154
336
  mutationFn,
155
337
  onSuccess(...args$1) {
156
- const originalFn = () => opts?.onSuccess?.(...args$1) ?? defaultOpts?.onSuccess?.(...args$1);
338
+ var _ref, _opts$meta;
339
+ const originalFn = () => {
340
+ var _opts$onSuccess, _opts$onSuccess2, _defaultOpts$onSucces;
341
+ 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);
342
+ };
157
343
  return mutationSuccessOverride({
158
344
  originalFn,
159
345
  queryClient,
160
- meta: opts?.meta ?? defaultOpts?.meta ?? {}
346
+ meta: (_ref = (_opts$meta = opts === null || opts === void 0 ? void 0 : opts.meta) !== null && _opts$meta !== void 0 ? _opts$meta : defaultOpts === null || defaultOpts === void 0 ? void 0 : defaultOpts.meta) !== null && _ref !== void 0 ? _ref : {}
161
347
  });
162
348
  },
163
349
  trpc: createTRPCOptionsResult({ path })
164
- };
350
+ });
165
351
  }
166
352
 
167
353
  //#endregion
168
354
  //#region src/internals/queryOptions.ts
355
+ var import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
169
356
  /**
170
357
  * @internal
171
358
  */
@@ -174,44 +361,39 @@ function trpcQueryOptions(args) {
174
361
  const queryClient = unwrapLazyArg(args.queryClient);
175
362
  const inputIsSkipToken = input === __tanstack_react_query.skipToken;
176
363
  const queryFn = async (queryFnContext) => {
177
- const actualOpts = {
178
- ...opts,
179
- trpc: {
180
- ...opts?.trpc,
181
- ...opts?.trpc?.abortOnUnmount ? { signal: queryFnContext.signal } : { signal: null }
182
- }
183
- };
364
+ var _opts$trpc;
365
+ 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 }) });
184
366
  const queryKey$1 = queryFnContext.queryKey;
185
367
  const result = await query(...getClientArgs(queryKey$1, actualOpts));
186
368
  if ((0, __trpc_server_unstable_core_do_not_import.isAsyncIterable)(result)) return buildQueryFromAsyncIterable(result, queryClient, queryKey$1);
187
369
  return result;
188
370
  };
189
- return Object.assign((0, __tanstack_react_query.queryOptions)({
190
- ...opts,
371
+ return Object.assign((0, __tanstack_react_query.queryOptions)((0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, opts), {}, {
191
372
  queryKey,
192
373
  queryFn: inputIsSkipToken ? __tanstack_react_query.skipToken : queryFn
193
- }), { trpc: createTRPCOptionsResult({ path }) });
374
+ })), { trpc: createTRPCOptionsResult({ path }) });
194
375
  }
195
376
 
196
377
  //#endregion
197
378
  //#region src/internals/subscriptionOptions.ts
379
+ var import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
198
380
  /**
199
381
  * @internal
200
382
  */
201
383
  const trpcSubscriptionOptions = (args) => {
384
+ var _queryKey$;
202
385
  const { subscribe, path, queryKey, opts = {} } = args;
203
- const input = queryKey[1]?.input;
386
+ const input = (_queryKey$ = queryKey[1]) === null || _queryKey$ === void 0 ? void 0 : _queryKey$.input;
204
387
  const enabled = "enabled" in opts ? !!opts.enabled : input !== __tanstack_react_query.skipToken;
205
388
  const _subscribe = (innerOpts) => {
206
- return subscribe(path.join("."), input ?? void 0, innerOpts);
389
+ return subscribe(path.join("."), input !== null && input !== void 0 ? input : void 0, innerOpts);
207
390
  };
208
- return {
209
- ...opts,
391
+ return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {
210
392
  enabled,
211
393
  subscribe: _subscribe,
212
394
  queryKey,
213
395
  trpc: createTRPCOptionsResult({ path })
214
- };
396
+ });
215
397
  };
216
398
  function useSubscription(opts) {
217
399
  const optsRef = react.useRef(opts);
@@ -222,51 +404,51 @@ function useSubscription(opts) {
222
404
  }, []);
223
405
  const currentSubscriptionRef = react.useRef(() => {});
224
406
  const reset = react.useCallback(() => {
225
- currentSubscriptionRef.current?.();
407
+ var _currentSubscriptionR;
408
+ (_currentSubscriptionR = currentSubscriptionRef.current) === null || _currentSubscriptionR === void 0 || _currentSubscriptionR.call(currentSubscriptionRef);
226
409
  updateState(getInitialState);
227
410
  if (!opts.enabled) return;
228
411
  const subscription = opts.subscribe({
229
412
  onStarted: () => {
230
- optsRef.current.onStarted?.();
231
- updateState((prev) => ({
232
- ...prev,
413
+ var _optsRef$current$onSt, _optsRef$current;
414
+ (_optsRef$current$onSt = (_optsRef$current = optsRef.current).onStarted) === null || _optsRef$current$onSt === void 0 || _optsRef$current$onSt.call(_optsRef$current);
415
+ updateState((prev) => (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
233
416
  status: "pending",
234
417
  error: null
235
418
  }));
236
419
  },
237
420
  onData: (data) => {
238
- optsRef.current.onData?.(data);
239
- updateState((prev) => ({
240
- ...prev,
421
+ var _optsRef$current$onDa, _optsRef$current2;
422
+ (_optsRef$current$onDa = (_optsRef$current2 = optsRef.current).onData) === null || _optsRef$current$onDa === void 0 || _optsRef$current$onDa.call(_optsRef$current2, data);
423
+ updateState((prev) => (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
241
424
  status: "pending",
242
425
  data,
243
426
  error: null
244
427
  }));
245
428
  },
246
429
  onError: (error) => {
247
- optsRef.current.onError?.(error);
248
- updateState((prev) => ({
249
- ...prev,
430
+ var _optsRef$current$onEr, _optsRef$current3;
431
+ (_optsRef$current$onEr = (_optsRef$current3 = optsRef.current).onError) === null || _optsRef$current$onEr === void 0 || _optsRef$current$onEr.call(_optsRef$current3, error);
432
+ updateState((prev) => (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
250
433
  status: "error",
251
434
  error
252
435
  }));
253
436
  },
254
437
  onConnectionStateChange: (result) => {
255
- optsRef.current.onConnectionStateChange?.(result);
438
+ var _optsRef$current$onCo, _optsRef$current4;
439
+ (_optsRef$current$onCo = (_optsRef$current4 = optsRef.current).onConnectionStateChange) === null || _optsRef$current$onCo === void 0 || _optsRef$current$onCo.call(_optsRef$current4, result);
256
440
  updateState((prev) => {
257
441
  switch (result.state) {
258
- case "connecting": return {
259
- ...prev,
442
+ case "connecting": return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
260
443
  status: "connecting",
261
444
  error: result.error
262
- };
445
+ });
263
446
  case "pending": return prev;
264
- case "idle": return {
265
- ...prev,
447
+ case "idle": return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, prev), {}, {
266
448
  status: "idle",
267
449
  data: void 0,
268
450
  error: null
269
- };
451
+ });
270
452
  }
271
453
  });
272
454
  }
@@ -305,7 +487,8 @@ function useSubscription(opts) {
305
487
  if (!opts.enabled) return;
306
488
  reset();
307
489
  return () => {
308
- currentSubscriptionRef.current?.();
490
+ var _currentSubscriptionR2;
491
+ (_currentSubscriptionR2 = currentSubscriptionRef.current) === null || _currentSubscriptionR2 === void 0 || _currentSubscriptionR2.call(currentSubscriptionRef);
309
492
  };
310
493
  }, [reset, opts.enabled]);
311
494
  return state;
@@ -320,6 +503,7 @@ function trackResult(result, onTrackResult) {
320
503
 
321
504
  //#endregion
322
505
  //#region src/internals/createOptionsProxy.ts
506
+ var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
323
507
  /**
324
508
  * Create a typed proxy from your router types. Can also be used on the server.
325
509
  *
@@ -351,10 +535,7 @@ function createTRPCOptionsProxy(opts) {
351
535
  return getQueryKeyInternal(path);
352
536
  },
353
537
  pathFilter: () => {
354
- return {
355
- ...arg1,
356
- queryKey: getQueryKeyInternal(path)
357
- };
538
+ return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, arg1), {}, { queryKey: getQueryKeyInternal(path) });
358
539
  },
359
540
  queryOptions: () => {
360
541
  return trpcQueryOptions({
@@ -370,10 +551,7 @@ function createTRPCOptionsProxy(opts) {
370
551
  return getQueryKeyInternal(path, arg1, "query");
371
552
  },
372
553
  queryFilter: () => {
373
- return {
374
- ...arg2,
375
- queryKey: getQueryKeyInternal(path, arg1, "query")
376
- };
554
+ return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, arg2), {}, { queryKey: getQueryKeyInternal(path, arg1, "query") });
377
555
  },
378
556
  infiniteQueryOptions: () => {
379
557
  return trpcInfiniteQueryOptions({
@@ -389,18 +567,16 @@ function createTRPCOptionsProxy(opts) {
389
567
  return getQueryKeyInternal(path, arg1, "infinite");
390
568
  },
391
569
  infiniteQueryFilter: () => {
392
- return {
393
- ...arg2,
394
- queryKey: getQueryKeyInternal(path, arg1, "infinite")
395
- };
570
+ return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, arg2), {}, { queryKey: getQueryKeyInternal(path, arg1, "infinite") });
396
571
  },
397
572
  mutationOptions: () => {
573
+ var _opts$overrides;
398
574
  return trpcMutationOptions({
399
575
  opts: arg1,
400
576
  path,
401
577
  queryClient: opts.queryClient,
402
578
  mutate: callIt("mutation"),
403
- overrides: opts.overrides?.mutations
579
+ overrides: (_opts$overrides = opts.overrides) === null || _opts$overrides === void 0 ? void 0 : _opts$overrides.mutations
404
580
  });
405
581
  },
406
582
  mutationKey: () => {