msw 2.3.0-ws.rc-6 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -9
- package/cli/init.js +0 -0
- package/config/scripts/postinstall.js +0 -0
- package/lib/browser/index.d.mts +6 -7
- package/lib/browser/index.d.ts +6 -7
- package/lib/browser/index.js +156 -83
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +156 -83
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{GraphQLHandler-DGyzNtRQ.d.ts → GraphQLHandler-COiPfZ8k.d.ts} +1 -1
- package/lib/core/{GraphQLHandler-CzcXr7At.d.mts → GraphQLHandler-Dq_WRbKe.d.mts} +1 -1
- package/lib/core/{HttpResponse-BOzDwzB6.d.ts → HttpResponse-B07UKAkU.d.ts} +2 -2
- package/lib/core/{HttpResponse-CSyJ1cbO.d.mts → HttpResponse-C7niBMwb.d.mts} +2 -2
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/SetupApi.d.mts +12 -15
- package/lib/core/SetupApi.d.ts +12 -15
- package/lib/core/SetupApi.js +1 -3
- package/lib/core/SetupApi.js.map +1 -1
- package/lib/core/SetupApi.mjs +1 -3
- package/lib/core/SetupApi.mjs.map +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +2 -2
- package/lib/core/graphql.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- 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/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +2 -5
- package/lib/core/index.d.ts +2 -5
- package/lib/core/index.js +1 -5
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +1 -7
- 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/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/executeHandlers.js +0 -4
- package/lib/core/utils/executeHandlers.js.map +1 -1
- package/lib/core/utils/executeHandlers.mjs +0 -6
- package/lib/core/utils/executeHandlers.mjs.map +1 -1
- package/lib/core/utils/handleRequest.d.mts +2 -2
- package/lib/core/utils/handleRequest.d.ts +2 -2
- package/lib/core/utils/handleRequest.js.map +1 -1
- package/lib/core/utils/handleRequest.mjs.map +1 -1
- package/lib/core/utils/internal/Disposable.d.mts +2 -2
- package/lib/core/utils/internal/Disposable.d.ts +2 -2
- package/lib/core/utils/internal/Disposable.js +5 -2
- package/lib/core/utils/internal/Disposable.js.map +1 -1
- package/lib/core/utils/internal/Disposable.mjs +5 -2
- package/lib/core/utils/internal/Disposable.mjs.map +1 -1
- package/lib/core/utils/internal/devUtils.d.mts +10 -1
- package/lib/core/utils/internal/devUtils.d.ts +10 -1
- package/lib/core/utils/internal/devUtils.js +7 -0
- package/lib/core/utils/internal/devUtils.js.map +1 -1
- package/lib/core/utils/internal/devUtils.mjs +7 -0
- package/lib/core/utils/internal/devUtils.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 +1 -4
- package/lib/core/utils/logging/getTimestamp.d.ts +1 -4
- package/lib/core/utils/logging/getTimestamp.js +2 -6
- package/lib/core/utils/logging/getTimestamp.js.map +1 -1
- package/lib/core/utils/logging/getTimestamp.mjs +2 -6
- package/lib/core/utils/logging/getTimestamp.mjs.map +1 -1
- package/lib/core/utils/matching/matchRequestUrl.d.mts +1 -2
- package/lib/core/utils/matching/matchRequestUrl.d.ts +1 -2
- package/lib/core/utils/matching/matchRequestUrl.js +0 -4
- package/lib/core/utils/matching/matchRequestUrl.js.map +1 -1
- package/lib/core/utils/matching/matchRequestUrl.mjs +0 -4
- package/lib/core/utils/matching/matchRequestUrl.mjs.map +1 -1
- package/lib/core/utils/matching/normalizePath.d.mts +1 -0
- package/lib/core/utils/matching/normalizePath.d.ts +1 -0
- package/lib/core/utils/matching/normalizePath.js.map +1 -1
- package/lib/core/utils/matching/normalizePath.mjs.map +1 -1
- package/lib/core/utils/request/onUnhandledRequest.js +3 -3
- package/lib/core/utils/request/onUnhandledRequest.js.map +1 -1
- package/lib/core/utils/request/onUnhandledRequest.mjs +4 -4
- package/lib/core/utils/request/onUnhandledRequest.mjs.map +1 -1
- package/lib/core/utils/url/cleanUrl.d.mts +2 -1
- package/lib/core/utils/url/cleanUrl.d.ts +2 -1
- package/lib/core/utils/url/cleanUrl.js +3 -0
- package/lib/core/utils/url/cleanUrl.js.map +1 -1
- package/lib/core/utils/url/cleanUrl.mjs +3 -0
- package/lib/core/utils/url/cleanUrl.mjs.map +1 -1
- package/lib/iife/index.js +180 -1103
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/lib/native/index.d.mts +5 -6
- package/lib/native/index.d.ts +5 -6
- package/lib/native/index.js +5 -13
- package/lib/native/index.js.map +1 -1
- package/lib/native/index.mjs +6 -14
- package/lib/native/index.mjs.map +1 -1
- package/lib/node/index.d.mts +7 -8
- package/lib/node/index.d.ts +7 -8
- package/lib/node/index.js +5 -13
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +6 -14
- package/lib/node/index.mjs.map +1 -1
- package/package.json +36 -29
- package/src/browser/setupWorker/glossary.ts +10 -10
- package/src/browser/setupWorker/setupWorker.ts +3 -34
- package/src/browser/setupWorker/stop/createStop.ts +0 -4
- package/src/core/SetupApi.ts +20 -28
- package/src/core/index.ts +1 -8
- package/src/core/utils/executeHandlers.ts +2 -6
- package/src/core/utils/handleRequest.ts +2 -1
- package/src/core/utils/internal/Disposable.ts +6 -3
- package/src/core/utils/internal/devUtils.test.ts +21 -0
- package/src/core/utils/internal/devUtils.ts +13 -0
- package/src/core/utils/logging/getTimestamp.test.ts +6 -20
- package/src/core/utils/logging/getTimestamp.ts +6 -11
- package/src/core/utils/matching/matchRequestUrl.test.ts +8 -41
- package/src/core/utils/matching/matchRequestUrl.ts +0 -4
- package/src/core/utils/matching/normalizePath.test.ts +7 -1
- package/src/core/utils/matching/normalizePath.ts +1 -0
- package/src/core/utils/request/onUnhandledRequest.test.ts +30 -4
- package/src/core/utils/request/onUnhandledRequest.ts +4 -4
- package/src/core/utils/url/cleanUrl.test.ts +8 -3
- package/src/core/utils/url/cleanUrl.ts +9 -1
- package/src/core/utils/url/getAbsoluteUrl.node.test.ts +3 -3
- package/src/core/utils/url/getAbsoluteUrl.test.ts +5 -5
- package/src/core/utils/url/isAbsoluteUrl.test.ts +7 -7
- package/src/node/SetupServerApi.ts +7 -8
- package/src/node/SetupServerCommonApi.ts +8 -15
- package/src/node/glossary.ts +7 -5
- package/src/node/setupServer.ts +1 -2
- package/lib/core/handlers/WebSocketHandler.d.mts +0 -32
- package/lib/core/handlers/WebSocketHandler.d.ts +0 -32
- package/lib/core/handlers/WebSocketHandler.js +0 -62
- package/lib/core/handlers/WebSocketHandler.js.map +0 -1
- package/lib/core/handlers/WebSocketHandler.mjs +0 -44
- package/lib/core/handlers/WebSocketHandler.mjs.map +0 -1
- package/lib/core/ws/WebSocketClientManager.d.mts +0 -58
- package/lib/core/ws/WebSocketClientManager.d.ts +0 -58
- package/lib/core/ws/WebSocketClientManager.js +0 -162
- package/lib/core/ws/WebSocketClientManager.js.map +0 -1
- package/lib/core/ws/WebSocketClientManager.mjs +0 -142
- package/lib/core/ws/WebSocketClientManager.mjs.map +0 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +0 -16
- package/lib/core/ws/handleWebSocketEvent.d.ts +0 -16
- package/lib/core/ws/handleWebSocketEvent.js +0 -56
- package/lib/core/ws/handleWebSocketEvent.js.map +0 -1
- package/lib/core/ws/handleWebSocketEvent.mjs +0 -36
- package/lib/core/ws/handleWebSocketEvent.mjs.map +0 -1
- package/lib/core/ws/utils/attachWebSocketLogger.d.mts +0 -34
- package/lib/core/ws/utils/attachWebSocketLogger.d.ts +0 -34
- package/lib/core/ws/utils/attachWebSocketLogger.js +0 -217
- package/lib/core/ws/utils/attachWebSocketLogger.js.map +0 -1
- package/lib/core/ws/utils/attachWebSocketLogger.mjs +0 -197
- package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +0 -1
- package/lib/core/ws/utils/getMessageLength.d.mts +0 -11
- package/lib/core/ws/utils/getMessageLength.d.ts +0 -11
- package/lib/core/ws/utils/getMessageLength.js +0 -33
- package/lib/core/ws/utils/getMessageLength.js.map +0 -1
- package/lib/core/ws/utils/getMessageLength.mjs +0 -13
- package/lib/core/ws/utils/getMessageLength.mjs.map +0 -1
- package/lib/core/ws/utils/getPublicData.d.mts +0 -5
- package/lib/core/ws/utils/getPublicData.d.ts +0 -5
- package/lib/core/ws/utils/getPublicData.js +0 -36
- package/lib/core/ws/utils/getPublicData.js.map +0 -1
- package/lib/core/ws/utils/getPublicData.mjs +0 -16
- package/lib/core/ws/utils/getPublicData.mjs.map +0 -1
- package/lib/core/ws/utils/truncateMessage.d.mts +0 -3
- package/lib/core/ws/utils/truncateMessage.d.ts +0 -3
- package/lib/core/ws/utils/truncateMessage.js +0 -31
- package/lib/core/ws/utils/truncateMessage.js.map +0 -1
- package/lib/core/ws/utils/truncateMessage.mjs +0 -11
- package/lib/core/ws/utils/truncateMessage.mjs.map +0 -1
- package/lib/core/ws/webSocketInterceptor.d.mts +0 -5
- package/lib/core/ws/webSocketInterceptor.d.ts +0 -5
- package/lib/core/ws/webSocketInterceptor.js +0 -26
- package/lib/core/ws/webSocketInterceptor.js.map +0 -1
- package/lib/core/ws/webSocketInterceptor.mjs +0 -6
- package/lib/core/ws/webSocketInterceptor.mjs.map +0 -1
- package/lib/core/ws.d.mts +0 -49
- package/lib/core/ws.d.ts +0 -49
- package/lib/core/ws.js +0 -65
- package/lib/core/ws.js.map +0 -1
- package/lib/core/ws.mjs +0 -48
- package/lib/core/ws.mjs.map +0 -1
- package/src/core/handlers/WebSocketHandler.ts +0 -71
- package/src/core/ws/WebSocketClientManager.test.ts +0 -157
- package/src/core/ws/WebSocketClientManager.ts +0 -234
- package/src/core/ws/handleWebSocketEvent.ts +0 -56
- package/src/core/ws/utils/attachWebSocketLogger.ts +0 -269
- package/src/core/ws/utils/getMessageLength.test.ts +0 -16
- package/src/core/ws/utils/getMessageLength.ts +0 -19
- package/src/core/ws/utils/getPublicData.test.ts +0 -38
- package/src/core/ws/utils/getPublicData.ts +0 -17
- package/src/core/ws/utils/truncateMessage.test.ts +0 -12
- package/src/core/ws/utils/truncateMessage.ts +0 -9
- package/src/core/ws/webSocketInterceptor.ts +0 -3
- package/src/core/ws.test.ts +0 -23
- package/src/core/ws.ts +0 -124
package/lib/mockServiceWorker.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.3.
|
|
11
|
+
const PACKAGE_VERSION = '2.3.1'
|
|
12
12
|
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
package/lib/native/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RequestHandler } from "../core/handlers/RequestHandler";
|
|
1
|
+
import { RequestHandler, RequestHandlerDefaultInfo } from "../core/handlers/RequestHandler";
|
|
2
2
|
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
|
|
3
3
|
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions";
|
|
4
4
|
import { SetupApi } from "../core/SetupApi";
|
|
5
|
-
import { WebSocketHandler } from "../core/handlers/WebSocketHandler";
|
|
6
5
|
import { PartialDeep } from 'type-fest';
|
|
7
6
|
|
|
8
7
|
interface SetupServerCommon {
|
|
@@ -23,7 +22,7 @@ interface SetupServerCommon {
|
|
|
23
22
|
*
|
|
24
23
|
* @see {@link https://mswjs.io/docs/api/setup-server/use `server.use()` API reference}
|
|
25
24
|
*/
|
|
26
|
-
use(...handlers: Array<RequestHandler
|
|
25
|
+
use(...handlers: Array<RequestHandler>): void;
|
|
27
26
|
/**
|
|
28
27
|
* Marks all request handlers that respond using `res.once()` as unused.
|
|
29
28
|
*
|
|
@@ -35,13 +34,13 @@ interface SetupServerCommon {
|
|
|
35
34
|
*
|
|
36
35
|
* @see {@link https://mswjs.io/docs/api/setup-server/reset-handlers `server.reset-handlers()` API reference}
|
|
37
36
|
*/
|
|
38
|
-
resetHandlers(...nextHandlers: Array<RequestHandler
|
|
37
|
+
resetHandlers(...nextHandlers: Array<RequestHandler>): void;
|
|
39
38
|
/**
|
|
40
39
|
* Returns a readonly list of currently active request handlers.
|
|
41
40
|
*
|
|
42
41
|
* @see {@link https://mswjs.io/docs/api/setup-server/list-handlers `server.listHandlers()` API reference}
|
|
43
42
|
*/
|
|
44
|
-
listHandlers(): ReadonlyArray<RequestHandler
|
|
43
|
+
listHandlers(): ReadonlyArray<RequestHandler<RequestHandlerDefaultInfo, any>>;
|
|
45
44
|
/**
|
|
46
45
|
* Life-cycle events.
|
|
47
46
|
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
|
@@ -61,7 +60,7 @@ declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implemen
|
|
|
61
60
|
private resolvedOptions;
|
|
62
61
|
constructor(interceptors: Array<{
|
|
63
62
|
new (): Interceptor<HttpRequestEventMap>;
|
|
64
|
-
}>, handlers: Array<RequestHandler
|
|
63
|
+
}>, handlers: Array<RequestHandler>);
|
|
65
64
|
/**
|
|
66
65
|
* Subscribe to all requests that are using the interceptor object
|
|
67
66
|
*/
|
package/lib/native/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { RequestHandler } from "../core/handlers/RequestHandler";
|
|
1
|
+
import { RequestHandler, RequestHandlerDefaultInfo } from "../core/handlers/RequestHandler";
|
|
2
2
|
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
|
|
3
3
|
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions";
|
|
4
4
|
import { SetupApi } from "../core/SetupApi";
|
|
5
|
-
import { WebSocketHandler } from "../core/handlers/WebSocketHandler";
|
|
6
5
|
import { PartialDeep } from 'type-fest';
|
|
7
6
|
|
|
8
7
|
interface SetupServerCommon {
|
|
@@ -23,7 +22,7 @@ interface SetupServerCommon {
|
|
|
23
22
|
*
|
|
24
23
|
* @see {@link https://mswjs.io/docs/api/setup-server/use `server.use()` API reference}
|
|
25
24
|
*/
|
|
26
|
-
use(...handlers: Array<RequestHandler
|
|
25
|
+
use(...handlers: Array<RequestHandler>): void;
|
|
27
26
|
/**
|
|
28
27
|
* Marks all request handlers that respond using `res.once()` as unused.
|
|
29
28
|
*
|
|
@@ -35,13 +34,13 @@ interface SetupServerCommon {
|
|
|
35
34
|
*
|
|
36
35
|
* @see {@link https://mswjs.io/docs/api/setup-server/reset-handlers `server.reset-handlers()` API reference}
|
|
37
36
|
*/
|
|
38
|
-
resetHandlers(...nextHandlers: Array<RequestHandler
|
|
37
|
+
resetHandlers(...nextHandlers: Array<RequestHandler>): void;
|
|
39
38
|
/**
|
|
40
39
|
* Returns a readonly list of currently active request handlers.
|
|
41
40
|
*
|
|
42
41
|
* @see {@link https://mswjs.io/docs/api/setup-server/list-handlers `server.listHandlers()` API reference}
|
|
43
42
|
*/
|
|
44
|
-
listHandlers(): ReadonlyArray<RequestHandler
|
|
43
|
+
listHandlers(): ReadonlyArray<RequestHandler<RequestHandlerDefaultInfo, any>>;
|
|
45
44
|
/**
|
|
46
45
|
* Life-cycle events.
|
|
47
46
|
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
|
@@ -61,7 +60,7 @@ declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implemen
|
|
|
61
60
|
private resolvedOptions;
|
|
62
61
|
constructor(interceptors: Array<{
|
|
63
62
|
new (): Interceptor<HttpRequestEventMap>;
|
|
64
|
-
}>, handlers: Array<RequestHandler
|
|
63
|
+
}>, handlers: Array<RequestHandler>);
|
|
65
64
|
/**
|
|
66
65
|
* Subscribe to all requests that are using the interceptor object
|
|
67
66
|
*/
|
package/lib/native/index.js
CHANGED
|
@@ -33,8 +33,6 @@ var import_SetupApi = require("../core/SetupApi.js");
|
|
|
33
33
|
var import_handleRequest = require("../core/utils/handleRequest.js");
|
|
34
34
|
var import_mergeRight = require("../core/utils/internal/mergeRight.js");
|
|
35
35
|
var import_devUtils = require("../core/utils/internal/devUtils.js");
|
|
36
|
-
var import_handleWebSocketEvent = require("../core/ws/handleWebSocketEvent.js");
|
|
37
|
-
var import_webSocketInterceptor = require("../core/ws/webSocketInterceptor.js");
|
|
38
36
|
var DEFAULT_LISTEN_OPTIONS = {
|
|
39
37
|
onUnhandledRequest: "warn"
|
|
40
38
|
};
|
|
@@ -67,6 +65,11 @@ var SetupServerCommonApi = class extends import_SetupApi.SetupApi {
|
|
|
67
65
|
}
|
|
68
66
|
return;
|
|
69
67
|
});
|
|
68
|
+
this.interceptor.on("unhandledException", ({ error }) => {
|
|
69
|
+
if (error instanceof import_devUtils.InternalError) {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
70
73
|
this.interceptor.on(
|
|
71
74
|
"response",
|
|
72
75
|
({ response, isMockedResponse, request, requestId }) => {
|
|
@@ -80,15 +83,6 @@ var SetupServerCommonApi = class extends import_SetupApi.SetupApi {
|
|
|
80
83
|
);
|
|
81
84
|
}
|
|
82
85
|
);
|
|
83
|
-
(0, import_handleWebSocketEvent.handleWebSocketEvent)({
|
|
84
|
-
getHandlers: () => {
|
|
85
|
-
return this.handlersController.currentHandlers();
|
|
86
|
-
},
|
|
87
|
-
onMockedConnection: () => {
|
|
88
|
-
},
|
|
89
|
-
onPassthroughConnection: () => {
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
86
|
}
|
|
93
87
|
listen(options = {}) {
|
|
94
88
|
this.resolvedOptions = (0, import_mergeRight.mergeRight)(
|
|
@@ -96,10 +90,8 @@ var SetupServerCommonApi = class extends import_SetupApi.SetupApi {
|
|
|
96
90
|
options
|
|
97
91
|
);
|
|
98
92
|
this.interceptor.apply();
|
|
99
|
-
import_webSocketInterceptor.webSocketInterceptor.apply();
|
|
100
93
|
this.subscriptions.push(() => {
|
|
101
94
|
this.interceptor.dispose();
|
|
102
|
-
import_webSocketInterceptor.webSocketInterceptor.dispose();
|
|
103
95
|
});
|
|
104
96
|
(0, import_outvariant.invariant)(
|
|
105
97
|
[import_interceptors.InterceptorReadyState.APPLYING, import_interceptors.InterceptorReadyState.APPLIED].includes(
|
package/lib/native/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/native/index.ts","../../src/node/SetupServerCommonApi.ts"],"sourcesContent":["import { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { SetupServerCommonApi } from '../node/SetupServerCommonApi'\n\n/**\n * Sets up a requests interception in React Native with the given request handlers.\n * @param {RequestHandler[]} handlers List of request handlers.\n *\n * @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}\n */\nexport function setupServer(\n ...handlers: Array<RequestHandler>\n): SetupServerCommonApi {\n // Provision request interception via patching the `XMLHttpRequest` class only\n // in React Native. There is no `http`/`https` modules in that environment.\n return new SetupServerCommonApi(\n [FetchInterceptor, XMLHttpRequestInterceptor],\n handlers,\n )\n}\n","/**\n * @note This API is extended by both \"msw/node\" and \"msw/native\"\n * so be minding about the things you import!\n */\nimport type { RequiredDeep } from 'type-fest'\nimport { invariant } from 'outvariant'\nimport {\n BatchInterceptor,\n InterceptorReadyState,\n type HttpRequestEventMap,\n type Interceptor,\n} from '@mswjs/interceptors'\nimport type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'\nimport { SetupApi } from '~/core/SetupApi'\nimport { handleRequest } from '~/core/utils/handleRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/native/index.ts","../../src/node/SetupServerCommonApi.ts"],"sourcesContent":["import { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { SetupServerCommonApi } from '../node/SetupServerCommonApi'\n\n/**\n * Sets up a requests interception in React Native with the given request handlers.\n * @param {RequestHandler[]} handlers List of request handlers.\n *\n * @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}\n */\nexport function setupServer(\n ...handlers: Array<RequestHandler>\n): SetupServerCommonApi {\n // Provision request interception via patching the `XMLHttpRequest` class only\n // in React Native. There is no `http`/`https` modules in that environment.\n return new SetupServerCommonApi(\n [FetchInterceptor, XMLHttpRequestInterceptor],\n handlers,\n )\n}\n","/**\n * @note This API is extended by both \"msw/node\" and \"msw/native\"\n * so be minding about the things you import!\n */\nimport type { RequiredDeep } from 'type-fest'\nimport { invariant } from 'outvariant'\nimport {\n BatchInterceptor,\n InterceptorReadyState,\n type HttpRequestEventMap,\n type Interceptor,\n} from '@mswjs/interceptors'\nimport type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'\nimport { SetupApi } from '~/core/SetupApi'\nimport { handleRequest } from '~/core/utils/handleRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { mergeRight } from '~/core/utils/internal/mergeRight'\nimport { InternalError, devUtils } from '~/core/utils/internal/devUtils'\nimport type { SetupServerCommon } from './glossary'\n\nexport const DEFAULT_LISTEN_OPTIONS: RequiredDeep<SharedOptions> = {\n onUnhandledRequest: 'warn',\n}\n\nexport class SetupServerCommonApi\n extends SetupApi<LifeCycleEventsMap>\n implements SetupServerCommon\n{\n protected readonly interceptor: BatchInterceptor<\n Array<Interceptor<HttpRequestEventMap>>,\n HttpRequestEventMap\n >\n private resolvedOptions: RequiredDeep<SharedOptions>\n\n constructor(\n interceptors: Array<{ new (): Interceptor<HttpRequestEventMap> }>,\n handlers: Array<RequestHandler>,\n ) {\n super(...handlers)\n\n this.interceptor = new BatchInterceptor({\n name: 'setup-server',\n interceptors: interceptors.map((Interceptor) => new Interceptor()),\n })\n\n this.resolvedOptions = {} as RequiredDeep<SharedOptions>\n\n this.init()\n }\n\n /**\n * Subscribe to all requests that are using the interceptor object\n */\n private init(): void {\n this.interceptor.on('request', async ({ request, requestId }) => {\n const response = await handleRequest(\n request,\n requestId,\n this.handlersController.currentHandlers(),\n this.resolvedOptions,\n this.emitter,\n )\n\n if (response) {\n request.respondWith(response)\n }\n\n return\n })\n\n this.interceptor.on('unhandledException', ({ error }) => {\n if (error instanceof InternalError) {\n throw error\n }\n })\n\n this.interceptor.on(\n 'response',\n ({ response, isMockedResponse, request, requestId }) => {\n this.emitter.emit(\n isMockedResponse ? 'response:mocked' : 'response:bypass',\n {\n response,\n request,\n requestId,\n },\n )\n },\n )\n }\n\n public listen(options: Partial<SharedOptions> = {}): void {\n this.resolvedOptions = mergeRight(\n DEFAULT_LISTEN_OPTIONS,\n options,\n ) as RequiredDeep<SharedOptions>\n\n // Apply the interceptor when starting the server.\n this.interceptor.apply()\n\n this.subscriptions.push(() => {\n this.interceptor.dispose()\n })\n\n // Assert that the interceptor has been applied successfully.\n // Also guards us from forgetting to call \"interceptor.apply()\"\n // as a part of the \"listen\" method.\n invariant(\n [InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(\n this.interceptor.readyState,\n ),\n devUtils.formatMessage(\n 'Failed to start \"setupServer\": the interceptor failed to apply. This is likely an issue with the library and you should report it at \"%s\".',\n ),\n 'https://github.com/mswjs/msw/issues/new/choose',\n )\n }\n\n public close(): void {\n this.dispose()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiC;AACjC,4BAA0C;;;ACI1C,wBAA0B;AAC1B,0BAKO;AAEP,sBAAyB;AACzB,2BAA8B;AAE9B,wBAA2B;AAC3B,sBAAwC;AAGjC,IAAM,yBAAsD;AAAA,EACjE,oBAAoB;AACtB;AAEO,IAAM,uBAAN,cACG,yBAEV;AAAA,EACqB;AAAA,EAIX;AAAA,EAER,YACE,cACA,UACA;AACA,UAAM,GAAG,QAAQ;AAEjB,SAAK,cAAc,IAAI,qCAAiB;AAAA,MACtC,MAAM;AAAA,MACN,cAAc,aAAa,IAAI,CAAC,gBAAgB,IAAI,YAAY,CAAC;AAAA,IACnE,CAAC;AAED,SAAK,kBAAkB,CAAC;AAExB,SAAK,KAAK;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAKQ,OAAa;AACnB,SAAK,YAAY,GAAG,WAAW,OAAO,EAAE,SAAS,UAAU,MAAM;AAC/D,YAAM,WAAW,UAAM;AAAA,QACrB;AAAA,QACA;AAAA,QACA,KAAK,mBAAmB,gBAAgB;AAAA,QACxC,KAAK;AAAA,QACL,KAAK;AAAA,MACP;AAEA,UAAI,UAAU;AACZ,gBAAQ,YAAY,QAAQ;AAAA,MAC9B;AAEA;AAAA,IACF,CAAC;AAED,SAAK,YAAY,GAAG,sBAAsB,CAAC,EAAE,MAAM,MAAM;AACvD,UAAI,iBAAiB,+BAAe;AAClC,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAED,SAAK,YAAY;AAAA,MACf;AAAA,MACA,CAAC,EAAE,UAAU,kBAAkB,SAAS,UAAU,MAAM;AACtD,aAAK,QAAQ;AAAA,UACX,mBAAmB,oBAAoB;AAAA,UACvC;AAAA,YACE;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEO,OAAO,UAAkC,CAAC,GAAS;AACxD,SAAK,sBAAkB;AAAA,MACrB;AAAA,MACA;AAAA,IACF;AAGA,SAAK,YAAY,MAAM;AAEvB,SAAK,cAAc,KAAK,MAAM;AAC5B,WAAK,YAAY,QAAQ;AAAA,IAC3B,CAAC;AAKD;AAAA,MACE,CAAC,0CAAsB,UAAU,0CAAsB,OAAO,EAAE;AAAA,QAC9D,KAAK,YAAY;AAAA,MACnB;AAAA,MACA,yBAAS;AAAA,QACP;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEO,QAAc;AACnB,SAAK,QAAQ;AAAA,EACf;AACF;;;AD9GO,SAAS,eACX,UACmB;AAGtB,SAAO,IAAI;AAAA,IACT,CAAC,+BAAkB,+CAAyB;AAAA,IAC5C;AAAA,EACF;AACF;","names":[]}
|
package/lib/native/index.mjs
CHANGED
|
@@ -11,9 +11,7 @@ import {
|
|
|
11
11
|
import { SetupApi } from '../core/SetupApi.mjs';
|
|
12
12
|
import { handleRequest } from '../core/utils/handleRequest.mjs';
|
|
13
13
|
import { mergeRight } from '../core/utils/internal/mergeRight.mjs';
|
|
14
|
-
import { devUtils } from '../core/utils/internal/devUtils.mjs';
|
|
15
|
-
import { handleWebSocketEvent } from '../core/ws/handleWebSocketEvent.mjs';
|
|
16
|
-
import { webSocketInterceptor } from '../core/ws/webSocketInterceptor.mjs';
|
|
14
|
+
import { InternalError, devUtils } from '../core/utils/internal/devUtils.mjs';
|
|
17
15
|
var DEFAULT_LISTEN_OPTIONS = {
|
|
18
16
|
onUnhandledRequest: "warn"
|
|
19
17
|
};
|
|
@@ -46,6 +44,11 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
|
46
44
|
}
|
|
47
45
|
return;
|
|
48
46
|
});
|
|
47
|
+
this.interceptor.on("unhandledException", ({ error }) => {
|
|
48
|
+
if (error instanceof InternalError) {
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
49
52
|
this.interceptor.on(
|
|
50
53
|
"response",
|
|
51
54
|
({ response, isMockedResponse, request, requestId }) => {
|
|
@@ -59,15 +62,6 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
|
59
62
|
);
|
|
60
63
|
}
|
|
61
64
|
);
|
|
62
|
-
handleWebSocketEvent({
|
|
63
|
-
getHandlers: () => {
|
|
64
|
-
return this.handlersController.currentHandlers();
|
|
65
|
-
},
|
|
66
|
-
onMockedConnection: () => {
|
|
67
|
-
},
|
|
68
|
-
onPassthroughConnection: () => {
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
65
|
}
|
|
72
66
|
listen(options = {}) {
|
|
73
67
|
this.resolvedOptions = mergeRight(
|
|
@@ -75,10 +69,8 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
|
75
69
|
options
|
|
76
70
|
);
|
|
77
71
|
this.interceptor.apply();
|
|
78
|
-
webSocketInterceptor.apply();
|
|
79
72
|
this.subscriptions.push(() => {
|
|
80
73
|
this.interceptor.dispose();
|
|
81
|
-
webSocketInterceptor.dispose();
|
|
82
74
|
});
|
|
83
75
|
invariant(
|
|
84
76
|
[InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(
|
package/lib/native/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/native/index.ts","../../src/node/SetupServerCommonApi.ts"],"sourcesContent":["import { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { SetupServerCommonApi } from '../node/SetupServerCommonApi'\n\n/**\n * Sets up a requests interception in React Native with the given request handlers.\n * @param {RequestHandler[]} handlers List of request handlers.\n *\n * @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}\n */\nexport function setupServer(\n ...handlers: Array<RequestHandler>\n): SetupServerCommonApi {\n // Provision request interception via patching the `XMLHttpRequest` class only\n // in React Native. There is no `http`/`https` modules in that environment.\n return new SetupServerCommonApi(\n [FetchInterceptor, XMLHttpRequestInterceptor],\n handlers,\n )\n}\n","/**\n * @note This API is extended by both \"msw/node\" and \"msw/native\"\n * so be minding about the things you import!\n */\nimport type { RequiredDeep } from 'type-fest'\nimport { invariant } from 'outvariant'\nimport {\n BatchInterceptor,\n InterceptorReadyState,\n type HttpRequestEventMap,\n type Interceptor,\n} from '@mswjs/interceptors'\nimport type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'\nimport { SetupApi } from '~/core/SetupApi'\nimport { handleRequest } from '~/core/utils/handleRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/native/index.ts","../../src/node/SetupServerCommonApi.ts"],"sourcesContent":["import { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { SetupServerCommonApi } from '../node/SetupServerCommonApi'\n\n/**\n * Sets up a requests interception in React Native with the given request handlers.\n * @param {RequestHandler[]} handlers List of request handlers.\n *\n * @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}\n */\nexport function setupServer(\n ...handlers: Array<RequestHandler>\n): SetupServerCommonApi {\n // Provision request interception via patching the `XMLHttpRequest` class only\n // in React Native. There is no `http`/`https` modules in that environment.\n return new SetupServerCommonApi(\n [FetchInterceptor, XMLHttpRequestInterceptor],\n handlers,\n )\n}\n","/**\n * @note This API is extended by both \"msw/node\" and \"msw/native\"\n * so be minding about the things you import!\n */\nimport type { RequiredDeep } from 'type-fest'\nimport { invariant } from 'outvariant'\nimport {\n BatchInterceptor,\n InterceptorReadyState,\n type HttpRequestEventMap,\n type Interceptor,\n} from '@mswjs/interceptors'\nimport type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'\nimport { SetupApi } from '~/core/SetupApi'\nimport { handleRequest } from '~/core/utils/handleRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { mergeRight } from '~/core/utils/internal/mergeRight'\nimport { InternalError, devUtils } from '~/core/utils/internal/devUtils'\nimport type { SetupServerCommon } from './glossary'\n\nexport const DEFAULT_LISTEN_OPTIONS: RequiredDeep<SharedOptions> = {\n onUnhandledRequest: 'warn',\n}\n\nexport class SetupServerCommonApi\n extends SetupApi<LifeCycleEventsMap>\n implements SetupServerCommon\n{\n protected readonly interceptor: BatchInterceptor<\n Array<Interceptor<HttpRequestEventMap>>,\n HttpRequestEventMap\n >\n private resolvedOptions: RequiredDeep<SharedOptions>\n\n constructor(\n interceptors: Array<{ new (): Interceptor<HttpRequestEventMap> }>,\n handlers: Array<RequestHandler>,\n ) {\n super(...handlers)\n\n this.interceptor = new BatchInterceptor({\n name: 'setup-server',\n interceptors: interceptors.map((Interceptor) => new Interceptor()),\n })\n\n this.resolvedOptions = {} as RequiredDeep<SharedOptions>\n\n this.init()\n }\n\n /**\n * Subscribe to all requests that are using the interceptor object\n */\n private init(): void {\n this.interceptor.on('request', async ({ request, requestId }) => {\n const response = await handleRequest(\n request,\n requestId,\n this.handlersController.currentHandlers(),\n this.resolvedOptions,\n this.emitter,\n )\n\n if (response) {\n request.respondWith(response)\n }\n\n return\n })\n\n this.interceptor.on('unhandledException', ({ error }) => {\n if (error instanceof InternalError) {\n throw error\n }\n })\n\n this.interceptor.on(\n 'response',\n ({ response, isMockedResponse, request, requestId }) => {\n this.emitter.emit(\n isMockedResponse ? 'response:mocked' : 'response:bypass',\n {\n response,\n request,\n requestId,\n },\n )\n },\n )\n }\n\n public listen(options: Partial<SharedOptions> = {}): void {\n this.resolvedOptions = mergeRight(\n DEFAULT_LISTEN_OPTIONS,\n options,\n ) as RequiredDeep<SharedOptions>\n\n // Apply the interceptor when starting the server.\n this.interceptor.apply()\n\n this.subscriptions.push(() => {\n this.interceptor.dispose()\n })\n\n // Assert that the interceptor has been applied successfully.\n // Also guards us from forgetting to call \"interceptor.apply()\"\n // as a part of the \"listen\" method.\n invariant(\n [InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(\n this.interceptor.readyState,\n ),\n devUtils.formatMessage(\n 'Failed to start \"setupServer\": the interceptor failed to apply. This is likely an issue with the library and you should report it at \"%s\".',\n ),\n 'https://github.com/mswjs/msw/issues/new/choose',\n )\n }\n\n public close(): void {\n this.dispose()\n }\n}\n"],"mappings":";AAAA,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;;;ACI1C,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAE9B,SAAS,kBAAkB;AAC3B,SAAS,eAAe,gBAAgB;AAGjC,IAAM,yBAAsD;AAAA,EACjE,oBAAoB;AACtB;AAEO,IAAM,uBAAN,cACG,SAEV;AAAA,EACqB;AAAA,EAIX;AAAA,EAER,YACE,cACA,UACA;AACA,UAAM,GAAG,QAAQ;AAEjB,SAAK,cAAc,IAAI,iBAAiB;AAAA,MACtC,MAAM;AAAA,MACN,cAAc,aAAa,IAAI,CAAC,gBAAgB,IAAI,YAAY,CAAC;AAAA,IACnE,CAAC;AAED,SAAK,kBAAkB,CAAC;AAExB,SAAK,KAAK;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAKQ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'type-fest';
|
|
2
|
-
import { RequestHandler } from "../core/handlers/RequestHandler";
|
|
3
|
-
import { WebSocketHandler } from "../core/handlers/WebSocketHandler";
|
|
2
|
+
import { RequestHandler, RequestHandlerDefaultInfo } from "../core/handlers/RequestHandler";
|
|
4
3
|
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions";
|
|
5
4
|
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
|
|
6
5
|
import { SetupApi } from "../core/SetupApi";
|
|
@@ -23,7 +22,7 @@ interface SetupServerCommon {
|
|
|
23
22
|
*
|
|
24
23
|
* @see {@link https://mswjs.io/docs/api/setup-server/use `server.use()` API reference}
|
|
25
24
|
*/
|
|
26
|
-
use(...handlers: Array<RequestHandler
|
|
25
|
+
use(...handlers: Array<RequestHandler>): void;
|
|
27
26
|
/**
|
|
28
27
|
* Marks all request handlers that respond using `res.once()` as unused.
|
|
29
28
|
*
|
|
@@ -35,13 +34,13 @@ interface SetupServerCommon {
|
|
|
35
34
|
*
|
|
36
35
|
* @see {@link https://mswjs.io/docs/api/setup-server/reset-handlers `server.reset-handlers()` API reference}
|
|
37
36
|
*/
|
|
38
|
-
resetHandlers(...nextHandlers: Array<RequestHandler
|
|
37
|
+
resetHandlers(...nextHandlers: Array<RequestHandler>): void;
|
|
39
38
|
/**
|
|
40
39
|
* Returns a readonly list of currently active request handlers.
|
|
41
40
|
*
|
|
42
41
|
* @see {@link https://mswjs.io/docs/api/setup-server/list-handlers `server.listHandlers()` API reference}
|
|
43
42
|
*/
|
|
44
|
-
listHandlers(): ReadonlyArray<RequestHandler
|
|
43
|
+
listHandlers(): ReadonlyArray<RequestHandler<RequestHandlerDefaultInfo, any>>;
|
|
45
44
|
/**
|
|
46
45
|
* Life-cycle events.
|
|
47
46
|
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
|
@@ -72,7 +71,7 @@ declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implemen
|
|
|
72
71
|
private resolvedOptions;
|
|
73
72
|
constructor(interceptors: Array<{
|
|
74
73
|
new (): Interceptor<HttpRequestEventMap>;
|
|
75
|
-
}>, handlers: Array<RequestHandler
|
|
74
|
+
}>, handlers: Array<RequestHandler>);
|
|
76
75
|
/**
|
|
77
76
|
* Subscribe to all requests that are using the interceptor object
|
|
78
77
|
*/
|
|
@@ -82,7 +81,7 @@ declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implemen
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
declare class SetupServerApi extends SetupServerCommonApi implements SetupServer {
|
|
85
|
-
constructor(handlers: Array<RequestHandler
|
|
84
|
+
constructor(handlers: Array<RequestHandler>);
|
|
86
85
|
boundary<Args extends Array<any>, R>(callback: (...args: Args) => R): (...args: Args) => R;
|
|
87
86
|
close(): void;
|
|
88
87
|
}
|
|
@@ -93,6 +92,6 @@ declare class SetupServerApi extends SetupServerCommonApi implements SetupServer
|
|
|
93
92
|
*
|
|
94
93
|
* @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}
|
|
95
94
|
*/
|
|
96
|
-
declare const setupServer: (...handlers: Array<RequestHandler
|
|
95
|
+
declare const setupServer: (...handlers: Array<RequestHandler>) => SetupServerApi;
|
|
97
96
|
|
|
98
97
|
export { type SetupServer, SetupServerApi, setupServer };
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PartialDeep } from 'type-fest';
|
|
2
|
-
import { RequestHandler } from "../core/handlers/RequestHandler";
|
|
3
|
-
import { WebSocketHandler } from "../core/handlers/WebSocketHandler";
|
|
2
|
+
import { RequestHandler, RequestHandlerDefaultInfo } from "../core/handlers/RequestHandler";
|
|
4
3
|
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions";
|
|
5
4
|
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
|
|
6
5
|
import { SetupApi } from "../core/SetupApi";
|
|
@@ -23,7 +22,7 @@ interface SetupServerCommon {
|
|
|
23
22
|
*
|
|
24
23
|
* @see {@link https://mswjs.io/docs/api/setup-server/use `server.use()` API reference}
|
|
25
24
|
*/
|
|
26
|
-
use(...handlers: Array<RequestHandler
|
|
25
|
+
use(...handlers: Array<RequestHandler>): void;
|
|
27
26
|
/**
|
|
28
27
|
* Marks all request handlers that respond using `res.once()` as unused.
|
|
29
28
|
*
|
|
@@ -35,13 +34,13 @@ interface SetupServerCommon {
|
|
|
35
34
|
*
|
|
36
35
|
* @see {@link https://mswjs.io/docs/api/setup-server/reset-handlers `server.reset-handlers()` API reference}
|
|
37
36
|
*/
|
|
38
|
-
resetHandlers(...nextHandlers: Array<RequestHandler
|
|
37
|
+
resetHandlers(...nextHandlers: Array<RequestHandler>): void;
|
|
39
38
|
/**
|
|
40
39
|
* Returns a readonly list of currently active request handlers.
|
|
41
40
|
*
|
|
42
41
|
* @see {@link https://mswjs.io/docs/api/setup-server/list-handlers `server.listHandlers()` API reference}
|
|
43
42
|
*/
|
|
44
|
-
listHandlers(): ReadonlyArray<RequestHandler
|
|
43
|
+
listHandlers(): ReadonlyArray<RequestHandler<RequestHandlerDefaultInfo, any>>;
|
|
45
44
|
/**
|
|
46
45
|
* Life-cycle events.
|
|
47
46
|
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
|
@@ -72,7 +71,7 @@ declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implemen
|
|
|
72
71
|
private resolvedOptions;
|
|
73
72
|
constructor(interceptors: Array<{
|
|
74
73
|
new (): Interceptor<HttpRequestEventMap>;
|
|
75
|
-
}>, handlers: Array<RequestHandler
|
|
74
|
+
}>, handlers: Array<RequestHandler>);
|
|
76
75
|
/**
|
|
77
76
|
* Subscribe to all requests that are using the interceptor object
|
|
78
77
|
*/
|
|
@@ -82,7 +81,7 @@ declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implemen
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
declare class SetupServerApi extends SetupServerCommonApi implements SetupServer {
|
|
85
|
-
constructor(handlers: Array<RequestHandler
|
|
84
|
+
constructor(handlers: Array<RequestHandler>);
|
|
86
85
|
boundary<Args extends Array<any>, R>(callback: (...args: Args) => R): (...args: Args) => R;
|
|
87
86
|
close(): void;
|
|
88
87
|
}
|
|
@@ -93,6 +92,6 @@ declare class SetupServerApi extends SetupServerCommonApi implements SetupServer
|
|
|
93
92
|
*
|
|
94
93
|
* @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}
|
|
95
94
|
*/
|
|
96
|
-
declare const setupServer: (...handlers: Array<RequestHandler
|
|
95
|
+
declare const setupServer: (...handlers: Array<RequestHandler>) => SetupServerApi;
|
|
97
96
|
|
|
98
97
|
export { type SetupServer, SetupServerApi, setupServer };
|
package/lib/node/index.js
CHANGED
|
@@ -38,8 +38,6 @@ var import_SetupApi = require("../core/SetupApi.js");
|
|
|
38
38
|
var import_handleRequest = require("../core/utils/handleRequest.js");
|
|
39
39
|
var import_mergeRight = require("../core/utils/internal/mergeRight.js");
|
|
40
40
|
var import_devUtils = require("../core/utils/internal/devUtils.js");
|
|
41
|
-
var import_handleWebSocketEvent = require("../core/ws/handleWebSocketEvent.js");
|
|
42
|
-
var import_webSocketInterceptor = require("../core/ws/webSocketInterceptor.js");
|
|
43
41
|
var DEFAULT_LISTEN_OPTIONS = {
|
|
44
42
|
onUnhandledRequest: "warn"
|
|
45
43
|
};
|
|
@@ -72,6 +70,11 @@ var SetupServerCommonApi = class extends import_SetupApi.SetupApi {
|
|
|
72
70
|
}
|
|
73
71
|
return;
|
|
74
72
|
});
|
|
73
|
+
this.interceptor.on("unhandledException", ({ error }) => {
|
|
74
|
+
if (error instanceof import_devUtils.InternalError) {
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
75
78
|
this.interceptor.on(
|
|
76
79
|
"response",
|
|
77
80
|
({ response, isMockedResponse, request, requestId }) => {
|
|
@@ -85,15 +88,6 @@ var SetupServerCommonApi = class extends import_SetupApi.SetupApi {
|
|
|
85
88
|
);
|
|
86
89
|
}
|
|
87
90
|
);
|
|
88
|
-
(0, import_handleWebSocketEvent.handleWebSocketEvent)({
|
|
89
|
-
getHandlers: () => {
|
|
90
|
-
return this.handlersController.currentHandlers();
|
|
91
|
-
},
|
|
92
|
-
onMockedConnection: () => {
|
|
93
|
-
},
|
|
94
|
-
onPassthroughConnection: () => {
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
91
|
}
|
|
98
92
|
listen(options = {}) {
|
|
99
93
|
this.resolvedOptions = (0, import_mergeRight.mergeRight)(
|
|
@@ -101,10 +95,8 @@ var SetupServerCommonApi = class extends import_SetupApi.SetupApi {
|
|
|
101
95
|
options
|
|
102
96
|
);
|
|
103
97
|
this.interceptor.apply();
|
|
104
|
-
import_webSocketInterceptor.webSocketInterceptor.apply();
|
|
105
98
|
this.subscriptions.push(() => {
|
|
106
99
|
this.interceptor.dispose();
|
|
107
|
-
import_webSocketInterceptor.webSocketInterceptor.dispose();
|
|
108
100
|
});
|
|
109
101
|
(0, import_outvariant.invariant)(
|
|
110
102
|
[import_interceptors.InterceptorReadyState.APPLYING, import_interceptors.InterceptorReadyState.APPLIED].includes(
|
package/lib/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node/index.ts","../../src/node/SetupServerApi.ts","../../src/node/SetupServerCommonApi.ts","../../src/node/setupServer.ts"],"sourcesContent":["export type { SetupServer } from './glossary'\nexport { SetupServerApi } from './SetupServerApi'\nexport { setupServer } from './setupServer'\n","import { AsyncLocalStorage } from 'node:async_hooks'\nimport { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { HandlersController } from '~/core/SetupApi'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport type { WebSocketHandler } from '~/core/handlers/WebSocketHandler'\nimport type { SetupServer } from './glossary'\nimport { SetupServerCommonApi } from './SetupServerCommonApi'\n\nconst store = new AsyncLocalStorage<RequestHandlersContext>()\n\ntype RequestHandlersContext = {\n initialHandlers: Array<RequestHandler | WebSocketHandler>\n handlers: Array<RequestHandler | WebSocketHandler>\n}\n\n/**\n * A handlers controller that utilizes `AsyncLocalStorage` in Node.js\n * to prevent the request handlers list from being a shared state\n * across mutliple tests.\n */\nclass AsyncHandlersController implements HandlersController {\n private rootContext: RequestHandlersContext\n\n constructor(initialHandlers: Array<RequestHandler | WebSocketHandler>) {\n this.rootContext = { initialHandlers, handlers: [] }\n }\n\n get context(): RequestHandlersContext {\n return store.getStore() || this.rootContext\n }\n\n public prepend(runtimeHandlers: Array<RequestHandler | WebSocketHandler>) {\n this.context.handlers.unshift(...runtimeHandlers)\n }\n\n public reset(nextHandlers: Array<RequestHandler | WebSocketHandler>) {\n const context = this.context\n context.handlers = []\n context.initialHandlers =\n nextHandlers.length > 0 ? nextHandlers : context.initialHandlers\n }\n\n public currentHandlers(): Array<RequestHandler | WebSocketHandler> {\n const { initialHandlers, handlers } = this.context\n return handlers.concat(initialHandlers)\n }\n}\n\nexport class SetupServerApi\n extends SetupServerCommonApi\n implements SetupServer\n{\n constructor(handlers: Array<RequestHandler | WebSocketHandler>) {\n super(\n [ClientRequestInterceptor, XMLHttpRequestInterceptor, FetchInterceptor],\n handlers,\n )\n\n this.handlersController = new AsyncHandlersController(handlers)\n }\n\n public boundary<Args extends Array<any>, R>(\n callback: (...args: Args) => R,\n ): (...args: Args) => R {\n return (...args: Args): R => {\n return store.run<any, any>(\n {\n initialHandlers: this.handlersController.currentHandlers(),\n handlers: [],\n },\n callback,\n ...args,\n )\n }\n }\n\n public close(): void {\n super.close()\n store.disable()\n }\n}\n","/**\n * @note This API is extended by both \"msw/node\" and \"msw/native\"\n * so be minding about the things you import!\n */\nimport type { RequiredDeep } from 'type-fest'\nimport { invariant } from 'outvariant'\nimport {\n BatchInterceptor,\n InterceptorReadyState,\n type HttpRequestEventMap,\n type Interceptor,\n} from '@mswjs/interceptors'\nimport type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'\nimport { SetupApi } from '~/core/SetupApi'\nimport { handleRequest } from '~/core/utils/handleRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport type { WebSocketHandler } from '~/core/handlers/WebSocketHandler'\nimport { mergeRight } from '~/core/utils/internal/mergeRight'\nimport { devUtils } from '~/core/utils/internal/devUtils'\nimport type { SetupServerCommon } from './glossary'\nimport { handleWebSocketEvent } from '~/core/ws/handleWebSocketEvent'\nimport { webSocketInterceptor } from '~/core/ws/webSocketInterceptor'\n\nexport const DEFAULT_LISTEN_OPTIONS: RequiredDeep<SharedOptions> = {\n onUnhandledRequest: 'warn',\n}\n\nexport class SetupServerCommonApi\n extends SetupApi<LifeCycleEventsMap>\n implements SetupServerCommon\n{\n protected readonly interceptor: BatchInterceptor<\n Array<Interceptor<HttpRequestEventMap>>,\n HttpRequestEventMap\n >\n private resolvedOptions: RequiredDeep<SharedOptions>\n\n constructor(\n interceptors: Array<{ new (): Interceptor<HttpRequestEventMap> }>,\n handlers: Array<RequestHandler | WebSocketHandler>,\n ) {\n super(...handlers)\n\n this.interceptor = new BatchInterceptor({\n name: 'setup-server',\n interceptors: interceptors.map((Interceptor) => new Interceptor()),\n })\n\n this.resolvedOptions = {} as RequiredDeep<SharedOptions>\n\n this.init()\n }\n\n /**\n * Subscribe to all requests that are using the interceptor object\n */\n private init(): void {\n this.interceptor.on('request', async ({ request, requestId }) => {\n const response = await handleRequest(\n request,\n requestId,\n this.handlersController.currentHandlers(),\n this.resolvedOptions,\n this.emitter,\n )\n\n if (response) {\n request.respondWith(response)\n }\n\n return\n })\n\n this.interceptor.on(\n 'response',\n ({ response, isMockedResponse, request, requestId }) => {\n this.emitter.emit(\n isMockedResponse ? 'response:mocked' : 'response:bypass',\n {\n response,\n request,\n requestId,\n },\n )\n },\n )\n\n handleWebSocketEvent({\n getHandlers: () => {\n return this.handlersController.currentHandlers()\n },\n onMockedConnection: () => {},\n onPassthroughConnection: () => {},\n })\n }\n\n public listen(options: Partial<SharedOptions> = {}): void {\n this.resolvedOptions = mergeRight(\n DEFAULT_LISTEN_OPTIONS,\n options,\n ) as RequiredDeep<SharedOptions>\n\n // Apply the interceptor when starting the server.\n this.interceptor.apply()\n webSocketInterceptor.apply()\n\n this.subscriptions.push(() => {\n this.interceptor.dispose()\n webSocketInterceptor.dispose()\n })\n\n // Assert that the interceptor has been applied successfully.\n // Also guards us from forgetting to call \"interceptor.apply()\"\n // as a part of the \"listen\" method.\n invariant(\n [InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(\n this.interceptor.readyState,\n ),\n devUtils.formatMessage(\n 'Failed to start \"setupServer\": the interceptor failed to apply. This is likely an issue with the library and you should report it at \"%s\".',\n ),\n 'https://github.com/mswjs/msw/issues/new/choose',\n )\n }\n\n public close(): void {\n this.dispose()\n }\n}\n","import type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport type { WebSocketHandler } from '~/core/handlers/WebSocketHandler'\nimport { SetupServerApi } from './SetupServerApi'\n\n/**\n * Sets up a requests interception in Node.js with the given request handlers.\n * @param {RequestHandler[]} handlers List of request handlers.\n *\n * @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}\n */\nexport const setupServer = (\n ...handlers: Array<RequestHandler | WebSocketHandler>\n): SetupServerApi => {\n return new SetupServerApi(handlers)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,8BAAkC;AAClC,2BAAyC;AACzC,4BAA0C;AAC1C,mBAAiC;;;ACEjC,wBAA0B;AAC1B,0BAKO;AAEP,sBAAyB;AACzB,2BAA8B;AAG9B,wBAA2B;AAC3B,sBAAyB;AAEzB,kCAAqC;AACrC,kCAAqC;AAE9B,IAAM,yBAA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AA,EAEO,QAAc;AACnB,UAAM,MAAM;AACZ,UAAM,QAAQ;AAAA,EAChB;AACF;;;AExEO,IAAM,cAAc,IACtB,aACgB;AACnB,SAAO,IAAI,eAAe,QAAQ;AACpC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/node/index.ts","../../src/node/SetupServerApi.ts","../../src/node/SetupServerCommonApi.ts","../../src/node/setupServer.ts"],"sourcesContent":["export type { SetupServer } from './glossary'\nexport { SetupServerApi } from './SetupServerApi'\nexport { setupServer } from './setupServer'\n","import { AsyncLocalStorage } from 'node:async_hooks'\nimport { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { HandlersController } from '~/core/SetupApi'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport type { SetupServer } from './glossary'\nimport { SetupServerCommonApi } from './SetupServerCommonApi'\n\nconst store = new AsyncLocalStorage<RequestHandlersContext>()\n\ntype RequestHandlersContext = {\n initialHandlers: Array<RequestHandler>\n handlers: Array<RequestHandler>\n}\n\n/**\n * A handlers controller that utilizes `AsyncLocalStorage` in Node.js\n * to prevent the request handlers list from being a shared state\n * across mutliple tests.\n */\nclass AsyncHandlersController implements HandlersController {\n private rootContext: RequestHandlersContext\n\n constructor(initialHandlers: Array<RequestHandler>) {\n this.rootContext = { initialHandlers, handlers: [] }\n }\n\n get context(): RequestHandlersContext {\n return store.getStore() || this.rootContext\n }\n\n public prepend(runtimeHandlers: Array<RequestHandler>) {\n this.context.handlers.unshift(...runtimeHandlers)\n }\n\n public reset(nextHandlers: Array<RequestHandler>) {\n const context = this.context\n context.handlers = []\n context.initialHandlers =\n nextHandlers.length > 0 ? nextHandlers : context.initialHandlers\n }\n\n public currentHandlers(): Array<RequestHandler> {\n const { initialHandlers, handlers } = this.context\n return handlers.concat(initialHandlers)\n }\n}\n\nexport class SetupServerApi\n extends SetupServerCommonApi\n implements SetupServer\n{\n constructor(handlers: Array<RequestHandler>) {\n super(\n [ClientRequestInterceptor, XMLHttpRequestInterceptor, FetchInterceptor],\n handlers,\n )\n\n this.handlersController = new AsyncHandlersController(handlers)\n }\n\n public boundary<Args extends Array<any>, R>(\n callback: (...args: Args) => R,\n ): (...args: Args) => R {\n return (...args: Args): R => {\n return store.run<any, any>(\n {\n initialHandlers: this.handlersController.currentHandlers(),\n handlers: [],\n },\n callback,\n ...args,\n )\n }\n }\n\n public close(): void {\n super.close()\n store.disable()\n }\n}\n","/**\n * @note This API is extended by both \"msw/node\" and \"msw/native\"\n * so be minding about the things you import!\n */\nimport type { RequiredDeep } from 'type-fest'\nimport { invariant } from 'outvariant'\nimport {\n BatchInterceptor,\n InterceptorReadyState,\n type HttpRequestEventMap,\n type Interceptor,\n} from '@mswjs/interceptors'\nimport type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'\nimport { SetupApi } from '~/core/SetupApi'\nimport { handleRequest } from '~/core/utils/handleRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { mergeRight } from '~/core/utils/internal/mergeRight'\nimport { InternalError, devUtils } from '~/core/utils/internal/devUtils'\nimport type { SetupServerCommon } from './glossary'\n\nexport const DEFAULT_LISTEN_OPTIONS: RequiredDeep<SharedOptions> = {\n onUnhandledRequest: 'warn',\n}\n\nexport class SetupServerCommonApi\n extends SetupApi<LifeCycleEventsMap>\n implements SetupServerCommon\n{\n protected readonly interceptor: BatchInterceptor<\n Array<Interceptor<HttpRequestEventMap>>,\n HttpRequestEventMap\n >\n private resolvedOptions: RequiredDeep<SharedOptions>\n\n constructor(\n interceptors: Array<{ new (): Interceptor<HttpRequestEventMap> }>,\n handlers: Array<RequestHandler>,\n ) {\n super(...handlers)\n\n this.interceptor = new BatchInterceptor({\n name: 'setup-server',\n interceptors: interceptors.map((Interceptor) => new Interceptor()),\n })\n\n this.resolvedOptions = {} as RequiredDeep<SharedOptions>\n\n this.init()\n }\n\n /**\n * Subscribe to all requests that are using the interceptor object\n */\n private init(): void {\n this.interceptor.on('request', async ({ request, requestId }) => {\n const response = await handleRequest(\n request,\n requestId,\n this.handlersController.currentHandlers(),\n this.resolvedOptions,\n this.emitter,\n )\n\n if (response) {\n request.respondWith(response)\n }\n\n return\n })\n\n this.interceptor.on('unhandledException', ({ error }) => {\n if (error instanceof InternalError) {\n throw error\n }\n })\n\n this.interceptor.on(\n 'response',\n ({ response, isMockedResponse, request, requestId }) => {\n this.emitter.emit(\n isMockedResponse ? 'response:mocked' : 'response:bypass',\n {\n response,\n request,\n requestId,\n },\n )\n },\n )\n }\n\n public listen(options: Partial<SharedOptions> = {}): void {\n this.resolvedOptions = mergeRight(\n DEFAULT_LISTEN_OPTIONS,\n options,\n ) as RequiredDeep<SharedOptions>\n\n // Apply the interceptor when starting the server.\n this.interceptor.apply()\n\n this.subscriptions.push(() => {\n this.interceptor.dispose()\n })\n\n // Assert that the interceptor has been applied successfully.\n // Also guards us from forgetting to call \"interceptor.apply()\"\n // as a part of the \"listen\" method.\n invariant(\n [InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(\n this.interceptor.readyState,\n ),\n devUtils.formatMessage(\n 'Failed to start \"setupServer\": the interceptor failed to apply. This is likely an issue with the library and you should report it at \"%s\".',\n ),\n 'https://github.com/mswjs/msw/issues/new/choose',\n )\n }\n\n public close(): void {\n this.dispose()\n }\n}\n","import type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { SetupServerApi } from './SetupServerApi'\n\n/**\n * Sets up a requests interception in Node.js with the given request handlers.\n * @param {RequestHandler[]} handlers List of request handlers.\n *\n * @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}\n */\nexport const setupServer = (\n ...handlers: Array<RequestHandler>\n): SetupServerApi => {\n return new SetupServerApi(handlers)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,8BAAkC;AAClC,2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AA,QACA,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAEO,QAAc;AACnB,UAAM,MAAM;AACZ,UAAM,QAAQ;AAAA,EAChB;AACF;;;AExEO,IAAM,cAAc,IACtB,aACgB;AACnB,SAAO,IAAI,eAAe,QAAQ;AACpC;","names":[]}
|
package/lib/node/index.mjs
CHANGED
|
@@ -13,9 +13,7 @@ import {
|
|
|
13
13
|
import { SetupApi } from '../core/SetupApi.mjs';
|
|
14
14
|
import { handleRequest } from '../core/utils/handleRequest.mjs';
|
|
15
15
|
import { mergeRight } from '../core/utils/internal/mergeRight.mjs';
|
|
16
|
-
import { devUtils } from '../core/utils/internal/devUtils.mjs';
|
|
17
|
-
import { handleWebSocketEvent } from '../core/ws/handleWebSocketEvent.mjs';
|
|
18
|
-
import { webSocketInterceptor } from '../core/ws/webSocketInterceptor.mjs';
|
|
16
|
+
import { InternalError, devUtils } from '../core/utils/internal/devUtils.mjs';
|
|
19
17
|
var DEFAULT_LISTEN_OPTIONS = {
|
|
20
18
|
onUnhandledRequest: "warn"
|
|
21
19
|
};
|
|
@@ -48,6 +46,11 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
|
48
46
|
}
|
|
49
47
|
return;
|
|
50
48
|
});
|
|
49
|
+
this.interceptor.on("unhandledException", ({ error }) => {
|
|
50
|
+
if (error instanceof InternalError) {
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
51
54
|
this.interceptor.on(
|
|
52
55
|
"response",
|
|
53
56
|
({ response, isMockedResponse, request, requestId }) => {
|
|
@@ -61,15 +64,6 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
|
61
64
|
);
|
|
62
65
|
}
|
|
63
66
|
);
|
|
64
|
-
handleWebSocketEvent({
|
|
65
|
-
getHandlers: () => {
|
|
66
|
-
return this.handlersController.currentHandlers();
|
|
67
|
-
},
|
|
68
|
-
onMockedConnection: () => {
|
|
69
|
-
},
|
|
70
|
-
onPassthroughConnection: () => {
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
67
|
}
|
|
74
68
|
listen(options = {}) {
|
|
75
69
|
this.resolvedOptions = mergeRight(
|
|
@@ -77,10 +71,8 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
|
77
71
|
options
|
|
78
72
|
);
|
|
79
73
|
this.interceptor.apply();
|
|
80
|
-
webSocketInterceptor.apply();
|
|
81
74
|
this.subscriptions.push(() => {
|
|
82
75
|
this.interceptor.dispose();
|
|
83
|
-
webSocketInterceptor.dispose();
|
|
84
76
|
});
|
|
85
77
|
invariant(
|
|
86
78
|
[InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(
|
package/lib/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node/SetupServerApi.ts","../../src/node/SetupServerCommonApi.ts","../../src/node/setupServer.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { HandlersController } from '~/core/SetupApi'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/node/SetupServerApi.ts","../../src/node/SetupServerCommonApi.ts","../../src/node/setupServer.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '@mswjs/interceptors/fetch'\nimport { HandlersController } from '~/core/SetupApi'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport type { SetupServer } from './glossary'\nimport { SetupServerCommonApi } from './SetupServerCommonApi'\n\nconst store = new AsyncLocalStorage<RequestHandlersContext>()\n\ntype RequestHandlersContext = {\n initialHandlers: Array<RequestHandler>\n handlers: Array<RequestHandler>\n}\n\n/**\n * A handlers controller that utilizes `AsyncLocalStorage` in Node.js\n * to prevent the request handlers list from being a shared state\n * across mutliple tests.\n */\nclass AsyncHandlersController implements HandlersController {\n private rootContext: RequestHandlersContext\n\n constructor(initialHandlers: Array<RequestHandler>) {\n this.rootContext = { initialHandlers, handlers: [] }\n }\n\n get context(): RequestHandlersContext {\n return store.getStore() || this.rootContext\n }\n\n public prepend(runtimeHandlers: Array<RequestHandler>) {\n this.context.handlers.unshift(...runtimeHandlers)\n }\n\n public reset(nextHandlers: Array<RequestHandler>) {\n const context = this.context\n context.handlers = []\n context.initialHandlers =\n nextHandlers.length > 0 ? nextHandlers : context.initialHandlers\n }\n\n public currentHandlers(): Array<RequestHandler> {\n const { initialHandlers, handlers } = this.context\n return handlers.concat(initialHandlers)\n }\n}\n\nexport class SetupServerApi\n extends SetupServerCommonApi\n implements SetupServer\n{\n constructor(handlers: Array<RequestHandler>) {\n super(\n [ClientRequestInterceptor, XMLHttpRequestInterceptor, FetchInterceptor],\n handlers,\n )\n\n this.handlersController = new AsyncHandlersController(handlers)\n }\n\n public boundary<Args extends Array<any>, R>(\n callback: (...args: Args) => R,\n ): (...args: Args) => R {\n return (...args: Args): R => {\n return store.run<any, any>(\n {\n initialHandlers: this.handlersController.currentHandlers(),\n handlers: [],\n },\n callback,\n ...args,\n )\n }\n }\n\n public close(): void {\n super.close()\n store.disable()\n }\n}\n","/**\n * @note This API is extended by both \"msw/node\" and \"msw/native\"\n * so be minding about the things you import!\n */\nimport type { RequiredDeep } from 'type-fest'\nimport { invariant } from 'outvariant'\nimport {\n BatchInterceptor,\n InterceptorReadyState,\n type HttpRequestEventMap,\n type Interceptor,\n} from '@mswjs/interceptors'\nimport type { LifeCycleEventsMap, SharedOptions } from '~/core/sharedOptions'\nimport { SetupApi } from '~/core/SetupApi'\nimport { handleRequest } from '~/core/utils/handleRequest'\nimport type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { mergeRight } from '~/core/utils/internal/mergeRight'\nimport { InternalError, devUtils } from '~/core/utils/internal/devUtils'\nimport type { SetupServerCommon } from './glossary'\n\nexport const DEFAULT_LISTEN_OPTIONS: RequiredDeep<SharedOptions> = {\n onUnhandledRequest: 'warn',\n}\n\nexport class SetupServerCommonApi\n extends SetupApi<LifeCycleEventsMap>\n implements SetupServerCommon\n{\n protected readonly interceptor: BatchInterceptor<\n Array<Interceptor<HttpRequestEventMap>>,\n HttpRequestEventMap\n >\n private resolvedOptions: RequiredDeep<SharedOptions>\n\n constructor(\n interceptors: Array<{ new (): Interceptor<HttpRequestEventMap> }>,\n handlers: Array<RequestHandler>,\n ) {\n super(...handlers)\n\n this.interceptor = new BatchInterceptor({\n name: 'setup-server',\n interceptors: interceptors.map((Interceptor) => new Interceptor()),\n })\n\n this.resolvedOptions = {} as RequiredDeep<SharedOptions>\n\n this.init()\n }\n\n /**\n * Subscribe to all requests that are using the interceptor object\n */\n private init(): void {\n this.interceptor.on('request', async ({ request, requestId }) => {\n const response = await handleRequest(\n request,\n requestId,\n this.handlersController.currentHandlers(),\n this.resolvedOptions,\n this.emitter,\n )\n\n if (response) {\n request.respondWith(response)\n }\n\n return\n })\n\n this.interceptor.on('unhandledException', ({ error }) => {\n if (error instanceof InternalError) {\n throw error\n }\n })\n\n this.interceptor.on(\n 'response',\n ({ response, isMockedResponse, request, requestId }) => {\n this.emitter.emit(\n isMockedResponse ? 'response:mocked' : 'response:bypass',\n {\n response,\n request,\n requestId,\n },\n )\n },\n )\n }\n\n public listen(options: Partial<SharedOptions> = {}): void {\n this.resolvedOptions = mergeRight(\n DEFAULT_LISTEN_OPTIONS,\n options,\n ) as RequiredDeep<SharedOptions>\n\n // Apply the interceptor when starting the server.\n this.interceptor.apply()\n\n this.subscriptions.push(() => {\n this.interceptor.dispose()\n })\n\n // Assert that the interceptor has been applied successfully.\n // Also guards us from forgetting to call \"interceptor.apply()\"\n // as a part of the \"listen\" method.\n invariant(\n [InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(\n this.interceptor.readyState,\n ),\n devUtils.formatMessage(\n 'Failed to start \"setupServer\": the interceptor failed to apply. This is likely an issue with the library and you should report it at \"%s\".',\n ),\n 'https://github.com/mswjs/msw/issues/new/choose',\n )\n }\n\n public close(): void {\n this.dispose()\n }\n}\n","import type { RequestHandler } from '~/core/handlers/RequestHandler'\nimport { SetupServerApi } from './SetupServerApi'\n\n/**\n * Sets up a requests interception in Node.js with the given request handlers.\n * @param {RequestHandler[]} handlers List of request handlers.\n *\n * @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}\n */\nexport const setupServer = (\n ...handlers: Array<RequestHandler>\n): SetupServerApi => {\n return new SetupServerApi(handlers)\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,SAAS,iCAAiC;AAC1C,SAAS,wBAAwB;;;ACEjC,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAE9B,SAAS,kBAAkB;AAC3B,SAAS,eAAe,gBAAgB;AAGjC,IAAM,yBAAsD;AAAA,EACjE,oBAAoB;AACtB;AAEO,IAAM,uBAAN,cACG,SAEV;AAAA,EACqB;AAAA,EAIX;AAAA,EAER,YACE,cACA,UACA;AACA,UAAM,GAAG,QAAQ;AAEjB,SAAK,cAAc,IAAI,iBAAiB;AAAA,MACtC,MAAM;AAAA,MACN,cAAc,aAAa,IAAI,CAAC,gBAAgB,IAAI,YAAY,CAAC;AAAA,IACnE,CAAC;AAED,SAAK,kBAAkB,CAAC;AAExB,SAAK,KAAK;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAKQ,OAAa;AACnB,SAAK,YAAY,GAAG,WAAW,OAAO,EAAE,SAAS,UAAU,MAAM;AAC/D,YAAM,WAAW,MAAM;AAAA,QACrB;AAAA,QACA;AAAA,QACA,KAAK,mBAAmB,gBAAgB;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