@trpc/client 11.1.2 → 11.1.3-alpha-tmp-tsdown.23

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 (234) hide show
  1. package/dist/TRPCClientError.d.mts +33 -0
  2. package/dist/TRPCClientError.d.mts.map +1 -0
  3. package/dist/TRPCClientError.d.ts +29 -25
  4. package/dist/TRPCClientError.d.ts.map +1 -1
  5. package/dist/TRPCClientError.js +48 -72
  6. package/dist/TRPCClientError.mjs +48 -71
  7. package/dist/TRPCClientError.mjs.map +1 -0
  8. package/dist/_virtual/rolldown_runtime.js +39 -0
  9. package/dist/_virtual/rolldown_runtime.mjs +27 -0
  10. package/dist/createTRPCClient.d.mts +73 -0
  11. package/dist/createTRPCClient.d.mts.map +1 -0
  12. package/dist/createTRPCClient.d.ts +38 -34
  13. package/dist/createTRPCClient.d.ts.map +1 -1
  14. package/dist/createTRPCClient.js +34 -34
  15. package/dist/createTRPCClient.mjs +33 -31
  16. package/dist/createTRPCClient.mjs.map +1 -0
  17. package/dist/createTRPCUntypedClient.d.mts +9 -0
  18. package/dist/createTRPCUntypedClient.d.mts.map +1 -0
  19. package/dist/createTRPCUntypedClient.d.ts +8 -6
  20. package/dist/createTRPCUntypedClient.d.ts.map +1 -1
  21. package/dist/createTRPCUntypedClient.js +5 -6
  22. package/dist/createTRPCUntypedClient.mjs +6 -3
  23. package/dist/createTRPCUntypedClient.mjs.map +1 -0
  24. package/dist/getFetch.d.mts +10 -0
  25. package/dist/getFetch.d.mts.map +1 -0
  26. package/dist/getFetch.d.ts +9 -2
  27. package/dist/getFetch.d.ts.map +1 -1
  28. package/dist/getFetch.js +8 -13
  29. package/dist/getFetch.mjs +8 -11
  30. package/dist/getFetch.mjs.map +1 -0
  31. package/dist/index.d.mts +21 -0
  32. package/dist/index.d.ts +21 -16
  33. package/dist/index.js +41 -42
  34. package/dist/index.mjs +18 -15
  35. package/dist/internals/TRPCUntypedClient.d.mts +46 -0
  36. package/dist/internals/TRPCUntypedClient.d.mts.map +1 -0
  37. package/dist/internals/TRPCUntypedClient.d.ts +40 -33
  38. package/dist/internals/TRPCUntypedClient.d.ts.map +1 -1
  39. package/dist/internals/TRPCUntypedClient.js +94 -113
  40. package/dist/internals/TRPCUntypedClient.mjs +93 -110
  41. package/dist/internals/TRPCUntypedClient.mjs.map +1 -0
  42. package/dist/internals/dataLoader.js +101 -116
  43. package/dist/internals/dataLoader.mjs +101 -114
  44. package/dist/internals/dataLoader.mjs.map +1 -0
  45. package/dist/internals/inputWithTrackedEventId.js +9 -12
  46. package/dist/internals/inputWithTrackedEventId.mjs +9 -10
  47. package/dist/internals/inputWithTrackedEventId.mjs.map +1 -0
  48. package/dist/internals/signals.js +39 -40
  49. package/dist/internals/signals.mjs +39 -39
  50. package/dist/internals/signals.mjs.map +1 -0
  51. package/dist/internals/transformer.d.mts +47 -0
  52. package/dist/internals/transformer.d.mts.map +1 -0
  53. package/dist/internals/transformer.d.ts +28 -23
  54. package/dist/internals/transformer.d.ts.map +1 -1
  55. package/dist/internals/transformer.js +25 -26
  56. package/dist/internals/transformer.mjs +25 -24
  57. package/dist/internals/transformer.mjs.map +1 -0
  58. package/dist/internals/types.d.mts +85 -0
  59. package/dist/internals/types.d.mts.map +1 -0
  60. package/dist/internals/types.d.ts +45 -42
  61. package/dist/internals/types.d.ts.map +1 -1
  62. package/dist/links/HTTPBatchLinkOptions.d.mts +25 -0
  63. package/dist/links/HTTPBatchLinkOptions.d.mts.map +1 -0
  64. package/dist/links/HTTPBatchLinkOptions.d.ts +23 -18
  65. package/dist/links/HTTPBatchLinkOptions.d.ts.map +1 -1
  66. package/dist/links/httpBatchLink.d.mts +18 -0
  67. package/dist/links/httpBatchLink.d.mts.map +1 -0
  68. package/dist/links/httpBatchLink.d.ts +14 -4
  69. package/dist/links/httpBatchLink.d.ts.map +1 -1
  70. package/dist/links/httpBatchLink.js +90 -106
  71. package/dist/links/httpBatchLink.mjs +89 -103
  72. package/dist/links/httpBatchLink.mjs.map +1 -0
  73. package/dist/links/httpBatchStreamLink.d.mts +22 -0
  74. package/dist/links/httpBatchStreamLink.d.mts.map +1 -0
  75. package/dist/links/httpBatchStreamLink.d.ts +15 -5
  76. package/dist/links/httpBatchStreamLink.d.ts.map +1 -1
  77. package/dist/links/httpBatchStreamLink.js +120 -144
  78. package/dist/links/httpBatchStreamLink.mjs +119 -141
  79. package/dist/links/httpBatchStreamLink.mjs.map +1 -0
  80. package/dist/links/httpLink.d.mts +24 -0
  81. package/dist/links/httpLink.d.mts.map +1 -0
  82. package/dist/links/httpLink.d.ts +19 -12
  83. package/dist/links/httpLink.d.ts.map +1 -1
  84. package/dist/links/httpLink.js +74 -90
  85. package/dist/links/httpLink.mjs +73 -87
  86. package/dist/links/httpLink.mjs.map +1 -0
  87. package/dist/links/httpSubscriptionLink.d.mts +30 -0
  88. package/dist/links/httpSubscriptionLink.d.mts.map +1 -0
  89. package/dist/links/httpSubscriptionLink.d.ts +21 -17
  90. package/dist/links/httpSubscriptionLink.d.ts.map +1 -1
  91. package/dist/links/httpSubscriptionLink.js +134 -179
  92. package/dist/links/httpSubscriptionLink.mjs +133 -176
  93. package/dist/links/httpSubscriptionLink.mjs.map +1 -0
  94. package/dist/links/internals/contentTypes.d.mts +10 -0
  95. package/dist/links/internals/contentTypes.d.mts.map +1 -0
  96. package/dist/links/internals/contentTypes.d.ts +9 -3
  97. package/dist/links/internals/contentTypes.d.ts.map +1 -1
  98. package/dist/links/internals/contentTypes.js +6 -6
  99. package/dist/links/internals/contentTypes.mjs +6 -4
  100. package/dist/links/internals/contentTypes.mjs.map +1 -0
  101. package/dist/links/internals/createChain.js +23 -23
  102. package/dist/links/internals/createChain.mjs +22 -20
  103. package/dist/links/internals/createChain.mjs.map +1 -0
  104. package/dist/links/internals/httpUtils.d.mts +26 -0
  105. package/dist/links/internals/httpUtils.d.mts.map +1 -0
  106. package/dist/links/internals/httpUtils.d.ts +22 -64
  107. package/dist/links/internals/httpUtils.d.ts.map +1 -1
  108. package/dist/links/internals/httpUtils.js +93 -116
  109. package/dist/links/internals/httpUtils.mjs +94 -113
  110. package/dist/links/internals/httpUtils.mjs.map +1 -0
  111. package/dist/links/internals/subscriptions.d.mts +20 -0
  112. package/dist/links/internals/subscriptions.d.mts.map +1 -0
  113. package/dist/links/internals/subscriptions.d.ts +11 -8
  114. package/dist/links/internals/subscriptions.d.ts.map +1 -1
  115. package/dist/links/internals/urlWithConnectionParams.d.mts +27 -0
  116. package/dist/links/internals/urlWithConnectionParams.d.mts.map +1 -0
  117. package/dist/links/internals/urlWithConnectionParams.d.ts +22 -18
  118. package/dist/links/internals/urlWithConnectionParams.d.ts.map +1 -1
  119. package/dist/links/internals/urlWithConnectionParams.js +8 -6
  120. package/dist/links/internals/urlWithConnectionParams.mjs +8 -4
  121. package/dist/links/internals/urlWithConnectionParams.mjs.map +1 -0
  122. package/dist/links/localLink.d.mts +22 -0
  123. package/dist/links/localLink.d.mts.map +1 -0
  124. package/dist/links/localLink.d.ts +22 -0
  125. package/dist/links/localLink.d.ts.map +1 -0
  126. package/dist/links/localLink.js +192 -0
  127. package/dist/links/localLink.mjs +193 -0
  128. package/dist/links/localLink.mjs.map +1 -0
  129. package/dist/links/loggerLink.d.mts +56 -0
  130. package/dist/links/loggerLink.d.mts.map +1 -0
  131. package/dist/links/loggerLink.d.ts +40 -36
  132. package/dist/links/loggerLink.d.ts.map +1 -1
  133. package/dist/links/loggerLink.js +113 -166
  134. package/dist/links/loggerLink.mjs +112 -163
  135. package/dist/links/loggerLink.mjs.map +1 -0
  136. package/dist/links/retryLink.d.mts +35 -0
  137. package/dist/links/retryLink.d.mts.map +1 -0
  138. package/dist/links/retryLink.d.ts +27 -25
  139. package/dist/links/retryLink.d.ts.map +1 -1
  140. package/dist/links/retryLink.js +60 -68
  141. package/dist/links/retryLink.mjs +59 -65
  142. package/dist/links/retryLink.mjs.map +1 -0
  143. package/dist/links/splitLink.d.mts +21 -0
  144. package/dist/links/splitLink.d.mts.map +1 -0
  145. package/dist/links/splitLink.d.ts +19 -12
  146. package/dist/links/splitLink.d.ts.map +1 -1
  147. package/dist/links/splitLink.js +20 -21
  148. package/dist/links/splitLink.mjs +19 -18
  149. package/dist/links/splitLink.mjs.map +1 -0
  150. package/dist/links/types.d.mts +71 -0
  151. package/dist/links/types.d.mts.map +1 -0
  152. package/dist/links/types.d.ts +37 -29
  153. package/dist/links/types.d.ts.map +1 -1
  154. package/dist/links/wsLink/createWsClient.d.mts +10 -0
  155. package/dist/links/wsLink/createWsClient.d.mts.map +1 -0
  156. package/dist/links/wsLink/createWsClient.d.ts +9 -5
  157. package/dist/links/wsLink/createWsClient.d.ts.map +1 -1
  158. package/dist/links/wsLink/createWsClient.js +5 -5
  159. package/dist/links/wsLink/createWsClient.mjs +5 -2
  160. package/dist/links/wsLink/createWsClient.mjs.map +1 -0
  161. package/dist/links/wsLink/wsClient/options.d.mts +69 -0
  162. package/dist/links/wsLink/wsClient/options.d.mts.map +1 -0
  163. package/dist/links/wsLink/wsClient/options.d.ts +54 -64
  164. package/dist/links/wsLink/wsClient/options.d.ts.map +1 -1
  165. package/dist/links/wsLink/wsClient/options.js +14 -12
  166. package/dist/links/wsLink/wsClient/options.mjs +14 -10
  167. package/dist/links/wsLink/wsClient/options.mjs.map +1 -0
  168. package/dist/links/wsLink/wsClient/requestManager.js +133 -135
  169. package/dist/links/wsLink/wsClient/requestManager.mjs +133 -132
  170. package/dist/links/wsLink/wsClient/requestManager.mjs.map +1 -0
  171. package/dist/links/wsLink/wsClient/utils.js +64 -81
  172. package/dist/links/wsLink/wsClient/utils.mjs +64 -78
  173. package/dist/links/wsLink/wsClient/utils.mjs.map +1 -0
  174. package/dist/links/wsLink/wsClient/wsClient.d.mts +104 -0
  175. package/dist/links/wsLink/wsClient/wsClient.d.mts.map +1 -0
  176. package/dist/links/wsLink/wsClient/wsClient.d.ts +99 -79
  177. package/dist/links/wsLink/wsClient/wsClient.d.ts.map +1 -1
  178. package/dist/links/wsLink/wsClient/wsClient.js +273 -322
  179. package/dist/links/wsLink/wsClient/wsClient.mjs +272 -319
  180. package/dist/links/wsLink/wsClient/wsClient.mjs.map +1 -0
  181. package/dist/links/wsLink/wsClient/wsConnection.js +155 -178
  182. package/dist/links/wsLink/wsClient/wsConnection.mjs +154 -175
  183. package/dist/links/wsLink/wsClient/wsConnection.mjs.map +1 -0
  184. package/dist/links/wsLink/wsLink.d.mts +15 -0
  185. package/dist/links/wsLink/wsLink.d.mts.map +1 -0
  186. package/dist/links/wsLink/wsLink.d.ts +13 -9
  187. package/dist/links/wsLink/wsLink.d.ts.map +1 -1
  188. package/dist/links/wsLink/wsLink.js +30 -31
  189. package/dist/links/wsLink/wsLink.mjs +29 -28
  190. package/dist/links/wsLink/wsLink.mjs.map +1 -0
  191. package/dist/links.js +11 -0
  192. package/dist/links.mjs +11 -0
  193. package/dist/node_modules/.pnpm/@oxc-project_runtime@0.71.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js +68 -0
  194. package/dist/node_modules/.pnpm/@oxc-project_runtime@0.71.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.mjs +66 -0
  195. package/dist/node_modules/.pnpm/@oxc-project_runtime@0.71.0/node_modules/@oxc-project/runtime/src/helpers/usingCtx.mjs.map +1 -0
  196. package/dist/unstable-internals.d.mts +3 -0
  197. package/dist/unstable-internals.d.ts +3 -3
  198. package/dist/unstable-internals.js +2 -6
  199. package/dist/unstable-internals.mjs +3 -1
  200. package/links/httpBatchLink/package.json +1 -0
  201. package/links/httpLink/package.json +1 -0
  202. package/links/loggerLink/package.json +1 -0
  203. package/links/splitLink/package.json +1 -0
  204. package/links/wsLink/wsLink/package.json +1 -0
  205. package/package.json +64 -29
  206. package/src/TRPCClientError.ts +4 -9
  207. package/src/internals/dataLoader.ts +2 -6
  208. package/src/internals/signals.ts +16 -0
  209. package/src/links/httpSubscriptionLink.ts +3 -18
  210. package/src/links/localLink.ts +277 -0
  211. package/src/links/wsLink/wsClient/requestManager.ts +9 -0
  212. package/src/links/wsLink/wsClient/wsClient.ts +1 -1
  213. package/src/links.ts +1 -0
  214. package/unstable-internals/package.json +1 -0
  215. package/dist/index.d.ts.map +0 -1
  216. package/dist/internals/dataLoader.d.ts +0 -13
  217. package/dist/internals/dataLoader.d.ts.map +0 -1
  218. package/dist/internals/inputWithTrackedEventId.d.ts +0 -2
  219. package/dist/internals/inputWithTrackedEventId.d.ts.map +0 -1
  220. package/dist/internals/signals.d.ts +0 -15
  221. package/dist/internals/signals.d.ts.map +0 -1
  222. package/dist/links/internals/createChain.d.ts +0 -8
  223. package/dist/links/internals/createChain.d.ts.map +0 -1
  224. package/dist/links/internals/dedupeLink.d.ts +0 -7
  225. package/dist/links/internals/dedupeLink.d.ts.map +0 -1
  226. package/dist/links/wsLink/wsClient/requestManager.d.ts +0 -102
  227. package/dist/links/wsLink/wsClient/requestManager.d.ts.map +0 -1
  228. package/dist/links/wsLink/wsClient/utils.d.ts +0 -38
  229. package/dist/links/wsLink/wsClient/utils.d.ts.map +0 -1
  230. package/dist/links/wsLink/wsClient/wsConnection.d.ts +0 -79
  231. package/dist/links/wsLink/wsClient/wsConnection.d.ts.map +0 -1
  232. package/dist/links.d.ts +0 -11
  233. package/dist/links.d.ts.map +0 -1
  234. package/dist/unstable-internals.d.ts.map +0 -1
@@ -1,136 +1,137 @@
1
- import { withResolvers } from './utils.mjs';
1
+ import { withResolvers } from "./utils.mjs";
2
2
 
3
- function _define_property(obj, key, value) {
4
- if (key in obj) {
5
- Object.defineProperty(obj, key, {
6
- value: value,
7
- enumerable: true,
8
- configurable: true,
9
- writable: true
10
- });
11
- } else {
12
- obj[key] = value;
13
- }
14
- return obj;
15
- }
3
+ //#region src/links/wsLink/wsClient/requestManager.ts
16
4
  /**
17
- * Manages WebSocket requests, tracking their lifecycle and providing utility methods
18
- * for handling outgoing and pending requests.
19
- *
20
- * - **Outgoing requests**: Requests that are queued and waiting to be sent.
21
- * - **Pending requests**: Requests that have been sent and are in flight awaiting a response.
22
- * For subscriptions, multiple responses may be received until the subscription is closed.
23
- */ class RequestManager {
24
- /**
25
- * Registers a new request by adding it to the outgoing queue and setting up
26
- * callbacks for lifecycle events such as completion or error.
27
- *
28
- * @param message - The outgoing message to be sent.
29
- * @param callbacks - Callback functions to observe the request's state.
30
- * @returns A cleanup function to manually remove the request.
31
- */ register(message, callbacks) {
32
- const { promise: end, resolve } = withResolvers();
33
- this.outgoingRequests.push({
34
- id: String(message.id),
35
- message,
36
- end,
37
- callbacks: {
38
- next: callbacks.next,
39
- complete: ()=>{
40
- callbacks.complete();
41
- resolve();
42
- },
43
- error: (e)=>{
44
- callbacks.error(e);
45
- resolve();
46
- }
47
- }
48
- });
49
- return ()=>{
50
- this.delete(message.id);
51
- callbacks.complete();
52
- resolve();
53
- };
54
- }
55
- /**
56
- * Deletes a request from both the outgoing and pending collections, if it exists.
57
- */ delete(messageId) {
58
- if (messageId === null) return;
59
- this.outgoingRequests = this.outgoingRequests.filter(({ id })=>id !== String(messageId));
60
- delete this.pendingRequests[String(messageId)];
61
- }
62
- /**
63
- * Moves all outgoing requests to the pending state and clears the outgoing queue.
64
- *
65
- * The caller is expected to handle the actual sending of the requests
66
- * (e.g., sending them over the network) after this method is called.
67
- *
68
- * @returns The list of requests that were transitioned to the pending state.
69
- */ flush() {
70
- const requests = this.outgoingRequests;
71
- this.outgoingRequests = [];
72
- for (const request of requests){
73
- this.pendingRequests[request.id] = request;
74
- }
75
- return requests;
76
- }
77
- /**
78
- * Retrieves all currently pending requests, which are in flight awaiting responses
79
- * or handling ongoing subscriptions.
80
- */ getPendingRequests() {
81
- return Object.values(this.pendingRequests);
82
- }
83
- /**
84
- * Retrieves a specific pending request by its message ID.
85
- */ getPendingRequest(messageId) {
86
- if (messageId === null) return null;
87
- return this.pendingRequests[String(messageId)];
88
- }
89
- /**
90
- * Retrieves all outgoing requests, which are waiting to be sent.
91
- */ getOutgoingRequests() {
92
- return this.outgoingRequests;
93
- }
94
- /**
95
- * Retrieves all requests, both outgoing and pending, with their respective states.
96
- *
97
- * @returns An array of all requests with their state ("outgoing" or "pending").
98
- */ getRequests() {
99
- return [
100
- ...this.getOutgoingRequests().map((request)=>({
101
- state: 'outgoing',
102
- message: request.message,
103
- end: request.end,
104
- callbacks: request.callbacks
105
- })),
106
- ...this.getPendingRequests().map((request)=>({
107
- state: 'pending',
108
- message: request.message,
109
- end: request.end,
110
- callbacks: request.callbacks
111
- }))
112
- ];
113
- }
114
- /**
115
- * Checks if there are any pending requests, including ongoing subscriptions.
116
- */ hasPendingRequests() {
117
- return this.getPendingRequests().length > 0;
118
- }
119
- /**
120
- * Checks if there are any outgoing requests waiting to be sent.
121
- */ hasOutgoingRequests() {
122
- return this.outgoingRequests.length > 0;
123
- }
124
- constructor(){
125
- /**
126
- * Stores requests that are outgoing, meaning they are registered but not yet sent over the WebSocket.
127
- */ _define_property(this, "outgoingRequests", new Array());
128
- /**
129
- * Stores requests that are pending (in flight), meaning they have been sent over the WebSocket
130
- * and are awaiting responses. For subscriptions, this includes requests
131
- * that may receive multiple responses.
132
- */ _define_property(this, "pendingRequests", {});
133
- }
134
- }
5
+ * Manages WebSocket requests, tracking their lifecycle and providing utility methods
6
+ * for handling outgoing and pending requests.
7
+ *
8
+ * - **Outgoing requests**: Requests that are queued and waiting to be sent.
9
+ * - **Pending requests**: Requests that have been sent and are in flight awaiting a response.
10
+ * For subscriptions, multiple responses may be received until the subscription is closed.
11
+ */
12
+ var RequestManager = class {
13
+ /**
14
+ * Stores requests that are outgoing, meaning they are registered but not yet sent over the WebSocket.
15
+ */
16
+ outgoingRequests = new Array();
17
+ /**
18
+ * Stores requests that are pending (in flight), meaning they have been sent over the WebSocket
19
+ * and are awaiting responses. For subscriptions, this includes requests
20
+ * that may receive multiple responses.
21
+ */
22
+ pendingRequests = {};
23
+ /**
24
+ * Registers a new request by adding it to the outgoing queue and setting up
25
+ * callbacks for lifecycle events such as completion or error.
26
+ *
27
+ * @param message - The outgoing message to be sent.
28
+ * @param callbacks - Callback functions to observe the request's state.
29
+ * @returns A cleanup function to manually remove the request.
30
+ */
31
+ register(message, callbacks) {
32
+ const { promise: end, resolve } = withResolvers();
33
+ this.outgoingRequests.push({
34
+ id: String(message.id),
35
+ message,
36
+ end,
37
+ callbacks: {
38
+ next: callbacks.next,
39
+ complete: () => {
40
+ callbacks.complete();
41
+ resolve();
42
+ },
43
+ error: (e) => {
44
+ callbacks.error(e);
45
+ resolve();
46
+ }
47
+ }
48
+ });
49
+ return () => {
50
+ this.delete(message.id);
51
+ callbacks.complete();
52
+ resolve();
53
+ };
54
+ }
55
+ /**
56
+ * Deletes a request from both the outgoing and pending collections, if it exists.
57
+ */
58
+ delete(messageId) {
59
+ if (messageId === null) return;
60
+ this.outgoingRequests = this.outgoingRequests.filter(({ id }) => id !== String(messageId));
61
+ delete this.pendingRequests[String(messageId)];
62
+ }
63
+ /**
64
+ * Moves all outgoing requests to the pending state and clears the outgoing queue.
65
+ *
66
+ * The caller is expected to handle the actual sending of the requests
67
+ * (e.g., sending them over the network) after this method is called.
68
+ *
69
+ * @returns The list of requests that were transitioned to the pending state.
70
+ */
71
+ flush() {
72
+ const requests = this.outgoingRequests;
73
+ this.outgoingRequests = [];
74
+ for (const request of requests) this.pendingRequests[request.id] = request;
75
+ return requests;
76
+ }
77
+ /**
78
+ * Retrieves all currently pending requests, which are in flight awaiting responses
79
+ * or handling ongoing subscriptions.
80
+ */
81
+ getPendingRequests() {
82
+ return Object.values(this.pendingRequests);
83
+ }
84
+ /**
85
+ * Retrieves a specific pending request by its message ID.
86
+ */
87
+ getPendingRequest(messageId) {
88
+ if (messageId === null) return null;
89
+ return this.pendingRequests[String(messageId)];
90
+ }
91
+ /**
92
+ * Retrieves all outgoing requests, which are waiting to be sent.
93
+ */
94
+ getOutgoingRequests() {
95
+ return this.outgoingRequests;
96
+ }
97
+ /**
98
+ * Retrieves all requests, both outgoing and pending, with their respective states.
99
+ *
100
+ * @returns An array of all requests with their state ("outgoing" or "pending").
101
+ */
102
+ getRequests() {
103
+ return [...this.getOutgoingRequests().map((request) => ({
104
+ state: "outgoing",
105
+ message: request.message,
106
+ end: request.end,
107
+ callbacks: request.callbacks
108
+ })), ...this.getPendingRequests().map((request) => ({
109
+ state: "pending",
110
+ message: request.message,
111
+ end: request.end,
112
+ callbacks: request.callbacks
113
+ }))];
114
+ }
115
+ /**
116
+ * Checks if there are any pending requests, including ongoing subscriptions.
117
+ */
118
+ hasPendingRequests() {
119
+ return this.getPendingRequests().length > 0;
120
+ }
121
+ /**
122
+ * Checks if there are any pending subscriptions
123
+ */
124
+ hasPendingSubscriptions() {
125
+ return this.getPendingRequests().some((request) => request.message.method === "subscription");
126
+ }
127
+ /**
128
+ * Checks if there are any outgoing requests waiting to be sent.
129
+ */
130
+ hasOutgoingRequests() {
131
+ return this.outgoingRequests.length > 0;
132
+ }
133
+ };
135
134
 
135
+ //#endregion
136
136
  export { RequestManager };
137
+ //# sourceMappingURL=requestManager.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestManager.mjs","names":["message: TRPCClientOutgoingMessage","callbacks: TCallbacks","messageId: MessageIdLike"],"sources":["../../../../src/links/wsLink/wsClient/requestManager.ts"],"sourcesContent":["import type { AnyTRPCRouter, inferRouterError } from '@trpc/server';\nimport type { Observer } from '@trpc/server/observable';\nimport type {\n TRPCClientOutgoingMessage,\n TRPCResponseMessage,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type { TRPCClientError } from '../../../TRPCClientError';\nimport { withResolvers } from './utils';\n\nexport type TCallbacks = Observer<\n TRPCResponseMessage<unknown, inferRouterError<AnyTRPCRouter>>,\n TRPCClientError<AnyTRPCRouter>\n>;\n\ntype MessageId = string;\ntype MessageIdLike = string | number | null;\n\n/**\n * Represents a WebSocket request managed by the RequestManager.\n * Combines the network message, a utility promise (`end`) that mirrors the lifecycle\n * handled by `callbacks`, and a set of state monitoring callbacks.\n */\ninterface Request {\n message: TRPCClientOutgoingMessage;\n end: Promise<void>;\n callbacks: TCallbacks;\n}\n\n/**\n * Manages WebSocket requests, tracking their lifecycle and providing utility methods\n * for handling outgoing and pending requests.\n *\n * - **Outgoing requests**: Requests that are queued and waiting to be sent.\n * - **Pending requests**: Requests that have been sent and are in flight awaiting a response.\n * For subscriptions, multiple responses may be received until the subscription is closed.\n */\nexport class RequestManager {\n /**\n * Stores requests that are outgoing, meaning they are registered but not yet sent over the WebSocket.\n */\n private outgoingRequests = new Array<Request & { id: MessageId }>();\n\n /**\n * Stores requests that are pending (in flight), meaning they have been sent over the WebSocket\n * and are awaiting responses. For subscriptions, this includes requests\n * that may receive multiple responses.\n */\n private pendingRequests: Record<MessageId, Request> = {};\n\n /**\n * Registers a new request by adding it to the outgoing queue and setting up\n * callbacks for lifecycle events such as completion or error.\n *\n * @param message - The outgoing message to be sent.\n * @param callbacks - Callback functions to observe the request's state.\n * @returns A cleanup function to manually remove the request.\n */\n public register(message: TRPCClientOutgoingMessage, callbacks: TCallbacks) {\n const { promise: end, resolve } = withResolvers<void>();\n\n this.outgoingRequests.push({\n id: String(message.id),\n message,\n end,\n callbacks: {\n next: callbacks.next,\n complete: () => {\n callbacks.complete();\n resolve();\n },\n error: (e) => {\n callbacks.error(e);\n resolve();\n },\n },\n });\n\n return () => {\n this.delete(message.id);\n callbacks.complete();\n resolve();\n };\n }\n\n /**\n * Deletes a request from both the outgoing and pending collections, if it exists.\n */\n public delete(messageId: MessageIdLike) {\n if (messageId === null) return;\n\n this.outgoingRequests = this.outgoingRequests.filter(\n ({ id }) => id !== String(messageId),\n );\n delete this.pendingRequests[String(messageId)];\n }\n\n /**\n * Moves all outgoing requests to the pending state and clears the outgoing queue.\n *\n * The caller is expected to handle the actual sending of the requests\n * (e.g., sending them over the network) after this method is called.\n *\n * @returns The list of requests that were transitioned to the pending state.\n */\n public flush() {\n const requests = this.outgoingRequests;\n this.outgoingRequests = [];\n\n for (const request of requests) {\n this.pendingRequests[request.id] = request;\n }\n return requests;\n }\n\n /**\n * Retrieves all currently pending requests, which are in flight awaiting responses\n * or handling ongoing subscriptions.\n */\n public getPendingRequests() {\n return Object.values(this.pendingRequests);\n }\n\n /**\n * Retrieves a specific pending request by its message ID.\n */\n public getPendingRequest(messageId: MessageIdLike) {\n if (messageId === null) return null;\n\n return this.pendingRequests[String(messageId)];\n }\n\n /**\n * Retrieves all outgoing requests, which are waiting to be sent.\n */\n public getOutgoingRequests() {\n return this.outgoingRequests;\n }\n\n /**\n * Retrieves all requests, both outgoing and pending, with their respective states.\n *\n * @returns An array of all requests with their state (\"outgoing\" or \"pending\").\n */\n public getRequests() {\n return [\n ...this.getOutgoingRequests().map((request) => ({\n state: 'outgoing' as const,\n message: request.message,\n end: request.end,\n callbacks: request.callbacks,\n })),\n ...this.getPendingRequests().map((request) => ({\n state: 'pending' as const,\n message: request.message,\n end: request.end,\n callbacks: request.callbacks,\n })),\n ];\n }\n\n /**\n * Checks if there are any pending requests, including ongoing subscriptions.\n */\n public hasPendingRequests() {\n return this.getPendingRequests().length > 0;\n }\n\n /**\n * Checks if there are any pending subscriptions\n */\n public hasPendingSubscriptions() {\n return this.getPendingRequests().some(\n (request) => request.message.method === 'subscription',\n );\n }\n\n /**\n * Checks if there are any outgoing requests waiting to be sent.\n */\n public hasOutgoingRequests() {\n return this.outgoingRequests.length > 0;\n }\n}\n"],"mappings":";;;;;;;;;;;AAoCA,IAAa,iBAAb,MAA4B;;;;CAI1B,AAAQ,mBAAmB,IAAI;;;;;;CAO/B,AAAQ,kBAA8C,CAAE;;;;;;;;;CAUxD,AAAO,SAASA,SAAoCC,WAAuB;EACzE,MAAM,EAAE,SAAS,KAAK,SAAS,GAAG,eAAqB;AAEvD,OAAK,iBAAiB,KAAK;GACzB,IAAI,OAAO,QAAQ,GAAG;GACtB;GACA;GACA,WAAW;IACT,MAAM,UAAU;IAChB,UAAU,MAAM;AACd,eAAU,UAAU;AACpB,cAAS;IACV;IACD,OAAO,CAAC,MAAM;AACZ,eAAU,MAAM,EAAE;AAClB,cAAS;IACV;GACF;EACF,EAAC;AAEF,SAAO,MAAM;AACX,QAAK,OAAO,QAAQ,GAAG;AACvB,aAAU,UAAU;AACpB,YAAS;EACV;CACF;;;;CAKD,AAAO,OAAOC,WAA0B;AACtC,MAAI,cAAc,KAAM;AAExB,OAAK,mBAAmB,KAAK,iBAAiB,OAC5C,CAAC,EAAE,IAAI,KAAK,OAAO,OAAO,UAAU,CACrC;AACD,SAAO,KAAK,gBAAgB,OAAO,UAAU;CAC9C;;;;;;;;;CAUD,AAAO,QAAQ;EACb,MAAM,WAAW,KAAK;AACtB,OAAK,mBAAmB,CAAE;AAE1B,OAAK,MAAM,WAAW,SACpB,MAAK,gBAAgB,QAAQ,MAAM;AAErC,SAAO;CACR;;;;;CAMD,AAAO,qBAAqB;AAC1B,SAAO,OAAO,OAAO,KAAK,gBAAgB;CAC3C;;;;CAKD,AAAO,kBAAkBA,WAA0B;AACjD,MAAI,cAAc,KAAM,QAAO;AAE/B,SAAO,KAAK,gBAAgB,OAAO,UAAU;CAC9C;;;;CAKD,AAAO,sBAAsB;AAC3B,SAAO,KAAK;CACb;;;;;;CAOD,AAAO,cAAc;AACnB,SAAO,CACL,GAAG,KAAK,qBAAqB,CAAC,IAAI,CAAC,aAAa;GAC9C,OAAO;GACP,SAAS,QAAQ;GACjB,KAAK,QAAQ;GACb,WAAW,QAAQ;EACpB,GAAE,EACH,GAAG,KAAK,oBAAoB,CAAC,IAAI,CAAC,aAAa;GAC7C,OAAO;GACP,SAAS,QAAQ;GACjB,KAAK,QAAQ;GACb,WAAW,QAAQ;EACpB,GAAE,AACJ;CACF;;;;CAKD,AAAO,qBAAqB;AAC1B,SAAO,KAAK,oBAAoB,CAAC,SAAS;CAC3C;;;;CAKD,AAAO,0BAA0B;AAC/B,SAAO,KAAK,oBAAoB,CAAC,KAC/B,CAAC,YAAY,QAAQ,QAAQ,WAAW,eACzC;CACF;;;;CAKD,AAAO,sBAAsB;AAC3B,SAAO,KAAK,iBAAiB,SAAS;CACvC;AACF"}
@@ -1,94 +1,77 @@
1
- 'use strict';
1
+ const require__Users_julius_dev_trpc_packages_client_src_links_internals_urlWithConnectionParams = require('../../internals/urlWithConnectionParams.js');
2
2
 
3
- var urlWithConnectionParams = require('../../internals/urlWithConnectionParams.js');
4
-
5
- function _define_property(obj, key, value) {
6
- if (key in obj) {
7
- Object.defineProperty(obj, key, {
8
- value: value,
9
- enumerable: true,
10
- configurable: true,
11
- writable: true
12
- });
13
- } else {
14
- obj[key] = value;
15
- }
16
- return obj;
17
- }
18
- class TRPCWebSocketClosedError extends Error {
19
- constructor(opts){
20
- super(opts.message, {
21
- cause: opts.cause
22
- });
23
- this.name = 'TRPCWebSocketClosedError';
24
- Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype);
25
- }
26
- }
3
+ //#region src/links/wsLink/wsClient/utils.ts
4
+ var TRPCWebSocketClosedError = class TRPCWebSocketClosedError extends Error {
5
+ constructor(opts) {
6
+ super(opts.message, { cause: opts.cause });
7
+ this.name = "TRPCWebSocketClosedError";
8
+ Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype);
9
+ }
10
+ };
27
11
  /**
28
- * Utility class for managing a timeout that can be started, stopped, and reset.
29
- * Useful for scenarios where the timeout duration is reset dynamically based on events.
30
- */ class ResettableTimeout {
31
- /**
32
- * Resets the current timeout, restarting it with the same duration.
33
- * Does nothing if no timeout is active.
34
- */ reset() {
35
- if (!this.timeout) return;
36
- clearTimeout(this.timeout);
37
- this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
38
- }
39
- start() {
40
- clearTimeout(this.timeout);
41
- this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
42
- }
43
- stop() {
44
- clearTimeout(this.timeout);
45
- this.timeout = undefined;
46
- }
47
- constructor(onTimeout, timeoutMs){
48
- _define_property(this, "onTimeout", void 0);
49
- _define_property(this, "timeoutMs", void 0);
50
- _define_property(this, "timeout", void 0);
51
- this.onTimeout = onTimeout;
52
- this.timeoutMs = timeoutMs;
53
- }
54
- }
55
- // Ponyfill for Promise.withResolvers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
12
+ * Utility class for managing a timeout that can be started, stopped, and reset.
13
+ * Useful for scenarios where the timeout duration is reset dynamically based on events.
14
+ */
15
+ var ResettableTimeout = class {
16
+ timeout;
17
+ constructor(onTimeout, timeoutMs) {
18
+ this.onTimeout = onTimeout;
19
+ this.timeoutMs = timeoutMs;
20
+ }
21
+ /**
22
+ * Resets the current timeout, restarting it with the same duration.
23
+ * Does nothing if no timeout is active.
24
+ */
25
+ reset() {
26
+ if (!this.timeout) return;
27
+ clearTimeout(this.timeout);
28
+ this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
29
+ }
30
+ start() {
31
+ clearTimeout(this.timeout);
32
+ this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
33
+ }
34
+ stop() {
35
+ clearTimeout(this.timeout);
36
+ this.timeout = void 0;
37
+ }
38
+ };
56
39
  function withResolvers() {
57
- let resolve;
58
- let reject;
59
- const promise = new Promise((res, rej)=>{
60
- resolve = res;
61
- reject = rej;
62
- });
63
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
- return {
65
- promise,
66
- resolve: resolve,
67
- reject: reject
68
- };
40
+ let resolve;
41
+ let reject;
42
+ const promise = new Promise((res, rej) => {
43
+ resolve = res;
44
+ reject = rej;
45
+ });
46
+ return {
47
+ promise,
48
+ resolve,
49
+ reject
50
+ };
69
51
  }
70
52
  /**
71
- * Resolves a WebSocket URL and optionally appends connection parameters.
72
- *
73
- * If connectionParams are provided, appends 'connectionParams=1' query parameter.
74
- */ async function prepareUrl(urlOptions) {
75
- const url = await urlWithConnectionParams.resultOf(urlOptions.url);
76
- if (!urlOptions.connectionParams) return url;
77
- // append `?connectionParams=1` when connection params are used
78
- const prefix = url.includes('?') ? '&' : '?';
79
- const connectionParams = `${prefix}connectionParams=1`;
80
- return url + connectionParams;
53
+ * Resolves a WebSocket URL and optionally appends connection parameters.
54
+ *
55
+ * If connectionParams are provided, appends 'connectionParams=1' query parameter.
56
+ */
57
+ async function prepareUrl(urlOptions) {
58
+ const url = await require__Users_julius_dev_trpc_packages_client_src_links_internals_urlWithConnectionParams.resultOf(urlOptions.url);
59
+ if (!urlOptions.connectionParams) return url;
60
+ const prefix = url.includes("?") ? "&" : "?";
61
+ const connectionParams = `${prefix}connectionParams=1`;
62
+ return url + connectionParams;
81
63
  }
82
64
  async function buildConnectionMessage(connectionParams) {
83
- const message = {
84
- method: 'connectionParams',
85
- data: await urlWithConnectionParams.resultOf(connectionParams)
86
- };
87
- return JSON.stringify(message);
65
+ const message = {
66
+ method: "connectionParams",
67
+ data: await require__Users_julius_dev_trpc_packages_client_src_links_internals_urlWithConnectionParams.resultOf(connectionParams)
68
+ };
69
+ return JSON.stringify(message);
88
70
  }
89
71
 
72
+ //#endregion
90
73
  exports.ResettableTimeout = ResettableTimeout;
91
74
  exports.TRPCWebSocketClosedError = TRPCWebSocketClosedError;
92
75
  exports.buildConnectionMessage = buildConnectionMessage;
93
76
  exports.prepareUrl = prepareUrl;
94
- exports.withResolvers = withResolvers;
77
+ exports.withResolvers = withResolvers;
@@ -1,88 +1,74 @@
1
- import { resultOf } from '../../internals/urlWithConnectionParams.mjs';
1
+ import { resultOf } from "../../internals/urlWithConnectionParams.mjs";
2
2
 
3
- function _define_property(obj, key, value) {
4
- if (key in obj) {
5
- Object.defineProperty(obj, key, {
6
- value: value,
7
- enumerable: true,
8
- configurable: true,
9
- writable: true
10
- });
11
- } else {
12
- obj[key] = value;
13
- }
14
- return obj;
15
- }
16
- class TRPCWebSocketClosedError extends Error {
17
- constructor(opts){
18
- super(opts.message, {
19
- cause: opts.cause
20
- });
21
- this.name = 'TRPCWebSocketClosedError';
22
- Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype);
23
- }
24
- }
3
+ //#region src/links/wsLink/wsClient/utils.ts
4
+ var TRPCWebSocketClosedError = class TRPCWebSocketClosedError extends Error {
5
+ constructor(opts) {
6
+ super(opts.message, { cause: opts.cause });
7
+ this.name = "TRPCWebSocketClosedError";
8
+ Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype);
9
+ }
10
+ };
25
11
  /**
26
- * Utility class for managing a timeout that can be started, stopped, and reset.
27
- * Useful for scenarios where the timeout duration is reset dynamically based on events.
28
- */ class ResettableTimeout {
29
- /**
30
- * Resets the current timeout, restarting it with the same duration.
31
- * Does nothing if no timeout is active.
32
- */ reset() {
33
- if (!this.timeout) return;
34
- clearTimeout(this.timeout);
35
- this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
36
- }
37
- start() {
38
- clearTimeout(this.timeout);
39
- this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
40
- }
41
- stop() {
42
- clearTimeout(this.timeout);
43
- this.timeout = undefined;
44
- }
45
- constructor(onTimeout, timeoutMs){
46
- _define_property(this, "onTimeout", void 0);
47
- _define_property(this, "timeoutMs", void 0);
48
- _define_property(this, "timeout", void 0);
49
- this.onTimeout = onTimeout;
50
- this.timeoutMs = timeoutMs;
51
- }
52
- }
53
- // Ponyfill for Promise.withResolvers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
12
+ * Utility class for managing a timeout that can be started, stopped, and reset.
13
+ * Useful for scenarios where the timeout duration is reset dynamically based on events.
14
+ */
15
+ var ResettableTimeout = class {
16
+ timeout;
17
+ constructor(onTimeout, timeoutMs) {
18
+ this.onTimeout = onTimeout;
19
+ this.timeoutMs = timeoutMs;
20
+ }
21
+ /**
22
+ * Resets the current timeout, restarting it with the same duration.
23
+ * Does nothing if no timeout is active.
24
+ */
25
+ reset() {
26
+ if (!this.timeout) return;
27
+ clearTimeout(this.timeout);
28
+ this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
29
+ }
30
+ start() {
31
+ clearTimeout(this.timeout);
32
+ this.timeout = setTimeout(this.onTimeout, this.timeoutMs);
33
+ }
34
+ stop() {
35
+ clearTimeout(this.timeout);
36
+ this.timeout = void 0;
37
+ }
38
+ };
54
39
  function withResolvers() {
55
- let resolve;
56
- let reject;
57
- const promise = new Promise((res, rej)=>{
58
- resolve = res;
59
- reject = rej;
60
- });
61
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
- return {
63
- promise,
64
- resolve: resolve,
65
- reject: reject
66
- };
40
+ let resolve;
41
+ let reject;
42
+ const promise = new Promise((res, rej) => {
43
+ resolve = res;
44
+ reject = rej;
45
+ });
46
+ return {
47
+ promise,
48
+ resolve,
49
+ reject
50
+ };
67
51
  }
68
52
  /**
69
- * Resolves a WebSocket URL and optionally appends connection parameters.
70
- *
71
- * If connectionParams are provided, appends 'connectionParams=1' query parameter.
72
- */ async function prepareUrl(urlOptions) {
73
- const url = await resultOf(urlOptions.url);
74
- if (!urlOptions.connectionParams) return url;
75
- // append `?connectionParams=1` when connection params are used
76
- const prefix = url.includes('?') ? '&' : '?';
77
- const connectionParams = `${prefix}connectionParams=1`;
78
- return url + connectionParams;
53
+ * Resolves a WebSocket URL and optionally appends connection parameters.
54
+ *
55
+ * If connectionParams are provided, appends 'connectionParams=1' query parameter.
56
+ */
57
+ async function prepareUrl(urlOptions) {
58
+ const url = await resultOf(urlOptions.url);
59
+ if (!urlOptions.connectionParams) return url;
60
+ const prefix = url.includes("?") ? "&" : "?";
61
+ const connectionParams = `${prefix}connectionParams=1`;
62
+ return url + connectionParams;
79
63
  }
80
64
  async function buildConnectionMessage(connectionParams) {
81
- const message = {
82
- method: 'connectionParams',
83
- data: await resultOf(connectionParams)
84
- };
85
- return JSON.stringify(message);
65
+ const message = {
66
+ method: "connectionParams",
67
+ data: await resultOf(connectionParams)
68
+ };
69
+ return JSON.stringify(message);
86
70
  }
87
71
 
72
+ //#endregion
88
73
  export { ResettableTimeout, TRPCWebSocketClosedError, buildConnectionMessage, prepareUrl, withResolvers };
74
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":["opts: { message: string; cause?: unknown }","onTimeout: () => void","timeoutMs: number","resolve: (value: T | PromiseLike<T>) => void","reject: (reason?: any) => void","urlOptions: UrlOptionsWithConnectionParams","connectionParams: CallbackOrValue<TRPCRequestInfo['connectionParams']>","message: TRPCConnectionParamsMessage"],"sources":["../../../../src/links/wsLink/wsClient/utils.ts"],"sourcesContent":["import type {\n TRPCConnectionParamsMessage,\n TRPCRequestInfo,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n CallbackOrValue,\n UrlOptionsWithConnectionParams,\n} from '../../internals/urlWithConnectionParams';\nimport { resultOf } from '../../internals/urlWithConnectionParams';\n\nexport class TRPCWebSocketClosedError extends Error {\n constructor(opts: { message: string; cause?: unknown }) {\n super(opts.message, {\n cause: opts.cause,\n });\n this.name = 'TRPCWebSocketClosedError';\n Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype);\n }\n}\n\n/**\n * Utility class for managing a timeout that can be started, stopped, and reset.\n * Useful for scenarios where the timeout duration is reset dynamically based on events.\n */\nexport class ResettableTimeout {\n private timeout: ReturnType<typeof setTimeout> | undefined;\n\n constructor(\n private readonly onTimeout: () => void,\n private readonly timeoutMs: number,\n ) {}\n\n /**\n * Resets the current timeout, restarting it with the same duration.\n * Does nothing if no timeout is active.\n */\n public reset() {\n if (!this.timeout) return;\n\n clearTimeout(this.timeout);\n this.timeout = setTimeout(this.onTimeout, this.timeoutMs);\n }\n\n public start() {\n clearTimeout(this.timeout);\n this.timeout = setTimeout(this.onTimeout, this.timeoutMs);\n }\n\n public stop() {\n clearTimeout(this.timeout);\n this.timeout = undefined;\n }\n}\n\n// Ponyfill for Promise.withResolvers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers\nexport function withResolvers<T>() {\n let resolve: (value: T | PromiseLike<T>) => void;\n let reject: (reason?: any) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return { promise, resolve: resolve!, reject: reject! };\n}\n\n/**\n * Resolves a WebSocket URL and optionally appends connection parameters.\n *\n * If connectionParams are provided, appends 'connectionParams=1' query parameter.\n */\nexport async function prepareUrl(urlOptions: UrlOptionsWithConnectionParams) {\n const url = await resultOf(urlOptions.url);\n\n if (!urlOptions.connectionParams) return url;\n\n // append `?connectionParams=1` when connection params are used\n const prefix = url.includes('?') ? '&' : '?';\n const connectionParams = `${prefix}connectionParams=1`;\n\n return url + connectionParams;\n}\n\nexport async function buildConnectionMessage(\n connectionParams: CallbackOrValue<TRPCRequestInfo['connectionParams']>,\n) {\n const message: TRPCConnectionParamsMessage = {\n method: 'connectionParams',\n data: await resultOf(connectionParams),\n };\n\n return JSON.stringify(message);\n}\n"],"mappings":";;;AAUA,IAAa,2BAAb,MAAa,iCAAiC,MAAM;CAClD,YAAYA,MAA4C;AACtD,QAAM,KAAK,SAAS,EAClB,OAAO,KAAK,MACb,EAAC;AACF,OAAK,OAAO;AACZ,SAAO,eAAe,MAAM,yBAAyB,UAAU;CAChE;AACF;;;;;AAMD,IAAa,oBAAb,MAA+B;CAC7B,AAAQ;CAER,YACmBC,WACAC,WACjB;EAFiB;EACA;CACf;;;;;CAMJ,AAAO,QAAQ;AACb,OAAK,KAAK,QAAS;AAEnB,eAAa,KAAK,QAAQ;AAC1B,OAAK,UAAU,WAAW,KAAK,WAAW,KAAK,UAAU;CAC1D;CAED,AAAO,QAAQ;AACb,eAAa,KAAK,QAAQ;AAC1B,OAAK,UAAU,WAAW,KAAK,WAAW,KAAK,UAAU;CAC1D;CAED,AAAO,OAAO;AACZ,eAAa,KAAK,QAAQ;AAC1B,OAAK;CACN;AACF;AAGD,SAAgB,gBAAmB;CACjC,IAAIC;CACJ,IAAIC;CACJ,MAAM,UAAU,IAAI,QAAW,CAAC,KAAK,QAAQ;AAC3C,YAAU;AACV,WAAS;CACV;AAGD,QAAO;EAAE;EAAkB;EAAkB;CAAS;AACvD;;;;;;AAOD,eAAsB,WAAWC,YAA4C;CAC3E,MAAM,MAAM,MAAM,SAAS,WAAW,IAAI;AAE1C,MAAK,WAAW,iBAAkB,QAAO;CAGzC,MAAM,SAAS,IAAI,SAAS,IAAI,GAAG,MAAM;CACzC,MAAM,oBAAoB,EAAE,OAAO;AAEnC,QAAO,MAAM;AACd;AAED,eAAsB,uBACpBC,kBACA;CACA,MAAMC,UAAuC;EAC3C,QAAQ;EACR,MAAM,MAAM,SAAS,iBAAiB;CACvC;AAED,QAAO,KAAK,UAAU,QAAQ;AAC/B"}