msw 2.3.0-ws.rc-3 → 2.3.0-ws.rc-4

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.
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.3.0-ws.rc-3'
11
+ const PACKAGE_VERSION = '2.3.0-ws.rc-4'
12
12
  const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "2.3.0-ws.rc-3",
3
+ "version": "2.3.0-ws.rc-4",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "main": "./lib/core/index.js",
6
6
  "module": "./lib/core/index.mjs",
@@ -125,7 +125,7 @@
125
125
  "@bundled-es-modules/statuses": "^1.0.1",
126
126
  "@inquirer/confirm": "^3.0.0",
127
127
  "@mswjs/cookies": "^1.1.0",
128
- "@mswjs/interceptors": "^0.26.15",
128
+ "@mswjs/interceptors": "^0.27.0",
129
129
  "@open-draft/until": "^2.1.0",
130
130
  "@types/cookie": "^0.6.0",
131
131
  "@types/statuses": "^2.0.4",
@@ -51,9 +51,6 @@ export function handleWebSocketEvent(options: HandleWebSocketEventOptions) {
51
51
  // If none of the "ws" handlers matched,
52
52
  // establish the WebSocket connection as-is.
53
53
  connection.server.connect()
54
- connection.client.addEventListener('message', (event) => {
55
- connection.server.send(event.data)
56
- })
57
54
  }
58
55
  })
59
56
  }
@@ -9,6 +9,13 @@ import { toPublicUrl } from '../../utils/request/toPublicUrl'
9
9
  import { getMessageLength } from './getMessageLength'
10
10
  import { getPublicData } from './getPublicData'
11
11
 
12
+ const colors = {
13
+ blue: '#3b82f6',
14
+ green: '#22c55e',
15
+ red: '#ef4444',
16
+ orange: '#ff6a33',
17
+ }
18
+
12
19
  export function attachWebSocketLogger(
13
20
  connection: WebSocketConnectionData,
14
21
  ): void {
@@ -111,8 +118,8 @@ export function logConnectionOpen(client: WebSocketClientConnection) {
111
118
  const publicUrl = toPublicUrl(client.url)
112
119
 
113
120
  console.groupCollapsed(
114
- devUtils.formatMessage(`${getTimestamp()} %c▸%c ${publicUrl}`),
115
- 'color:blue',
121
+ devUtils.formatMessage(`${getTimestamp()} %c▶%c ${publicUrl}`),
122
+ `color:${colors.blue}`,
116
123
  'color:inherit',
117
124
  )
118
125
  console.log('Client:', client.socket)
@@ -132,7 +139,7 @@ export async function logOutgoingClientMessage(
132
139
  devUtils.formatMessage(
133
140
  `${getTimestamp({ milliseconds: true })} %c↑%c ${publicData} %c${byteLength}%c`,
134
141
  ),
135
- 'color:green',
142
+ `color:${colors.green}`,
136
143
  'color:inherit',
137
144
  'color:gray;font-weight:normal',
138
145
  'color:inherit;font-weight:inherit',
@@ -155,7 +162,7 @@ export async function logOutgoingMockedClientMessage(
155
162
  devUtils.formatMessage(
156
163
  `${getTimestamp({ milliseconds: true })} %c⇡%c ${publicData} %c${byteLength}%c`,
157
164
  ),
158
- 'color:orangered',
165
+ `color:${colors.orange}`,
159
166
  'color:inherit',
160
167
  'color:gray;font-weight:normal',
161
168
  'color:inherit;font-weight:inherit',
@@ -180,7 +187,7 @@ export async function logIncomingClientMessage(
180
187
  devUtils.formatMessage(
181
188
  `${getTimestamp({ milliseconds: true })} %c↓%c ${publicData} %c${byteLength}%c`,
182
189
  ),
183
- 'color:red',
190
+ `color:${colors.red}`,
184
191
  'color:inherit',
185
192
  'color:gray;font-weight:normal',
186
193
  'color:inherit;font-weight:inherit',
@@ -203,7 +210,7 @@ export async function logIncomingMockedClientMessage(
203
210
  devUtils.formatMessage(
204
211
  `${getTimestamp({ milliseconds: true })} %c⇣%c ${publicData} %c${byteLength}%c`,
205
212
  ),
206
- 'color:orangered',
213
+ `color:${colors.orange}`,
207
214
  'color:inherit',
208
215
  'color:gray;font-weight:normal',
209
216
  'color:inherit;font-weight:inherit',
@@ -220,7 +227,7 @@ function logConnectionClose(event: CloseEvent) {
220
227
  devUtils.formatMessage(
221
228
  `${getTimestamp({ milliseconds: true })} %c■%c ${publicUrl}`,
222
229
  ),
223
- 'color:blue',
230
+ `color:${colors.blue}`,
224
231
  'color:inherit',
225
232
  )
226
233
  console.log(event)
@@ -237,7 +244,7 @@ export async function logIncomingServerMessage(
237
244
  devUtils.formatMessage(
238
245
  `${getTimestamp({ milliseconds: true })} %c⇣%c ${publicData} %c${byteLength}%c`,
239
246
  ),
240
- 'color:orangered',
247
+ `color:${colors.green}`,
241
248
  'color:inherit',
242
249
  'color:gray;font-weight:normal',
243
250
  'color:inherit;font-weight:inherit',
@@ -254,7 +261,7 @@ function logClientError(event: Event) {
254
261
  devUtils.formatMessage(
255
262
  `${getTimestamp({ milliseconds: true })} %c\u00D7%c ${publicUrl}`,
256
263
  ),
257
- 'color:red',
264
+ `color:${colors.blue}`,
258
265
  'color:inherit',
259
266
  )
260
267
  console.log(event)
@@ -19,5 +19,5 @@ it('throws an error when given a non-path argument to "ws.link()"', () => {
19
19
  expect(() =>
20
20
  // @ts-expect-error Intentionally invalid argument.
21
21
  ws.link(2),
22
- ).toThrow('Expected a WebSocket server URL but got number')
22
+ ).toThrow('Expected a WebSocket server URL to be a valid path but got number')
23
23
  })