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