msw 2.10.0 → 2.10.1

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.
@@ -7,7 +7,7 @@
7
7
  * - Please do NOT modify this file.
8
8
  */
9
9
 
10
- const PACKAGE_VERSION = '2.10.0'
10
+ const PACKAGE_VERSION = '2.10.1'
11
11
  const INTEGRITY_CHECKSUM = 'f5825c521429caf22a4dd13b66e243af'
12
12
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
13
13
  const activeClientIds = new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "type": "commonjs",
6
6
  "main": "./lib/core/index.js",
@@ -218,7 +218,7 @@
218
218
  "@bundled-es-modules/statuses": "^1.0.1",
219
219
  "@bundled-es-modules/tough-cookie": "^0.1.6",
220
220
  "@inquirer/confirm": "^5.0.0",
221
- "@mswjs/interceptors": "^0.38.7",
221
+ "@mswjs/interceptors": "^0.39.1",
222
222
  "@open-draft/deferred-promise": "^2.2.0",
223
223
  "@open-draft/until": "^2.1.0",
224
224
  "@types/cookie": "^0.6.0",
@@ -280,7 +280,7 @@
280
280
  "vitest-environment-miniflare": "^2.14.4",
281
281
  "webpack": "^5.95.0",
282
282
  "webpack-http-server": "^0.5.0",
283
- "msw": "2.10.0"
283
+ "msw": "2.10.1"
284
284
  },
285
285
  "peerDependencies": {
286
286
  "typescript": ">= 4.8.x"
@@ -1,6 +1,10 @@
1
1
  import { Emitter } from 'strict-event-emitter'
2
2
  import { createRequestId } from '@mswjs/interceptors'
3
- import type { WebSocketConnectionData } from '@mswjs/interceptors/WebSocket'
3
+ import type {
4
+ WebSocketClientConnectionProtocol,
5
+ WebSocketConnectionData,
6
+ WebSocketServerConnectionProtocol,
7
+ } from '@mswjs/interceptors/WebSocket'
4
8
  import {
5
9
  type Match,
6
10
  type Path,
@@ -18,7 +22,10 @@ export type WebSocketHandlerEventMap = {
18
22
  connection: [args: WebSocketHandlerConnection]
19
23
  }
20
24
 
21
- export interface WebSocketHandlerConnection extends WebSocketConnectionData {
25
+ export interface WebSocketHandlerConnection {
26
+ client: WebSocketClientConnectionProtocol
27
+ server: WebSocketServerConnectionProtocol
28
+ info: WebSocketConnectionData['info']
22
29
  params: PathParams
23
30
  }
24
31
 
@@ -67,7 +74,9 @@ export class WebSocketHandler {
67
74
  return args.parsedResult.match.matches
68
75
  }
69
76
 
70
- public async run(connection: WebSocketConnectionData): Promise<boolean> {
77
+ public async run(
78
+ connection: Omit<WebSocketHandlerConnection, 'params'>,
79
+ ): Promise<boolean> {
71
80
  const parsedResult = this.parse({
72
81
  url: connection.client.url,
73
82
  })
@@ -1,7 +1,7 @@
1
1
  import type {
2
2
  WebSocketData,
3
- WebSocketClientConnection,
4
3
  WebSocketClientConnectionProtocol,
4
+ WebSocketClientEventMap,
5
5
  } from '@mswjs/interceptors/WebSocket'
6
6
  import { WebSocketClientStore } from './WebSocketClientStore'
7
7
  import { WebSocketMemoryClientStore } from './WebSocketMemoryClientStore'
@@ -105,7 +105,9 @@ export class WebSocketClientManager {
105
105
  this.channel.postMessage({ type: 'db:update' })
106
106
  }
107
107
 
108
- private async addClient(client: WebSocketClientConnection): Promise<void> {
108
+ private async addClient(
109
+ client: WebSocketClientConnectionProtocol,
110
+ ): Promise<void> {
109
111
  await this.store.add(client)
110
112
  // Sync the in-memory clients in this runtime with the
111
113
  // updated database. This pulls in all the stored clients.
@@ -119,7 +121,9 @@ export class WebSocketClientManager {
119
121
  * connection object because `addConnection()` is called only
120
122
  * for the opened connections in the same runtime.
121
123
  */
122
- public async addConnection(client: WebSocketClientConnection): Promise<void> {
124
+ public async addConnection(
125
+ client: WebSocketClientConnectionProtocol,
126
+ ): Promise<void> {
123
127
  // Store this client in the map of clients created in this runtime.
124
128
  // This way, the manager can distinguish between this runtime clients
125
129
  // and extraneous runtime clients when synchronizing clients storage.
@@ -208,4 +212,30 @@ export class WebSocketRemoteClientConnection
208
212
  },
209
213
  } as WebSocketBroadcastChannelMessage)
210
214
  }
215
+
216
+ addEventListener<EventType extends keyof WebSocketClientEventMap>(
217
+ _type: EventType,
218
+ _listener: (
219
+ this: WebSocket,
220
+ event: WebSocketClientEventMap[EventType],
221
+ ) => void,
222
+ _options?: AddEventListenerOptions | boolean,
223
+ ): void {
224
+ throw new Error(
225
+ 'WebSocketRemoteClientConnection.addEventListener is not supported',
226
+ )
227
+ }
228
+
229
+ removeEventListener<EventType extends keyof WebSocketClientEventMap>(
230
+ _event: EventType,
231
+ _listener: (
232
+ this: WebSocket,
233
+ event: WebSocketClientEventMap[EventType],
234
+ ) => void,
235
+ _options?: EventListenerOptions | boolean,
236
+ ): void {
237
+ throw new Error(
238
+ 'WebSocketRemoteClientConnection.removeEventListener is not supported',
239
+ )
240
+ }
211
241
  }