msw 2.10.0 → 2.10.2
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/lib/browser/index.js +8 -8
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +8 -8
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{HttpResponse-DzeJL_i8.d.ts → HttpResponse-CCdkF1fJ.d.ts} +103 -2
- package/lib/core/{HttpResponse-BOGtXZ-B.d.mts → HttpResponse-I457nh8V.d.mts} +103 -2
- package/lib/core/HttpResponse.d.mts +3 -1
- package/lib/core/HttpResponse.d.ts +3 -1
- package/lib/core/HttpResponse.js +5 -1
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs +5 -1
- package/lib/core/HttpResponse.mjs.map +1 -1
- package/lib/core/SetupApi.d.mts +3 -2
- package/lib/core/SetupApi.d.ts +3 -2
- package/lib/core/getResponse.d.mts +3 -1
- package/lib/core/getResponse.d.ts +3 -1
- package/lib/core/graphql.d.mts +1 -2
- package/lib/core/graphql.d.ts +1 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +1 -2
- package/lib/core/handlers/HttpHandler.d.mts +2 -1
- package/lib/core/handlers/HttpHandler.d.ts +2 -1
- package/lib/core/handlers/RequestHandler.d.mts +3 -1
- package/lib/core/handlers/RequestHandler.d.ts +3 -1
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/handlers/WebSocketHandler.d.mts +6 -3
- package/lib/core/handlers/WebSocketHandler.d.ts +6 -3
- package/lib/core/handlers/WebSocketHandler.js.map +1 -1
- package/lib/core/handlers/WebSocketHandler.mjs.map +1 -1
- package/lib/core/http.d.mts +2 -1
- package/lib/core/http.d.ts +2 -1
- package/lib/core/index.d.mts +1 -2
- package/lib/core/index.d.ts +1 -2
- package/lib/core/passthrough.d.mts +3 -1
- package/lib/core/passthrough.d.ts +3 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +3 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +3 -1
- package/lib/core/utils/executeHandlers.d.mts +3 -1
- package/lib/core/utils/executeHandlers.d.ts +3 -1
- package/lib/core/utils/handleRequest.d.mts +3 -1
- package/lib/core/utils/handleRequest.d.ts +3 -1
- package/lib/core/utils/internal/isHandlerKind.d.mts +3 -2
- package/lib/core/utils/internal/isHandlerKind.d.ts +3 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +3 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +3 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +3 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +3 -1
- package/lib/core/ws/WebSocketClientManager.d.mts +4 -2
- package/lib/core/ws/WebSocketClientManager.d.ts +4 -2
- package/lib/core/ws/WebSocketClientManager.js +10 -0
- package/lib/core/ws/WebSocketClientManager.js.map +1 -1
- package/lib/core/ws/WebSocketClientManager.mjs +10 -0
- package/lib/core/ws/WebSocketClientManager.mjs.map +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +3 -2
- package/lib/core/ws/handleWebSocketEvent.d.ts +3 -2
- package/lib/iife/index.js +23 -9
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +3 -3
- package/src/core/HttpResponse.ts +8 -1
- package/src/core/handlers/RequestHandler.ts +17 -2
- package/src/core/handlers/WebSocketHandler.ts +12 -3
- package/src/core/ws/WebSocketClientManager.ts +33 -3
- package/lib/core/GraphQLHandler-DOXAygvT.d.mts +0 -100
- package/lib/core/GraphQLHandler-noP9MRWa.d.ts +0 -100
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n WebSocketClientConnectionProtocol,\n WebSocketClientEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { WebSocketClientStore } from './WebSocketClientStore'\nimport { WebSocketMemoryClientStore } from './WebSocketMemoryClientStore'\nimport { WebSocketIndexedDBClientStore } from './WebSocketIndexedDBClientStore'\n\nexport type WebSocketBroadcastChannelMessage =\n | {\n type: 'extraneous:send'\n payload: {\n clientId: string\n data: WebSocketData\n }\n }\n | {\n type: 'extraneous:close'\n payload: {\n clientId: string\n code?: number\n reason?: string\n }\n }\n\n/**\n * A manager responsible for accumulating WebSocket client\n * connections across different browser runtimes.\n */\nexport class WebSocketClientManager {\n private store: WebSocketClientStore\n private runtimeClients: Map<string, WebSocketClientConnectionProtocol>\n private allClients: Set<WebSocketClientConnectionProtocol>\n\n constructor(private channel: BroadcastChannel) {\n // Store the clients in the IndexedDB in the browser,\n // otherwise, store the clients in memory.\n this.store =\n typeof indexedDB !== 'undefined'\n ? new WebSocketIndexedDBClientStore()\n : new WebSocketMemoryClientStore()\n\n this.runtimeClients = new Map()\n this.allClients = new Set()\n\n this.channel.addEventListener('message', (message) => {\n if (message.data?.type === 'db:update') {\n this.flushDatabaseToMemory()\n }\n })\n\n if (typeof window !== 'undefined') {\n window.addEventListener('message', async (message) => {\n if (message.data?.type === 'msw/worker:stop') {\n await this.removeRuntimeClients()\n }\n })\n }\n }\n\n private async flushDatabaseToMemory() {\n const storedClients = await this.store.getAll()\n\n this.allClients = new Set(\n storedClients.map((client) => {\n const runtimeClient = this.runtimeClients.get(client.id)\n\n /**\n * @note For clients originating in this runtime, use their\n * direct references. No need to wrap them in a remote connection.\n */\n if (runtimeClient) {\n return runtimeClient\n }\n\n return new WebSocketRemoteClientConnection(\n client.id,\n new URL(client.url),\n this.channel,\n )\n }),\n )\n }\n\n private async removeRuntimeClients(): Promise<void> {\n await this.store.deleteMany(Array.from(this.runtimeClients.keys()))\n this.runtimeClients.clear()\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * All active WebSocket client connections.\n */\n get clients(): Set<WebSocketClientConnectionProtocol> {\n return this.allClients\n }\n\n /**\n * Notify other runtimes about the database update\n * using the shared `BroadcastChannel` instance.\n */\n private notifyOthersAboutDatabaseUpdate(): void {\n this.channel.postMessage({ type: 'db:update' })\n }\n\n private async addClient(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n await this.store.add(client)\n // Sync the in-memory clients in this runtime with the\n // updated database. This pulls in all the stored clients.\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * Adds the given `WebSocket` client connection to the set\n * of all connections. The given connection is always the complete\n * connection object because `addConnection()` is called only\n * for the opened connections in the same runtime.\n */\n public async addConnection(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n // Store this client in the map of clients created in this runtime.\n // This way, the manager can distinguish between this runtime clients\n // and extraneous runtime clients when synchronizing clients storage.\n this.runtimeClients.set(client.id, client)\n\n // Add the new client to the storage.\n await this.addClient(client)\n\n // Handle the incoming BroadcastChannel messages from other runtimes\n // that attempt to control this runtime (via a remote connection wrapper).\n // E.g. another runtime calling `client.send()` for the client in this runtime.\n const handleExtraneousMessage = (\n message: MessageEvent<WebSocketBroadcastChannelMessage>,\n ) => {\n const { type, payload } = message.data\n\n // Ignore broadcasted messages for other clients.\n if (\n typeof payload === 'object' &&\n 'clientId' in payload &&\n payload.clientId !== client.id\n ) {\n return\n }\n\n switch (type) {\n case 'extraneous:send': {\n client.send(payload.data)\n break\n }\n\n case 'extraneous:close': {\n client.close(payload.code, payload.reason)\n break\n }\n }\n }\n\n const abortController = new AbortController()\n\n this.channel.addEventListener('message', handleExtraneousMessage, {\n signal: abortController.signal,\n })\n\n // Once closed, this connection cannot be operated on.\n // This must include the extraneous runtimes as well.\n client.addEventListener('close', () => abortController.abort(), {\n once: true,\n })\n }\n}\n\n/**\n * A wrapper class to operate with WebSocket client connections\n * from other runtimes. This class maintains 1-1 public API\n * compatibility to the `WebSocketClientConnection` but relies\n * on the given `BroadcastChannel` to communicate instructions\n * with the client connections from other runtimes.\n */\nexport class WebSocketRemoteClientConnection\n implements WebSocketClientConnectionProtocol\n{\n constructor(\n public readonly id: string,\n public readonly url: URL,\n private channel: BroadcastChannel,\n ) {}\n\n send(data: WebSocketData): void {\n this.channel.postMessage({\n type: 'extraneous:send',\n payload: {\n clientId: this.id,\n data,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n close(code?: number | undefined, reason?: string | undefined): void {\n this.channel.postMessage({\n type: 'extraneous:close',\n payload: {\n clientId: this.id,\n code,\n reason,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n addEventListener<EventType extends keyof WebSocketClientEventMap>(\n _type: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: AddEventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.addEventListener is not supported',\n )\n }\n\n removeEventListener<EventType extends keyof WebSocketClientEventMap>(\n _event: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: EventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.removeEventListener is not supported',\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,wCAA2C;AAC3C,2CAA8C;AAuBvC,MAAM,uBAAuB;AAAA,EAKlC,YAAoB,SAA2B;AAA3B;AAGlB,SAAK,QACH,OAAO,cAAc,cACjB,IAAI,mEAA8B,IAClC,IAAI,6DAA2B;AAErC,SAAK,iBAAiB,oBAAI,IAAI;AAC9B,SAAK,aAAa,oBAAI,IAAI;AAE1B,SAAK,QAAQ,iBAAiB,WAAW,CAAC,YAAY;AACpD,U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,EACF;AACF;","names":[]}
|
|
@@ -121,6 +121,16 @@ class WebSocketRemoteClientConnection {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
+
addEventListener(_type, _listener, _options) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
"WebSocketRemoteClientConnection.addEventListener is not supported"
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
removeEventListener(_event, _listener, _options) {
|
|
130
|
+
throw new Error(
|
|
131
|
+
"WebSocketRemoteClientConnection.removeEventListener is not supported"
|
|
132
|
+
);
|
|
133
|
+
}
|
|
124
134
|
}
|
|
125
135
|
export {
|
|
126
136
|
WebSocketClientManager,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n WebSocketClientConnectionProtocol,\n WebSocketClientEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { WebSocketClientStore } from './WebSocketClientStore'\nimport { WebSocketMemoryClientStore } from './WebSocketMemoryClientStore'\nimport { WebSocketIndexedDBClientStore } from './WebSocketIndexedDBClientStore'\n\nexport type WebSocketBroadcastChannelMessage =\n | {\n type: 'extraneous:send'\n payload: {\n clientId: string\n data: WebSocketData\n }\n }\n | {\n type: 'extraneous:close'\n payload: {\n clientId: string\n code?: number\n reason?: string\n }\n }\n\n/**\n * A manager responsible for accumulating WebSocket client\n * connections across different browser runtimes.\n */\nexport class WebSocketClientManager {\n private store: WebSocketClientStore\n private runtimeClients: Map<string, WebSocketClientConnectionProtocol>\n private allClients: Set<WebSocketClientConnectionProtocol>\n\n constructor(private channel: BroadcastChannel) {\n // Store the clients in the IndexedDB in the browser,\n // otherwise, store the clients in memory.\n this.store =\n typeof indexedDB !== 'undefined'\n ? new WebSocketIndexedDBClientStore()\n : new WebSocketMemoryClientStore()\n\n this.runtimeClients = new Map()\n this.allClients = new Set()\n\n this.channel.addEventListener('message', (message) => {\n if (message.data?.type === 'db:update') {\n this.flushDatabaseToMemory()\n }\n })\n\n if (typeof window !== 'undefined') {\n window.addEventListener('message', async (message) => {\n if (message.data?.type === 'msw/worker:stop') {\n await this.removeRuntimeClients()\n }\n })\n }\n }\n\n private async flushDatabaseToMemory() {\n const storedClients = await this.store.getAll()\n\n this.allClients = new Set(\n storedClients.map((client) => {\n const runtimeClient = this.runtimeClients.get(client.id)\n\n /**\n * @note For clients originating in this runtime, use their\n * direct references. No need to wrap them in a remote connection.\n */\n if (runtimeClient) {\n return runtimeClient\n }\n\n return new WebSocketRemoteClientConnection(\n client.id,\n new URL(client.url),\n this.channel,\n )\n }),\n )\n }\n\n private async removeRuntimeClients(): Promise<void> {\n await this.store.deleteMany(Array.from(this.runtimeClients.keys()))\n this.runtimeClients.clear()\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * All active WebSocket client connections.\n */\n get clients(): Set<WebSocketClientConnectionProtocol> {\n return this.allClients\n }\n\n /**\n * Notify other runtimes about the database update\n * using the shared `BroadcastChannel` instance.\n */\n private notifyOthersAboutDatabaseUpdate(): void {\n this.channel.postMessage({ type: 'db:update' })\n }\n\n private async addClient(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n await this.store.add(client)\n // Sync the in-memory clients in this runtime with the\n // updated database. This pulls in all the stored clients.\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * Adds the given `WebSocket` client connection to the set\n * of all connections. The given connection is always the complete\n * connection object because `addConnection()` is called only\n * for the opened connections in the same runtime.\n */\n public async addConnection(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n // Store this client in the map of clients created in this runtime.\n // This way, the manager can distinguish between this runtime clients\n // and extraneous runtime clients when synchronizing clients storage.\n this.runtimeClients.set(client.id, client)\n\n // Add the new client to the storage.\n await this.addClient(client)\n\n // Handle the incoming BroadcastChannel messages from other runtimes\n // that attempt to control this runtime (via a remote connection wrapper).\n // E.g. another runtime calling `client.send()` for the client in this runtime.\n const handleExtraneousMessage = (\n message: MessageEvent<WebSocketBroadcastChannelMessage>,\n ) => {\n const { type, payload } = message.data\n\n // Ignore broadcasted messages for other clients.\n if (\n typeof payload === 'object' &&\n 'clientId' in payload &&\n payload.clientId !== client.id\n ) {\n return\n }\n\n switch (type) {\n case 'extraneous:send': {\n client.send(payload.data)\n break\n }\n\n case 'extraneous:close': {\n client.close(payload.code, payload.reason)\n break\n }\n }\n }\n\n const abortController = new AbortController()\n\n this.channel.addEventListener('message', handleExtraneousMessage, {\n signal: abortController.signal,\n })\n\n // Once closed, this connection cannot be operated on.\n // This must include the extraneous runtimes as well.\n client.addEventListener('close', () => abortController.abort(), {\n once: true,\n })\n }\n}\n\n/**\n * A wrapper class to operate with WebSocket client connections\n * from other runtimes. This class maintains 1-1 public API\n * compatibility to the `WebSocketClientConnection` but relies\n * on the given `BroadcastChannel` to communicate instructions\n * with the client connections from other runtimes.\n */\nexport class WebSocketRemoteClientConnection\n implements WebSocketClientConnectionProtocol\n{\n constructor(\n public readonly id: string,\n public readonly url: URL,\n private channel: BroadcastChannel,\n ) {}\n\n send(data: WebSocketData): void {\n this.channel.postMessage({\n type: 'extraneous:send',\n payload: {\n clientId: this.id,\n data,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n close(code?: number | undefined, reason?: string | undefined): void {\n this.channel.postMessage({\n type: 'extraneous:close',\n payload: {\n clientId: this.id,\n code,\n reason,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n addEventListener<EventType extends keyof WebSocketClientEventMap>(\n _type: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: AddEventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.addEventListener is not supported',\n )\n }\n\n removeEventListener<EventType extends keyof WebSocketClientEventMap>(\n _event: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: EventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.removeEventListener is not supported',\n )\n }\n}\n"],"mappings":"AAMA,SAAS,kCAAkC;AAC3C,SAAS,qCAAqC;AAuBvC,MAAM,uBAAuB;AAAA,EAKlC,YAAoB,SAA2B;AAA3B;AAGlB,SAAK,QACH,OAAO,cAAc,cACjB,IAAI,8BAA8B,IAClC,IAAI,2BAA2B;AAErC,SAAK,iBAAiB,oBAAI,IAAI;AAC9B,SAAK,aAAa,oBAAI,IAAI;AAE1B,SAAK,QAAQ,iBAAiB,WAAW,CAAC,YAAY;AACpD,UAAI,QAAQ,MAAM,SAAS,aAAa;AACtC,aAAK,sBAAsB;AAAA,MAC7B;AAAA,IACF,CAAC;AAED,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO,iBAAiB,WAAW,OAAO,YAAY;AACpD,YAAI,QAAQ,MAAM,SAAS,mBAAmB;AAC5C,gBAAM,KAAK,qBAAqB;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EA5BQ;AAAA,EACA;AAAA,EACA;AAAA,EA4BR,MAAc,wBAAwB;AACpC,UAAM,gBAAgB,MAAM,KAAK,MAAM,OAAO;AAE9C,SAAK,aAAa,IAAI;AAAA,MACpB,cAAc,IAAI,CAAC,WAAW;AAC5B,cAAM,gBAAgB,KAAK,eAAe,IAAI,OAAO,EAAE;AAMvD,YAAI,eAAe;AACjB,iBAAO;AAAA,QACT;AAEA,eAAO,IAAI;AAAA,UACT,OAAO;AAAA,UACP,IAAI,IAAI,OAAO,GAAG;AAAA,UAClB,KAAK;AAAA,QACP;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,MAAc,uBAAsC;AAClD,UAAM,KAAK,MAAM,WAAW,MAAM,KAAK,KAAK,eAAe,KAAK,CAAC,CAAC;AAClE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AAQ,YAAY;AAAA,MACvB,MAAM;AAAA,MACN,SAAS;AAAA,QACP,UAAU,KAAK;AAAA,QACf;AAAA,MACF;AAAA,IACF,CAAqC;AAAA,EACvC;AAAA,EAEA,MAAM,MAA2B,QAAmC;AAClE,SAAK,QAAQ,YAAY;AAAA,MACvB,MAAM;AAAA,MACN,SAAS;AAAA,QACP,UAAU,KAAK;AAAA,QACf;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAqC;AAAA,EACvC;AAAA,EAEA,iBACE,OACA,WAIA,UACM;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEA,oBACE,QACA,WAIA,UACM;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-I457nh8V.mjs';
|
|
3
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.mjs';
|
|
4
4
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.mjs';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../utils/internal/isIterable.mjs';
|
|
7
7
|
import '../typeUtils.mjs';
|
|
8
|
+
import 'graphql';
|
|
9
|
+
import '../utils/matching/matchRequestUrl.mjs';
|
|
8
10
|
import 'strict-event-emitter';
|
|
9
11
|
import '@mswjs/interceptors/WebSocket';
|
|
10
|
-
import '../utils/matching/matchRequestUrl.mjs';
|
|
11
12
|
|
|
12
13
|
interface HandleWebSocketEventOptions {
|
|
13
14
|
getUnhandledRequestStrategy: () => UnhandledRequestStrategy;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-CCdkF1fJ.js';
|
|
3
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.js';
|
|
4
4
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.js';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
6
6
|
import '../utils/internal/isIterable.js';
|
|
7
7
|
import '../typeUtils.js';
|
|
8
|
+
import 'graphql';
|
|
9
|
+
import '../utils/matching/matchRequestUrl.js';
|
|
8
10
|
import 'strict-event-emitter';
|
|
9
11
|
import '@mswjs/interceptors/WebSocket';
|
|
10
|
-
import '../utils/matching/matchRequestUrl.js';
|
|
11
12
|
|
|
12
13
|
interface HandleWebSocketEventOptions {
|
|
13
14
|
getUnhandledRequestStrategy: () => UnhandledRequestStrategy;
|
package/lib/iife/index.js
CHANGED
|
@@ -13126,6 +13126,7 @@ ${operationTypes.join("\n")}
|
|
|
13126
13126
|
SetupApi: () => SetupApi,
|
|
13127
13127
|
SetupWorkerApi: () => SetupWorkerApi,
|
|
13128
13128
|
WebSocketHandler: () => WebSocketHandler,
|
|
13129
|
+
bodyType: () => bodyType,
|
|
13129
13130
|
bypass: () => bypass,
|
|
13130
13131
|
cleanUrl: () => cleanUrl,
|
|
13131
13132
|
delay: () => delay,
|
|
@@ -14246,7 +14247,7 @@ ${operationTypes.join("\n")}
|
|
|
14246
14247
|
return stringToRegexp(path, keys, options);
|
|
14247
14248
|
}
|
|
14248
14249
|
|
|
14249
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14250
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
14250
14251
|
var encoder = new TextEncoder();
|
|
14251
14252
|
function encodeBuffer(text) {
|
|
14252
14253
|
return encoder.encode(text);
|
|
@@ -14262,7 +14263,7 @@ ${operationTypes.join("\n")}
|
|
|
14262
14263
|
);
|
|
14263
14264
|
}
|
|
14264
14265
|
|
|
14265
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14266
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-3RXCRGL2.mjs
|
|
14266
14267
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
14267
14268
|
function canParseUrl(url) {
|
|
14268
14269
|
try {
|
|
@@ -14643,7 +14644,7 @@ ${operationTypes.join("\n")}
|
|
|
14643
14644
|
return message3.toString();
|
|
14644
14645
|
}
|
|
14645
14646
|
|
|
14646
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14647
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
|
14647
14648
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
14648
14649
|
function getGlobalSymbol(symbol) {
|
|
14649
14650
|
return (
|
|
@@ -14791,7 +14792,7 @@ ${operationTypes.join("\n")}
|
|
|
14791
14792
|
return Math.random().toString(16).slice(2);
|
|
14792
14793
|
}
|
|
14793
14794
|
|
|
14794
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14795
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
14795
14796
|
var BatchInterceptor = class extends Interceptor {
|
|
14796
14797
|
constructor(options) {
|
|
14797
14798
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -28450,6 +28451,16 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
28450
28451
|
}
|
|
28451
28452
|
});
|
|
28452
28453
|
}
|
|
28454
|
+
addEventListener(_type, _listener, _options) {
|
|
28455
|
+
throw new Error(
|
|
28456
|
+
"WebSocketRemoteClientConnection.addEventListener is not supported"
|
|
28457
|
+
);
|
|
28458
|
+
}
|
|
28459
|
+
removeEventListener(_event, _listener, _options) {
|
|
28460
|
+
throw new Error(
|
|
28461
|
+
"WebSocketRemoteClientConnection.removeEventListener is not supported"
|
|
28462
|
+
);
|
|
28463
|
+
}
|
|
28453
28464
|
};
|
|
28454
28465
|
|
|
28455
28466
|
// src/core/ws.ts
|
|
@@ -28726,6 +28737,9 @@ Read more: https://mswjs.io/docs/http/intercepting-requests`;
|
|
|
28726
28737
|
super(body, responseInit);
|
|
28727
28738
|
decorateResponse(this, responseInit);
|
|
28728
28739
|
}
|
|
28740
|
+
static error() {
|
|
28741
|
+
return super.error();
|
|
28742
|
+
}
|
|
28729
28743
|
/**
|
|
28730
28744
|
* Create a `Response` with a `Content-Type: "text/plain"` body.
|
|
28731
28745
|
* @example
|
|
@@ -29361,7 +29375,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29361
29375
|
}
|
|
29362
29376
|
};
|
|
29363
29377
|
|
|
29364
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29378
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-L37TY7LC.mjs
|
|
29365
29379
|
var InterceptorError = class extends Error {
|
|
29366
29380
|
constructor(message3) {
|
|
29367
29381
|
super(message3);
|
|
@@ -29578,7 +29592,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29578
29592
|
return false;
|
|
29579
29593
|
}
|
|
29580
29594
|
|
|
29581
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29595
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-TX5GBTFY.mjs
|
|
29582
29596
|
function hasConfigurableGlobal(propertyName) {
|
|
29583
29597
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
|
29584
29598
|
if (typeof descriptor === "undefined") {
|
|
@@ -29599,7 +29613,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29599
29613
|
return true;
|
|
29600
29614
|
}
|
|
29601
29615
|
|
|
29602
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29616
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-ARPHZXGT.mjs
|
|
29603
29617
|
function createNetworkError(cause) {
|
|
29604
29618
|
return Object.assign(new TypeError("Failed to fetch"), {
|
|
29605
29619
|
cause
|
|
@@ -29855,7 +29869,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29855
29869
|
var FetchInterceptor = _FetchInterceptor;
|
|
29856
29870
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
29857
29871
|
|
|
29858
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29872
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-QKSBFQDK.mjs
|
|
29859
29873
|
function concatArrayBuffer(left, right) {
|
|
29860
29874
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
29861
29875
|
result.set(left, 0);
|
|
@@ -30728,7 +30742,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
30728
30742
|
}
|
|
30729
30743
|
}
|
|
30730
30744
|
|
|
30731
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
30745
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
|
|
30732
30746
|
function bindEvent(target, event) {
|
|
30733
30747
|
Object.defineProperties(event, {
|
|
30734
30748
|
target: {
|