@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
@@ -0,0 +1,69 @@
1
+ import { UrlOptionsWithConnectionParams } from "../../internals/urlWithConnectionParams.mjs";
2
+
3
+ //#region src/links/wsLink/wsClient/options.d.ts
4
+ interface WebSocketClientOptions extends UrlOptionsWithConnectionParams {
5
+ /**
6
+ * Ponyfill which WebSocket implementation to use
7
+ */
8
+ WebSocket?: typeof WebSocket;
9
+ /**
10
+ * The number of milliseconds before a reconnect is attempted.
11
+ * @default {@link exponentialBackoff}
12
+ */
13
+ retryDelayMs?: (attemptIndex: number) => number;
14
+ /**
15
+ * Triggered when a WebSocket connection is established
16
+ */
17
+ onOpen?: () => void;
18
+ /**
19
+ * Triggered when a WebSocket connection encounters an error
20
+ */
21
+ onError?: (evt?: Event) => void;
22
+ /**
23
+ * Triggered when a WebSocket connection is closed
24
+ */
25
+ onClose?: (cause?: {
26
+ code?: number;
27
+ }) => void;
28
+ /**
29
+ * Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)
30
+ */
31
+ lazy?: {
32
+ /**
33
+ * Enable lazy mode
34
+ * @default false
35
+ */
36
+ enabled: boolean;
37
+ /**
38
+ * Close the WebSocket after this many milliseconds
39
+ * @default 0
40
+ */
41
+ closeMs: number;
42
+ };
43
+ /**
44
+ * Send ping messages to the server and kill the connection if no pong message is returned
45
+ */
46
+ keepAlive?: {
47
+ /**
48
+ * @default false
49
+ */
50
+ enabled: boolean;
51
+ /**
52
+ * Send a ping message every this many milliseconds
53
+ * @default 5_000
54
+ */
55
+ intervalMs?: number;
56
+ /**
57
+ * Close the WebSocket after this many milliseconds if the server does not respond
58
+ * @default 1_000
59
+ */
60
+ pongTimeoutMs?: number;
61
+ };
62
+ } //#endregion
63
+
64
+ /**
65
+ * Default options for lazy WebSocket connections.
66
+ * Determines whether the connection should be established lazily and defines the delay before closure.
67
+ */
68
+ export { WebSocketClientOptions };
69
+ //# sourceMappingURL=options.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.mts","names":[],"sources":["../../../../src/links/wsLink/wsClient/options.ts"],"sourcesContent":[],"mappings":";;;UAEiB,sBAAA,SAA+B;;AAAhD;;EAAwC,SAInB,CAAA,EAAA,OAAA,SAAA;EAAS;;AAJgD;;;;;;;;;;mBAiB3D"}
@@ -1,79 +1,69 @@
1
- import type { UrlOptionsWithConnectionParams } from '../../internals/urlWithConnectionParams';
2
- export interface WebSocketClientOptions extends UrlOptionsWithConnectionParams {
1
+ import { UrlOptionsWithConnectionParams } from "../../internals/urlWithConnectionParams.js";
2
+
3
+ //#region src/links/wsLink/wsClient/options.d.ts
4
+ interface WebSocketClientOptions extends UrlOptionsWithConnectionParams {
5
+ /**
6
+ * Ponyfill which WebSocket implementation to use
7
+ */
8
+ WebSocket?: typeof WebSocket;
9
+ /**
10
+ * The number of milliseconds before a reconnect is attempted.
11
+ * @default {@link exponentialBackoff}
12
+ */
13
+ retryDelayMs?: (attemptIndex: number) => number;
14
+ /**
15
+ * Triggered when a WebSocket connection is established
16
+ */
17
+ onOpen?: () => void;
18
+ /**
19
+ * Triggered when a WebSocket connection encounters an error
20
+ */
21
+ onError?: (evt?: Event) => void;
22
+ /**
23
+ * Triggered when a WebSocket connection is closed
24
+ */
25
+ onClose?: (cause?: {
26
+ code?: number;
27
+ }) => void;
28
+ /**
29
+ * Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)
30
+ */
31
+ lazy?: {
3
32
  /**
4
- * Ponyfill which WebSocket implementation to use
33
+ * Enable lazy mode
34
+ * @default false
5
35
  */
6
- WebSocket?: typeof WebSocket;
36
+ enabled: boolean;
7
37
  /**
8
- * The number of milliseconds before a reconnect is attempted.
9
- * @default {@link exponentialBackoff}
38
+ * Close the WebSocket after this many milliseconds
39
+ * @default 0
10
40
  */
11
- retryDelayMs?: (attemptIndex: number) => number;
41
+ closeMs: number;
42
+ };
43
+ /**
44
+ * Send ping messages to the server and kill the connection if no pong message is returned
45
+ */
46
+ keepAlive?: {
12
47
  /**
13
- * Triggered when a WebSocket connection is established
48
+ * @default false
14
49
  */
15
- onOpen?: () => void;
50
+ enabled: boolean;
16
51
  /**
17
- * Triggered when a WebSocket connection encounters an error
52
+ * Send a ping message every this many milliseconds
53
+ * @default 5_000
18
54
  */
19
- onError?: (evt?: Event) => void;
55
+ intervalMs?: number;
20
56
  /**
21
- * Triggered when a WebSocket connection is closed
57
+ * Close the WebSocket after this many milliseconds if the server does not respond
58
+ * @default 1_000
22
59
  */
23
- onClose?: (cause?: {
24
- code?: number;
25
- }) => void;
26
- /**
27
- * Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)
28
- */
29
- lazy?: {
30
- /**
31
- * Enable lazy mode
32
- * @default false
33
- */
34
- enabled: boolean;
35
- /**
36
- * Close the WebSocket after this many milliseconds
37
- * @default 0
38
- */
39
- closeMs: number;
40
- };
41
- /**
42
- * Send ping messages to the server and kill the connection if no pong message is returned
43
- */
44
- keepAlive?: {
45
- /**
46
- * @default false
47
- */
48
- enabled: boolean;
49
- /**
50
- * Send a ping message every this many milliseconds
51
- * @default 5_000
52
- */
53
- intervalMs?: number;
54
- /**
55
- * Close the WebSocket after this many milliseconds if the server does not respond
56
- * @default 1_000
57
- */
58
- pongTimeoutMs?: number;
59
- };
60
- }
60
+ pongTimeoutMs?: number;
61
+ };
62
+ } //#endregion
63
+
61
64
  /**
62
65
  * Default options for lazy WebSocket connections.
63
66
  * Determines whether the connection should be established lazily and defines the delay before closure.
64
67
  */
65
- export type LazyOptions = Required<NonNullable<WebSocketClientOptions['lazy']>>;
66
- export declare const lazyDefaults: LazyOptions;
67
- /**
68
- * Default options for the WebSocket keep-alive mechanism.
69
- * Configures whether keep-alive is enabled and specifies the timeout and interval for ping-pong messages.
70
- */
71
- export type KeepAliveOptions = Required<NonNullable<WebSocketClientOptions['keepAlive']>>;
72
- export declare const keepAliveDefaults: KeepAliveOptions;
73
- /**
74
- * Calculates a delay for exponential backoff based on the retry attempt index.
75
- * The delay starts at 0 for the first attempt and doubles for each subsequent attempt,
76
- * capped at 30 seconds.
77
- */
78
- export declare const exponentialBackoff: (attemptIndex: number) => number;
68
+ export { WebSocketClientOptions };
79
69
  //# sourceMappingURL=options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../src/links/wsLink/wsClient/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAE9F,MAAM,WAAW,sBAAuB,SAAQ,8BAA8B;IAC5E;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC9C;;OAEG;IACH,IAAI,CAAC,EAAE;QACL;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF;;OAEG;IACH,SAAS,CAAC,EAAE;QACV;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAChF,eAAO,MAAM,YAAY,EAAE,WAG1B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACrC,WAAW,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CACjD,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,gBAI/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,cAAc,MAAM,WAEtD,CAAC"}
1
+ {"version":3,"file":"options.d.ts","names":[],"sources":["../../../../src/links/wsLink/wsClient/options.ts"],"sourcesContent":[],"mappings":";;;UAEiB,sBAAA,SAA+B;;AAAhD;;EAAwC,SAInB,CAAA,EAAA,OAAA,SAAA;EAAS;;AAJgD;;;;;;;;;;mBAiB3D"}
@@ -1,22 +1,24 @@
1
- 'use strict';
2
1
 
2
+ //#region src/links/wsLink/wsClient/options.ts
3
3
  const lazyDefaults = {
4
- enabled: false,
5
- closeMs: 0
4
+ enabled: false,
5
+ closeMs: 0
6
6
  };
7
7
  const keepAliveDefaults = {
8
- enabled: false,
9
- pongTimeoutMs: 1000,
10
- intervalMs: 5000
8
+ enabled: false,
9
+ pongTimeoutMs: 1e3,
10
+ intervalMs: 5e3
11
11
  };
12
12
  /**
13
- * Calculates a delay for exponential backoff based on the retry attempt index.
14
- * The delay starts at 0 for the first attempt and doubles for each subsequent attempt,
15
- * capped at 30 seconds.
16
- */ const exponentialBackoff = (attemptIndex)=>{
17
- return attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
13
+ * Calculates a delay for exponential backoff based on the retry attempt index.
14
+ * The delay starts at 0 for the first attempt and doubles for each subsequent attempt,
15
+ * capped at 30 seconds.
16
+ */
17
+ const exponentialBackoff = (attemptIndex) => {
18
+ return attemptIndex === 0 ? 0 : Math.min(1e3 * 2 ** attemptIndex, 3e4);
18
19
  };
19
20
 
21
+ //#endregion
20
22
  exports.exponentialBackoff = exponentialBackoff;
21
23
  exports.keepAliveDefaults = keepAliveDefaults;
22
- exports.lazyDefaults = lazyDefaults;
24
+ exports.lazyDefaults = lazyDefaults;
@@ -1,18 +1,22 @@
1
+ //#region src/links/wsLink/wsClient/options.ts
1
2
  const lazyDefaults = {
2
- enabled: false,
3
- closeMs: 0
3
+ enabled: false,
4
+ closeMs: 0
4
5
  };
5
6
  const keepAliveDefaults = {
6
- enabled: false,
7
- pongTimeoutMs: 1000,
8
- intervalMs: 5000
7
+ enabled: false,
8
+ pongTimeoutMs: 1e3,
9
+ intervalMs: 5e3
9
10
  };
10
11
  /**
11
- * Calculates a delay for exponential backoff based on the retry attempt index.
12
- * The delay starts at 0 for the first attempt and doubles for each subsequent attempt,
13
- * capped at 30 seconds.
14
- */ const exponentialBackoff = (attemptIndex)=>{
15
- return attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);
12
+ * Calculates a delay for exponential backoff based on the retry attempt index.
13
+ * The delay starts at 0 for the first attempt and doubles for each subsequent attempt,
14
+ * capped at 30 seconds.
15
+ */
16
+ const exponentialBackoff = (attemptIndex) => {
17
+ return attemptIndex === 0 ? 0 : Math.min(1e3 * 2 ** attemptIndex, 3e4);
16
18
  };
17
19
 
20
+ //#endregion
18
21
  export { exponentialBackoff, keepAliveDefaults, lazyDefaults };
22
+ //# sourceMappingURL=options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.mjs","names":["lazyDefaults: LazyOptions","keepAliveDefaults: KeepAliveOptions","attemptIndex: number"],"sources":["../../../../src/links/wsLink/wsClient/options.ts"],"sourcesContent":["import type { UrlOptionsWithConnectionParams } from '../../internals/urlWithConnectionParams';\n\nexport interface WebSocketClientOptions extends UrlOptionsWithConnectionParams {\n /**\n * Ponyfill which WebSocket implementation to use\n */\n WebSocket?: typeof WebSocket;\n /**\n * The number of milliseconds before a reconnect is attempted.\n * @default {@link exponentialBackoff}\n */\n retryDelayMs?: (attemptIndex: number) => number;\n /**\n * Triggered when a WebSocket connection is established\n */\n onOpen?: () => void;\n /**\n * Triggered when a WebSocket connection encounters an error\n */\n onError?: (evt?: Event) => void;\n /**\n * Triggered when a WebSocket connection is closed\n */\n onClose?: (cause?: { code?: number }) => void;\n /**\n * Lazy mode will close the WebSocket automatically after a period of inactivity (no messages sent or received and no pending requests)\n */\n lazy?: {\n /**\n * Enable lazy mode\n * @default false\n */\n enabled: boolean;\n /**\n * Close the WebSocket after this many milliseconds\n * @default 0\n */\n closeMs: number;\n };\n /**\n * Send ping messages to the server and kill the connection if no pong message is returned\n */\n keepAlive?: {\n /**\n * @default false\n */\n enabled: boolean;\n /**\n * Send a ping message every this many milliseconds\n * @default 5_000\n */\n intervalMs?: number;\n /**\n * Close the WebSocket after this many milliseconds if the server does not respond\n * @default 1_000\n */\n pongTimeoutMs?: number;\n };\n}\n\n/**\n * Default options for lazy WebSocket connections.\n * Determines whether the connection should be established lazily and defines the delay before closure.\n */\nexport type LazyOptions = Required<NonNullable<WebSocketClientOptions['lazy']>>;\nexport const lazyDefaults: LazyOptions = {\n enabled: false,\n closeMs: 0,\n};\n\n/**\n * Default options for the WebSocket keep-alive mechanism.\n * Configures whether keep-alive is enabled and specifies the timeout and interval for ping-pong messages.\n */\nexport type KeepAliveOptions = Required<\n NonNullable<WebSocketClientOptions['keepAlive']>\n>;\nexport const keepAliveDefaults: KeepAliveOptions = {\n enabled: false,\n pongTimeoutMs: 1_000,\n intervalMs: 5_000,\n};\n\n/**\n * Calculates a delay for exponential backoff based on the retry attempt index.\n * The delay starts at 0 for the first attempt and doubles for each subsequent attempt,\n * capped at 30 seconds.\n */\nexport const exponentialBackoff = (attemptIndex: number) => {\n return attemptIndex === 0 ? 0 : Math.min(1000 * 2 ** attemptIndex, 30000);\n};\n"],"mappings":";AAiEA,MAAaA,eAA4B;CACvC,SAAS;CACT,SAAS;AACV;AASD,MAAaC,oBAAsC;CACjD,SAAS;CACT,eAAe;CACf,YAAY;AACb;;;;;;AAOD,MAAa,qBAAqB,CAACC,iBAAyB;AAC1D,QAAO,iBAAiB,IAAI,IAAI,KAAK,IAAI,MAAO,KAAK,cAAc,IAAM;AAC1E"}
@@ -1,138 +1,136 @@
1
- 'use strict';
1
+ const require__Users_julius_dev_trpc_packages_client_src_links_wsLink_wsClient_utils = require('./utils.js');
2
2
 
3
- var utils = require('./utils.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
- }
3
+ //#region src/links/wsLink/wsClient/requestManager.ts
18
4
  /**
19
- * Manages WebSocket requests, tracking their lifecycle and providing utility methods
20
- * for handling outgoing and pending requests.
21
- *
22
- * - **Outgoing requests**: Requests that are queued and waiting to be sent.
23
- * - **Pending requests**: Requests that have been sent and are in flight awaiting a response.
24
- * For subscriptions, multiple responses may be received until the subscription is closed.
25
- */ class RequestManager {
26
- /**
27
- * Registers a new request by adding it to the outgoing queue and setting up
28
- * callbacks for lifecycle events such as completion or error.
29
- *
30
- * @param message - The outgoing message to be sent.
31
- * @param callbacks - Callback functions to observe the request's state.
32
- * @returns A cleanup function to manually remove the request.
33
- */ register(message, callbacks) {
34
- const { promise: end, resolve } = utils.withResolvers();
35
- this.outgoingRequests.push({
36
- id: String(message.id),
37
- message,
38
- end,
39
- callbacks: {
40
- next: callbacks.next,
41
- complete: ()=>{
42
- callbacks.complete();
43
- resolve();
44
- },
45
- error: (e)=>{
46
- callbacks.error(e);
47
- resolve();
48
- }
49
- }
50
- });
51
- return ()=>{
52
- this.delete(message.id);
53
- callbacks.complete();
54
- resolve();
55
- };
56
- }
57
- /**
58
- * Deletes a request from both the outgoing and pending collections, if it exists.
59
- */ delete(messageId) {
60
- if (messageId === null) return;
61
- this.outgoingRequests = this.outgoingRequests.filter(({ id })=>id !== String(messageId));
62
- delete this.pendingRequests[String(messageId)];
63
- }
64
- /**
65
- * Moves all outgoing requests to the pending state and clears the outgoing queue.
66
- *
67
- * The caller is expected to handle the actual sending of the requests
68
- * (e.g., sending them over the network) after this method is called.
69
- *
70
- * @returns The list of requests that were transitioned to the pending state.
71
- */ flush() {
72
- const requests = this.outgoingRequests;
73
- this.outgoingRequests = [];
74
- for (const request of requests){
75
- this.pendingRequests[request.id] = request;
76
- }
77
- return requests;
78
- }
79
- /**
80
- * Retrieves all currently pending requests, which are in flight awaiting responses
81
- * or handling ongoing subscriptions.
82
- */ getPendingRequests() {
83
- return Object.values(this.pendingRequests);
84
- }
85
- /**
86
- * Retrieves a specific pending request by its message ID.
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
- */ getOutgoingRequests() {
94
- return this.outgoingRequests;
95
- }
96
- /**
97
- * Retrieves all requests, both outgoing and pending, with their respective states.
98
- *
99
- * @returns An array of all requests with their state ("outgoing" or "pending").
100
- */ getRequests() {
101
- return [
102
- ...this.getOutgoingRequests().map((request)=>({
103
- state: 'outgoing',
104
- message: request.message,
105
- end: request.end,
106
- callbacks: request.callbacks
107
- })),
108
- ...this.getPendingRequests().map((request)=>({
109
- state: 'pending',
110
- message: request.message,
111
- end: request.end,
112
- callbacks: request.callbacks
113
- }))
114
- ];
115
- }
116
- /**
117
- * Checks if there are any pending requests, including ongoing subscriptions.
118
- */ hasPendingRequests() {
119
- return this.getPendingRequests().length > 0;
120
- }
121
- /**
122
- * Checks if there are any outgoing requests waiting to be sent.
123
- */ hasOutgoingRequests() {
124
- return this.outgoingRequests.length > 0;
125
- }
126
- constructor(){
127
- /**
128
- * Stores requests that are outgoing, meaning they are registered but not yet sent over the WebSocket.
129
- */ _define_property(this, "outgoingRequests", new Array());
130
- /**
131
- * Stores requests that are pending (in flight), meaning they have been sent over the WebSocket
132
- * and are awaiting responses. For subscriptions, this includes requests
133
- * that may receive multiple responses.
134
- */ _define_property(this, "pendingRequests", {});
135
- }
136
- }
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 } = require__Users_julius_dev_trpc_packages_client_src_links_wsLink_wsClient_utils.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
+ };
137
134
 
138
- exports.RequestManager = RequestManager;
135
+ //#endregion
136
+ exports.RequestManager = RequestManager;