msw 2.13.4 → 2.13.6
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.map +1 -1
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{HttpResponse-BF4NGRsf.d.mts → HttpResponse-BMMzfpjG.d.mts} +14 -1
- package/lib/core/{HttpResponse-yukpQS4a.d.ts → HttpResponse-DPDqE4Pb.d.ts} +14 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/experimental/compat.d.mts +1 -1
- package/lib/core/experimental/compat.d.ts +1 -1
- package/lib/core/experimental/define-network.d.mts +1 -1
- package/lib/core/experimental/define-network.d.ts +1 -1
- package/lib/core/experimental/define-network.js +1 -5
- package/lib/core/experimental/define-network.js.map +1 -1
- package/lib/core/experimental/define-network.mjs +1 -5
- package/lib/core/experimental/define-network.mjs.map +1 -1
- package/lib/core/experimental/frames/http-frame.d.mts +1 -1
- package/lib/core/experimental/frames/http-frame.d.ts +1 -1
- package/lib/core/experimental/frames/network-frame.d.mts +1 -1
- package/lib/core/experimental/frames/network-frame.d.ts +1 -1
- package/lib/core/experimental/frames/websocket-frame.d.mts +1 -1
- package/lib/core/experimental/frames/websocket-frame.d.ts +1 -1
- package/lib/core/experimental/handlers-controller.d.mts +2 -1
- package/lib/core/experimental/handlers-controller.d.ts +2 -1
- package/lib/core/experimental/handlers-controller.js +12 -0
- package/lib/core/experimental/handlers-controller.js.map +1 -1
- package/lib/core/experimental/handlers-controller.mjs +12 -0
- package/lib/core/experimental/handlers-controller.mjs.map +1 -1
- package/lib/core/experimental/index.d.mts +1 -1
- package/lib/core/experimental/index.d.ts +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.mts +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.ts +1 -1
- package/lib/core/experimental/setup-api.d.mts +1 -1
- package/lib/core/experimental/setup-api.d.ts +1 -1
- package/lib/core/experimental/setup-api.js +1 -5
- package/lib/core/experimental/setup-api.js.map +1 -1
- package/lib/core/experimental/setup-api.mjs +1 -5
- package/lib/core/experimental/setup-api.mjs.map +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.mts +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.ts +1 -1
- package/lib/core/experimental/sources/network-source.d.mts +1 -1
- package/lib/core/experimental/sources/network-source.d.ts +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +1 -1
- package/lib/core/graphql.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.ts +1 -1
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.js +25 -0
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs +25 -0
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/handlers/WebSocketHandler.d.mts +5 -2
- package/lib/core/handlers/WebSocketHandler.d.ts +5 -2
- package/lib/core/handlers/WebSocketHandler.js +22 -5
- package/lib/core/handlers/WebSocketHandler.js.map +1 -1
- package/lib/core/handlers/WebSocketHandler.mjs +22 -5
- 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 +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/sse.d.mts +1 -1
- package/lib/core/sse.d.ts +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/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/internal/isHandlerKind.d.mts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.ts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.ts +1 -1
- package/lib/iife/index.js +61 -15
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +2 -2
- package/src/browser/utils/deserializeRequest.ts +2 -1
- package/src/browser/utils/pruneGetRequestBody.ts +3 -3
- package/src/core/experimental/define-network.ts +4 -7
- package/src/core/experimental/handlers-controller.ts +14 -0
- package/src/core/experimental/setup-api.ts +1 -5
- package/src/core/handlers/RequestHandler.ts +28 -0
- package/src/core/handlers/WebSocketHandler.test.ts +58 -0
- package/src/core/handlers/WebSocketHandler.ts +36 -7
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +0 -12
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +0 -12
- package/lib/core/utils/internal/requestHandlerUtils.js +0 -37
- package/lib/core/utils/internal/requestHandlerUtils.js.map +0 -1
- package/lib/core/utils/internal/requestHandlerUtils.mjs +0 -17
- package/lib/core/utils/internal/requestHandlerUtils.mjs.map +0 -1
- package/src/core/utils/internal/requestHandlerUtils.ts +0 -21
package/lib/core/sse.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ResponseResolver } from './HttpResponse-
|
|
1
|
+
import { a as ResponseResolver } from './HttpResponse-DPDqE4Pb.js';
|
|
2
2
|
import { HttpRequestResolverExtras, HttpHandler } from './handlers/HttpHandler.js';
|
|
3
3
|
import { PathParams, Path } from './utils/matching/matchRequestUrl.js';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { s as HandlersExecutionResult, m as ResponseResolutionContext, t as executeHandlers } from '../HttpResponse-BMMzfpjG.mjs';
|
|
2
2
|
import '@mswjs/interceptors';
|
|
3
3
|
import './internal/isIterable.mjs';
|
|
4
4
|
import '../typeUtils.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { s as HandlersExecutionResult, m as ResponseResolutionContext, t as executeHandlers } from '../HttpResponse-DPDqE4Pb.js';
|
|
2
2
|
import '@mswjs/interceptors';
|
|
3
3
|
import './internal/isIterable.js';
|
|
4
4
|
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 { R as RequestHandler, m as ResponseResolutionContext,
|
|
4
|
+
import { R as RequestHandler, m as ResponseResolutionContext, s as HandlersExecutionResult } from '../HttpResponse-BMMzfpjG.mjs';
|
|
5
5
|
import 'rettime';
|
|
6
6
|
import './request/onUnhandledRequest.mjs';
|
|
7
7
|
import '@mswjs/interceptors';
|
|
@@ -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 { R as RequestHandler, m as ResponseResolutionContext,
|
|
4
|
+
import { R as RequestHandler, m as ResponseResolutionContext, s as HandlersExecutionResult } from '../HttpResponse-DPDqE4Pb.js';
|
|
5
5
|
import 'rettime';
|
|
6
6
|
import './request/onUnhandledRequest.js';
|
|
7
7
|
import '@mswjs/interceptors';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyHandler } from '../../experimental/handlers-controller.mjs';
|
|
2
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../../HttpResponse-BMMzfpjG.mjs';
|
|
3
3
|
import { WebSocketHandler } from '../../handlers/WebSocketHandler.mjs';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import './isIterable.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyHandler } from '../../experimental/handlers-controller.js';
|
|
2
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../../HttpResponse-DPDqE4Pb.js';
|
|
3
3
|
import { WebSocketHandler } from '../../handlers/WebSocketHandler.js';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import './isIterable.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { x as GraphQLMultipartRequestBody, w as GraphQLParsedOperationsMap, u as ParsedGraphQLQuery, P as ParsedGraphQLRequest, v as parseDocumentNode, y as parseGraphQLRequest } from '../../HttpResponse-
|
|
2
|
+
export { x as GraphQLMultipartRequestBody, w as GraphQLParsedOperationsMap, u as ParsedGraphQLQuery, P as ParsedGraphQLRequest, v as parseDocumentNode, y as parseGraphQLRequest } from '../../HttpResponse-BMMzfpjG.mjs';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import './isIterable.mjs';
|
|
5
5
|
import '../../typeUtils.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { x as GraphQLMultipartRequestBody, w as GraphQLParsedOperationsMap, u as ParsedGraphQLQuery, P as ParsedGraphQLRequest, v as parseDocumentNode, y as parseGraphQLRequest } from '../../HttpResponse-
|
|
2
|
+
export { x as GraphQLMultipartRequestBody, w as GraphQLParsedOperationsMap, u as ParsedGraphQLQuery, P as ParsedGraphQLRequest, v as parseDocumentNode, y as parseGraphQLRequest } from '../../HttpResponse-DPDqE4Pb.js';
|
|
3
3
|
import '@mswjs/interceptors';
|
|
4
4
|
import './isIterable.js';
|
|
5
5
|
import '../../typeUtils.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketConnectionData } from '@mswjs/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-BMMzfpjG.mjs';
|
|
3
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.mjs';
|
|
4
4
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.mjs';
|
|
5
5
|
import '@mswjs/interceptors';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketConnectionData } from '@mswjs/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-DPDqE4Pb.js';
|
|
3
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.js';
|
|
4
4
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.js';
|
|
5
5
|
import '@mswjs/interceptors';
|
package/lib/iife/index.js
CHANGED
|
@@ -16143,6 +16143,31 @@ ${operationTypes.join("\n")}
|
|
|
16143
16143
|
};
|
|
16144
16144
|
this.isUsed = false;
|
|
16145
16145
|
}
|
|
16146
|
+
/**
|
|
16147
|
+
* Reset the runtime state accumulated during response resolution,
|
|
16148
|
+
* such as generator iterator progress. Called when this handler is
|
|
16149
|
+
* removed from the active handlers list so re-adding it later starts
|
|
16150
|
+
* from a clean state.
|
|
16151
|
+
*/
|
|
16152
|
+
reset() {
|
|
16153
|
+
const iterator = this.resolverIterator;
|
|
16154
|
+
this.resolverIterator = void 0;
|
|
16155
|
+
this.resolverIteratorResult = void 0;
|
|
16156
|
+
if (typeof iterator?.return === "function") {
|
|
16157
|
+
void Promise.resolve(iterator.return());
|
|
16158
|
+
}
|
|
16159
|
+
}
|
|
16160
|
+
/**
|
|
16161
|
+
* Restore this handler so it can match requests again after being
|
|
16162
|
+
* exhausted (e.g. via `{ once: true }`). Also clears any accumulated
|
|
16163
|
+
* resolution state.
|
|
16164
|
+
*/
|
|
16165
|
+
restore() {
|
|
16166
|
+
if (this.options?.once) {
|
|
16167
|
+
this.reset();
|
|
16168
|
+
this.isUsed = false;
|
|
16169
|
+
}
|
|
16170
|
+
}
|
|
16146
16171
|
/**
|
|
16147
16172
|
* Parse the intercepted request to extract additional information from it.
|
|
16148
16173
|
* Parsed result is then exposed to other methods of this request handler.
|
|
@@ -16938,12 +16963,12 @@ ${operationTypes.join("\n")}
|
|
|
16938
16963
|
predicate(args) {
|
|
16939
16964
|
return args.parsedResult.match.matches;
|
|
16940
16965
|
}
|
|
16966
|
+
test(url, resolutionContext) {
|
|
16967
|
+
return this.#match(url, resolutionContext) != null;
|
|
16968
|
+
}
|
|
16941
16969
|
async run(connection, resolutionContext) {
|
|
16942
|
-
const parsedResult = this.
|
|
16943
|
-
|
|
16944
|
-
resolutionContext
|
|
16945
|
-
});
|
|
16946
|
-
if (!this.predicate({ url: connection.client.url, parsedResult })) {
|
|
16970
|
+
const parsedResult = this.#match(connection.client.url, resolutionContext);
|
|
16971
|
+
if (parsedResult == null) {
|
|
16947
16972
|
return null;
|
|
16948
16973
|
}
|
|
16949
16974
|
const resolvedConnection = {
|
|
@@ -16958,6 +16983,23 @@ ${operationTypes.join("\n")}
|
|
|
16958
16983
|
}
|
|
16959
16984
|
return resolvedConnection;
|
|
16960
16985
|
}
|
|
16986
|
+
#match(url, resolutionContext) {
|
|
16987
|
+
const resolvedUrl = this.#resolveWebSocketUrl(
|
|
16988
|
+
url.toString(),
|
|
16989
|
+
resolutionContext?.baseUrl
|
|
16990
|
+
);
|
|
16991
|
+
const parsedResult = this.parse({
|
|
16992
|
+
url: resolvedUrl,
|
|
16993
|
+
resolutionContext
|
|
16994
|
+
});
|
|
16995
|
+
if (this.predicate({
|
|
16996
|
+
url,
|
|
16997
|
+
parsedResult
|
|
16998
|
+
})) {
|
|
16999
|
+
return parsedResult;
|
|
17000
|
+
}
|
|
17001
|
+
return null;
|
|
17002
|
+
}
|
|
16961
17003
|
[kConnect](connection) {
|
|
16962
17004
|
connection.client.addEventListener(
|
|
16963
17005
|
"message",
|
|
@@ -17086,6 +17128,11 @@ ${operationTypes.join("\n")}
|
|
|
17086
17128
|
"Failed to replace initial handlers during reset: invalid handlers. Did you forget to spread the handlers array?"
|
|
17087
17129
|
)
|
|
17088
17130
|
);
|
|
17131
|
+
for (const handler of this.currentHandlers()) {
|
|
17132
|
+
if ("reset" in handler) {
|
|
17133
|
+
handler["reset"]();
|
|
17134
|
+
}
|
|
17135
|
+
}
|
|
17089
17136
|
const { initialHandlers } = this.getState();
|
|
17090
17137
|
if (nextHandlers.length === 0) {
|
|
17091
17138
|
this.setState({
|
|
@@ -17099,6 +17146,13 @@ ${operationTypes.join("\n")}
|
|
|
17099
17146
|
handlers: { ...normalizedNextHandlers }
|
|
17100
17147
|
});
|
|
17101
17148
|
}
|
|
17149
|
+
restore() {
|
|
17150
|
+
for (const handler of this.currentHandlers()) {
|
|
17151
|
+
if ("restore" in handler) {
|
|
17152
|
+
handler["restore"]();
|
|
17153
|
+
}
|
|
17154
|
+
}
|
|
17155
|
+
}
|
|
17102
17156
|
#validateHandlers(handlers) {
|
|
17103
17157
|
return handlers.every((handler) => !Array.isArray(handler));
|
|
17104
17158
|
}
|
|
@@ -17167,11 +17221,7 @@ ${operationTypes.join("\n")}
|
|
|
17167
17221
|
this.handlersController.use(runtimeHandlers);
|
|
17168
17222
|
}
|
|
17169
17223
|
restoreHandlers() {
|
|
17170
|
-
this.handlersController.
|
|
17171
|
-
if ("isUsed" in handler) {
|
|
17172
|
-
handler.isUsed = false;
|
|
17173
|
-
}
|
|
17174
|
-
});
|
|
17224
|
+
this.handlersController.restore();
|
|
17175
17225
|
}
|
|
17176
17226
|
resetHandlers(...nextHandlers) {
|
|
17177
17227
|
this.handlersController.reset(nextHandlers);
|
|
@@ -22665,11 +22715,7 @@ Read more: https://mswjs.io/docs/http/intercepting-requests`;
|
|
|
22665
22715
|
handlersController.reset(handlers);
|
|
22666
22716
|
},
|
|
22667
22717
|
restoreHandlers() {
|
|
22668
|
-
|
|
22669
|
-
if ("isUsed" in handler) {
|
|
22670
|
-
handler.isUsed = false;
|
|
22671
|
-
}
|
|
22672
|
-
}
|
|
22718
|
+
handlersController.restore();
|
|
22673
22719
|
},
|
|
22674
22720
|
listHandlers() {
|
|
22675
22721
|
return toReadonlyArray(handlersController.currentHandlers());
|