websocket-ts 2.1.4 → 2.2.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.
- package/LICENSE +21 -21
- package/README.md +212 -211
- package/dist/cjs/src/backoff/constantbackoff.js.map +1 -1
- package/dist/cjs/src/backoff/exponentialbackoff.js.map +1 -1
- package/dist/cjs/src/backoff/linearbackoff.js.map +1 -1
- package/dist/cjs/src/queue/ring_queue.js.map +1 -1
- package/dist/cjs/src/websocket.d.ts +1 -1
- package/dist/cjs/src/websocket.d.ts.map +1 -1
- package/dist/cjs/src/websocket.js +4 -3
- package/dist/cjs/src/websocket.js.map +1 -1
- package/dist/esm/src/backoff/constantbackoff.js.map +1 -1
- package/dist/esm/src/backoff/exponentialbackoff.js.map +1 -1
- package/dist/esm/src/backoff/linearbackoff.js.map +1 -1
- package/dist/esm/src/queue/ring_queue.js.map +1 -1
- package/dist/esm/src/websocket.d.ts +1 -1
- package/dist/esm/src/websocket.d.ts.map +1 -1
- package/dist/esm/src/websocket.js +4 -3
- package/dist/esm/src/websocket.js.map +1 -1
- package/eslint.config.mjs +43 -0
- package/package.json +27 -20
- package/src/queue/ring_queue.ts +2 -2
- package/src/websocket.ts +5 -4
- package/tsconfig.cjs.json +74 -71
- package/tsconfig.esm.json +74 -71
- package/websocket-ts-2.2.0.tgz +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Joscha Behrmann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,211 +1,212 @@
|
|
|
1
|
-
<div>
|
|
2
|
-
<div align="center">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/jjxxs/websocket-ts/gh-pages/websocket-ts-logo.svg" alt="websocket-ts" width="300" height="65" />
|
|
4
|
-
</div>
|
|
5
|
-
<p align="center">
|
|
6
|
-
<img src="https://github.com/jjxxs/websocket-ts/actions/workflows/build.yml/badge.svg" alt="Build Status" />
|
|
7
|
-
<img src="https://github.com/jjxxs/websocket-ts/actions/workflows/test.yml/badge.svg" alt="Build Status" />
|
|
8
|
-
<a href="https://coveralls.io/github/jjxxs/websocket-ts?branch=master">
|
|
9
|
-
<img src="https://coveralls.io/repos/github/jjxxs/websocket-ts/badge.svg?branch=master&service=github" alt="Coverage Status" />
|
|
10
|
-
</a>
|
|
11
|
-
<a href="https://github.com/jjxxs/websocket-ts/releases/latest">
|
|
12
|
-
<img src="https://img.shields.io/github/v/release/jjxxs/websocket-ts" alt="Release" />
|
|
13
|
-
</a>
|
|
14
|
-
<a href="/LICENSE">
|
|
15
|
-
<img src="https://img.shields.io/github/license/jjxxs/websocket-ts" alt="License" />
|
|
16
|
-
</a>
|
|
17
|
-
</p>
|
|
18
|
-
</div>
|
|
19
|
-
|
|
20
|
-
<div align="center">
|
|
21
|
-
A <b>WebSocket</b> for browsers with <b>auto-reconnect</b> and <b>message buffering</b> written in <b>TypeScript</b>.
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
## Features
|
|
25
|
-
|
|
26
|
-
- **Lightweight & Standalone**: No dependencies, 2.1 kB minified & gzipped.
|
|
27
|
-
- **Browser-native**: Utilizes WebSocket API, offers direct access.
|
|
28
|
-
- **Smart Reconnect**: Optional auto-reconnect and message buffering.
|
|
29
|
-
- **Easy Setup**: Optional builder class for quick initialization.
|
|
30
|
-
- **Well-Tested**: High test coverage, well-documented for extensibility.
|
|
31
|
-
- **Module Support**: Supports CommonJS
|
|
32
|
-
|
|
33
|
-
## Installation
|
|
34
|
-
|
|
35
|
-
Install `websocket-ts` with npm:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
$ npm install websocket-ts
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Quickstart
|
|
42
|
-
This example shows how to use the package, complete with message buffering and automatic reconnection.
|
|
43
|
-
The created websocket will echo back any received messages. It will buffer messages when disconnected
|
|
44
|
-
and attempt to reconnect every 1 second.
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import {
|
|
48
|
-
ArrayQueue,
|
|
49
|
-
ConstantBackoff,
|
|
50
|
-
Websocket,
|
|
51
|
-
WebsocketBuilder,
|
|
52
|
-
WebsocketEvent,
|
|
53
|
-
} from "websocket-ts";
|
|
54
|
-
|
|
55
|
-
// Initialize WebSocket with buffering and 1s reconnection delay
|
|
56
|
-
const ws = new WebsocketBuilder("ws://localhost:8080")
|
|
57
|
-
.withBuffer(new ArrayQueue()) // buffer messages when disconnected
|
|
58
|
-
.withBackoff(new ConstantBackoff(1000)) // retry every 1s
|
|
59
|
-
.build();
|
|
60
|
-
|
|
61
|
-
// Function to output & echo received messages
|
|
62
|
-
const echoOnMessage = (i: Websocket, ev: MessageEvent) => {
|
|
63
|
-
console.log(`received message: ${ev.data}`);
|
|
64
|
-
i.send(`echo: ${ev.data}`);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Add event listeners
|
|
68
|
-
ws.addEventListener(WebsocketEvent.open, () => console.log("opened!"));
|
|
69
|
-
ws.addEventListener(WebsocketEvent.close, () => console.log("closed!"));
|
|
70
|
-
ws.addEventListener(WebsocketEvent.message, echoOnMessage);
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Usage
|
|
74
|
-
This will demonstrate how to use `websocket-ts` in your project using the provided `WebsocketBuild`-class.
|
|
75
|
-
|
|
76
|
-
For a more detailed description of the API, please refer to the [API Documentation](https://jjxxs.github.io/websocket-ts/).
|
|
77
|
-
|
|
78
|
-
#### Initialization
|
|
79
|
-
|
|
80
|
-
Create a new instance with the `WebsocketBuilder`:
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
const ws = new WebsocketBuilder("ws://localhost:42421").build();
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
#### Events
|
|
87
|
-
|
|
88
|
-
There are six events which can be subscribed to through with event listeners:
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
export enum WebsocketEvent {
|
|
92
|
-
open = "open", // Connection opened
|
|
93
|
-
close = "close", // Connection closed
|
|
94
|
-
error = "error", // Error-induced closure
|
|
95
|
-
message = "message", // Message received
|
|
96
|
-
retry = "retry", // Reconnect attempt
|
|
97
|
-
reconnect = "reconnect" // Successful reconnect
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
#### Add Event Listeners
|
|
102
|
-
Event listeners receive the websocket instance (`i`) and the triggering event (`ev`) as arguments.
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
106
|
-
.onOpen((i, ev) => console.log("opened"))
|
|
107
|
-
.onClose((i, ev) => console.log("closed"))
|
|
108
|
-
.onError((i, ev) => console.log("error"))
|
|
109
|
-
.onMessage((i, ev) => console.log("message"))
|
|
110
|
-
.onRetry((i, ev) => console.log("retry"))
|
|
111
|
-
.onReconnect((i, ev) => console.log("reconnect"))
|
|
112
|
-
.build();
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
#### Remove Event Listeners
|
|
116
|
-
|
|
117
|
-
To unregister a specific event listener, use `removeEventListener`:
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
let ws: Websocket
|
|
121
|
-
/* ... */
|
|
122
|
-
ws.removeEventListener(WebsocketEvent.open, openEventListener);
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
#### Send Message
|
|
126
|
-
|
|
127
|
-
Use the `send` method to send a message to the server:
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
let ws: Websocket;
|
|
131
|
-
/* ... */
|
|
132
|
-
ws.send("Hello World!");
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
#### Reconnect & Backoff (Optional)
|
|
136
|
-
|
|
137
|
-
If you'd like the websocket to automatically reconnect upon disconnection, you can optionally provide a `Backoff` strategy.
|
|
138
|
-
This sets the delay between reconnection attempts. There are three built-in `Backoff` implementations, or you can create
|
|
139
|
-
your own by implementing the `Backoff` interface. If no Backoff is provided, the websocket will not attempt to reconnect.
|
|
140
|
-
|
|
141
|
-
##### ConstantBackoff
|
|
142
|
-
|
|
143
|
-
The `ConstantBackoff` strategy enforces a fixed delay between each reconnection attempt.
|
|
144
|
-
To set a constant 1-second wait time, use:
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
148
|
-
.withBackoff(new ConstantBackoff(1000)) // 1000ms = 1s
|
|
149
|
-
.build();
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
##### LinearBackoff
|
|
153
|
-
|
|
154
|
-
The `LinearBackoff` strategy increases the delay between reconnection attempts linearly,
|
|
155
|
-
up to an optional maximum. For example, to start with a 0-second delay and increase by
|
|
156
|
-
10 second for each retry, capping at 60 seconds, use:
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
160
|
-
.withBackoff(new LinearBackoff(0, 10000, 60000)) // 0ms, 10s, 20s, 30s, 40s, 50s, 60s
|
|
161
|
-
.build();
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
##### ExponentialBackoff
|
|
165
|
-
|
|
166
|
-
The `ExponentialBackoff` strategy doubles the delay between each reconnection attempt, up
|
|
167
|
-
to a specified maximum. This approach is inspired by the binary exponential backoff algorithm
|
|
168
|
-
commonly used in networking. For example, to generate a backoff series like `[1s, 2s, 4s, 8s]`, use:
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
172
|
-
.withBackoff(new ExponentialBackoff(1000, 6)) // 1s, 2s, 4s, 8s, 16s, 32s, 64s
|
|
173
|
-
.build();
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
#### Buffer (Optional)
|
|
177
|
-
|
|
178
|
-
To buffer outgoing messages when the websocket is disconnected, you can optionally specify
|
|
179
|
-
a `Queue`. This queue will temporarily store your messages and send them in sequence when
|
|
180
|
-
the websocket (re)connects. Two built-in `Queue` implementations are available, or you can
|
|
181
|
-
create your own by implementing the `Queue` interface. If no queue is provided, messages
|
|
182
|
-
won't be buffered.
|
|
183
|
-
|
|
184
|
-
##### RingQueue
|
|
185
|
-
|
|
186
|
-
The `RingQueue` is a fixed-capacity, first-in-first-out (FIFO) queue. When it reaches capacity,
|
|
187
|
-
the oldest element is removed to accommodate new ones. Reading from the queue returns and
|
|
188
|
-
removes the oldest element. For instance, to set up a `RingQueue` with a 100-element capacity,
|
|
189
|
-
use:
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
193
|
-
.withBuffer(new RingQueue(100))
|
|
194
|
-
.build();
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
##### ArrayQueue
|
|
198
|
-
|
|
199
|
-
The ArrayQueue offers an unbounded capacity, functioning as a first-in-first-out (FIFO) queue.
|
|
200
|
-
Reading from this queue returns and removes the oldest element. To use an `ArrayQueue`, use:
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
204
|
-
.withBuffer(new ArrayQueue())
|
|
205
|
-
.build();
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
## Build & Tests
|
|
209
|
-
|
|
210
|
-
To compile the project, execute `npm run build`.
|
|
211
|
-
|
|
1
|
+
<div>
|
|
2
|
+
<div align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/jjxxs/websocket-ts/gh-pages/websocket-ts-logo.svg" alt="websocket-ts" width="300" height="65" />
|
|
4
|
+
</div>
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://github.com/jjxxs/websocket-ts/actions/workflows/build.yml/badge.svg" alt="Build Status" />
|
|
7
|
+
<img src="https://github.com/jjxxs/websocket-ts/actions/workflows/test.yml/badge.svg" alt="Build Status" />
|
|
8
|
+
<a href="https://coveralls.io/github/jjxxs/websocket-ts?branch=master">
|
|
9
|
+
<img src="https://coveralls.io/repos/github/jjxxs/websocket-ts/badge.svg?branch=master&service=github" alt="Coverage Status" />
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://github.com/jjxxs/websocket-ts/releases/latest">
|
|
12
|
+
<img src="https://img.shields.io/github/v/release/jjxxs/websocket-ts" alt="Release" />
|
|
13
|
+
</a>
|
|
14
|
+
<a href="/LICENSE">
|
|
15
|
+
<img src="https://img.shields.io/github/license/jjxxs/websocket-ts" alt="License" />
|
|
16
|
+
</a>
|
|
17
|
+
</p>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div align="center">
|
|
21
|
+
A <b>WebSocket</b> for browsers with <b>auto-reconnect</b> and <b>message buffering</b> written in <b>TypeScript</b>.
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **Lightweight & Standalone**: No dependencies, 2.1 kB minified & gzipped.
|
|
27
|
+
- **Browser-native**: Utilizes WebSocket API, offers direct access.
|
|
28
|
+
- **Smart Reconnect**: Optional auto-reconnect and message buffering.
|
|
29
|
+
- **Easy Setup**: Optional builder class for quick initialization.
|
|
30
|
+
- **Well-Tested**: High test coverage, well-documented for extensibility.
|
|
31
|
+
- **Module Support**: Supports CommonJS and ES6 modules.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
Install `websocket-ts` with npm:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
$ npm install websocket-ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
This example shows how to use the package, complete with message buffering and automatic reconnection.
|
|
43
|
+
The created websocket will echo back any received messages. It will buffer messages when disconnected
|
|
44
|
+
and attempt to reconnect every 1 second.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import {
|
|
48
|
+
ArrayQueue,
|
|
49
|
+
ConstantBackoff,
|
|
50
|
+
Websocket,
|
|
51
|
+
WebsocketBuilder,
|
|
52
|
+
WebsocketEvent,
|
|
53
|
+
} from "websocket-ts";
|
|
54
|
+
|
|
55
|
+
// Initialize WebSocket with buffering and 1s reconnection delay
|
|
56
|
+
const ws = new WebsocketBuilder("ws://localhost:8080")
|
|
57
|
+
.withBuffer(new ArrayQueue()) // buffer messages when disconnected
|
|
58
|
+
.withBackoff(new ConstantBackoff(1000)) // retry every 1s
|
|
59
|
+
.build();
|
|
60
|
+
|
|
61
|
+
// Function to output & echo received messages
|
|
62
|
+
const echoOnMessage = (i: Websocket, ev: MessageEvent) => {
|
|
63
|
+
console.log(`received message: ${ev.data}`);
|
|
64
|
+
i.send(`echo: ${ev.data}`);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Add event listeners
|
|
68
|
+
ws.addEventListener(WebsocketEvent.open, () => console.log("opened!"));
|
|
69
|
+
ws.addEventListener(WebsocketEvent.close, () => console.log("closed!"));
|
|
70
|
+
ws.addEventListener(WebsocketEvent.message, echoOnMessage);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
This will demonstrate how to use `websocket-ts` in your project using the provided `WebsocketBuild`-class.
|
|
75
|
+
|
|
76
|
+
For a more detailed description of the API, please refer to the [API Documentation](https://jjxxs.github.io/websocket-ts/).
|
|
77
|
+
|
|
78
|
+
#### Initialization
|
|
79
|
+
|
|
80
|
+
Create a new instance with the `WebsocketBuilder`:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const ws = new WebsocketBuilder("ws://localhost:42421").build();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Events
|
|
87
|
+
|
|
88
|
+
There are six events which can be subscribed to through with event listeners:
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
export enum WebsocketEvent {
|
|
92
|
+
open = "open", // Connection opened
|
|
93
|
+
close = "close", // Connection closed
|
|
94
|
+
error = "error", // Error-induced closure
|
|
95
|
+
message = "message", // Message received
|
|
96
|
+
retry = "retry", // Reconnect attempt
|
|
97
|
+
reconnect = "reconnect" // Successful reconnect
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Add Event Listeners
|
|
102
|
+
Event listeners receive the websocket instance (`i`) and the triggering event (`ev`) as arguments.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
106
|
+
.onOpen((i, ev) => console.log("opened"))
|
|
107
|
+
.onClose((i, ev) => console.log("closed"))
|
|
108
|
+
.onError((i, ev) => console.log("error"))
|
|
109
|
+
.onMessage((i, ev) => console.log("message"))
|
|
110
|
+
.onRetry((i, ev) => console.log("retry"))
|
|
111
|
+
.onReconnect((i, ev) => console.log("reconnect"))
|
|
112
|
+
.build();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Remove Event Listeners
|
|
116
|
+
|
|
117
|
+
To unregister a specific event listener, use `removeEventListener`:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
let ws: Websocket
|
|
121
|
+
/* ... */
|
|
122
|
+
ws.removeEventListener(WebsocketEvent.open, openEventListener);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Send Message
|
|
126
|
+
|
|
127
|
+
Use the `send` method to send a message to the server:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
let ws: Websocket;
|
|
131
|
+
/* ... */
|
|
132
|
+
ws.send("Hello World!");
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### Reconnect & Backoff (Optional)
|
|
136
|
+
|
|
137
|
+
If you'd like the websocket to automatically reconnect upon disconnection, you can optionally provide a `Backoff` strategy.
|
|
138
|
+
This sets the delay between reconnection attempts. There are three built-in `Backoff` implementations, or you can create
|
|
139
|
+
your own by implementing the `Backoff` interface. If no Backoff is provided, the websocket will not attempt to reconnect.
|
|
140
|
+
|
|
141
|
+
##### ConstantBackoff
|
|
142
|
+
|
|
143
|
+
The `ConstantBackoff` strategy enforces a fixed delay between each reconnection attempt.
|
|
144
|
+
To set a constant 1-second wait time, use:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
148
|
+
.withBackoff(new ConstantBackoff(1000)) // 1000ms = 1s
|
|
149
|
+
.build();
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
##### LinearBackoff
|
|
153
|
+
|
|
154
|
+
The `LinearBackoff` strategy increases the delay between reconnection attempts linearly,
|
|
155
|
+
up to an optional maximum. For example, to start with a 0-second delay and increase by
|
|
156
|
+
10 second for each retry, capping at 60 seconds, use:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
160
|
+
.withBackoff(new LinearBackoff(0, 10000, 60000)) // 0ms, 10s, 20s, 30s, 40s, 50s, 60s
|
|
161
|
+
.build();
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
##### ExponentialBackoff
|
|
165
|
+
|
|
166
|
+
The `ExponentialBackoff` strategy doubles the delay between each reconnection attempt, up
|
|
167
|
+
to a specified maximum. This approach is inspired by the binary exponential backoff algorithm
|
|
168
|
+
commonly used in networking. For example, to generate a backoff series like `[1s, 2s, 4s, 8s]`, use:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
172
|
+
.withBackoff(new ExponentialBackoff(1000, 6)) // 1s, 2s, 4s, 8s, 16s, 32s, 64s
|
|
173
|
+
.build();
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Buffer (Optional)
|
|
177
|
+
|
|
178
|
+
To buffer outgoing messages when the websocket is disconnected, you can optionally specify
|
|
179
|
+
a `Queue`. This queue will temporarily store your messages and send them in sequence when
|
|
180
|
+
the websocket (re)connects. Two built-in `Queue` implementations are available, or you can
|
|
181
|
+
create your own by implementing the `Queue` interface. If no queue is provided, messages
|
|
182
|
+
won't be buffered.
|
|
183
|
+
|
|
184
|
+
##### RingQueue
|
|
185
|
+
|
|
186
|
+
The `RingQueue` is a fixed-capacity, first-in-first-out (FIFO) queue. When it reaches capacity,
|
|
187
|
+
the oldest element is removed to accommodate new ones. Reading from the queue returns and
|
|
188
|
+
removes the oldest element. For instance, to set up a `RingQueue` with a 100-element capacity,
|
|
189
|
+
use:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
193
|
+
.withBuffer(new RingQueue(100))
|
|
194
|
+
.build();
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
##### ArrayQueue
|
|
198
|
+
|
|
199
|
+
The ArrayQueue offers an unbounded capacity, functioning as a first-in-first-out (FIFO) queue.
|
|
200
|
+
Reading from this queue returns and removes the oldest element. To use an `ArrayQueue`, use:
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
const ws = new WebsocketBuilder("ws://localhost:42421")
|
|
204
|
+
.withBuffer(new ArrayQueue())
|
|
205
|
+
.build();
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Build & Tests
|
|
209
|
+
|
|
210
|
+
To compile the project, execute `npm run build`.
|
|
211
|
+
|
|
212
|
+
To run tests, use `npm run test`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constantbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/constantbackoff.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH;IAIE;;;OAGG;IACH,yBAAY,OAAe;QANnB,aAAQ,GAAW,CAAC,CAAC;QAO3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"constantbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/constantbackoff.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH;IAIE;;;OAGG;IACH,yBAAY,OAAe;QANnB,aAAQ,GAAW,CAAC,CAAC;QAO3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,sBAAI,oCAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IAED,sBAAI,oCAAO;aAAX;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAED,8BAAI,GAAJ;QACE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,+BAAK,GAAL;QACE,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpB,CAAC;IACH,sBAAC;AAAD,CAAC,AAhCD,IAgCC;AAhCY,0CAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exponentialbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/exponentialbackoff.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH;IAME;;;;OAIG;IACH,4BAAY,IAAY,EAAE,MAAe;QAPjC,aAAQ,GAAW,CAA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,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,kCAAK,GAAL;QACE,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IACH,yBAAC;AAAD,CAAC,AA7CD,IA6CC;AA7CY,gDAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linearbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/linearbackoff.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH;IAOE;;;;;OAKG;IACH,uBAAY,OAAe,EAAE,SAAiB,EAAE,GAAY;QATpD,MAAC,GAAW,CAAC,CAAC;QACd,aAAQ,GAAW,CAAC,CAAC;QAS3B,IAAI,OAAO,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"linearbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/linearbackoff.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH;IAOE;;;;;OAKG;IACH,uBAAY,OAAe,EAAE,SAAiB,EAAE,GAAY;QATpD,MAAC,GAAW,CAAC,CAAC;QACd,aAAQ,GAAW,CAAC,CAAC;QAS3B,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,GA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CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,0BAAM,GAAN;QACE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;YAC5B,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI;gBACrB,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI;gBACvB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACrD,CAAC;IAED,2BAAO,GAAP;QACE,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,wBAAI,GAAJ;QACE,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,wBAAI,GAAJ;QACE,IAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACH,gBAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,8BAAS"}
|
|
@@ -58,7 +58,7 @@ export declare class Websocket {
|
|
|
58
58
|
*/
|
|
59
59
|
get backoff(): Backoff | undefined;
|
|
60
60
|
/**
|
|
61
|
-
* Whether the websocket was closed by the user. A websocket is closed by the user
|
|
61
|
+
* Whether the websocket was closed by the user. A websocket is closed by the user by calling close().
|
|
62
62
|
*
|
|
63
63
|
* @return true if the websocket was closed by the user, false otherwise.
|
|
64
64
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../../src/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAGL,cAAc,EACd,sBAAsB,EACtB,6BAA6B,EAI9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAoB;IAEhD,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,eAAe,CAAC,CAAO;IAC/B,OAAO,CAAC,oBAAoB,CAAY;IACxC,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../../src/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAGL,cAAc,EACd,sBAAsB,EACtB,6BAA6B,EAI9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAoB;IAEhD,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,eAAe,CAAC,CAAO;IAC/B,OAAO,CAAC,oBAAoB,CAAY;IACxC,OAAO,CAAC,YAAY,CAAC,CAA2C;IAEhE,OAAO,CAAC,QAAQ,CAC0C;IAE1D;;;;;;OAMG;gB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AAsB,CAAC,CAAC,CAAC,EACnC,OAAO,CAAC,EAAE,6BAA6B,GACtC,IAAI;IAIP;;;;;;OAMG;IACI,mBAAmB,CAAC,CAAC,SAAS,cAAc,EACjD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC,EACnC,OAAO,CAAC,EAAE,6BAA6B,GACtC,IAAI;IASP;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAsBlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAoBtB;;;OAGG;IACH,OAAO,CAAC,eAAe,CACwB;IAE/C;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CACwB;IAEhD;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CACwB;IAEhD;;;OAGG;IACH,OAAO,CAAC,kBAAkB,CACwB;IAElD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAuBrB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAyCnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAwCvC;;OAEG;IACH,OAAO,CAAC,8BAA8B;CAGvC"}
|
|
@@ -149,7 +149,7 @@ var Websocket = /** @class */ (function () {
|
|
|
149
149
|
});
|
|
150
150
|
Object.defineProperty(Websocket.prototype, "closedByUser", {
|
|
151
151
|
/**
|
|
152
|
-
* Whether the websocket was closed by the user. A websocket is closed by the user
|
|
152
|
+
* Whether the websocket was closed by the user. A websocket is closed by the user by calling close().
|
|
153
153
|
*
|
|
154
154
|
* @return true if the websocket was closed by the user, false otherwise.
|
|
155
155
|
*/
|
|
@@ -404,6 +404,7 @@ var Websocket = /** @class */ (function () {
|
|
|
404
404
|
if (this.backoff === undefined) {
|
|
405
405
|
return; // no backoff defined, no retry
|
|
406
406
|
}
|
|
407
|
+
// handler dispatches the retry event to all listeners of the retry event-type
|
|
407
408
|
var handleRetryEvent = function (detail) {
|
|
408
409
|
var event = new CustomEvent(websocket_event_1.WebsocketEvent.retry, { detail: detail });
|
|
409
410
|
_this.handleEvent(websocket_event_1.WebsocketEvent.retry, event);
|
|
@@ -419,14 +420,14 @@ var Websocket = /** @class */ (function () {
|
|
|
419
420
|
// schedule a new connection-retry if the maximum number of retries is not reached yet
|
|
420
421
|
if (this._options.retry.maxRetries === undefined ||
|
|
421
422
|
retryEventDetail.retries <= this._options.retry.maxRetries) {
|
|
422
|
-
this.retryTimeout =
|
|
423
|
+
this.retryTimeout = globalThis.setTimeout(function () { return handleRetryEvent(retryEventDetail); }, retryEventDetail.backoff);
|
|
423
424
|
}
|
|
424
425
|
};
|
|
425
426
|
/**
|
|
426
427
|
* Cancels the scheduled connection-retry, if there is one.
|
|
427
428
|
*/
|
|
428
429
|
Websocket.prototype.cancelScheduledConnectionRetry = function () {
|
|
429
|
-
|
|
430
|
+
globalThis.clearTimeout(this.retryTimeout);
|
|
430
431
|
};
|
|
431
432
|
return Websocket;
|
|
432
433
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/websocket.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,qDAS2B;AAG3B;;GAEG;AACH;IAYE;;;;;;OAMG;IACH,mBACE,GAAW,EACX,SAA6B,EAC7B,OAA0B;QAH5B,iBA2BC;;QA1CO,kBAAa,GAAY,KAAK,CAAC,CAAC,+CAA+C;QAwSvF;;;WAGG;QACK,oBAAe,GAAG,UAAC,KAAY;YACrC,OAAA,KAAI,CAAC,WAAW,CAAC,gCAAc,CAAC,IAAI,EAAE,KAAK,CAAC;QAA5C,CAA4C,CAAC;QAE/C;;;WAGG;QACK,qBAAgB,GAAG,UAAC,KAAY;YACtC,OAAA,KAAI,CAAC,WAAW,CAAC,gCAAc,CAAC,KAAK,EAAE,KAAK,CAAC;QAA7C,CAA6C,CAAC;QAEhD;;;WAGG;QACK,qBAAgB,GAAG,UAAC,KAAiB;YAC3C,OAAA,KAAI,CAAC,WAAW,CAAC,gCAAc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,OAAO,EACL,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,gBAAgB,KAAK,IAAI;gBAC3C,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO;YAC1B,cAAc,EAAE,IAAI,CAAC,eAAe;SACrC,CAAC;QAEF,sFAAsF;QACtF,IACE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;YAC5C,gBAAgB,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,EAC1D,CAAC;YACD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,UAAU,CACvC,cAAM,OAAA,gBAAgB,CAAC,gBAAgB,CAAC,EAAlC,CAAkC,EACxC,gBAAgB,CAAC,OAAO,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACK,kDAA8B,GAAtC;QACE,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IACH,gBAAC;AAAD,CAAC,AAtdD,IAsdC;AAtdY,8BAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constantbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/constantbackoff.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,eAAe;IAI1B;;;OAGG;IACH,YAAY,OAAe;QANnB,aAAQ,GAAW,CAAC,CAAC;QAO3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"constantbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/constantbackoff.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,eAAe;IAI1B;;;OAGG;IACH,YAAY,OAAe;QANnB,aAAQ,GAAW,CAAC,CAAC;QAO3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI;QACF,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACpB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exponentialbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/exponentialbackoff.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,kBAAkB;IAM7B;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAe;QAPjC,aAAQ,GAAW,CAAC,CAAC;QAQ3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"exponentialbackoff.js","sourceRoot":"","sources":["../../../../src/backoff/exponentialbackoff.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,kBAAkB;IAM7B;;;;OAIG;IACH,YAAY,IAAY,EAAE,MAAe;QAPjC,aAAQ,GAAW,CAAC,CAAC;QAQ3B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,MAAM,KAAK,SA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