@trpc/client 11.4.0 → 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.
Files changed (68) hide show
  1. package/dist/TRPCClientError-CjKyS10w.mjs +47 -0
  2. package/dist/{TRPCClientError-COkhCKf3.mjs.map → TRPCClientError-CjKyS10w.mjs.map} +1 -1
  3. package/dist/{TRPCClientError-CGgRtttT.cjs → TRPCClientError-Dey88Uiy.cjs} +15 -24
  4. package/dist/{httpBatchLink-DIfnmmcu.mjs → httpBatchLink-BfUVex5U.mjs} +33 -24
  5. package/dist/{httpBatchLink-DIfnmmcu.mjs.map → httpBatchLink-BfUVex5U.mjs.map} +1 -1
  6. package/dist/{httpBatchLink-CIC9PZ_Z.cjs → httpBatchLink-JKXaA6dG.cjs} +32 -23
  7. package/dist/{httpBatchLink.d-BN2Iw_cK.d.mts → httpBatchLink.d-CAaMQOtX.d.mts} +3 -3
  8. package/dist/{httpBatchLink.d-BN2Iw_cK.d.mts.map → httpBatchLink.d-CAaMQOtX.d.mts.map} +1 -1
  9. package/dist/{httpLink-BbVj_TgM.cjs → httpLink-CbZZVG--.cjs} +10 -11
  10. package/dist/{httpLink-9bpwQ15c.mjs → httpLink-Dptv1zSJ.mjs} +11 -12
  11. package/dist/{httpLink-9bpwQ15c.mjs.map → httpLink-Dptv1zSJ.mjs.map} +1 -1
  12. package/dist/{httpLink.d-CTSOARfE.d.mts → httpLink.d-B0nHKy2W.d.mts} +3 -3
  13. package/dist/{httpLink.d-CTSOARfE.d.mts.map → httpLink.d-B0nHKy2W.d.mts.map} +1 -1
  14. package/dist/{httpUtils-3pbQzhUL.mjs → httpUtils-ZiawzpnD.mjs} +12 -13
  15. package/dist/{httpUtils-3pbQzhUL.mjs.map → httpUtils-ZiawzpnD.mjs.map} +1 -1
  16. package/dist/{httpUtils-Buf6jCgh.cjs → httpUtils-rn2lxsJO.cjs} +12 -12
  17. package/dist/{httpUtils.d-C8wPxU79.d.mts → httpUtils.d-cQRQZrfo.d.mts} +3 -3
  18. package/dist/{httpUtils.d-C8wPxU79.d.mts.map → httpUtils.d-cQRQZrfo.d.mts.map} +1 -1
  19. package/dist/index.cjs +268 -104
  20. package/dist/index.d.mts +9 -9
  21. package/dist/index.mjs +269 -131
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/links/httpBatchLink.cjs +5 -4
  24. package/dist/links/httpBatchLink.d.mts +5 -5
  25. package/dist/links/httpBatchLink.mjs +5 -4
  26. package/dist/links/httpLink.cjs +5 -4
  27. package/dist/links/httpLink.d.mts +5 -5
  28. package/dist/links/httpLink.mjs +5 -4
  29. package/dist/links/loggerLink.cjs +2 -1
  30. package/dist/links/loggerLink.d.mts +3 -3
  31. package/dist/links/loggerLink.mjs +2 -1
  32. package/dist/links/splitLink.d.mts +3 -3
  33. package/dist/links/splitLink.mjs +1 -1
  34. package/dist/links/wsLink/wsLink.cjs +4 -3
  35. package/dist/links/wsLink/wsLink.d.mts +4 -4
  36. package/dist/links/wsLink/wsLink.mjs +4 -3
  37. package/dist/{loggerLink-CsDfg5Bb.cjs → loggerLink-CuYvRzyH.cjs} +14 -21
  38. package/dist/{loggerLink-PGBSQFcR.mjs → loggerLink-ineCN1PO.mjs} +15 -22
  39. package/dist/{loggerLink-PGBSQFcR.mjs.map → loggerLink-ineCN1PO.mjs.map} +1 -1
  40. package/dist/{loggerLink.d-CZjK1CXm.d.mts → loggerLink.d-g_uYSbus.d.mts} +2 -2
  41. package/dist/{loggerLink.d-CZjK1CXm.d.mts.map → loggerLink.d-g_uYSbus.d.mts.map} +1 -1
  42. package/dist/objectSpread2-Bsvh_OqM.cjs +100 -0
  43. package/dist/objectSpread2-BvkFp-_Y.mjs +114 -0
  44. package/dist/objectSpread2-BvkFp-_Y.mjs.map +1 -0
  45. package/dist/{splitLink-BVblHq4n.mjs → splitLink-B7Cuf2c_.mjs} +1 -1
  46. package/dist/{splitLink-BVblHq4n.mjs.map → splitLink-B7Cuf2c_.mjs.map} +1 -1
  47. package/dist/{splitLink.d-BAqgq0NG.d.mts → splitLink.d-od8YIcex.d.mts} +2 -2
  48. package/dist/{splitLink.d-BAqgq0NG.d.mts.map → splitLink.d-od8YIcex.d.mts.map} +1 -1
  49. package/dist/{subscriptions.d-U92STdZl.d.mts → subscriptions.d-Dlr1nWGD.d.mts} +1 -1
  50. package/dist/{subscriptions.d-U92STdZl.d.mts.map → subscriptions.d-Dlr1nWGD.d.mts.map} +1 -1
  51. package/dist/{types.d-DXbqQLCC.d.mts → types.d-POgEdUB1.d.mts} +2 -2
  52. package/dist/{types.d-DXbqQLCC.d.mts.map → types.d-POgEdUB1.d.mts.map} +1 -1
  53. package/dist/{unstable-internals-DU4WecoG.mjs → unstable-internals-Bg7n9BBj.mjs} +1 -1
  54. package/dist/{unstable-internals-DU4WecoG.mjs.map → unstable-internals-Bg7n9BBj.mjs.map} +1 -1
  55. package/dist/unstable-internals.cjs +1 -1
  56. package/dist/{unstable-internals.d-DyLd-B0J.d.mts → unstable-internals.d-BOmV7EK1.d.mts} +1 -1
  57. package/dist/{unstable-internals.d-DyLd-B0J.d.mts.map → unstable-internals.d-BOmV7EK1.d.mts.map} +1 -1
  58. package/dist/unstable-internals.d.mts +2 -2
  59. package/dist/unstable-internals.mjs +1 -1
  60. package/dist/{wsLink-DhJ50EC5.cjs → wsLink-BcTLPVgc.cjs} +93 -106
  61. package/dist/{wsLink-DbSHOzlB.mjs → wsLink-H5IjZfJW.mjs} +94 -107
  62. package/dist/wsLink-H5IjZfJW.mjs.map +1 -0
  63. package/dist/{wsLink.d-BqO7ltN_.d.mts → wsLink.d-BZxAJRBO.d.mts} +4 -4
  64. package/dist/{wsLink.d-BqO7ltN_.d.mts.map → wsLink.d-BZxAJRBO.d.mts.map} +1 -1
  65. package/package.json +32 -32
  66. package/dist/TRPCClientError-COkhCKf3.mjs +0 -56
  67. package/dist/wsLink-DbSHOzlB.mjs.map +0 -1
  68. /package/dist/{unstable-internals-CYBH4jbF.cjs → unstable-internals-M84gUQCV.cjs} +0 -0
package/dist/index.mjs CHANGED
@@ -1,66 +1,44 @@
1
- import { createChain, splitLink } from "./splitLink-BVblHq4n.mjs";
2
- import { TRPCClientError, isTRPCClientError } from "./TRPCClientError-COkhCKf3.mjs";
3
- import { fetchHTTPResponse, getBody, getFetch, getUrl, resolveHTTPLinkOptions } from "./httpUtils-3pbQzhUL.mjs";
4
- import { httpLink, isFormData, isNonJsonSerializable, isOctetType } from "./httpLink-9bpwQ15c.mjs";
5
- import { abortSignalToPromise, allAbortSignals, dataLoader, httpBatchLink, raceAbortSignals } from "./httpBatchLink-DIfnmmcu.mjs";
6
- import { getTransformer } from "./unstable-internals-DU4WecoG.mjs";
7
- import { loggerLink } from "./loggerLink-PGBSQFcR.mjs";
8
- import { createWSClient, resultOf, wsLink } from "./wsLink-DbSHOzlB.mjs";
1
+ import { __commonJS, __toESM, require_defineProperty, require_objectSpread2 } from "./objectSpread2-BvkFp-_Y.mjs";
2
+ import { createChain, splitLink } from "./splitLink-B7Cuf2c_.mjs";
3
+ import { TRPCClientError, isTRPCClientError } from "./TRPCClientError-CjKyS10w.mjs";
4
+ import { fetchHTTPResponse, getBody, getFetch, getUrl, resolveHTTPLinkOptions } from "./httpUtils-ZiawzpnD.mjs";
5
+ import { httpLink, isFormData, isNonJsonSerializable, isOctetType } from "./httpLink-Dptv1zSJ.mjs";
6
+ import { abortSignalToPromise, allAbortSignals, dataLoader, httpBatchLink, raceAbortSignals } from "./httpBatchLink-BfUVex5U.mjs";
7
+ import { getTransformer } from "./unstable-internals-Bg7n9BBj.mjs";
8
+ import { loggerLink } from "./loggerLink-ineCN1PO.mjs";
9
+ import { createWSClient, resultOf, wsLink } from "./wsLink-H5IjZfJW.mjs";
9
10
  import { behaviorSubject, observable, observableToPromise, share } from "@trpc/server/observable";
10
11
  import { callProcedure, createFlatProxy, createRecursiveProxy, isAbortError, isAsyncIterable, iteratorResource, jsonlStreamConsumer, makeResource, retryableRpcCodes, run, sseStreamConsumer } from "@trpc/server/unstable-core-do-not-import";
11
12
  import { getTRPCErrorFromUnknown, getTRPCErrorShape, isTrackedEnvelope } from "@trpc/server";
12
13
  import { TRPC_ERROR_CODES_BY_KEY } from "@trpc/server/rpc";
13
14
 
14
- //#region rolldown:runtime
15
- var __create = Object.create;
16
- var __defProp = Object.defineProperty;
17
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
18
- var __getOwnPropNames = Object.getOwnPropertyNames;
19
- var __getProtoOf = Object.getPrototypeOf;
20
- var __hasOwnProp = Object.prototype.hasOwnProperty;
21
- var __commonJS = (cb, mod) => function() {
22
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
23
- };
24
- var __copyProps = (to, from, except, desc) => {
25
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
26
- key = keys[i];
27
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
28
- get: ((k) => from[k]).bind(null, key),
29
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
30
- });
31
- }
32
- return to;
33
- };
34
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
35
- value: mod,
36
- enumerable: true
37
- }) : target, mod));
38
-
39
- //#endregion
40
15
  //#region src/internals/TRPCUntypedClient.ts
16
+ var import_defineProperty = __toESM(require_defineProperty(), 1);
17
+ var import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
41
18
  var TRPCUntypedClient = class {
42
- links;
43
- runtime;
44
- requestId;
45
19
  constructor(opts) {
20
+ (0, import_defineProperty.default)(this, "links", void 0);
21
+ (0, import_defineProperty.default)(this, "runtime", void 0);
22
+ (0, import_defineProperty.default)(this, "requestId", void 0);
46
23
  this.requestId = 0;
47
24
  this.runtime = {};
48
25
  this.links = opts.links.map((link) => link(this.runtime));
49
26
  }
50
27
  $request(opts) {
28
+ var _opts$context;
51
29
  const chain$ = createChain({
52
30
  links: this.links,
53
- op: {
54
- ...opts,
55
- context: opts.context ?? {},
31
+ op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
32
+ context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
56
33
  id: ++this.requestId
57
- }
34
+ })
58
35
  });
59
36
  return chain$.pipe(share());
60
37
  }
61
38
  async requestAsPromise(opts) {
39
+ var _this = this;
62
40
  try {
63
- const req$ = this.$request(opts);
41
+ const req$ = _this.$request(opts);
64
42
  const envelope = await observableToPromise(req$);
65
43
  const data = envelope.result.data;
66
44
  return data;
@@ -73,8 +51,8 @@ var TRPCUntypedClient = class {
73
51
  type: "query",
74
52
  path,
75
53
  input,
76
- context: opts?.context,
77
- signal: opts?.signal
54
+ context: opts === null || opts === void 0 ? void 0 : opts.context,
55
+ signal: opts === null || opts === void 0 ? void 0 : opts.signal
78
56
  });
79
57
  }
80
58
  mutation(path, input, opts) {
@@ -82,8 +60,8 @@ var TRPCUntypedClient = class {
82
60
  type: "mutation",
83
61
  path,
84
62
  input,
85
- context: opts?.context,
86
- signal: opts?.signal
63
+ context: opts === null || opts === void 0 ? void 0 : opts.context,
64
+ signal: opts === null || opts === void 0 ? void 0 : opts.signal
87
65
  });
88
66
  }
89
67
  subscription(path, input, opts) {
@@ -98,29 +76,35 @@ var TRPCUntypedClient = class {
98
76
  next(envelope) {
99
77
  switch (envelope.result.type) {
100
78
  case "state": {
101
- opts.onConnectionStateChange?.(envelope.result);
79
+ var _opts$onConnectionSta;
80
+ (_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
102
81
  break;
103
82
  }
104
83
  case "started": {
105
- opts.onStarted?.({ context: envelope.context });
84
+ var _opts$onStarted;
85
+ (_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
106
86
  break;
107
87
  }
108
88
  case "stopped": {
109
- opts.onStopped?.();
89
+ var _opts$onStopped;
90
+ (_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
110
91
  break;
111
92
  }
112
93
  case "data":
113
94
  case void 0: {
114
- opts.onData?.(envelope.result.data);
95
+ var _opts$onData;
96
+ (_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
115
97
  break;
116
98
  }
117
99
  }
118
100
  },
119
101
  error(err) {
120
- opts.onError?.(err);
102
+ var _opts$onError;
103
+ (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
121
104
  },
122
105
  complete() {
123
- opts.onComplete?.();
106
+ var _opts$onComplete;
107
+ (_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
124
108
  }
125
109
  });
126
110
  }
@@ -174,13 +158,15 @@ function getUntypedClient(client) {
174
158
 
175
159
  //#endregion
176
160
  //#region src/links/httpBatchStreamLink.ts
161
+ var import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
177
162
  /**
178
163
  * @see https://trpc.io/docs/client/links/httpBatchStreamLink
179
164
  */
180
165
  function httpBatchStreamLink(opts) {
166
+ var _opts$maxURLLength, _opts$maxItems;
181
167
  const resolvedOpts = resolveHTTPLinkOptions(opts);
182
- const maxURLLength = opts.maxURLLength ?? Infinity;
183
- const maxItems = opts.maxItems ?? Infinity;
168
+ const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity;
169
+ const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity;
184
170
  return () => {
185
171
  const batchLoader = (type) => {
186
172
  return {
@@ -189,13 +175,12 @@ function httpBatchStreamLink(opts) {
189
175
  if (batchOps.length > maxItems) return false;
190
176
  const path = batchOps.map((op) => op.path).join(",");
191
177
  const inputs = batchOps.map((op) => op.input);
192
- const url = getUrl({
193
- ...resolvedOpts,
178
+ const url = getUrl((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
194
179
  type,
195
180
  path,
196
181
  inputs,
197
182
  signal: null
198
- });
183
+ }));
199
184
  return url.length <= maxURLLength;
200
185
  },
201
186
  async fetch(batchOps) {
@@ -203,8 +188,7 @@ function httpBatchStreamLink(opts) {
203
188
  const inputs = batchOps.map((op) => op.input);
204
189
  const batchSignals = allAbortSignals(...batchOps.map((op) => op.signal));
205
190
  const abortController = new AbortController();
206
- const responsePromise = fetchHTTPResponse({
207
- ...resolvedOpts,
191
+ const responsePromise = fetchHTTPResponse((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, resolvedOpts), {}, {
208
192
  signal: raceAbortSignals(batchSignals, abortController.signal),
209
193
  type,
210
194
  contentTypeHeader: "application/json",
@@ -218,7 +202,7 @@ function httpBatchStreamLink(opts) {
218
202
  if (typeof opts.headers === "function") return opts.headers({ opList: batchOps });
219
203
  return opts.headers;
220
204
  }
221
- });
205
+ }));
222
206
  const res = await responsePromise;
223
207
  const [head] = await jsonlStreamConsumer({
224
208
  from: res.body,
@@ -276,7 +260,7 @@ function httpBatchStreamLink(opts) {
276
260
  }
277
261
  observer.complete();
278
262
  }).catch((err) => {
279
- observer.error(TRPCClientError.from(err, { meta: _res?.meta }));
263
+ observer.error(TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta }));
280
264
  });
281
265
  return () => {};
282
266
  });
@@ -290,17 +274,63 @@ const unstable_httpBatchStreamLink = httpBatchStreamLink;
290
274
 
291
275
  //#endregion
292
276
  //#region src/internals/inputWithTrackedEventId.ts
277
+ var import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
293
278
  function inputWithTrackedEventId(input, lastEventId) {
294
279
  if (!lastEventId) return input;
295
280
  if (input != null && typeof input !== "object") return input;
296
- return {
297
- ...input ?? {},
298
- lastEventId
299
- };
281
+ return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, input !== null && input !== void 0 ? input : {}), {}, { lastEventId });
300
282
  }
301
283
 
284
+ //#endregion
285
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js
286
+ var require_asyncIterator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
287
+ function _asyncIterator$1(r) {
288
+ var n, t, o, e = 2;
289
+ for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) {
290
+ if (t && null != (n = r[t])) return n.call(r);
291
+ if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
292
+ t = "@@asyncIterator", o = "@@iterator";
293
+ }
294
+ throw new TypeError("Object is not async iterable");
295
+ }
296
+ function AsyncFromSyncIterator(r) {
297
+ function AsyncFromSyncIteratorContinuation(r$1) {
298
+ if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
299
+ var n = r$1.done;
300
+ return Promise.resolve(r$1.value).then(function(r$2) {
301
+ return {
302
+ value: r$2,
303
+ done: n
304
+ };
305
+ });
306
+ }
307
+ return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
308
+ this.s = r$1, this.n = r$1.next;
309
+ }, AsyncFromSyncIterator.prototype = {
310
+ s: null,
311
+ n: null,
312
+ next: function next() {
313
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
314
+ },
315
+ "return": function _return(r$1) {
316
+ var n = this.s["return"];
317
+ return void 0 === n ? Promise.resolve({
318
+ value: r$1,
319
+ done: !0
320
+ }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
321
+ },
322
+ "throw": function _throw(r$1) {
323
+ var n = this.s["return"];
324
+ return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
325
+ }
326
+ }, new AsyncFromSyncIterator(r);
327
+ }
328
+ module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
329
+ } });
330
+
302
331
  //#endregion
303
332
  //#region src/links/httpSubscriptionLink.ts
333
+ var import_asyncIterator = __toESM(require_asyncIterator(), 1);
304
334
  async function urlWithConnectionParams(opts) {
305
335
  let url = await resultOf(opts.url);
306
336
  if (opts.connectionParams) {
@@ -318,6 +348,7 @@ function httpSubscriptionLink(opts) {
318
348
  return () => {
319
349
  return ({ op }) => {
320
350
  return observable((observer) => {
351
+ var _opts$EventSource;
321
352
  const { type, path, input } = op;
322
353
  /* istanbul ignore if -- @preserve */
323
354
  if (type !== "subscription") throw new Error("httpSubscriptionLink only supports subscriptions");
@@ -336,7 +367,7 @@ function httpSubscriptionLink(opts) {
336
367
  init: () => resultOf(opts.eventSourceOptions, { op }),
337
368
  signal,
338
369
  deserialize: transformer.output.deserialize,
339
- EventSource: opts.EventSource ?? globalThis.EventSource
370
+ EventSource: (_opts$EventSource = opts.EventSource) !== null && _opts$EventSource !== void 0 ? _opts$EventSource : globalThis.EventSource
340
371
  });
341
372
  const connectionState = behaviorSubject({
342
373
  type: "state",
@@ -347,63 +378,80 @@ function httpSubscriptionLink(opts) {
347
378
  observer.next({ result: state });
348
379
  } });
349
380
  run(async () => {
350
- for await (const chunk of eventSourceStream) switch (chunk.type) {
351
- case "ping": break;
352
- case "data":
353
- const chunkData = chunk.data;
354
- let result;
355
- if (chunkData.id) {
356
- lastEventId = chunkData.id;
357
- result = {
358
- id: chunkData.id,
359
- data: chunkData
360
- };
361
- } else result = { data: chunkData.data };
362
- observer.next({
363
- result,
364
- context: { eventSource: chunk.eventSource }
365
- });
366
- break;
367
- case "connected": {
368
- observer.next({
369
- result: { type: "started" },
370
- context: { eventSource: chunk.eventSource }
371
- });
372
- connectionState.next({
373
- type: "state",
374
- state: "pending",
375
- error: null
376
- });
377
- break;
378
- }
379
- case "serialized-error": {
380
- const error = TRPCClientError.from({ error: chunk.error });
381
- if (retryableRpcCodes.includes(chunk.error.code)) {
382
- connectionState.next({
381
+ var _iteratorAbruptCompletion = false;
382
+ var _didIteratorError = false;
383
+ var _iteratorError;
384
+ try {
385
+ for (var _iterator = (0, import_asyncIterator.default)(eventSourceStream), _step; _iteratorAbruptCompletion = !(_step = await _iterator.next()).done; _iteratorAbruptCompletion = false) {
386
+ const chunk = _step.value;
387
+ switch (chunk.type) {
388
+ case "ping": break;
389
+ case "data":
390
+ const chunkData = chunk.data;
391
+ let result;
392
+ if (chunkData.id) {
393
+ lastEventId = chunkData.id;
394
+ result = {
395
+ id: chunkData.id,
396
+ data: chunkData
397
+ };
398
+ } else result = { data: chunkData.data };
399
+ observer.next({
400
+ result,
401
+ context: { eventSource: chunk.eventSource }
402
+ });
403
+ break;
404
+ case "connected": {
405
+ observer.next({
406
+ result: { type: "started" },
407
+ context: { eventSource: chunk.eventSource }
408
+ });
409
+ connectionState.next({
410
+ type: "state",
411
+ state: "pending",
412
+ error: null
413
+ });
414
+ break;
415
+ }
416
+ case "serialized-error": {
417
+ const error = TRPCClientError.from({ error: chunk.error });
418
+ if (retryableRpcCodes.includes(chunk.error.code)) {
419
+ connectionState.next({
420
+ type: "state",
421
+ state: "connecting",
422
+ error
423
+ });
424
+ break;
425
+ }
426
+ throw error;
427
+ }
428
+ case "connecting": {
429
+ const lastState = connectionState.get();
430
+ const error = chunk.event && TRPCClientError.from(chunk.event);
431
+ if (!error && lastState.state === "connecting") break;
432
+ connectionState.next({
433
+ type: "state",
434
+ state: "connecting",
435
+ error
436
+ });
437
+ break;
438
+ }
439
+ case "timeout": connectionState.next({
383
440
  type: "state",
384
441
  state: "connecting",
385
- error
442
+ error: new TRPCClientError(`Timeout of ${chunk.ms}ms reached while waiting for a response`)
386
443
  });
387
- break;
388
444
  }
389
- throw error;
390
445
  }
391
- case "connecting": {
392
- const lastState = connectionState.get();
393
- const error = chunk.event && TRPCClientError.from(chunk.event);
394
- if (!error && lastState.state === "connecting") break;
395
- connectionState.next({
396
- type: "state",
397
- state: "connecting",
398
- error
399
- });
400
- break;
446
+ } catch (err) {
447
+ _didIteratorError = true;
448
+ _iteratorError = err;
449
+ } finally {
450
+ try {
451
+ if (_iteratorAbruptCompletion && _iterator.return != null) await _iterator.return();
452
+ } finally {
453
+ if (_didIteratorError) throw _iteratorError;
401
454
  }
402
- case "timeout": connectionState.next({
403
- type: "state",
404
- state: "connecting",
405
- error: new TRPCClientError(`Timeout of ${chunk.ms}ms reached while waiting for a response`)
406
- });
407
455
  }
408
456
  observer.next({ result: { type: "stopped" } });
409
457
  connectionState.next({
@@ -431,6 +479,7 @@ const unstable_httpSubscriptionLink = httpSubscriptionLink;
431
479
 
432
480
  //#endregion
433
481
  //#region src/links/retryLink.ts
482
+ var import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
434
483
  /**
435
484
  * @see https://trpc.io/docs/v11/client/links/retryLink
436
485
  */
@@ -445,15 +494,13 @@ function retryLink(opts) {
445
494
  function opWithLastEventId() {
446
495
  const op = callOpts.op;
447
496
  if (!lastEventId) return op;
448
- return {
449
- ...op,
450
- input: inputWithTrackedEventId(op.input, lastEventId)
451
- };
497
+ return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, op), {}, { input: inputWithTrackedEventId(op.input, lastEventId) });
452
498
  }
453
499
  function attempt(attempts) {
454
500
  const op = opWithLastEventId();
455
501
  next$ = callOpts.next(op).subscribe({
456
502
  error(error) {
503
+ var _opts$retryDelayMs, _opts$retryDelayMs2;
457
504
  const shouldRetry = opts.retry({
458
505
  op,
459
506
  attempts,
@@ -463,7 +510,7 @@ function retryLink(opts) {
463
510
  observer.error(error);
464
511
  return;
465
512
  }
466
- const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
513
+ const delayMs = (_opts$retryDelayMs = (_opts$retryDelayMs2 = opts.retryDelayMs) === null || _opts$retryDelayMs2 === void 0 ? void 0 : _opts$retryDelayMs2.call(opts, attempts)) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : 0;
467
514
  if (delayMs <= 0) {
468
515
  attempt(attempts + 1);
469
516
  return;
@@ -548,9 +595,102 @@ var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runti
548
595
  module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
549
596
  } });
550
597
 
598
+ //#endregion
599
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js
600
+ var require_OverloadYield = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
601
+ function _OverloadYield(e, d) {
602
+ this.v = e, this.k = d;
603
+ }
604
+ module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
605
+ } });
606
+
607
+ //#endregion
608
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js
609
+ var require_awaitAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
610
+ var OverloadYield$1 = require_OverloadYield();
611
+ function _awaitAsyncGenerator$1(e) {
612
+ return new OverloadYield$1(e, 0);
613
+ }
614
+ module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
615
+ } });
616
+
617
+ //#endregion
618
+ //#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js
619
+ var require_wrapAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
620
+ var OverloadYield = require_OverloadYield();
621
+ function _wrapAsyncGenerator$1(e) {
622
+ return function() {
623
+ return new AsyncGenerator(e.apply(this, arguments));
624
+ };
625
+ }
626
+ function AsyncGenerator(e) {
627
+ var r, t;
628
+ function resume(r$1, t$1) {
629
+ try {
630
+ var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
631
+ Promise.resolve(u ? o.v : o).then(function(t$2) {
632
+ if (u) {
633
+ var i = "return" === r$1 ? "return" : "next";
634
+ if (!o.k || t$2.done) return resume(i, t$2);
635
+ t$2 = e[i](t$2).value;
636
+ }
637
+ settle(n.done ? "return" : "normal", t$2);
638
+ }, function(e$1) {
639
+ resume("throw", e$1);
640
+ });
641
+ } catch (e$1) {
642
+ settle("throw", e$1);
643
+ }
644
+ }
645
+ function settle(e$1, n) {
646
+ switch (e$1) {
647
+ case "return":
648
+ r.resolve({
649
+ value: n,
650
+ done: !0
651
+ });
652
+ break;
653
+ case "throw":
654
+ r.reject(n);
655
+ break;
656
+ default: r.resolve({
657
+ value: n,
658
+ done: !1
659
+ });
660
+ }
661
+ (r = r.next) ? resume(r.key, r.arg) : t = null;
662
+ }
663
+ this._invoke = function(e$1, n) {
664
+ return new Promise(function(o, u) {
665
+ var i = {
666
+ key: e$1,
667
+ arg: n,
668
+ resolve: o,
669
+ reject: u,
670
+ next: null
671
+ };
672
+ t ? t = t.next = i : (r = t = i, resume(e$1, n));
673
+ });
674
+ }, "function" != typeof e["return"] && (this["return"] = void 0);
675
+ }
676
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
677
+ return this;
678
+ }, AsyncGenerator.prototype.next = function(e) {
679
+ return this._invoke("next", e);
680
+ }, AsyncGenerator.prototype["throw"] = function(e) {
681
+ return this._invoke("throw", e);
682
+ }, AsyncGenerator.prototype["return"] = function(e) {
683
+ return this._invoke("return", e);
684
+ };
685
+ module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
686
+ } });
687
+
551
688
  //#endregion
552
689
  //#region src/links/localLink.ts
553
690
  var import_usingCtx = __toESM(require_usingCtx(), 1);
691
+ var import_awaitAsyncGenerator = __toESM(require_awaitAsyncGenerator(), 1);
692
+ var import_wrapAsyncGenerator = __toESM(require_wrapAsyncGenerator(), 1);
693
+ var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
554
694
  /**
555
695
  * localLink is a terminating link that allows you to make tRPC procedure calls directly in your application without going through HTTP.
556
696
  *
@@ -585,8 +725,9 @@ function unstable_localLink(opts) {
585
725
  });
586
726
  }
587
727
  function onErrorCallback(cause) {
728
+ var _opts$onError;
588
729
  if (isAbortError(cause)) return;
589
- opts.onError?.({
730
+ (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
590
731
  error: getTRPCErrorFromUnknown(cause),
591
732
  type: op.type,
592
733
  path: op.path,
@@ -617,7 +758,7 @@ function unstable_localLink(opts) {
617
758
  observer.complete();
618
759
  break;
619
760
  }
620
- observer.next({ result: { data: async function* () {
761
+ observer.next({ result: { data: (0, import_wrapAsyncGenerator.default)(function* () {
621
762
  try {
622
763
  var _usingCtx$1 = (0, import_usingCtx.default)();
623
764
  const iterator = _usingCtx$1.a(iteratorResource(result));
@@ -626,7 +767,7 @@ function unstable_localLink(opts) {
626
767
  }));
627
768
  try {
628
769
  while (true) {
629
- const res = await Promise.race([iterator.next(), signalPromise]);
770
+ const res = yield (0, import_awaitAsyncGenerator.default)(Promise.race([iterator.next(), signalPromise]));
630
771
  if (res.done) return transformChunk(res.value);
631
772
  yield transformChunk(res.value);
632
773
  }
@@ -637,9 +778,9 @@ function unstable_localLink(opts) {
637
778
  } catch (_) {
638
779
  _usingCtx$1.e = _;
639
780
  } finally {
640
- await _usingCtx$1.d();
781
+ yield (0, import_awaitAsyncGenerator.default)(_usingCtx$1.d());
641
782
  }
642
- }() } });
783
+ })() } });
643
784
  break;
644
785
  }
645
786
  case "subscription": try {
@@ -701,10 +842,7 @@ function unstable_localLink(opts) {
701
842
  }
702
843
  };
703
844
  } else chunk = { data: res.value };
704
- observer.next({ result: {
705
- ...chunk,
706
- data: transformChunk(chunk.data)
707
- } });
845
+ observer.next({ result: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, chunk), {}, { data: transformChunk(chunk.data) }) });
708
846
  }
709
847
  } catch (_) {
710
848
  _usingCtx4.e = _;