websocket-ts 2.2.1 → 3.0.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 (196) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +201 -63
  3. package/dist/cjs/{src/backoff → backoff}/backoff.d.ts +6 -3
  4. package/dist/{esm/src → cjs}/backoff/backoff.d.ts.map +1 -1
  5. package/dist/{esm/src → cjs}/backoff/backoff.js.map +1 -1
  6. package/dist/cjs/{src/backoff → backoff}/constantbackoff.d.ts +2 -2
  7. package/dist/cjs/backoff/constantbackoff.d.ts.map +1 -0
  8. package/dist/cjs/backoff/constantbackoff.js +34 -0
  9. package/dist/cjs/backoff/constantbackoff.js.map +1 -0
  10. package/dist/{esm/src → cjs}/backoff/exponentialbackoff.d.ts +2 -2
  11. package/dist/cjs/backoff/exponentialbackoff.d.ts.map +1 -0
  12. package/dist/cjs/{src/backoff → backoff}/exponentialbackoff.js +19 -27
  13. package/dist/cjs/backoff/exponentialbackoff.js.map +1 -0
  14. package/dist/{esm/src → cjs}/backoff/linearbackoff.d.ts +1 -1
  15. package/dist/cjs/backoff/linearbackoff.d.ts.map +1 -0
  16. package/dist/cjs/{src/backoff → backoff}/linearbackoff.js +23 -31
  17. package/dist/cjs/backoff/linearbackoff.js.map +1 -0
  18. package/dist/cjs/index.d.ts +14 -0
  19. package/dist/cjs/index.d.ts.map +1 -0
  20. package/dist/cjs/index.js +20 -0
  21. package/dist/cjs/index.js.map +1 -0
  22. package/dist/cjs/package.json +1 -0
  23. package/dist/{esm/src → cjs}/queue/array_queue.d.ts +1 -1
  24. package/dist/cjs/queue/array_queue.d.ts.map +1 -0
  25. package/dist/cjs/{src/queue → queue}/array_queue.js +17 -18
  26. package/dist/cjs/queue/array_queue.js.map +1 -0
  27. package/dist/cjs/queue/queue.d.ts.map +1 -0
  28. package/dist/cjs/{src/queue → queue}/queue.js.map +1 -1
  29. package/dist/cjs/{src/queue → queue}/ring_queue.d.ts +1 -1
  30. package/dist/cjs/queue/ring_queue.d.ts.map +1 -0
  31. package/dist/cjs/{src/queue → queue}/ring_queue.js +25 -22
  32. package/dist/cjs/queue/ring_queue.js.map +1 -0
  33. package/dist/cjs/{src/websocket.d.ts → websocket.d.ts} +84 -20
  34. package/dist/cjs/websocket.d.ts.map +1 -0
  35. package/dist/cjs/websocket.js +588 -0
  36. package/dist/cjs/websocket.js.map +1 -0
  37. package/dist/cjs/{src/websocket_buffer.d.ts → websocket_buffer.d.ts} +1 -1
  38. package/dist/cjs/websocket_buffer.d.ts.map +1 -0
  39. package/dist/cjs/websocket_buffer.js.map +1 -0
  40. package/dist/{esm/src → cjs}/websocket_builder.d.ts +22 -13
  41. package/dist/cjs/websocket_builder.d.ts.map +1 -0
  42. package/dist/cjs/websocket_builder.js +236 -0
  43. package/dist/cjs/websocket_builder.js.map +1 -0
  44. package/dist/cjs/websocket_event.d.ts +93 -0
  45. package/dist/cjs/websocket_event.d.ts.map +1 -0
  46. package/dist/cjs/websocket_event.js +27 -0
  47. package/dist/cjs/websocket_event.js.map +1 -0
  48. package/dist/{esm/src → cjs}/websocket_options.d.ts +6 -5
  49. package/dist/cjs/websocket_options.d.ts.map +1 -0
  50. package/dist/cjs/websocket_options.js.map +1 -0
  51. package/dist/{esm/src → cjs}/websocket_retry_options.d.ts +4 -3
  52. package/dist/cjs/websocket_retry_options.d.ts.map +1 -0
  53. package/dist/cjs/websocket_retry_options.js.map +1 -0
  54. package/dist/esm/{src/backoff → backoff}/backoff.d.ts +6 -3
  55. package/dist/{cjs/src → esm}/backoff/backoff.d.ts.map +1 -1
  56. package/dist/{cjs/src → esm}/backoff/backoff.js.map +1 -1
  57. package/dist/esm/{src/backoff → backoff}/constantbackoff.d.ts +2 -2
  58. package/dist/esm/backoff/constantbackoff.d.ts.map +1 -0
  59. package/dist/esm/{src/backoff → backoff}/constantbackoff.js +3 -3
  60. package/dist/esm/backoff/constantbackoff.js.map +1 -0
  61. package/dist/{cjs/src → esm}/backoff/exponentialbackoff.d.ts +2 -2
  62. package/dist/esm/backoff/exponentialbackoff.d.ts.map +1 -0
  63. package/dist/esm/{src/backoff → backoff}/exponentialbackoff.js +6 -5
  64. package/dist/esm/backoff/exponentialbackoff.js.map +1 -0
  65. package/dist/{cjs/src → esm}/backoff/linearbackoff.d.ts +1 -1
  66. package/dist/esm/backoff/linearbackoff.d.ts.map +1 -0
  67. package/dist/esm/{src/backoff → backoff}/linearbackoff.js +8 -7
  68. package/dist/esm/backoff/linearbackoff.js.map +1 -0
  69. package/dist/esm/index.d.ts +14 -0
  70. package/dist/esm/index.d.ts.map +1 -0
  71. package/dist/esm/index.js +9 -0
  72. package/dist/esm/index.js.map +1 -0
  73. package/dist/esm/package.json +1 -0
  74. package/dist/{cjs/src → esm}/queue/array_queue.d.ts +1 -1
  75. package/dist/esm/queue/array_queue.d.ts.map +1 -0
  76. package/dist/esm/queue/array_queue.js.map +1 -0
  77. package/dist/esm/queue/queue.d.ts.map +1 -0
  78. package/dist/esm/{src/queue → queue}/queue.js.map +1 -1
  79. package/dist/esm/{src/queue → queue}/ring_queue.d.ts +1 -1
  80. package/dist/esm/queue/ring_queue.d.ts.map +1 -0
  81. package/dist/esm/{src/queue → queue}/ring_queue.js +7 -3
  82. package/dist/esm/queue/ring_queue.js.map +1 -0
  83. package/dist/esm/{src/websocket.d.ts → websocket.d.ts} +84 -20
  84. package/dist/esm/websocket.d.ts.map +1 -0
  85. package/dist/esm/websocket.js +584 -0
  86. package/dist/esm/websocket.js.map +1 -0
  87. package/dist/esm/{src/websocket_buffer.d.ts → websocket_buffer.d.ts} +1 -1
  88. package/dist/esm/websocket_buffer.d.ts.map +1 -0
  89. package/dist/esm/websocket_buffer.js.map +1 -0
  90. package/dist/{cjs/src → esm}/websocket_builder.d.ts +22 -13
  91. package/dist/esm/websocket_builder.d.ts.map +1 -0
  92. package/dist/esm/{src/websocket_builder.js → websocket_builder.js} +42 -23
  93. package/dist/esm/websocket_builder.js.map +1 -0
  94. package/dist/esm/websocket_event.d.ts +93 -0
  95. package/dist/esm/websocket_event.d.ts.map +1 -0
  96. package/dist/esm/websocket_event.js +24 -0
  97. package/dist/esm/websocket_event.js.map +1 -0
  98. package/dist/{cjs/src → esm}/websocket_options.d.ts +6 -5
  99. package/dist/esm/websocket_options.d.ts.map +1 -0
  100. package/dist/esm/websocket_options.js.map +1 -0
  101. package/dist/{cjs/src → esm}/websocket_retry_options.d.ts +4 -3
  102. package/dist/esm/websocket_retry_options.d.ts.map +1 -0
  103. package/dist/esm/websocket_retry_options.js.map +1 -0
  104. package/package.json +44 -25
  105. package/src/backoff/backoff.ts +6 -3
  106. package/src/backoff/constantbackoff.ts +4 -4
  107. package/src/backoff/exponentialbackoff.ts +7 -6
  108. package/src/backoff/linearbackoff.ts +9 -8
  109. package/src/index.ts +14 -13
  110. package/src/queue/array_queue.ts +1 -1
  111. package/src/queue/ring_queue.ts +12 -8
  112. package/src/websocket.ts +343 -78
  113. package/src/websocket_buffer.ts +1 -3
  114. package/src/websocket_builder.ts +33 -22
  115. package/src/websocket_event.ts +47 -13
  116. package/src/websocket_options.ts +6 -5
  117. package/src/websocket_retry_options.ts +4 -3
  118. package/dist/cjs/src/backoff/constantbackoff.d.ts.map +0 -1
  119. package/dist/cjs/src/backoff/constantbackoff.js +0 -43
  120. package/dist/cjs/src/backoff/constantbackoff.js.map +0 -1
  121. package/dist/cjs/src/backoff/exponentialbackoff.d.ts.map +0 -1
  122. package/dist/cjs/src/backoff/exponentialbackoff.js.map +0 -1
  123. package/dist/cjs/src/backoff/linearbackoff.d.ts.map +0 -1
  124. package/dist/cjs/src/backoff/linearbackoff.js.map +0 -1
  125. package/dist/cjs/src/index.d.ts +0 -14
  126. package/dist/cjs/src/index.d.ts.map +0 -1
  127. package/dist/cjs/src/index.js +0 -20
  128. package/dist/cjs/src/index.js.map +0 -1
  129. package/dist/cjs/src/queue/array_queue.d.ts.map +0 -1
  130. package/dist/cjs/src/queue/array_queue.js.map +0 -1
  131. package/dist/cjs/src/queue/queue.d.ts.map +0 -1
  132. package/dist/cjs/src/queue/ring_queue.d.ts.map +0 -1
  133. package/dist/cjs/src/queue/ring_queue.js.map +0 -1
  134. package/dist/cjs/src/websocket.d.ts.map +0 -1
  135. package/dist/cjs/src/websocket.js +0 -435
  136. package/dist/cjs/src/websocket.js.map +0 -1
  137. package/dist/cjs/src/websocket_buffer.d.ts.map +0 -1
  138. package/dist/cjs/src/websocket_buffer.js.map +0 -1
  139. package/dist/cjs/src/websocket_builder.d.ts.map +0 -1
  140. package/dist/cjs/src/websocket_builder.js +0 -263
  141. package/dist/cjs/src/websocket_builder.js.map +0 -1
  142. package/dist/cjs/src/websocket_event.d.ts +0 -67
  143. package/dist/cjs/src/websocket_event.d.ts.map +0 -1
  144. package/dist/cjs/src/websocket_event.js +0 -22
  145. package/dist/cjs/src/websocket_event.js.map +0 -1
  146. package/dist/cjs/src/websocket_options.d.ts.map +0 -1
  147. package/dist/cjs/src/websocket_options.js.map +0 -1
  148. package/dist/cjs/src/websocket_retry_options.d.ts.map +0 -1
  149. package/dist/cjs/src/websocket_retry_options.js.map +0 -1
  150. package/dist/esm/src/backoff/constantbackoff.d.ts.map +0 -1
  151. package/dist/esm/src/backoff/constantbackoff.js.map +0 -1
  152. package/dist/esm/src/backoff/exponentialbackoff.d.ts.map +0 -1
  153. package/dist/esm/src/backoff/exponentialbackoff.js.map +0 -1
  154. package/dist/esm/src/backoff/linearbackoff.d.ts.map +0 -1
  155. package/dist/esm/src/backoff/linearbackoff.js.map +0 -1
  156. package/dist/esm/src/index.d.ts +0 -14
  157. package/dist/esm/src/index.d.ts.map +0 -1
  158. package/dist/esm/src/index.js +0 -9
  159. package/dist/esm/src/index.js.map +0 -1
  160. package/dist/esm/src/queue/array_queue.d.ts.map +0 -1
  161. package/dist/esm/src/queue/array_queue.js.map +0 -1
  162. package/dist/esm/src/queue/queue.d.ts.map +0 -1
  163. package/dist/esm/src/queue/ring_queue.d.ts.map +0 -1
  164. package/dist/esm/src/queue/ring_queue.js.map +0 -1
  165. package/dist/esm/src/websocket.d.ts.map +0 -1
  166. package/dist/esm/src/websocket.js +0 -357
  167. package/dist/esm/src/websocket.js.map +0 -1
  168. package/dist/esm/src/websocket_buffer.d.ts.map +0 -1
  169. package/dist/esm/src/websocket_buffer.js.map +0 -1
  170. package/dist/esm/src/websocket_builder.d.ts.map +0 -1
  171. package/dist/esm/src/websocket_builder.js.map +0 -1
  172. package/dist/esm/src/websocket_event.d.ts +0 -67
  173. package/dist/esm/src/websocket_event.d.ts.map +0 -1
  174. package/dist/esm/src/websocket_event.js +0 -19
  175. package/dist/esm/src/websocket_event.js.map +0 -1
  176. package/dist/esm/src/websocket_options.d.ts.map +0 -1
  177. package/dist/esm/src/websocket_options.js.map +0 -1
  178. package/dist/esm/src/websocket_retry_options.d.ts.map +0 -1
  179. package/dist/esm/src/websocket_retry_options.js.map +0 -1
  180. package/eslint.config.mjs +0 -43
  181. package/tsconfig.cjs.json +0 -74
  182. package/tsconfig.esm.json +0 -74
  183. package/websocket-ts-2.2.1.tgz +0 -0
  184. /package/dist/cjs/{src/backoff → backoff}/backoff.js +0 -0
  185. /package/dist/cjs/{src/queue → queue}/queue.d.ts +0 -0
  186. /package/dist/cjs/{src/queue → queue}/queue.js +0 -0
  187. /package/dist/cjs/{src/websocket_buffer.js → websocket_buffer.js} +0 -0
  188. /package/dist/cjs/{src/websocket_options.js → websocket_options.js} +0 -0
  189. /package/dist/cjs/{src/websocket_retry_options.js → websocket_retry_options.js} +0 -0
  190. /package/dist/esm/{src/backoff → backoff}/backoff.js +0 -0
  191. /package/dist/esm/{src/queue → queue}/array_queue.js +0 -0
  192. /package/dist/esm/{src/queue → queue}/queue.d.ts +0 -0
  193. /package/dist/esm/{src/queue → queue}/queue.js +0 -0
  194. /package/dist/esm/{src/websocket_buffer.js → websocket_buffer.js} +0 -0
  195. /package/dist/esm/{src/websocket_options.js → websocket_options.js} +0 -0
  196. /package/dist/esm/{src/websocket_retry_options.js → websocket_retry_options.js} +0 -0
@@ -0,0 +1,584 @@
1
+ import { WebsocketEvent, } from "./websocket_event.js";
2
+ /**
3
+ * A websocket wrapper that can be configured to reconnect automatically and buffer messages when the websocket is not connected.
4
+ */
5
+ export class Websocket {
6
+ /**
7
+ * Creates a new websocket.
8
+ *
9
+ * @param url to connect to, or a function that returns a URL.
10
+ * @param protocols optional protocols to use.
11
+ * @param options optional options to use.
12
+ * @throws Error if retry options (maxRetries, instantReconnect) are set without a backoff.
13
+ * @throws Error if maxRetries is neither Infinity nor a non-negative integer.
14
+ */
15
+ constructor(url, protocols, options) {
16
+ var _a, _b, _c, _d, _e, _f, _g;
17
+ this._closedByUser = false; // whether the websocket was closed by the user
18
+ // incremented by close() and reconnect() to invalidate in-flight lifecycle
19
+ // work: event handlers and retry timers belonging to an older generation
20
+ // must not commit further state transitions or create sockets
21
+ this._connectionGeneration = 0;
22
+ // for each listener-registration made with an AbortSignal, the function that
23
+ // unhooks the 'abort'-handler again; used to avoid piling up dead handlers on
24
+ // long-lived signals when listeners are removed by other means
25
+ this.abortHandlerCleanups = new WeakMap();
26
+ /**
27
+ * Handles the 'open' event of the browser-native websocket.
28
+ * @param event to handle.
29
+ */
30
+ this.handleOpenEvent = (event) => this.handleEvent(WebsocketEvent.open, event);
31
+ /**
32
+ * Handles the 'error' event of the browser-native websocket.
33
+ * @param event to handle.
34
+ */
35
+ this.handleErrorEvent = (event) => this.handleEvent(WebsocketEvent.error, event);
36
+ /**
37
+ * Handles the 'close' event of the browser-native websocket.
38
+ * @param event to handle.
39
+ */
40
+ this.handleCloseEvent = (event) => this.handleEvent(WebsocketEvent.close, event);
41
+ /**
42
+ * Handles the 'message' event of the browser-native websocket.
43
+ * @param event to handle.
44
+ */
45
+ this.handleMessageEvent = (event) => this.handleEvent(WebsocketEvent.message, event);
46
+ if (((_a = options === null || options === void 0 ? void 0 : options.retry) === null || _a === void 0 ? void 0 : _a.backoff) === undefined &&
47
+ (((_b = options === null || options === void 0 ? void 0 : options.retry) === null || _b === void 0 ? void 0 : _b.maxRetries) !== undefined ||
48
+ ((_c = options === null || options === void 0 ? void 0 : options.retry) === null || _c === void 0 ? void 0 : _c.instantReconnect) !== undefined)) {
49
+ // retrying is driven by the backoff; without one, the other retry options would silently do nothing
50
+ throw new Error("Retry options (maxRetries, instantReconnect) require a backoff to be configured");
51
+ }
52
+ const maxRetries = (_d = options === null || options === void 0 ? void 0 : options.retry) === null || _d === void 0 ? void 0 : _d.maxRetries;
53
+ if (maxRetries !== undefined &&
54
+ maxRetries !== Infinity &&
55
+ (!Number.isInteger(maxRetries) || maxRetries < 0)) {
56
+ // NaN would silently never exhaust, negative values exhaust before any
57
+ // retry, and fractions break the promise that the exhausted-detail
58
+ // retries equal the configured limit; fail fast like the backoffs do.
59
+ // Infinity is accepted as an explicit 'no limit', like undefined
60
+ throw new Error("MaxRetries must be undefined, Infinity or a non-negative integer");
61
+ }
62
+ this._urlProvider = url;
63
+ this._protocols = protocols;
64
+ // make a copy of the options to prevent the user from changing them
65
+ this._options = {
66
+ buffer: options === null || options === void 0 ? void 0 : options.buffer,
67
+ retry: {
68
+ maxRetries: (_e = options === null || options === void 0 ? void 0 : options.retry) === null || _e === void 0 ? void 0 : _e.maxRetries,
69
+ instantReconnect: (_f = options === null || options === void 0 ? void 0 : options.retry) === null || _f === void 0 ? void 0 : _f.instantReconnect,
70
+ backoff: (_g = options === null || options === void 0 ? void 0 : options.retry) === null || _g === void 0 ? void 0 : _g.backoff,
71
+ },
72
+ listeners: {
73
+ open: [],
74
+ close: [],
75
+ error: [],
76
+ message: [],
77
+ retry: [],
78
+ reconnect: [],
79
+ exhausted: [],
80
+ },
81
+ };
82
+ try {
83
+ // register the initial listeners through addEventListener so that
84
+ // listener options (e.g. 'signal') are honored for them as well; the
85
+ // generic helper keeps each event's listeners typed for that event
86
+ const register = (type) => {
87
+ var _a, _b;
88
+ return (_b = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a[type]) === null || _b === void 0 ? void 0 : _b.forEach((l) => this.addEventListener(type, l.listener, l.options));
89
+ };
90
+ Object.values(WebsocketEvent).forEach(register);
91
+ // this first attempt always assigns the underlying websocket: the URL
92
+ // provider is called without the instance as 'this', so it cannot reach
93
+ // close() or reconnect() to supersede it
94
+ this.tryConnect();
95
+ }
96
+ catch (error) {
97
+ // the caller never receives this instance and cannot remove its
98
+ // listeners, so unhook their abort-handlers; otherwise a long-lived
99
+ // signal would retain the failed instance and everything it references
100
+ Object.values(this._options.listeners).forEach((listeners) => listeners.forEach((l) => this.cleanupAbortHandler(l)));
101
+ throw error;
102
+ }
103
+ }
104
+ /**
105
+ * Getter for the url of the most recently constructed underlying websocket. This is not
106
+ * necessarily the URL of the last successful connection, and a URL that the WebSocket
107
+ * constructor rejected, or whose connection attempt was superseded, is not recorded.
108
+ *
109
+ * @return the url.
110
+ */
111
+ get url() {
112
+ return this._url;
113
+ }
114
+ /**
115
+ * Getter for the protocols.
116
+ *
117
+ * @return the protocols, or undefined if none were provided.
118
+ */
119
+ get protocols() {
120
+ return this._protocols;
121
+ }
122
+ /**
123
+ * Getter for the buffer.
124
+ *
125
+ * @return the buffer, or undefined if none was provided.
126
+ */
127
+ get buffer() {
128
+ return this._options.buffer;
129
+ }
130
+ /**
131
+ * Getter for the maxRetries.
132
+ *
133
+ * @return the maxRetries, or undefined if none was provided (no limit).
134
+ */
135
+ get maxRetries() {
136
+ return this._options.retry.maxRetries;
137
+ }
138
+ /**
139
+ * Getter for the instantReconnect.
140
+ *
141
+ * @return the instantReconnect, or undefined if none was provided.
142
+ */
143
+ get instantReconnect() {
144
+ return this._options.retry.instantReconnect;
145
+ }
146
+ /**
147
+ * Getter for the backoff.
148
+ *
149
+ * @return the backoff, or undefined if none was provided.
150
+ */
151
+ get backoff() {
152
+ return this._options.retry.backoff;
153
+ }
154
+ /**
155
+ * Whether the websocket was closed by the user. A websocket is closed by the user by calling close().
156
+ *
157
+ * @return true if the websocket was closed by the user, false otherwise.
158
+ */
159
+ get closedByUser() {
160
+ return this._closedByUser;
161
+ }
162
+ /**
163
+ * Getter for the time of the last 'open' event, i.e. the last time the websocket was connected.
164
+ *
165
+ * @return the time of the last 'open' event, or undefined if the websocket was never connected.
166
+ */
167
+ get lastConnection() {
168
+ // defensive copy: retry/reconnect/exhausted event details are derived
169
+ // from the internal timestamp, so callers must not be able to mutate it
170
+ return this._lastConnection && new Date(this._lastConnection);
171
+ }
172
+ /**
173
+ * Getter for the underlying websocket. This can be used to access the browser's native websocket directly.
174
+ *
175
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
176
+ * @return the underlying websocket.
177
+ */
178
+ get underlyingWebsocket() {
179
+ return this._underlyingWebsocket;
180
+ }
181
+ /**
182
+ * Getter for the readyState of the underlying websocket.
183
+ *
184
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState
185
+ * @return the readyState of the underlying websocket.
186
+ */
187
+ get readyState() {
188
+ return this._underlyingWebsocket.readyState;
189
+ }
190
+ /**
191
+ * Getter for the bufferedAmount of the underlying websocket.
192
+ *
193
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/bufferedAmount
194
+ * @return the bufferedAmount of the underlying websocket.
195
+ */
196
+ get bufferedAmount() {
197
+ return this._underlyingWebsocket.bufferedAmount;
198
+ }
199
+ /**
200
+ * Getter for the extensions of the underlying websocket.
201
+ *
202
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/extensions
203
+ * @return the extensions of the underlying websocket.
204
+ */
205
+ get extensions() {
206
+ return this._underlyingWebsocket.extensions;
207
+ }
208
+ /**
209
+ * Getter for the binaryType of the underlying websocket.
210
+ *
211
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType
212
+ * @return the binaryType of the underlying websocket.
213
+ */
214
+ get binaryType() {
215
+ return this._underlyingWebsocket.binaryType;
216
+ }
217
+ /**
218
+ * Setter for the binaryType of the underlying websocket. The value is remembered
219
+ * and re-applied whenever a new underlying websocket is created after a reconnect.
220
+ *
221
+ * @param value to set, 'blob' or 'arraybuffer'.
222
+ */
223
+ set binaryType(value) {
224
+ this._binaryType = value;
225
+ this._underlyingWebsocket.binaryType = value;
226
+ }
227
+ /**
228
+ * Sends data over the websocket.
229
+ *
230
+ * If the websocket is not connected and a buffer was provided on creation, the data will be added to the buffer.
231
+ * If no buffer was provided or the websocket was closed by the user, the data will be dropped.
232
+ *
233
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
234
+ * @param data to send.
235
+ */
236
+ send(data) {
237
+ if (this.closedByUser)
238
+ return; // no-op if closed by user
239
+ if (this._underlyingWebsocket.readyState === this._underlyingWebsocket.OPEN) {
240
+ this._underlyingWebsocket.send(data); // websocket is connected, send data
241
+ }
242
+ else if (this.buffer !== undefined) {
243
+ this.buffer.add(data); // websocket is not connected, add data to buffer
244
+ }
245
+ }
246
+ /**
247
+ * Close the websocket. No automatic connection-retry will be attempted after this,
248
+ * until reconnect() is called.
249
+ *
250
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close
251
+ * @param code optional close code.
252
+ * @param reason optional close reason.
253
+ */
254
+ close(code, reason) {
255
+ this._connectionGeneration++; // invalidate in-flight lifecycle work and pending retries
256
+ this.cancelScheduledConnectionRetry(); // cancel any scheduled retries
257
+ this._closedByUser = true; // mark websocket as closed by user
258
+ this._underlyingWebsocket.close(code, reason); // close underlying websocket with provided code and reason
259
+ }
260
+ /**
261
+ * (Re-)connects the websocket immediately, regardless of its current state:
262
+ * any scheduled retry is cancelled, the backoff and its retry-counter are
263
+ * reset, the URL provider is resolved again and a new connection is opened.
264
+ * This also revives a websocket that was closed by the user or that gave up
265
+ * after exceeding maxRetries (see the 'exhausted' event).
266
+ *
267
+ * Typical uses: a "reconnect" button after the 'exhausted' event, reacting to
268
+ * the browser's 'online' event, or forcing the URL provider to pick up a new
269
+ * auth token without waiting for the connection to drop.
270
+ *
271
+ * @throws whatever the URL provider or the WebSocket constructor throws.
272
+ */
273
+ reconnect() {
274
+ var _a;
275
+ this._connectionGeneration++; // invalidate in-flight lifecycle work and pending retries
276
+ this.cancelScheduledConnectionRetry(); // cancel any scheduled retries
277
+ this._closedByUser = false; // revive if the websocket was closed by the user
278
+ (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.reset(); // start the next disconnection episode with a fresh retry budget
279
+ this.clearWebsocket(); // detach and close the current underlying websocket
280
+ this.tryConnect();
281
+ }
282
+ /**
283
+ * Adds an event listener for the given event-type. When an AbortSignal is
284
+ * provided in the options, aborting it removes exactly this registration;
285
+ * a listener whose signal is already aborted is never registered, mirroring
286
+ * the native EventTarget.
287
+ *
288
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
289
+ * @param type of the event to add the listener for.
290
+ * @param listener to add.
291
+ * @param options to use when adding the listener.
292
+ */
293
+ addEventListener(type, listener, options) {
294
+ const signal = options === null || options === void 0 ? void 0 : options.signal;
295
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
296
+ return; // the signal is already aborted, never register the listener
297
+ }
298
+ const entry = { listener, options };
299
+ if (signal !== undefined) {
300
+ // aborting the signal removes exactly this registration; the same
301
+ // listener-function may be registered again with a different signal
302
+ const removeOnAbort = () => {
303
+ this.abortHandlerCleanups.delete(entry);
304
+ this._options.listeners[type] = this._options.listeners[type].filter((l) => l !== entry);
305
+ };
306
+ signal.addEventListener("abort", removeOnAbort, { once: true });
307
+ this.abortHandlerCleanups.set(entry, () => signal.removeEventListener("abort", removeOnAbort));
308
+ }
309
+ this._options.listeners[type].push(entry); // add listener to list of listeners
310
+ }
311
+ /**
312
+ * Removes all event listeners for the given event-type that match the given listener.
313
+ *
314
+ * Matching is done by listener identity only, mirroring the native EventTarget:
315
+ * the options a listener was added with are ignored when matching.
316
+ *
317
+ * @param type of the event to remove the listener for.
318
+ * @param listener to remove.
319
+ * @param options ignored when matching, present for backward compatibility.
320
+ */
321
+ removeEventListener(type, listener,
322
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
323
+ options) {
324
+ const isListenerNotToBeRemoved = (l) => l.listener !== listener;
325
+ this._options.listeners[type]
326
+ .filter((l) => !isListenerNotToBeRemoved(l))
327
+ .forEach((l) => this.cleanupAbortHandler(l)); // unhook abort-handlers of removed listeners
328
+ this._options.listeners[type] =
329
+ this._options.listeners[type].filter(isListenerNotToBeRemoved); // only keep listeners that are not to be removed
330
+ }
331
+ /**
332
+ * Creates a new browser-native websocket and connects it to the given URL with the given protocols
333
+ * and adds all event listeners to the browser-native websocket. The new websocket is stored in the
334
+ * '_underlyingWebsocket' property, unless the URL provider superseded this attempt by calling close()
335
+ * or reconnect().
336
+ */
337
+ tryConnect() {
338
+ const generation = this._connectionGeneration;
339
+ const urlProvider = this._urlProvider; // call the provider without the wrapper as receiver
340
+ const url = typeof urlProvider === "function" ? urlProvider() : urlProvider;
341
+ // the URL provider is user code and may have re-entered close() or
342
+ // reconnect(); that call now owns the lifecycle, so this attempt must
343
+ // neither open a socket after close() nor overwrite (and thereby orphan)
344
+ // the socket a nested reconnect() already committed
345
+ if (generation !== this._connectionGeneration)
346
+ return;
347
+ const socket = new WebSocket(url, this.protocols); // create new browser-native websocket and add all event listeners
348
+ this._url = url;
349
+ this._underlyingWebsocket = socket;
350
+ if (this._binaryType !== undefined) {
351
+ this._underlyingWebsocket.binaryType = this._binaryType; // re-apply the user-chosen binaryType
352
+ }
353
+ this._underlyingWebsocket.addEventListener(WebsocketEvent.open, this.handleOpenEvent);
354
+ this._underlyingWebsocket.addEventListener(WebsocketEvent.close, this.handleCloseEvent);
355
+ this._underlyingWebsocket.addEventListener(WebsocketEvent.error, this.handleErrorEvent);
356
+ this._underlyingWebsocket.addEventListener(WebsocketEvent.message, this.handleMessageEvent);
357
+ }
358
+ /**
359
+ * Removes all event listeners from the browser-native websocket and closes it.
360
+ */
361
+ clearWebsocket() {
362
+ this._underlyingWebsocket.removeEventListener(WebsocketEvent.open, this.handleOpenEvent);
363
+ this._underlyingWebsocket.removeEventListener(WebsocketEvent.close, this.handleCloseEvent);
364
+ this._underlyingWebsocket.removeEventListener(WebsocketEvent.error, this.handleErrorEvent);
365
+ this._underlyingWebsocket.removeEventListener(WebsocketEvent.message, this.handleMessageEvent);
366
+ this._underlyingWebsocket.close();
367
+ }
368
+ /**
369
+ * Dispatch an event to all listeners of the given event-type.
370
+ *
371
+ * @param type of the event to dispatch.
372
+ * @param event to dispatch.
373
+ */
374
+ dispatchEvent(type, event) {
375
+ // iterate over a snapshot so that listeners registered during dispatch are
376
+ // not invoked in this round, while mutations of the live list persist
377
+ const snapshot = [
378
+ ...this._options.listeners[type],
379
+ ];
380
+ snapshot.forEach((listenerWithOptions) => {
381
+ var _a;
382
+ // re-read the live list on every invocation: a listener may have
383
+ // added/removed listeners of this type, or replaced the list entirely
384
+ const listeners = this._options.listeners[type];
385
+ const index = listeners.indexOf(listenerWithOptions);
386
+ if (index === -1) {
387
+ return; // listener was removed during dispatch, don't invoke it
388
+ }
389
+ if ((_a = listenerWithOptions.options) === null || _a === void 0 ? void 0 : _a.once) {
390
+ listeners.splice(index, 1); // remove once-listener before invoking it
391
+ this.cleanupAbortHandler(listenerWithOptions); // unhook its abort-handler, if any
392
+ }
393
+ try {
394
+ listenerWithOptions.listener(this, event); // invoke listener with event
395
+ }
396
+ catch (error) {
397
+ // a throwing listener must neither stop the remaining listeners nor the
398
+ // lifecycle work that follows dispatch (retry scheduling, reconnection),
399
+ // mirroring how the native EventTarget isolates listener exceptions
400
+ this.reportListenerError(error);
401
+ }
402
+ });
403
+ }
404
+ /**
405
+ * Reports an exception thrown by a user-provided event listener. Uses
406
+ * globalThis.reportError where available (browsers); otherwise the exception
407
+ * is rethrown asynchronously so it still reaches the runtime's global
408
+ * error handling (e.g. 'uncaughtException' in Node.js) without breaking
409
+ * the dispatch it escaped from.
410
+ *
411
+ * @param error the exception thrown by the listener.
412
+ */
413
+ reportListenerError(error) {
414
+ if (typeof globalThis.reportError === "function") {
415
+ globalThis.reportError(error);
416
+ }
417
+ else {
418
+ globalThis.setTimeout(() => {
419
+ throw error;
420
+ }, 0);
421
+ }
422
+ }
423
+ /**
424
+ * Handles the given event by dispatching it to all listeners of the given event-type.
425
+ *
426
+ * @param type of the event to handle.
427
+ * @param event to handle.
428
+ */
429
+ handleEvent(type, event) {
430
+ // a listener may re-enter close() or reconnect() during dispatch; both bump
431
+ // the generation, in which case the transitions below must not be committed
432
+ const generation = this._connectionGeneration;
433
+ switch (type) {
434
+ case WebsocketEvent.close:
435
+ this.dispatchEvent(type, event);
436
+ if (generation !== this._connectionGeneration)
437
+ break; // a listener already closed/reconnected
438
+ this.scheduleConnectionRetryIfNeeded(); // schedule a new connection retry if the websocket was closed by the server
439
+ break;
440
+ case WebsocketEvent.open: {
441
+ if (this.backoff !== undefined && this.backoff.retries > 0) {
442
+ // a retry preceded this open, so the websocket was reconnected; this
443
+ // includes recovery from a server that was unavailable at construction,
444
+ // where no previous connection exists yet
445
+ const detail = {
446
+ retries: this.backoff.retries,
447
+ lastConnection: this._lastConnection && new Date(this._lastConnection),
448
+ };
449
+ this.backoff.reset(); // reset before dispatch, so listeners observe a fresh retry budget
450
+ const event = new CustomEvent(WebsocketEvent.reconnect, {
451
+ detail,
452
+ });
453
+ this.dispatchEvent(WebsocketEvent.reconnect, event);
454
+ if (generation !== this._connectionGeneration)
455
+ break;
456
+ }
457
+ this._lastConnection = new Date();
458
+ this.dispatchEvent(type, event); // dispatch open event and send buffered data
459
+ if (generation !== this._connectionGeneration)
460
+ break;
461
+ this.sendBufferedData();
462
+ break;
463
+ }
464
+ case WebsocketEvent.retry:
465
+ this.dispatchEvent(type, event); // dispatch retry event and try to connect
466
+ if (generation !== this._connectionGeneration)
467
+ break; // this attempt was superseded during dispatch
468
+ this.clearWebsocket(); // clear the old websocket
469
+ try {
470
+ this.tryConnect();
471
+ }
472
+ catch (error) {
473
+ // the url provider or websocket-construction threw; surface the thrown
474
+ // value as an 'error' event and keep the retry chain alive under the
475
+ // usual rules. Native error events are plain Events, so listeners can
476
+ // tell this case apart with 'instanceof ErrorEvent'
477
+ this.dispatchEvent(WebsocketEvent.error, new ErrorEvent(WebsocketEvent.error, {
478
+ error,
479
+ message: error instanceof Error ? error.message : "",
480
+ }));
481
+ if (generation !== this._connectionGeneration)
482
+ break;
483
+ this.scheduleConnectionRetryIfNeeded();
484
+ }
485
+ break;
486
+ default:
487
+ this.dispatchEvent(type, event); // dispatch event to all listeners of the given event-type
488
+ break;
489
+ }
490
+ }
491
+ /**
492
+ * Sends buffered data if there is a buffer defined. Draining stops as soon as the
493
+ * websocket is no longer open, e.g. when a listener closed it during the drain;
494
+ * remaining elements stay buffered for the next successful connection. Without
495
+ * this guard, send() would re-add each read element to the buffer, cycling forever.
496
+ */
497
+ sendBufferedData() {
498
+ if (this.buffer === undefined) {
499
+ return; // no buffer defined, nothing to send
500
+ }
501
+ while (!this.closedByUser &&
502
+ this._underlyingWebsocket.readyState === this._underlyingWebsocket.OPEN) {
503
+ const ele = this.buffer.read();
504
+ if (ele === undefined) {
505
+ return; // buffer is empty
506
+ }
507
+ this.send(ele); // send buffered data
508
+ }
509
+ }
510
+ /**
511
+ * Schedules a connection-retry if there is a backoff defined and the websocket was not closed by the user.
512
+ */
513
+ scheduleConnectionRetryIfNeeded() {
514
+ if (this.closedByUser) {
515
+ return; // user closed the websocket, no retry
516
+ }
517
+ if (this.backoff === undefined) {
518
+ return; // no backoff defined, no retry
519
+ }
520
+ // handler dispatches the retry event to all listeners of the retry event-type
521
+ const handleRetryEvent = (detail) => {
522
+ const event = new CustomEvent(WebsocketEvent.retry, { detail });
523
+ this.handleEvent(WebsocketEvent.retry, event);
524
+ };
525
+ // when the maximum number of retries is exceeded, give up and dispatch the
526
+ // exhausted event; checked before advancing the backoff so that the counter
527
+ // equals the number of retries actually performed
528
+ if (this._options.retry.maxRetries !== undefined &&
529
+ this.backoff.retries >= this._options.retry.maxRetries) {
530
+ const detail = {
531
+ retries: this.backoff.retries,
532
+ lastConnection: this._lastConnection && new Date(this._lastConnection),
533
+ };
534
+ const event = new CustomEvent(WebsocketEvent.exhausted, {
535
+ detail,
536
+ });
537
+ this.dispatchEvent(WebsocketEvent.exhausted, event);
538
+ return;
539
+ }
540
+ // the backoff is reset on every successful reconnect, so a retry-count of
541
+ // zero means this is the first retry of the current disconnection episode
542
+ const isFirstRetryOfEpisode = this.backoff.retries === 0;
543
+ // advance the backoff so the retry-count is accurate and maxRetries applies;
544
+ // with 'instantReconnect' only the episode's first retry is instant. Browsers
545
+ // store timer delays as signed 32-bit integers, so longer delays would
546
+ // overflow and fire (almost) immediately; cap them at the maximum instead
547
+ const backoff = Math.min(this.backoff.next(), 2 ** 31 - 1);
548
+ const retryEventDetail = {
549
+ backoff: this._options.retry.instantReconnect === true && isFirstRetryOfEpisode
550
+ ? 0
551
+ : backoff,
552
+ retries: this.backoff.retries,
553
+ lastConnection: this._lastConnection && new Date(this._lastConnection), // copy so listeners can't mutate our state
554
+ };
555
+ // no generation check is needed here: close() and reconnect() bump the
556
+ // generation and synchronously cancel this timeout, so a superseded
557
+ // attempt can never fire
558
+ this.retryTimeout = globalThis.setTimeout(() => {
559
+ this.retryTimeout = undefined;
560
+ handleRetryEvent(retryEventDetail);
561
+ }, retryEventDetail.backoff);
562
+ }
563
+ /**
564
+ * Cancels the scheduled connection-retry, if there is one.
565
+ */
566
+ cancelScheduledConnectionRetry() {
567
+ globalThis.clearTimeout(this.retryTimeout);
568
+ this.retryTimeout = undefined;
569
+ }
570
+ /**
571
+ * Unhooks the 'abort'-handler that was registered on the AbortSignal of the
572
+ * given listener-registration, if there is one.
573
+ *
574
+ * @param entry the listener-registration to unhook the abort-handler for.
575
+ */
576
+ cleanupAbortHandler(entry) {
577
+ const cleanup = this.abortHandlerCleanups.get(entry);
578
+ if (cleanup !== undefined) {
579
+ cleanup();
580
+ this.abortHandlerCleanups.delete(entry);
581
+ }
582
+ }
583
+ }
584
+ //# sourceMappingURL=websocket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.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UAAU,CAAC,UAAU,CAAC,GAAG,EAAE;YAC7C,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;YAC9B,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QACrC,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACK,8BAA8B;QACpC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACK,mBAAmB,CAAC,KAAa;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A WebsocketBuffer is used to store messages temporarily until they can be sent.
3
3
  */
4
- export interface WebsocketBuffer<E = string | ArrayBufferLike | Blob | ArrayBufferView> {
4
+ export interface WebsocketBuffer<E = string | Blob | BufferSource> {
5
5
  /**
6
6
  * Adds an element to the buffer.
7
7
  * @param element the element to add
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket_buffer.d.ts","sourceRoot":"","sources":["../../src/websocket_buffer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG,YAAY;IAC/D;;;OAGG;IACH,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAEtB;;;OAGG;IACH,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC;CACvB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket_buffer.js","sourceRoot":"","sources":["../../src/websocket_buffer.ts"],"names":[],"mappings":""}