@trpc/client 11.18.1-canary.9 → 11.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/bin/intent.js +0 -0
  2. package/dist/TRPCClientError-CmHlBkPF.cjs +56 -0
  3. package/dist/{TRPCClientError-apv8gw59.mjs → TRPCClientError-CxFRO7Js.mjs} +11 -14
  4. package/dist/TRPCClientError-CxFRO7Js.mjs.map +1 -0
  5. package/dist/{httpBatchLink-LhidKAPw.mjs → httpBatchLink-BMtWxLJV.mjs} +25 -72
  6. package/dist/httpBatchLink-BMtWxLJV.mjs.map +1 -0
  7. package/dist/{httpBatchLink.d-7jyWtY5H.d.cts → httpBatchLink-Br-pzPXf.d.cts} +4 -8
  8. package/dist/httpBatchLink-Br-pzPXf.d.cts.map +1 -0
  9. package/dist/{httpBatchLink-BGZRsGNf.cjs → httpBatchLink-DO3WQoxu.cjs} +37 -104
  10. package/dist/{httpBatchLink.d-p8Y9QM8p.d.mts → httpBatchLink-nvc48L_N.d.mts} +4 -8
  11. package/dist/httpBatchLink-nvc48L_N.d.mts.map +1 -0
  12. package/dist/{httpLink.d-CjpPCq4q.d.mts → httpLink-D5FQijY2.d.cts} +4 -7
  13. package/dist/httpLink-D5FQijY2.d.cts.map +1 -0
  14. package/dist/{httpLink-B8Iv31Ee.cjs → httpLink-MDJTSlpi.cjs} +39 -38
  15. package/dist/{httpLink-lG_6juPY.mjs → httpLink-Tm93WWFA.mjs} +17 -14
  16. package/dist/httpLink-Tm93WWFA.mjs.map +1 -0
  17. package/dist/{httpLink.d-D5qR9haY.d.cts → httpLink-eSAq8J9S.d.mts} +4 -7
  18. package/dist/httpLink-eSAq8J9S.d.mts.map +1 -0
  19. package/dist/{httpUtils.d-BqmeKEGo.d.cts → httpUtils-C37jRVnj.d.mts} +4 -6
  20. package/dist/httpUtils-C37jRVnj.d.mts.map +1 -0
  21. package/dist/{httpUtils-pyf5RF99.mjs → httpUtils-CB_100ND.mjs} +51 -14
  22. package/dist/httpUtils-CB_100ND.mjs.map +1 -0
  23. package/dist/{httpUtils.d-C5t5to0D.d.mts → httpUtils-CUqAubVD.d.cts} +4 -6
  24. package/dist/httpUtils-CUqAubVD.d.cts.map +1 -0
  25. package/dist/{httpUtils-wv2o-njD.cjs → httpUtils-cggqcHz0.cjs} +102 -49
  26. package/dist/index.cjs +248 -309
  27. package/dist/index.d.cts +38 -41
  28. package/dist/index.d.cts.map +1 -1
  29. package/dist/index.d.mts +38 -41
  30. package/dist/index.d.mts.map +1 -1
  31. package/dist/index.mjs +212 -272
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/links/httpBatchLink.cjs +3 -7
  34. package/dist/links/httpBatchLink.d.cts +1 -5
  35. package/dist/links/httpBatchLink.d.mts +1 -5
  36. package/dist/links/httpBatchLink.mjs +2 -7
  37. package/dist/links/httpLink.cjs +3 -7
  38. package/dist/links/httpLink.d.cts +1 -5
  39. package/dist/links/httpLink.d.mts +1 -5
  40. package/dist/links/httpLink.mjs +2 -7
  41. package/dist/links/loggerLink.cjs +113 -4
  42. package/dist/links/loggerLink.d.cts +1 -3
  43. package/dist/links/loggerLink.d.mts +1 -3
  44. package/dist/links/loggerLink.mjs +113 -3
  45. package/dist/links/loggerLink.mjs.map +1 -0
  46. package/dist/links/splitLink.cjs +3 -3
  47. package/dist/links/splitLink.d.cts +1 -3
  48. package/dist/links/splitLink.d.mts +1 -3
  49. package/dist/links/splitLink.mjs +2 -3
  50. package/dist/links/wsLink/wsLink.cjs +3 -6
  51. package/dist/links/wsLink/wsLink.d.cts +2 -5
  52. package/dist/links/wsLink/wsLink.d.mts +2 -5
  53. package/dist/links/wsLink/wsLink.mjs +2 -6
  54. package/dist/{loggerLink.d-0ABgt7oh.d.mts → loggerLink-2o-uZ3r1.d.cts} +3 -4
  55. package/dist/loggerLink-2o-uZ3r1.d.cts.map +1 -0
  56. package/dist/{loggerLink.d-BxSIj5kx.d.cts → loggerLink-CFercTVc.d.mts} +3 -4
  57. package/dist/loggerLink-CFercTVc.d.mts.map +1 -0
  58. package/dist/objectSpread2-D-dJi1gK.cjs +73 -0
  59. package/dist/objectSpread2-weooBxVk.mjs +62 -0
  60. package/dist/{splitLink-B7Cuf2c_.mjs → splitLink-BZPioDdG.mjs} +6 -11
  61. package/dist/splitLink-BZPioDdG.mjs.map +1 -0
  62. package/dist/{splitLink.d-BBFK_mCw.d.cts → splitLink-CJdcmEmS.d.cts} +3 -6
  63. package/dist/splitLink-CJdcmEmS.d.cts.map +1 -0
  64. package/dist/{splitLink.d-CkHNg1Se.d.mts → splitLink-CixmF14P.d.mts} +3 -6
  65. package/dist/splitLink-CixmF14P.d.mts.map +1 -0
  66. package/dist/{splitLink-BMgxggng.cjs → splitLink-MXnaFlEb.cjs} +17 -24
  67. package/dist/{subscriptions.d-Ciljg_dH.d.cts → subscriptions-DcqRZc4h.d.cts} +2 -2
  68. package/dist/subscriptions-DcqRZc4h.d.cts.map +1 -0
  69. package/dist/{subscriptions.d-Dlr1nWGD.d.mts → subscriptions-DcqRZc4h.d.mts} +2 -2
  70. package/dist/subscriptions-DcqRZc4h.d.mts.map +1 -0
  71. package/dist/{types.d-CAr6snH0.d.mts → types-BxbMkv6C.d.cts} +4 -15
  72. package/dist/types-BxbMkv6C.d.cts.map +1 -0
  73. package/dist/{types.d-Dmmedc5G.d.cts → types-CAPs7vhA.d.mts} +4 -15
  74. package/dist/types-CAPs7vhA.d.mts.map +1 -0
  75. package/dist/{unstable-internals.d-BOmV7EK1.d.mts → unstable-internals-CE8gFBQ9.d.cts} +2 -4
  76. package/dist/unstable-internals-CE8gFBQ9.d.cts.map +1 -0
  77. package/dist/{unstable-internals.d-kWsZTlQq.d.cts → unstable-internals-CE8gFBQ9.d.mts} +2 -4
  78. package/dist/unstable-internals-CE8gFBQ9.d.mts.map +1 -0
  79. package/dist/unstable-internals.cjs +28 -3
  80. package/dist/unstable-internals.d.cts +2 -2
  81. package/dist/unstable-internals.d.mts +2 -2
  82. package/dist/unstable-internals.mjs +28 -2
  83. package/dist/unstable-internals.mjs.map +1 -0
  84. package/dist/{wsLink-DSf4KOdW.mjs → wsLink-Bm5LKL6z.mjs} +73 -94
  85. package/dist/wsLink-Bm5LKL6z.mjs.map +1 -0
  86. package/dist/{wsLink-CobRSm6C.cjs → wsLink-CKAsNP9P.cjs} +100 -123
  87. package/dist/{wsLink.d-pFN64NkG.d.mts → wsLink-DoiyfDgJ.d.cts} +11 -31
  88. package/dist/wsLink-DoiyfDgJ.d.cts.map +1 -0
  89. package/dist/{wsLink.d-DzZZZGZQ.d.cts → wsLink-U8pJ7LD2.d.mts} +11 -31
  90. package/dist/wsLink-U8pJ7LD2.d.mts.map +1 -0
  91. package/package.json +10 -10
  92. package/src/getFetch.ts +3 -2
  93. package/src/links/httpBatchLink.ts +12 -3
  94. package/src/links/httpBatchStreamLink.ts +7 -8
  95. package/src/links/httpLink.ts +9 -2
  96. package/src/links/httpSubscriptionLink.ts +1 -3
  97. package/src/links/internals/subscriptions.ts +3 -2
  98. package/src/links/types.ts +1 -2
  99. package/src/links/wsLink/wsClient/wsClient.ts +8 -1
  100. package/dist/TRPCClientError-CQrTQLrk.cjs +0 -61
  101. package/dist/TRPCClientError-apv8gw59.mjs.map +0 -1
  102. package/dist/chunk-DWy1uDak.cjs +0 -39
  103. package/dist/httpBatchLink-LhidKAPw.mjs.map +0 -1
  104. package/dist/httpBatchLink.d-7jyWtY5H.d.cts.map +0 -1
  105. package/dist/httpBatchLink.d-p8Y9QM8p.d.mts.map +0 -1
  106. package/dist/httpLink-lG_6juPY.mjs.map +0 -1
  107. package/dist/httpLink.d-CjpPCq4q.d.mts.map +0 -1
  108. package/dist/httpLink.d-D5qR9haY.d.cts.map +0 -1
  109. package/dist/httpUtils-pyf5RF99.mjs.map +0 -1
  110. package/dist/httpUtils.d-BqmeKEGo.d.cts.map +0 -1
  111. package/dist/httpUtils.d-C5t5to0D.d.mts.map +0 -1
  112. package/dist/loggerLink-CuYvRzyH.cjs +0 -123
  113. package/dist/loggerLink-ineCN1PO.mjs +0 -118
  114. package/dist/loggerLink-ineCN1PO.mjs.map +0 -1
  115. package/dist/loggerLink.d-0ABgt7oh.d.mts.map +0 -1
  116. package/dist/loggerLink.d-BxSIj5kx.d.cts.map +0 -1
  117. package/dist/objectSpread2-Bsvh_OqM.cjs +0 -100
  118. package/dist/objectSpread2-BvkFp-_Y.mjs +0 -114
  119. package/dist/objectSpread2-BvkFp-_Y.mjs.map +0 -1
  120. package/dist/splitLink-B7Cuf2c_.mjs.map +0 -1
  121. package/dist/splitLink.d-BBFK_mCw.d.cts.map +0 -1
  122. package/dist/splitLink.d-CkHNg1Se.d.mts.map +0 -1
  123. package/dist/subscriptions.d-Ciljg_dH.d.cts.map +0 -1
  124. package/dist/subscriptions.d-Dlr1nWGD.d.mts.map +0 -1
  125. package/dist/types.d-CAr6snH0.d.mts.map +0 -1
  126. package/dist/types.d-Dmmedc5G.d.cts.map +0 -1
  127. package/dist/unstable-internals-Bg7n9BBj.mjs +0 -29
  128. package/dist/unstable-internals-Bg7n9BBj.mjs.map +0 -1
  129. package/dist/unstable-internals-M84gUQCV.cjs +0 -34
  130. package/dist/unstable-internals.d-BOmV7EK1.d.mts.map +0 -1
  131. package/dist/unstable-internals.d-kWsZTlQq.d.cts.map +0 -1
  132. package/dist/wsLink-DSf4KOdW.mjs.map +0 -1
  133. package/dist/wsLink.d-DzZZZGZQ.d.cts.map +0 -1
  134. package/dist/wsLink.d-pFN64NkG.d.mts.map +0 -1
@@ -1,19 +1,56 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
2
- const require_objectSpread2$1 = require('./objectSpread2-Bsvh_OqM.cjs');
3
- const require_unstable_internals = require('./unstable-internals-M84gUQCV.cjs');
4
-
1
+ const require_objectSpread2 = require("./objectSpread2-D-dJi1gK.cjs");
2
+ const require_unstable_internals = require("./unstable-internals.cjs");
5
3
  //#region src/getFetch.ts
6
4
  const isFunction = (fn) => typeof fn === "function";
7
5
  function getFetch(customFetchImpl) {
8
6
  if (customFetchImpl) return customFetchImpl;
9
- if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
7
+ if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch.bind(window);
10
8
  if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
11
9
  throw new Error("No fetch implementation found");
12
10
  }
13
-
11
+ //#endregion
12
+ //#region src/internals/signals.ts
13
+ /**
14
+ * Like `Promise.all()` but for abort signals
15
+ * - When all signals have been aborted, the merged signal will be aborted
16
+ * - If one signal is `null`, no signal will be aborted
17
+ */
18
+ function allAbortSignals(...signals) {
19
+ const ac = new AbortController();
20
+ const count = signals.length;
21
+ let abortedCount = 0;
22
+ const onAbort = () => {
23
+ if (++abortedCount === count) ac.abort();
24
+ };
25
+ for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) onAbort();
26
+ else signal === null || signal === void 0 || signal.addEventListener("abort", onAbort, { once: true });
27
+ return ac.signal;
28
+ }
29
+ /**
30
+ * Like `Promise.race` but for abort signals
31
+ *
32
+ * Basically, a ponyfill for
33
+ * [`AbortSignal.any`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static).
34
+ */
35
+ function raceAbortSignals(...signals) {
36
+ const ac = new AbortController();
37
+ for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) ac.abort();
38
+ else signal === null || signal === void 0 || signal.addEventListener("abort", () => ac.abort(), { once: true });
39
+ return ac.signal;
40
+ }
41
+ function abortSignalToPromise(signal) {
42
+ return new Promise((_, reject) => {
43
+ if (signal.aborted) {
44
+ reject(signal.reason);
45
+ return;
46
+ }
47
+ signal.addEventListener("abort", () => {
48
+ reject(signal.reason);
49
+ }, { once: true });
50
+ });
51
+ }
14
52
  //#endregion
15
53
  //#region src/links/internals/httpUtils.ts
16
- var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
17
54
  function resolveHTTPLinkOptions(opts) {
18
55
  return {
19
56
  url: opts.url.toString(),
@@ -40,8 +77,7 @@ function getInput(opts) {
40
77
  }
41
78
  const getUrl = (opts) => {
42
79
  const parts = opts.url.split("?");
43
- const base = parts[0].replace(/\/$/, "");
44
- let url = base + "/" + opts.path;
80
+ let url = parts[0].replace(/\/$/, "") + "/" + opts.path;
45
81
  const queryParts = [];
46
82
  if (parts[1]) queryParts.push(parts[1]);
47
83
  if ("inputs" in opts) queryParts.push("batch=1");
@@ -53,12 +89,12 @@ const getUrl = (opts) => {
53
89
  return url;
54
90
  };
55
91
  const getBody = (opts) => {
56
- if (opts.type === "query" && opts.methodOverride !== "POST") return void 0;
92
+ if (opts.type === "query" && opts.methodOverride !== "POST") return;
57
93
  const input = getInput(opts);
58
94
  return input !== void 0 ? JSON.stringify(input) : void 0;
59
95
  };
60
96
  const jsonHttpRequester = (opts) => {
61
- return httpRequest((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
97
+ return httpRequest(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, opts), {}, {
62
98
  contentTypeHeader: "application/json",
63
99
  getUrl,
64
100
  getBody
@@ -98,7 +134,7 @@ async function fetchHTTPResponse(opts) {
98
134
  if (Symbol.iterator in heads) return Object.fromEntries(heads);
99
135
  return heads;
100
136
  })();
101
- const headers = (0, import_objectSpread2.default)((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== void 0 ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : void 0), resolvedHeaders);
137
+ const headers = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== void 0 ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : void 0), resolvedHeaders);
102
138
  return getFetch(opts.fetch)(url, {
103
139
  method,
104
140
  signal: opts.signal,
@@ -117,47 +153,64 @@ async function httpRequest(opts) {
117
153
  meta
118
154
  };
119
155
  }
120
-
121
156
  //#endregion
122
- Object.defineProperty(exports, 'fetchHTTPResponse', {
123
- enumerable: true,
124
- get: function () {
125
- return fetchHTTPResponse;
126
- }
157
+ Object.defineProperty(exports, "abortSignalToPromise", {
158
+ enumerable: true,
159
+ get: function() {
160
+ return abortSignalToPromise;
161
+ }
127
162
  });
128
- Object.defineProperty(exports, 'getBody', {
129
- enumerable: true,
130
- get: function () {
131
- return getBody;
132
- }
163
+ Object.defineProperty(exports, "allAbortSignals", {
164
+ enumerable: true,
165
+ get: function() {
166
+ return allAbortSignals;
167
+ }
133
168
  });
134
- Object.defineProperty(exports, 'getFetch', {
135
- enumerable: true,
136
- get: function () {
137
- return getFetch;
138
- }
169
+ Object.defineProperty(exports, "fetchHTTPResponse", {
170
+ enumerable: true,
171
+ get: function() {
172
+ return fetchHTTPResponse;
173
+ }
174
+ });
175
+ Object.defineProperty(exports, "getBody", {
176
+ enumerable: true,
177
+ get: function() {
178
+ return getBody;
179
+ }
180
+ });
181
+ Object.defineProperty(exports, "getFetch", {
182
+ enumerable: true,
183
+ get: function() {
184
+ return getFetch;
185
+ }
186
+ });
187
+ Object.defineProperty(exports, "getUrl", {
188
+ enumerable: true,
189
+ get: function() {
190
+ return getUrl;
191
+ }
192
+ });
193
+ Object.defineProperty(exports, "httpRequest", {
194
+ enumerable: true,
195
+ get: function() {
196
+ return httpRequest;
197
+ }
139
198
  });
140
- Object.defineProperty(exports, 'getUrl', {
141
- enumerable: true,
142
- get: function () {
143
- return getUrl;
144
- }
199
+ Object.defineProperty(exports, "jsonHttpRequester", {
200
+ enumerable: true,
201
+ get: function() {
202
+ return jsonHttpRequester;
203
+ }
145
204
  });
146
- Object.defineProperty(exports, 'httpRequest', {
147
- enumerable: true,
148
- get: function () {
149
- return httpRequest;
150
- }
205
+ Object.defineProperty(exports, "raceAbortSignals", {
206
+ enumerable: true,
207
+ get: function() {
208
+ return raceAbortSignals;
209
+ }
151
210
  });
152
- Object.defineProperty(exports, 'jsonHttpRequester', {
153
- enumerable: true,
154
- get: function () {
155
- return jsonHttpRequester;
156
- }
211
+ Object.defineProperty(exports, "resolveHTTPLinkOptions", {
212
+ enumerable: true,
213
+ get: function() {
214
+ return resolveHTTPLinkOptions;
215
+ }
157
216
  });
158
- Object.defineProperty(exports, 'resolveHTTPLinkOptions', {
159
- enumerable: true,
160
- get: function () {
161
- return resolveHTTPLinkOptions;
162
- }
163
- });