msw 2.3.0-ws.rc-1 → 2.3.0-ws.rc-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/README.md +8 -3
- package/cli/init.js +1 -1
- package/lib/browser/index.d.mts +4 -4
- package/lib/browser/index.js +64 -59
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +64 -59
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{GraphQLHandler-Cbu12sb0.d.ts → GraphQLHandler-3gvpA65n.d.ts} +3 -3
- package/lib/core/{GraphQLHandler-QGQY_9Rc.d.mts → GraphQLHandler-4DPdxG0R.d.mts} +3 -3
- package/lib/core/{HttpResponse-BWB1yDNM.d.mts → HttpResponse-aJY-D0oG.d.ts} +3 -3
- package/lib/core/{HttpResponse-DeJBWGN5.d.ts → HttpResponse-xuSipbNt.d.mts} +3 -3
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs.map +1 -1
- package/lib/core/SetupApi.d.mts +1 -1
- package/lib/core/SetupApi.d.ts +1 -1
- package/lib/core/bypass.js +6 -1
- package/lib/core/bypass.js.map +1 -1
- package/lib/core/bypass.mjs +6 -1
- package/lib/core/bypass.mjs.map +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/getResponse.js +2 -2
- package/lib/core/getResponse.js.map +1 -1
- package/lib/core/getResponse.mjs +2 -2
- package/lib/core/getResponse.mjs.map +1 -1
- package/lib/core/graphql.d.mts +8 -6
- package/lib/core/graphql.d.ts +8 -6
- package/lib/core/graphql.js.map +1 -1
- package/lib/core/graphql.mjs.map +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.js.map +1 -1
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/HttpHandler.js +1 -1
- package/lib/core/handlers/HttpHandler.js.map +1 -1
- package/lib/core/handlers/HttpHandler.mjs +1 -1
- package/lib/core/handlers/HttpHandler.mjs.map +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/handlers/WebSocketHandler.d.mts +11 -17
- package/lib/core/handlers/WebSocketHandler.d.ts +11 -17
- package/lib/core/handlers/WebSocketHandler.js +9 -12
- package/lib/core/handlers/WebSocketHandler.js.map +1 -1
- package/lib/core/handlers/WebSocketHandler.mjs +9 -12
- package/lib/core/handlers/WebSocketHandler.mjs.map +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +4 -4
- package/lib/core/index.d.ts +4 -4
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +4 -0
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/typeUtils.d.mts +6 -1
- package/lib/core/typeUtils.d.ts +6 -1
- package/lib/core/typeUtils.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
- package/lib/core/utils/HttpResponse/decorators.js +4 -1
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +4 -1
- package/lib/core/utils/HttpResponse/decorators.mjs.map +1 -1
- package/lib/core/utils/executeHandlers.d.mts +1 -1
- package/lib/core/utils/executeHandlers.d.ts +1 -1
- package/lib/core/utils/handleRequest.d.mts +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/handleRequest.js.map +1 -1
- package/lib/core/utils/handleRequest.mjs.map +1 -1
- package/lib/core/utils/handleWebSocketEvent.d.mts +8 -2
- package/lib/core/utils/handleWebSocketEvent.d.ts +8 -2
- package/lib/core/utils/handleWebSocketEvent.js +20 -17
- package/lib/core/utils/handleWebSocketEvent.js.map +1 -1
- package/lib/core/utils/handleWebSocketEvent.mjs +21 -22
- package/lib/core/utils/handleWebSocketEvent.mjs.map +1 -1
- package/lib/core/utils/internal/mergeRight.js +15 -12
- package/lib/core/utils/internal/mergeRight.js.map +1 -1
- package/lib/core/utils/internal/mergeRight.mjs +15 -12
- package/lib/core/utils/internal/mergeRight.mjs.map +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
- package/lib/core/utils/logging/getTimestamp.d.mts +4 -1
- package/lib/core/utils/logging/getTimestamp.d.ts +4 -1
- package/lib/core/utils/logging/getTimestamp.js +6 -2
- package/lib/core/utils/logging/getTimestamp.js.map +1 -1
- package/lib/core/utils/logging/getTimestamp.mjs +6 -2
- package/lib/core/utils/logging/getTimestamp.mjs.map +1 -1
- package/lib/core/ws/utils/attachWebSocketLogger.d.mts +34 -0
- package/lib/core/ws/utils/attachWebSocketLogger.d.ts +34 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js +211 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js.map +1 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs +191 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +1 -0
- package/lib/core/ws/utils/getMessageLength.d.mts +11 -0
- package/lib/core/ws/utils/getMessageLength.d.ts +11 -0
- package/lib/core/ws/utils/getMessageLength.js +33 -0
- package/lib/core/ws/utils/getMessageLength.js.map +1 -0
- package/lib/core/ws/utils/getMessageLength.mjs +13 -0
- package/lib/core/ws/utils/getMessageLength.mjs.map +1 -0
- package/lib/core/ws/utils/getPublicData.d.mts +5 -0
- package/lib/core/ws/utils/getPublicData.d.ts +5 -0
- package/lib/core/ws/utils/getPublicData.js +36 -0
- package/lib/core/ws/utils/getPublicData.js.map +1 -0
- package/lib/core/ws/utils/getPublicData.mjs +16 -0
- package/lib/core/ws/utils/getPublicData.mjs.map +1 -0
- package/lib/core/ws/utils/truncateMessage.d.mts +3 -0
- package/lib/core/ws/utils/truncateMessage.d.ts +3 -0
- package/lib/core/{utils/internal/randomId.js → ws/utils/truncateMessage.js} +11 -7
- package/lib/core/ws/utils/truncateMessage.js.map +1 -0
- package/lib/core/ws/utils/truncateMessage.mjs +11 -0
- package/lib/core/ws/utils/truncateMessage.mjs.map +1 -0
- package/lib/iife/index.js +508 -231
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +8 -11
- package/lib/native/index.d.mts +4 -4
- package/lib/native/index.js +8 -2
- package/lib/native/index.js.map +1 -1
- package/lib/native/index.mjs +8 -2
- package/lib/native/index.mjs.map +1 -1
- package/lib/node/index.d.mts +6 -6
- package/lib/node/index.d.ts +2 -2
- package/lib/node/index.js +8 -2
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +8 -2
- package/lib/node/index.mjs.map +1 -1
- package/package.json +8 -11
- package/src/browser/setupWorker/glossary.ts +4 -1
- package/src/browser/setupWorker/setupWorker.ts +19 -2
- package/src/browser/setupWorker/start/createRequestListener.ts +1 -1
- package/src/browser/setupWorker/start/createStartHandler.ts +9 -19
- package/src/browser/setupWorker/start/utils/createMessageChannel.ts +1 -1
- package/src/browser/utils/checkWorkerIntegrity.ts +34 -0
- package/src/core/HttpResponse.ts +3 -2
- package/src/core/bypass.test.ts +22 -0
- package/src/core/bypass.ts +9 -1
- package/src/core/getResponse.ts +2 -2
- package/src/core/graphql.ts +6 -3
- package/src/core/handlers/GraphQLHandler.test.ts +4 -5
- package/src/core/handlers/GraphQLHandler.ts +7 -4
- package/src/core/handlers/HttpHandler.test.ts +5 -5
- package/src/core/handlers/HttpHandler.ts +1 -1
- package/src/core/handlers/WebSocketHandler.ts +21 -39
- package/src/core/index.ts +6 -2
- package/src/core/typeUtils.ts +16 -10
- package/src/core/utils/HttpResponse/decorators.ts +8 -4
- package/src/core/utils/handleRequest.test.ts +14 -14
- package/src/core/utils/handleRequest.ts +1 -1
- package/src/core/utils/handleWebSocketEvent.ts +39 -29
- package/src/core/utils/internal/mergeRight.ts +16 -13
- package/src/core/utils/logging/getTimestamp.test.ts +20 -6
- package/src/core/utils/logging/getTimestamp.ts +11 -6
- package/src/core/ws/utils/attachWebSocketLogger.ts +262 -0
- package/src/core/ws/utils/getMessageLength.test.ts +16 -0
- package/src/core/ws/utils/getMessageLength.ts +19 -0
- package/src/core/ws/utils/getPublicData.test.ts +38 -0
- package/src/core/ws/utils/getPublicData.ts +17 -0
- package/src/core/ws/utils/truncateMessage.test.ts +12 -0
- package/src/core/ws/utils/truncateMessage.ts +9 -0
- package/src/mockServiceWorker.js +7 -10
- package/src/node/SetupServerApi.ts +4 -4
- package/src/node/SetupServerCommonApi.ts +6 -2
- package/src/node/glossary.ts +3 -3
- package/lib/core/utils/internal/randomId.d.mts +0 -3
- package/lib/core/utils/internal/randomId.d.ts +0 -3
- package/lib/core/utils/internal/randomId.js.map +0 -1
- package/lib/core/utils/internal/randomId.mjs +0 -7
- package/lib/core/utils/internal/randomId.mjs.map +0 -1
- package/src/browser/utils/requestIntegrityCheck.ts +0 -23
- package/src/core/utils/internal/randomId.ts +0 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import statuses from "@bundled-es-modules/statuses";
|
|
2
|
+
import { Headers as HeadersPolyfill } from "headers-polyfill";
|
|
2
3
|
const { message } = statuses;
|
|
3
4
|
function normalizeResponseInit(init = {}) {
|
|
4
5
|
const status = init?.status || 200;
|
|
@@ -20,7 +21,9 @@ function decorateResponse(response, init) {
|
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
if (typeof document !== "undefined") {
|
|
23
|
-
const responseCookies =
|
|
24
|
+
const responseCookies = HeadersPolyfill.prototype.getSetCookie.call(
|
|
25
|
+
init.headers
|
|
26
|
+
);
|
|
24
27
|
for (const cookieString of responseCookies) {
|
|
25
28
|
document.cookie = cookieString;
|
|
26
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow to mock the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n // Cookie forwarding is only relevant in the browser.\n if (typeof document !== 'undefined') {\n // Write the mocked response cookies to the document.\n //
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '@bundled-es-modules/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\nimport { Headers as HeadersPolyfill } from 'headers-polyfill'\n\nconst { message } = statuses\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow to mock the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n // Cookie forwarding is only relevant in the browser.\n if (typeof document !== 'undefined') {\n // Write the mocked response cookies to the document.\n // Use `headers-polyfill` to get the Set-Cookie header value correctly.\n // This is an alternative until TypeScript 5.2\n // and Node.js v20 become the minimum supported version\n // and getSetCookie in Headers can be used directly.\n const responseCookies = HeadersPolyfill.prototype.getSetCookie.call(\n init.headers,\n )\n\n for (const cookieString of responseCookies) {\n // No need to parse the cookie headers because it's defined\n // as the valid cookie string to begin with.\n document.cookie = cookieString\n }\n }\n\n return response\n}\n"],"mappings":"AAAA,OAAO,cAAc;AAErB,SAAS,WAAW,uBAAuB;AAE3C,MAAM,EAAE,QAAQ,IAAI;AAQb,SAAS,sBACd,OAAyB,CAAC,GACC;AAC3B,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,aAAa,MAAM,cAAc,QAAQ,MAAM,KAAK;AAC1D,QAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;AAEzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,iBACd,UACA,MACU;AAEV,MAAI,KAAK,MAAM;AACb,WAAO,eAAe,UAAU,QAAQ;AAAA,MACtC,OAAO,KAAK;AAAA,MACZ,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAGA,MAAI,OAAO,aAAa,aAAa;AAMnC,UAAM,kBAAkB,gBAAgB,UAAU,aAAa;AAAA,MAC7D,KAAK;AAAA,IACP;AAEA,eAAW,gBAAgB,iBAAiB;AAG1C,eAAS,SAAS;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { g as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-
|
|
1
|
+
export { g as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-xuSipbNt.mjs';
|
|
2
2
|
import '../typeUtils.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { g as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-
|
|
1
|
+
export { g as HandlersExecutionResult, i as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-aJY-D0oG.js';
|
|
2
2
|
import '../typeUtils.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
2
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.mjs';
|
|
3
3
|
import { RequiredDeep } from '../typeUtils.mjs';
|
|
4
|
-
import { g as HandlersExecutionResult } from '../HttpResponse-
|
|
4
|
+
import { g as HandlersExecutionResult } from '../HttpResponse-xuSipbNt.mjs';
|
|
5
5
|
import './request/onUnhandledRequest.mjs';
|
|
6
6
|
|
|
7
7
|
interface HandleRequestOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
2
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.js';
|
|
3
3
|
import { RequiredDeep } from '../typeUtils.js';
|
|
4
|
-
import { g as HandlersExecutionResult } from '../HttpResponse-
|
|
4
|
+
import { g as HandlersExecutionResult } from '../HttpResponse-aJY-D0oG.js';
|
|
5
5
|
import './request/onUnhandledRequest.js';
|
|
6
6
|
|
|
7
7
|
interface HandleRequestOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { readResponseCookies } from './request/readResponseCookies'\n\nexport interface HandleRequestOptions {\n /**\n * `resolutionContext` is not part of the general public api\n * but is exposed to aid in creating extensions like\n * `@mswjs/http-middleware`.\n */\n resolutionContext?: {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n }\n\n /**\n * Transforms a `MockedResponse` instance returned from a handler\n * to a response instance supported by the lower tooling (i.e. interceptors).\n */\n transformResponse?(response: Response): Response\n\n /**\n * Invoked whenever a request is performed as-is.\n */\n onPassthroughResponse?(request: Request): void\n\n /**\n * Invoked when the mocked response is ready to be sent.\n */\n onMockedResponse?(\n response: Response,\n handler: RequiredDeep<HandlersExecutionResult>,\n ): void\n}\n\nexport async function handleRequest(\n request: Request,\n requestId: string,\n handlers: Array<unknown>,\n options: RequiredDeep<SharedOptions>,\n emitter: Emitter<LifeCycleEventsMap>,\n handleRequestOptions?: HandleRequestOptions,\n): Promise<Response | undefined> {\n emitter.emit('request:start', { request, requestId })\n\n // Perform bypassed requests (i.e.
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { readResponseCookies } from './request/readResponseCookies'\n\nexport interface HandleRequestOptions {\n /**\n * `resolutionContext` is not part of the general public api\n * but is exposed to aid in creating extensions like\n * `@mswjs/http-middleware`.\n */\n resolutionContext?: {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n }\n\n /**\n * Transforms a `MockedResponse` instance returned from a handler\n * to a response instance supported by the lower tooling (i.e. interceptors).\n */\n transformResponse?(response: Response): Response\n\n /**\n * Invoked whenever a request is performed as-is.\n */\n onPassthroughResponse?(request: Request): void\n\n /**\n * Invoked when the mocked response is ready to be sent.\n */\n onMockedResponse?(\n response: Response,\n handler: RequiredDeep<HandlersExecutionResult>,\n ): void\n}\n\nexport async function handleRequest(\n request: Request,\n requestId: string,\n handlers: Array<unknown>,\n options: RequiredDeep<SharedOptions>,\n emitter: Emitter<LifeCycleEventsMap>,\n handleRequestOptions?: HandleRequestOptions,\n): Promise<Response | undefined> {\n emitter.emit('request:start', { request, requestId })\n\n // Perform bypassed requests (i.e. wrapped in \"bypass()\") as-is.\n if (request.headers.get('x-msw-intention') === 'bypass') {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Resolve a mocked response from the list of request handlers.\n const lookupResult = await until(() => {\n return executeHandlers({\n request,\n requestId,\n handlers,\n resolutionContext: handleRequestOptions?.resolutionContext,\n })\n })\n\n if (lookupResult.error) {\n // Allow developers to react to unhandled exceptions in request handlers.\n emitter.emit('unhandledException', {\n error: lookupResult.error,\n request,\n requestId,\n })\n throw lookupResult.error\n }\n\n // If the handler lookup returned nothing, no request handler was found\n // matching this request. Report the request as unhandled.\n if (!lookupResult.data) {\n await onUnhandledRequest(request, options.onUnhandledRequest)\n emitter.emit('request:unhandled', { request, requestId })\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n const { response } = lookupResult.data\n\n // When the handled request returned no mocked response, warn the developer,\n // as it may be an oversight on their part. Perform the request as-is.\n if (!response) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Perform the request as-is when the developer explicitly returned \"req.passthrough()\".\n // This produces no warning as the request was handled.\n if (\n response.status === 302 &&\n response.headers.get('x-msw-intention') === 'passthrough'\n ) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Store all the received response cookies in the virtual cookie store.\n readResponseCookies(request, response)\n\n emitter.emit('request:match', { request, requestId })\n\n const requiredLookupResult =\n lookupResult.data as RequiredDeep<HandlersExecutionResult>\n\n const transformedResponse =\n handleRequestOptions?.transformResponse?.(response) ||\n (response as any as Response)\n\n handleRequestOptions?.onMockedResponse?.(\n transformedResponse,\n requiredLookupResult,\n )\n\n emitter.emit('request:end', { request, requestId })\n\n return transformedResponse\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AAItB,6BAAyD;AACzD,gCAAmC;AACnC,iCAAoC;AAqCpC,eAAsB,cACpB,SACA,WACA,UACA,SACA,SACA,sBAC+B;AAC/B,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAGpD,MAAI,QAAQ,QAAQ,IAAI,iBAAiB,MAAM,UAAU;AACvD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,QAAM,eAAe,UAAM,oBAAM,MAAM;AACrC,eAAO,wCAAgB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,sBAAsB;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AAED,MAAI,aAAa,OAAO;AAEtB,YAAQ,KAAK,sBAAsB;AAAA,MACjC,OAAO,aAAa;AAAA,MACpB;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa;AAAA,EACrB;AAIA,MAAI,CAAC,aAAa,MAAM;AACtB,cAAM,8CAAmB,SAAS,QAAQ,kBAAkB;AAC5D,YAAQ,KAAK,qBAAqB,EAAE,SAAS,UAAU,CAAC;AACxD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,IAAI,aAAa;AAIlC,MAAI,CAAC,UAAU;AACb,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAIA,MACE,SAAS,WAAW,OACpB,SAAS,QAAQ,IAAI,iBAAiB,MAAM,eAC5C;AACA,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,sDAAoB,SAAS,QAAQ;AAErC,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAEpD,QAAM,uBACJ,aAAa;AAEf,QAAM,sBACJ,sBAAsB,oBAAoB,QAAQ,KACjD;AAEH,wBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAEA,UAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAElD,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { readResponseCookies } from './request/readResponseCookies'\n\nexport interface HandleRequestOptions {\n /**\n * `resolutionContext` is not part of the general public api\n * but is exposed to aid in creating extensions like\n * `@mswjs/http-middleware`.\n */\n resolutionContext?: {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n }\n\n /**\n * Transforms a `MockedResponse` instance returned from a handler\n * to a response instance supported by the lower tooling (i.e. interceptors).\n */\n transformResponse?(response: Response): Response\n\n /**\n * Invoked whenever a request is performed as-is.\n */\n onPassthroughResponse?(request: Request): void\n\n /**\n * Invoked when the mocked response is ready to be sent.\n */\n onMockedResponse?(\n response: Response,\n handler: RequiredDeep<HandlersExecutionResult>,\n ): void\n}\n\nexport async function handleRequest(\n request: Request,\n requestId: string,\n handlers: Array<unknown>,\n options: RequiredDeep<SharedOptions>,\n emitter: Emitter<LifeCycleEventsMap>,\n handleRequestOptions?: HandleRequestOptions,\n): Promise<Response | undefined> {\n emitter.emit('request:start', { request, requestId })\n\n // Perform bypassed requests (i.e.
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleRequest.ts"],"sourcesContent":["import { until } from '@open-draft/until'\nimport { Emitter } from 'strict-event-emitter'\nimport { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'\nimport { RequiredDeep } from '../typeUtils'\nimport { HandlersExecutionResult, executeHandlers } from './executeHandlers'\nimport { onUnhandledRequest } from './request/onUnhandledRequest'\nimport { readResponseCookies } from './request/readResponseCookies'\n\nexport interface HandleRequestOptions {\n /**\n * `resolutionContext` is not part of the general public api\n * but is exposed to aid in creating extensions like\n * `@mswjs/http-middleware`.\n */\n resolutionContext?: {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n }\n\n /**\n * Transforms a `MockedResponse` instance returned from a handler\n * to a response instance supported by the lower tooling (i.e. interceptors).\n */\n transformResponse?(response: Response): Response\n\n /**\n * Invoked whenever a request is performed as-is.\n */\n onPassthroughResponse?(request: Request): void\n\n /**\n * Invoked when the mocked response is ready to be sent.\n */\n onMockedResponse?(\n response: Response,\n handler: RequiredDeep<HandlersExecutionResult>,\n ): void\n}\n\nexport async function handleRequest(\n request: Request,\n requestId: string,\n handlers: Array<unknown>,\n options: RequiredDeep<SharedOptions>,\n emitter: Emitter<LifeCycleEventsMap>,\n handleRequestOptions?: HandleRequestOptions,\n): Promise<Response | undefined> {\n emitter.emit('request:start', { request, requestId })\n\n // Perform bypassed requests (i.e. wrapped in \"bypass()\") as-is.\n if (request.headers.get('x-msw-intention') === 'bypass') {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Resolve a mocked response from the list of request handlers.\n const lookupResult = await until(() => {\n return executeHandlers({\n request,\n requestId,\n handlers,\n resolutionContext: handleRequestOptions?.resolutionContext,\n })\n })\n\n if (lookupResult.error) {\n // Allow developers to react to unhandled exceptions in request handlers.\n emitter.emit('unhandledException', {\n error: lookupResult.error,\n request,\n requestId,\n })\n throw lookupResult.error\n }\n\n // If the handler lookup returned nothing, no request handler was found\n // matching this request. Report the request as unhandled.\n if (!lookupResult.data) {\n await onUnhandledRequest(request, options.onUnhandledRequest)\n emitter.emit('request:unhandled', { request, requestId })\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n const { response } = lookupResult.data\n\n // When the handled request returned no mocked response, warn the developer,\n // as it may be an oversight on their part. Perform the request as-is.\n if (!response) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Perform the request as-is when the developer explicitly returned \"req.passthrough()\".\n // This produces no warning as the request was handled.\n if (\n response.status === 302 &&\n response.headers.get('x-msw-intention') === 'passthrough'\n ) {\n emitter.emit('request:end', { request, requestId })\n handleRequestOptions?.onPassthroughResponse?.(request)\n return\n }\n\n // Store all the received response cookies in the virtual cookie store.\n readResponseCookies(request, response)\n\n emitter.emit('request:match', { request, requestId })\n\n const requiredLookupResult =\n lookupResult.data as RequiredDeep<HandlersExecutionResult>\n\n const transformedResponse =\n handleRequestOptions?.transformResponse?.(response) ||\n (response as any as Response)\n\n handleRequestOptions?.onMockedResponse?.(\n transformedResponse,\n requiredLookupResult,\n )\n\n emitter.emit('request:end', { request, requestId })\n\n return transformedResponse\n}\n"],"mappings":"AAAA,SAAS,aAAa;AAItB,SAAkC,uBAAuB;AACzD,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AAqCpC,eAAsB,cACpB,SACA,WACA,UACA,SACA,SACA,sBAC+B;AAC/B,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAGpD,MAAI,QAAQ,QAAQ,IAAI,iBAAiB,MAAM,UAAU;AACvD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,QAAM,eAAe,MAAM,MAAM,MAAM;AACrC,WAAO,gBAAgB;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,sBAAsB;AAAA,IAC3C,CAAC;AAAA,EACH,CAAC;AAED,MAAI,aAAa,OAAO;AAEtB,YAAQ,KAAK,sBAAsB;AAAA,MACjC,OAAO,aAAa;AAAA,MACpB;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,aAAa;AAAA,EACrB;AAIA,MAAI,CAAC,aAAa,MAAM;AACtB,UAAM,mBAAmB,SAAS,QAAQ,kBAAkB;AAC5D,YAAQ,KAAK,qBAAqB,EAAE,SAAS,UAAU,CAAC;AACxD,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAEA,QAAM,EAAE,SAAS,IAAI,aAAa;AAIlC,MAAI,CAAC,UAAU;AACb,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAIA,MACE,SAAS,WAAW,OACpB,SAAS,QAAQ,IAAI,iBAAiB,MAAM,eAC5C;AACA,YAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAClD,0BAAsB,wBAAwB,OAAO;AACrD;AAAA,EACF;AAGA,sBAAoB,SAAS,QAAQ;AAErC,UAAQ,KAAK,iBAAiB,EAAE,SAAS,UAAU,CAAC;AAEpD,QAAM,uBACJ,aAAa;AAEf,QAAM,sBACJ,sBAAsB,oBAAoB,QAAQ,KACjD;AAEH,wBAAsB;AAAA,IACpB;AAAA,IACA;AAAA,EACF;AAEA,UAAQ,KAAK,eAAe,EAAE,SAAS,UAAU,CAAC;AAElD,SAAO;AACT;","names":[]}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-xuSipbNt.mjs';
|
|
2
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.mjs';
|
|
3
4
|
import '../typeUtils.mjs';
|
|
4
5
|
import 'strict-event-emitter';
|
|
5
6
|
import '@mswjs/interceptors/WebSocket';
|
|
6
7
|
import './matching/matchRequestUrl.mjs';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
interface HandleWebSocketEventOptions {
|
|
10
|
+
getHandlers: () => Array<RequestHandler | WebSocketHandler>;
|
|
11
|
+
onMockedConnection: (connection: WebSocketConnectionData) => void;
|
|
12
|
+
onPassthroughConnection: (onnection: WebSocketConnectionData) => void;
|
|
13
|
+
}
|
|
14
|
+
declare function handleWebSocketEvent(options: HandleWebSocketEventOptions): void;
|
|
9
15
|
|
|
10
16
|
export { handleWebSocketEvent };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-aJY-D0oG.js';
|
|
2
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.js';
|
|
3
4
|
import '../typeUtils.js';
|
|
4
5
|
import 'strict-event-emitter';
|
|
5
6
|
import '@mswjs/interceptors/WebSocket';
|
|
6
7
|
import './matching/matchRequestUrl.js';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
interface HandleWebSocketEventOptions {
|
|
10
|
+
getHandlers: () => Array<RequestHandler | WebSocketHandler>;
|
|
11
|
+
onMockedConnection: (connection: WebSocketConnectionData) => void;
|
|
12
|
+
onPassthroughConnection: (onnection: WebSocketConnectionData) => void;
|
|
13
|
+
}
|
|
14
|
+
declare function handleWebSocketEvent(options: HandleWebSocketEventOptions): void;
|
|
9
15
|
|
|
10
16
|
export { handleWebSocketEvent };
|
|
@@ -23,29 +23,32 @@ __export(handleWebSocketEvent_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(handleWebSocketEvent_exports);
|
|
24
24
|
var import_WebSocketHandler = require("../handlers/WebSocketHandler.js");
|
|
25
25
|
var import_webSocketInterceptor = require("../ws/webSocketInterceptor.js");
|
|
26
|
-
function handleWebSocketEvent(
|
|
26
|
+
function handleWebSocketEvent(options) {
|
|
27
27
|
import_webSocketInterceptor.webSocketInterceptor.on("connection", (connection) => {
|
|
28
|
-
const handlers =
|
|
28
|
+
const handlers = options.getHandlers();
|
|
29
29
|
const connectionEvent = new MessageEvent("connection", {
|
|
30
30
|
data: connection
|
|
31
|
-
/**
|
|
32
|
-
* @note This message event should be marked as "cancelable"
|
|
33
|
-
* to have its default prevented using "event.preventDefault()".
|
|
34
|
-
* There's a bug in Node.js that breaks the "cancelable" flag.
|
|
35
|
-
* @see https://github.com/nodejs/node/issues/51767
|
|
36
|
-
*/
|
|
37
31
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
const matchingHandlers = handlers.filter(
|
|
33
|
+
(handler) => {
|
|
34
|
+
if (handler instanceof import_WebSocketHandler.WebSocketHandler) {
|
|
35
|
+
return handler.predicate({
|
|
36
|
+
event: connectionEvent,
|
|
37
|
+
parsedResult: handler.parse({
|
|
38
|
+
event: connectionEvent
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
if (matchingHandlers.length > 0) {
|
|
46
|
+
options?.onMockedConnection(connection);
|
|
47
|
+
for (const handler of matchingHandlers) {
|
|
45
48
|
handler[import_WebSocketHandler.kDispatchEvent](connectionEvent);
|
|
46
49
|
}
|
|
47
|
-
}
|
|
48
|
-
|
|
50
|
+
} else {
|
|
51
|
+
options?.onPassthroughConnection(connection);
|
|
49
52
|
connection.server.connect();
|
|
50
53
|
connection.client.addEventListener("message", (event) => {
|
|
51
54
|
connection.server.send(event.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/handleWebSocketEvent.ts"],"sourcesContent":["import { RequestHandler } from '../handlers/RequestHandler'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleWebSocketEvent.ts"],"sourcesContent":["import type { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket'\nimport { RequestHandler } from '../handlers/RequestHandler'\nimport { WebSocketHandler, kDispatchEvent } from '../handlers/WebSocketHandler'\nimport { webSocketInterceptor } from '../ws/webSocketInterceptor'\n\ninterface HandleWebSocketEventOptions {\n getHandlers: () => Array<RequestHandler | WebSocketHandler>\n onMockedConnection: (connection: WebSocketConnectionData) => void\n onPassthroughConnection: (onnection: WebSocketConnectionData) => void\n}\n\nexport function handleWebSocketEvent(options: HandleWebSocketEventOptions) {\n webSocketInterceptor.on('connection', (connection) => {\n const handlers = options.getHandlers()\n\n const connectionEvent = new MessageEvent('connection', {\n data: connection,\n })\n\n // First, filter only those WebSocket handlers that\n // match the \"ws.link()\" endpoint predicate. Don't dispatch\n // anything yet so the logger can be attached to the connection\n // before it potentially sends events.\n const matchingHandlers = handlers.filter<WebSocketHandler>(\n (handler): handler is WebSocketHandler => {\n if (handler instanceof WebSocketHandler) {\n return handler.predicate({\n event: connectionEvent,\n parsedResult: handler.parse({\n event: connectionEvent,\n }),\n })\n }\n\n return false\n },\n )\n\n if (matchingHandlers.length > 0) {\n options?.onMockedConnection(connection)\n\n // Iterate over the handlers and forward the connection\n // event to WebSocket event handlers. This is equivalent\n // to dispatching that event onto multiple listeners.\n for (const handler of matchingHandlers) {\n handler[kDispatchEvent](connectionEvent)\n }\n } else {\n options?.onPassthroughConnection(connection)\n\n // If none of the \"ws\" handlers matched,\n // establish the WebSocket connection as-is.\n connection.server.connect()\n connection.client.addEventListener('message', (event) => {\n connection.server.send(event.data)\n })\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,8BAAiD;AACjD,kCAAqC;AAQ9B,SAAS,qBAAqB,SAAsC;AACzE,mDAAqB,GAAG,cAAc,CAAC,eAAe;AACpD,UAAM,WAAW,QAAQ,YAAY;AAErC,UAAM,kBAAkB,IAAI,aAAa,cAAc;AAAA,MACrD,MAAM;AAAA,IACR,CAAC;AAMD,UAAM,mBAAmB,SAAS;AAAA,MAChC,CAAC,YAAyC;AACxC,YAAI,mBAAmB,0CAAkB;AACvC,iBAAO,QAAQ,UAAU;AAAA,YACvB,OAAO;AAAA,YACP,cAAc,QAAQ,MAAM;AAAA,cAC1B,OAAO;AAAA,YACT,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AAEA,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,iBAAiB,SAAS,GAAG;AAC/B,eAAS,mBAAmB,UAAU;AAKtC,iBAAW,WAAW,kBAAkB;AACtC,gBAAQ,sCAAc,EAAE,eAAe;AAAA,MACzC;AAAA,IACF,OAAO;AACL,eAAS,wBAAwB,UAAU;AAI3C,iBAAW,OAAO,QAAQ;AAC1B,iBAAW,OAAO,iBAAiB,WAAW,CAAC,UAAU;AACvD,mBAAW,OAAO,KAAK,MAAM,IAAI;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WebSocketHandler,
|
|
3
|
-
kDefaultPrevented,
|
|
4
|
-
kDispatchEvent
|
|
5
|
-
} from '../handlers/WebSocketHandler.mjs';
|
|
1
|
+
import { WebSocketHandler, kDispatchEvent } from '../handlers/WebSocketHandler.mjs';
|
|
6
2
|
import { webSocketInterceptor } from '../ws/webSocketInterceptor.mjs';
|
|
7
|
-
function handleWebSocketEvent(
|
|
3
|
+
function handleWebSocketEvent(options) {
|
|
8
4
|
webSocketInterceptor.on("connection", (connection) => {
|
|
9
|
-
const handlers =
|
|
5
|
+
const handlers = options.getHandlers();
|
|
10
6
|
const connectionEvent = new MessageEvent("connection", {
|
|
11
7
|
data: connection
|
|
12
|
-
/**
|
|
13
|
-
* @note This message event should be marked as "cancelable"
|
|
14
|
-
* to have its default prevented using "event.preventDefault()".
|
|
15
|
-
* There's a bug in Node.js that breaks the "cancelable" flag.
|
|
16
|
-
* @see https://github.com/nodejs/node/issues/51767
|
|
17
|
-
*/
|
|
18
8
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
const matchingHandlers = handlers.filter(
|
|
10
|
+
(handler) => {
|
|
11
|
+
if (handler instanceof WebSocketHandler) {
|
|
12
|
+
return handler.predicate({
|
|
13
|
+
event: connectionEvent,
|
|
14
|
+
parsedResult: handler.parse({
|
|
15
|
+
event: connectionEvent
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
if (matchingHandlers.length > 0) {
|
|
23
|
+
options?.onMockedConnection(connection);
|
|
24
|
+
for (const handler of matchingHandlers) {
|
|
26
25
|
handler[kDispatchEvent](connectionEvent);
|
|
27
26
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
27
|
+
} else {
|
|
28
|
+
options?.onPassthroughConnection(connection);
|
|
30
29
|
connection.server.connect();
|
|
31
30
|
connection.client.addEventListener("message", (event) => {
|
|
32
31
|
connection.server.send(event.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/handleWebSocketEvent.ts"],"sourcesContent":["import { RequestHandler } from '../handlers/RequestHandler'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/handleWebSocketEvent.ts"],"sourcesContent":["import type { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket'\nimport { RequestHandler } from '../handlers/RequestHandler'\nimport { WebSocketHandler, kDispatchEvent } from '../handlers/WebSocketHandler'\nimport { webSocketInterceptor } from '../ws/webSocketInterceptor'\n\ninterface HandleWebSocketEventOptions {\n getHandlers: () => Array<RequestHandler | WebSocketHandler>\n onMockedConnection: (connection: WebSocketConnectionData) => void\n onPassthroughConnection: (onnection: WebSocketConnectionData) => void\n}\n\nexport function handleWebSocketEvent(options: HandleWebSocketEventOptions) {\n webSocketInterceptor.on('connection', (connection) => {\n const handlers = options.getHandlers()\n\n const connectionEvent = new MessageEvent('connection', {\n data: connection,\n })\n\n // First, filter only those WebSocket handlers that\n // match the \"ws.link()\" endpoint predicate. Don't dispatch\n // anything yet so the logger can be attached to the connection\n // before it potentially sends events.\n const matchingHandlers = handlers.filter<WebSocketHandler>(\n (handler): handler is WebSocketHandler => {\n if (handler instanceof WebSocketHandler) {\n return handler.predicate({\n event: connectionEvent,\n parsedResult: handler.parse({\n event: connectionEvent,\n }),\n })\n }\n\n return false\n },\n )\n\n if (matchingHandlers.length > 0) {\n options?.onMockedConnection(connection)\n\n // Iterate over the handlers and forward the connection\n // event to WebSocket event handlers. This is equivalent\n // to dispatching that event onto multiple listeners.\n for (const handler of matchingHandlers) {\n handler[kDispatchEvent](connectionEvent)\n }\n } else {\n options?.onPassthroughConnection(connection)\n\n // If none of the \"ws\" handlers matched,\n // establish the WebSocket connection as-is.\n connection.server.connect()\n connection.client.addEventListener('message', (event) => {\n connection.server.send(event.data)\n })\n }\n })\n}\n"],"mappings":"AAEA,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,4BAA4B;AAQ9B,SAAS,qBAAqB,SAAsC;AACzE,uBAAqB,GAAG,cAAc,CAAC,eAAe;AACpD,UAAM,WAAW,QAAQ,YAAY;AAErC,UAAM,kBAAkB,IAAI,aAAa,cAAc;AAAA,MACrD,MAAM;AAAA,IACR,CAAC;AAMD,UAAM,mBAAmB,SAAS;AAAA,MAChC,CAAC,YAAyC;AACxC,YAAI,mBAAmB,kBAAkB;AACvC,iBAAO,QAAQ,UAAU;AAAA,YACvB,OAAO;AAAA,YACP,cAAc,QAAQ,MAAM;AAAA,cAC1B,OAAO;AAAA,YACT,CAAC;AAAA,UACH,CAAC;AAAA,QACH;AAEA,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,iBAAiB,SAAS,GAAG;AAC/B,eAAS,mBAAmB,UAAU;AAKtC,iBAAW,WAAW,kBAAkB;AACtC,gBAAQ,cAAc,EAAE,eAAe;AAAA,MACzC;AAAA,IACF,OAAO;AACL,eAAS,wBAAwB,UAAU;AAI3C,iBAAW,OAAO,QAAQ;AAC1B,iBAAW,OAAO,iBAAiB,WAAW,CAAC,UAAU;AACvD,mBAAW,OAAO,KAAK,MAAM,IAAI;AAAA,MACnC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -23,18 +23,21 @@ __export(mergeRight_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(mergeRight_exports);
|
|
24
24
|
var import_isObject = require("./isObject.js");
|
|
25
25
|
function mergeRight(left, right) {
|
|
26
|
-
return Object.entries(right).reduce(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
return Object.entries(right).reduce(
|
|
27
|
+
(result, [key, rightValue]) => {
|
|
28
|
+
const leftValue = result[key];
|
|
29
|
+
if (Array.isArray(leftValue) && Array.isArray(rightValue)) {
|
|
30
|
+
result[key] = leftValue.concat(rightValue);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
if ((0, import_isObject.isObject)(leftValue) && (0, import_isObject.isObject)(rightValue)) {
|
|
34
|
+
result[key] = mergeRight(leftValue, rightValue);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
result[key] = rightValue;
|
|
30
38
|
return result;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
result[key] = rightValue;
|
|
37
|
-
return result;
|
|
38
|
-
}, Object.assign({}, left));
|
|
39
|
+
},
|
|
40
|
+
Object.assign({}, left)
|
|
41
|
+
);
|
|
39
42
|
}
|
|
40
43
|
//# sourceMappingURL=mergeRight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/internal/mergeRight.ts"],"sourcesContent":["import { isObject } from './isObject'\n\n/**\n * Deeply merges two given objects with the right one\n * having a priority during property assignment.\n */\nexport function mergeRight(\n left: Record<string, any>,\n right: Record<string, any>,\n) {\n return Object.entries(right).reduce((result, [key, rightValue]) => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/internal/mergeRight.ts"],"sourcesContent":["import { isObject } from './isObject'\n\n/**\n * Deeply merges two given objects with the right one\n * having a priority during property assignment.\n */\nexport function mergeRight(\n left: Record<string, any>,\n right: Record<string, any>,\n) {\n return Object.entries(right).reduce(\n (result, [key, rightValue]) => {\n const leftValue = result[key]\n\n if (Array.isArray(leftValue) && Array.isArray(rightValue)) {\n result[key] = leftValue.concat(rightValue)\n return result\n }\n\n if (isObject(leftValue) && isObject(rightValue)) {\n result[key] = mergeRight(leftValue, rightValue)\n return result\n }\n\n result[key] = rightValue\n return result\n },\n Object.assign({}, left),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAMlB,SAAS,WACd,MACA,OACA;AACA,SAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,IAC3B,CAAC,QAAQ,CAAC,KAAK,UAAU,MAAM;AAC7B,YAAM,YAAY,OAAO,GAAG;AAE5B,UAAI,MAAM,QAAQ,SAAS,KAAK,MAAM,QAAQ,UAAU,GAAG;AACzD,eAAO,GAAG,IAAI,UAAU,OAAO,UAAU;AACzC,eAAO;AAAA,MACT;AAEA,cAAI,0BAAS,SAAS,SAAK,0BAAS,UAAU,GAAG;AAC/C,eAAO,GAAG,IAAI,WAAW,WAAW,UAAU;AAC9C,eAAO;AAAA,MACT;AAEA,aAAO,GAAG,IAAI;AACd,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAO,CAAC,GAAG,IAAI;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { isObject } from './isObject.mjs';
|
|
2
2
|
function mergeRight(left, right) {
|
|
3
|
-
return Object.entries(right).reduce(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
return Object.entries(right).reduce(
|
|
4
|
+
(result, [key, rightValue]) => {
|
|
5
|
+
const leftValue = result[key];
|
|
6
|
+
if (Array.isArray(leftValue) && Array.isArray(rightValue)) {
|
|
7
|
+
result[key] = leftValue.concat(rightValue);
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
if (isObject(leftValue) && isObject(rightValue)) {
|
|
11
|
+
result[key] = mergeRight(leftValue, rightValue);
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
result[key] = rightValue;
|
|
7
15
|
return result;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return result;
|
|
12
|
-
}
|
|
13
|
-
result[key] = rightValue;
|
|
14
|
-
return result;
|
|
15
|
-
}, Object.assign({}, left));
|
|
16
|
+
},
|
|
17
|
+
Object.assign({}, left)
|
|
18
|
+
);
|
|
16
19
|
}
|
|
17
20
|
export {
|
|
18
21
|
mergeRight
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/internal/mergeRight.ts"],"sourcesContent":["import { isObject } from './isObject'\n\n/**\n * Deeply merges two given objects with the right one\n * having a priority during property assignment.\n */\nexport function mergeRight(\n left: Record<string, any>,\n right: Record<string, any>,\n) {\n return Object.entries(right).reduce((result, [key, rightValue]) => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/internal/mergeRight.ts"],"sourcesContent":["import { isObject } from './isObject'\n\n/**\n * Deeply merges two given objects with the right one\n * having a priority during property assignment.\n */\nexport function mergeRight(\n left: Record<string, any>,\n right: Record<string, any>,\n) {\n return Object.entries(right).reduce(\n (result, [key, rightValue]) => {\n const leftValue = result[key]\n\n if (Array.isArray(leftValue) && Array.isArray(rightValue)) {\n result[key] = leftValue.concat(rightValue)\n return result\n }\n\n if (isObject(leftValue) && isObject(rightValue)) {\n result[key] = mergeRight(leftValue, rightValue)\n return result\n }\n\n result[key] = rightValue\n return result\n },\n Object.assign({}, left),\n )\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AAMlB,SAAS,WACd,MACA,OACA;AACA,SAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,IAC3B,CAAC,QAAQ,CAAC,KAAK,UAAU,MAAM;AAC7B,YAAM,YAAY,OAAO,GAAG;AAE5B,UAAI,MAAM,QAAQ,SAAS,KAAK,MAAM,QAAQ,UAAU,GAAG;AACzD,eAAO,GAAG,IAAI,UAAU,OAAO,UAAU;AACzC,eAAO;AAAA,MACT;AAEA,UAAI,SAAS,SAAS,KAAK,SAAS,UAAU,GAAG;AAC/C,eAAO,GAAG,IAAI,WAAW,WAAW,UAAU;AAC9C,eAAO;AAAA,MACT;AAEA,aAAO,GAAG,IAAI;AACd,aAAO;AAAA,IACT;AAAA,IACA,OAAO,OAAO,CAAC,GAAG,IAAI;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-4DPdxG0R.mjs';
|
|
3
|
+
import '../../HttpResponse-xuSipbNt.mjs';
|
|
4
4
|
import '../../typeUtils.mjs';
|
|
5
5
|
import '../matching/matchRequestUrl.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-3gvpA65n.js';
|
|
3
|
+
import '../../HttpResponse-aJY-D0oG.js';
|
|
4
4
|
import '../../typeUtils.js';
|
|
5
5
|
import '../matching/matchRequestUrl.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, h as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, h as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-xuSipbNt.mjs';
|
|
2
2
|
import '../../typeUtils.mjs';
|
|
3
3
|
|
|
4
4
|
declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, h as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, h as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-aJY-D0oG.js';
|
|
2
2
|
import '../../typeUtils.js';
|
|
3
3
|
|
|
4
4
|
declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
interface GetTimestampOptions {
|
|
2
|
+
milliseconds?: boolean;
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* Returns a timestamp string in a "HH:MM:SS" format.
|
|
3
6
|
*/
|
|
4
|
-
declare function getTimestamp(): string;
|
|
7
|
+
declare function getTimestamp(options?: GetTimestampOptions): string;
|
|
5
8
|
|
|
6
9
|
export { getTimestamp };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
interface GetTimestampOptions {
|
|
2
|
+
milliseconds?: boolean;
|
|
3
|
+
}
|
|
1
4
|
/**
|
|
2
5
|
* Returns a timestamp string in a "HH:MM:SS" format.
|
|
3
6
|
*/
|
|
4
|
-
declare function getTimestamp(): string;
|
|
7
|
+
declare function getTimestamp(options?: GetTimestampOptions): string;
|
|
5
8
|
|
|
6
9
|
export { getTimestamp };
|
|
@@ -21,8 +21,12 @@ __export(getTimestamp_exports, {
|
|
|
21
21
|
getTimestamp: () => getTimestamp
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(getTimestamp_exports);
|
|
24
|
-
function getTimestamp() {
|
|
24
|
+
function getTimestamp(options) {
|
|
25
25
|
const now = /* @__PURE__ */ new Date();
|
|
26
|
-
|
|
26
|
+
const timestamp = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
|
27
|
+
if (options?.milliseconds) {
|
|
28
|
+
return `${timestamp}.${now.getMilliseconds().toString().padStart(3, "0")}`;
|
|
29
|
+
}
|
|
30
|
+
return timestamp;
|
|
27
31
|
}
|
|
28
32
|
//# sourceMappingURL=getTimestamp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(): string {\n const now = new Date()\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["interface GetTimestampOptions {\n milliseconds?: boolean\n}\n\n/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(options?: GetTimestampOptions): string {\n const now = new Date()\n const timestamp = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`\n\n if (options?.milliseconds) {\n return `${timestamp}.${now.getMilliseconds().toString().padStart(3, '0')}`\n }\n\n return timestamp\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,aAAa,SAAuC;AAClE,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,YAAY,GAAG,IAAI,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAE/J,MAAI,SAAS,cAAc;AACzB,WAAO,GAAG,SAAS,IAAI,IAAI,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,EAC1E;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
function getTimestamp() {
|
|
1
|
+
function getTimestamp(options) {
|
|
2
2
|
const now = /* @__PURE__ */ new Date();
|
|
3
|
-
|
|
3
|
+
const timestamp = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
|
4
|
+
if (options?.milliseconds) {
|
|
5
|
+
return `${timestamp}.${now.getMilliseconds().toString().padStart(3, "0")}`;
|
|
6
|
+
}
|
|
7
|
+
return timestamp;
|
|
4
8
|
}
|
|
5
9
|
export {
|
|
6
10
|
getTimestamp
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(): string {\n const now = new Date()\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/logging/getTimestamp.ts"],"sourcesContent":["interface GetTimestampOptions {\n milliseconds?: boolean\n}\n\n/**\n * Returns a timestamp string in a \"HH:MM:SS\" format.\n */\nexport function getTimestamp(options?: GetTimestampOptions): string {\n const now = new Date()\n const timestamp = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`\n\n if (options?.milliseconds) {\n return `${timestamp}.${now.getMilliseconds().toString().padStart(3, '0')}`\n }\n\n return timestamp\n}\n"],"mappings":"AAOO,SAAS,aAAa,SAAuC;AAClE,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,YAAY,GAAG,IAAI,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,IAAI,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAE/J,MAAI,SAAS,cAAc;AACzB,WAAO,GAAG,SAAS,IAAI,IAAI,gBAAgB,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC;AAAA,EAC1E;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WebSocketConnectionData, WebSocketClientConnection, WebSocketData } from '@mswjs/interceptors/WebSocket';
|
|
2
|
+
|
|
3
|
+
declare function attachWebSocketLogger(connection: WebSocketConnectionData): void;
|
|
4
|
+
/**
|
|
5
|
+
* Prints the WebSocket connection.
|
|
6
|
+
* This is meant to be logged by every WebSocket handler
|
|
7
|
+
* that intercepted this connection. This helps you see
|
|
8
|
+
* what handlers observe this connection.
|
|
9
|
+
*/
|
|
10
|
+
declare function logConnectionOpen(client: WebSocketClientConnection): void;
|
|
11
|
+
/**
|
|
12
|
+
* Prints the outgoing client message.
|
|
13
|
+
*/
|
|
14
|
+
declare function logOutgoingClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Prints the outgoing client message initiated
|
|
17
|
+
* by `server.send()` in the event handler.
|
|
18
|
+
*/
|
|
19
|
+
declare function logOutgoingMockedClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Prings the message received by the WebSocket client.
|
|
22
|
+
* This is fired when the "message" event is dispatched
|
|
23
|
+
* on the actual WebSocket client instance, and translates to
|
|
24
|
+
* the client receiving a message from the server.
|
|
25
|
+
*/
|
|
26
|
+
declare function logIncomingClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Prints the outgoing client message initiated
|
|
29
|
+
* by `client.send()` in the event handler.
|
|
30
|
+
*/
|
|
31
|
+
declare function logIncomingMockedClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
32
|
+
declare function logIncomingServerMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
33
|
+
|
|
34
|
+
export { attachWebSocketLogger, logConnectionOpen, logIncomingClientMessage, logIncomingMockedClientMessage, logIncomingServerMessage, logOutgoingClientMessage, logOutgoingMockedClientMessage };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WebSocketConnectionData, WebSocketClientConnection, WebSocketData } from '@mswjs/interceptors/WebSocket';
|
|
2
|
+
|
|
3
|
+
declare function attachWebSocketLogger(connection: WebSocketConnectionData): void;
|
|
4
|
+
/**
|
|
5
|
+
* Prints the WebSocket connection.
|
|
6
|
+
* This is meant to be logged by every WebSocket handler
|
|
7
|
+
* that intercepted this connection. This helps you see
|
|
8
|
+
* what handlers observe this connection.
|
|
9
|
+
*/
|
|
10
|
+
declare function logConnectionOpen(client: WebSocketClientConnection): void;
|
|
11
|
+
/**
|
|
12
|
+
* Prints the outgoing client message.
|
|
13
|
+
*/
|
|
14
|
+
declare function logOutgoingClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Prints the outgoing client message initiated
|
|
17
|
+
* by `server.send()` in the event handler.
|
|
18
|
+
*/
|
|
19
|
+
declare function logOutgoingMockedClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Prings the message received by the WebSocket client.
|
|
22
|
+
* This is fired when the "message" event is dispatched
|
|
23
|
+
* on the actual WebSocket client instance, and translates to
|
|
24
|
+
* the client receiving a message from the server.
|
|
25
|
+
*/
|
|
26
|
+
declare function logIncomingClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Prints the outgoing client message initiated
|
|
29
|
+
* by `client.send()` in the event handler.
|
|
30
|
+
*/
|
|
31
|
+
declare function logIncomingMockedClientMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
32
|
+
declare function logIncomingServerMessage(event: MessageEvent<WebSocketData>): Promise<void>;
|
|
33
|
+
|
|
34
|
+
export { attachWebSocketLogger, logConnectionOpen, logIncomingClientMessage, logIncomingMockedClientMessage, logIncomingServerMessage, logOutgoingClientMessage, logOutgoingMockedClientMessage };
|