msw 2.7.1 → 2.7.3
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/core/{GraphQLHandler-DYshTG2D.d.mts → GraphQLHandler-D4_CxZQj.d.mts} +1 -1
- package/lib/core/{GraphQLHandler-B2C8S1zW.d.ts → GraphQLHandler-Pox7fIFM.d.ts} +1 -1
- package/lib/core/{HttpResponse-3ReBq-Rf.d.mts → HttpResponse-BRDnWbjc.d.mts} +3 -2
- package/lib/core/{HttpResponse-BPOVeNkE.d.ts → HttpResponse-Cy7ytzUn.d.ts} +3 -2
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/HttpResponse.js +2 -0
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs +2 -0
- 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/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 +3 -2
- package/lib/core/index.d.ts +3 -2
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +2 -0
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/isCommonAssetRequest.d.mts +20 -0
- package/lib/core/isCommonAssetRequest.d.ts +20 -0
- package/lib/core/isCommonAssetRequest.js +42 -0
- package/lib/core/isCommonAssetRequest.js.map +1 -0
- package/lib/core/isCommonAssetRequest.mjs +22 -0
- package/lib/core/isCommonAssetRequest.mjs.map +1 -0
- 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/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 +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/request/onUnhandledRequest.js +3 -3
- package/lib/core/utils/request/onUnhandledRequest.js.map +1 -1
- package/lib/core/utils/request/onUnhandledRequest.mjs +3 -3
- package/lib/core/utils/request/onUnhandledRequest.mjs.map +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 +25 -3
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +1 -1
- package/src/core/HttpResponse.ts +4 -2
- package/src/core/index.ts +1 -0
- package/src/core/isCommonAssetRequest.ts +45 -0
- package/src/core/utils/request/onUnhandledRequest.test.ts +65 -10
- package/src/core/utils/request/onUnhandledRequest.ts +6 -10
|
@@ -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 {
|
|
4
|
+
import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-BRDnWbjc.mjs';
|
|
5
5
|
import './request/onUnhandledRequest.mjs';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import './internal/isIterable.mjs';
|
|
@@ -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 {
|
|
4
|
+
import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-Cy7ytzUn.js';
|
|
5
5
|
import './request/onUnhandledRequest.js';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import './internal/isIterable.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HandlerKind } from '../../handlers/common.mjs';
|
|
2
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../../HttpResponse-BRDnWbjc.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 { HandlerKind } from '../../handlers/common.js';
|
|
2
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../../HttpResponse-Cy7ytzUn.js';
|
|
3
3
|
import { WebSocketHandler } from '../../handlers/WebSocketHandler.js';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import './isIterable.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
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-D4_CxZQj.mjs';
|
|
3
|
+
import '../../HttpResponse-BRDnWbjc.mjs';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import './isIterable.mjs';
|
|
6
6
|
import '../../typeUtils.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
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-Pox7fIFM.js';
|
|
3
|
+
import '../../HttpResponse-Cy7ytzUn.js';
|
|
4
4
|
import '@mswjs/interceptors';
|
|
5
5
|
import './isIterable.js';
|
|
6
6
|
import '../../typeUtils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler,
|
|
1
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-BRDnWbjc.mjs';
|
|
2
2
|
import '@mswjs/interceptors';
|
|
3
3
|
import './isIterable.mjs';
|
|
4
4
|
import '../../typeUtils.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler,
|
|
1
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-Cy7ytzUn.js';
|
|
2
2
|
import '@mswjs/interceptors';
|
|
3
3
|
import './isIterable.js';
|
|
4
4
|
import '../../typeUtils.js';
|
|
@@ -23,6 +23,7 @@ __export(onUnhandledRequest_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(onUnhandledRequest_exports);
|
|
24
24
|
var import_toPublicUrl = require("./toPublicUrl.js");
|
|
25
25
|
var import_devUtils = require("../internal/devUtils.js");
|
|
26
|
+
var import_isCommonAssetRequest = require("../../isCommonAssetRequest.js");
|
|
26
27
|
async function onUnhandledRequest(request, strategy = "warn") {
|
|
27
28
|
const url = new URL(request.url);
|
|
28
29
|
const publicUrl = (0, import_toPublicUrl.toPublicUrl)(url) + url.search;
|
|
@@ -68,9 +69,8 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
68
69
|
});
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
71
|
-
if (
|
|
72
|
-
|
|
72
|
+
if (!(0, import_isCommonAssetRequest.isCommonAssetRequest)(request)) {
|
|
73
|
+
applyStrategy(strategy);
|
|
73
74
|
}
|
|
74
|
-
applyStrategy(strategy);
|
|
75
75
|
}
|
|
76
76
|
//# sourceMappingURL=onUnhandledRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\nimport { isCommonAssetRequest } from '../../isCommonAssetRequest'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n // Ignore common static asset requests when using a built-in strategy.\n // There's a slight overhead here because this utility will create a request URL\n // instance again despite us having done so previously in this function.\n if (!isCommonAssetRequest(request)) {\n applyStrategy(strategy)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4B;AAC5B,sBAAwC;AACxC,kCAAqC;AAkBrC,eAAsB,mBACpB,SACA,WAAqC,QACtB;AACf,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QAAM,gBAAY,gCAAY,GAAG,IAAI,IAAI;AAEzC,QAAM,cACJ,QAAQ,WAAW,UAAU,QAAQ,WAAW,QAC5C,OACA,MAAM,QAAQ,MAAM,EAAE,KAAK;AACjC,QAAM,iBAAiB;AAAA;AAAA,WAAgB,QAAQ,MAAM,IAAI,SAAS;AAAA;AAAA,EAAO,cAAc,0BAA0B,WAAW;AAAA;AAAA,IAAS,EAAE;AACvI,QAAM,0BAA0B,4DAA4D,cAAc;AAAA;AAE1G,WAAS,cAAcA,WAAoC;AACzD,YAAQA,WAAU;AAAA,MAChB,KAAK,SAAS;AAEZ,iCAAS,MAAM,aAAa,uBAAuB;AAGnD,cAAM,IAAI;AAAA,UACR,yBAAS;AAAA,YACP;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ;AACX,iCAAS,KAAK,eAAe,uBAAuB;AACpD;AAAA,MACF;AAAA,MAEA,KAAK;AACH;AAAA,MAEF;AACE,cAAM,IAAI;AAAA,UACR,yBAAS;AAAA,YACP;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,IACJ;AAAA,EACF;AAEA,MAAI,OAAO,aAAa,YAAY;AAClC,aAAS,SAAS;AAAA,MAChB,SAAS,cAAc,KAAK,MAAM,MAAM;AAAA,MACxC,OAAO,cAAc,KAAK,MAAM,OAAO;AAAA,IACzC,CAAC;AACD;AAAA,EACF;AAKA,MAAI,KAAC,kDAAqB,OAAO,GAAG;AAClC,kBAAc,QAAQ;AAAA,EACxB;AACF;","names":["strategy"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { toPublicUrl } from './toPublicUrl.mjs';
|
|
2
2
|
import { InternalError, devUtils } from '../internal/devUtils.mjs';
|
|
3
|
+
import { isCommonAssetRequest } from '../../isCommonAssetRequest.mjs';
|
|
3
4
|
async function onUnhandledRequest(request, strategy = "warn") {
|
|
4
5
|
const url = new URL(request.url);
|
|
5
6
|
const publicUrl = toPublicUrl(url) + url.search;
|
|
@@ -45,10 +46,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
45
46
|
});
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
if (
|
|
49
|
-
|
|
49
|
+
if (!isCommonAssetRequest(request)) {
|
|
50
|
+
applyStrategy(strategy);
|
|
50
51
|
}
|
|
51
|
-
applyStrategy(strategy);
|
|
52
52
|
}
|
|
53
53
|
export {
|
|
54
54
|
onUnhandledRequest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/utils/request/onUnhandledRequest.ts"],"sourcesContent":["import { toPublicUrl } from './toPublicUrl'\nimport { InternalError, devUtils } from '../internal/devUtils'\nimport { isCommonAssetRequest } from '../../isCommonAssetRequest'\n\nexport interface UnhandledRequestPrint {\n warning(): void\n error(): void\n}\n\nexport type UnhandledRequestCallback = (\n request: Request,\n print: UnhandledRequestPrint,\n) => void\n\nexport type UnhandledRequestStrategy =\n | 'bypass'\n | 'warn'\n | 'error'\n | UnhandledRequestCallback\n\nexport async function onUnhandledRequest(\n request: Request,\n strategy: UnhandledRequestStrategy = 'warn',\n): Promise<void> {\n const url = new URL(request.url)\n const publicUrl = toPublicUrl(url) + url.search\n\n const requestBody =\n request.method === 'HEAD' || request.method === 'GET'\n ? null\n : await request.clone().text()\n const messageDetails = `\\n\\n \\u2022 ${request.method} ${publicUrl}\\n\\n${requestBody ? ` \\u2022 Request body: ${requestBody}\\n\\n` : ''}`\n const unhandledRequestMessage = `intercepted a request without a matching request handler:${messageDetails}If you still wish to intercept this unhandled request, please create a request handler for it.\\nRead more: https://mswjs.io/docs/getting-started/mocks`\n\n function applyStrategy(strategy: UnhandledRequestStrategy) {\n switch (strategy) {\n case 'error': {\n // Print a developer-friendly error.\n devUtils.error('Error: %s', unhandledRequestMessage)\n\n // Throw an exception to halt request processing and not perform the original request.\n throw new InternalError(\n devUtils.formatMessage(\n 'Cannot bypass a request when using the \"error\" strategy for the \"onUnhandledRequest\" option.',\n ),\n )\n }\n\n case 'warn': {\n devUtils.warn('Warning: %s', unhandledRequestMessage)\n break\n }\n\n case 'bypass':\n break\n\n default:\n throw new InternalError(\n devUtils.formatMessage(\n 'Failed to react to an unhandled request: unknown strategy \"%s\". Please provide one of the supported strategies (\"bypass\", \"warn\", \"error\") or a custom callback function as the value of the \"onUnhandledRequest\" option.',\n strategy,\n ),\n )\n }\n }\n\n if (typeof strategy === 'function') {\n strategy(request, {\n warning: applyStrategy.bind(null, 'warn'),\n error: applyStrategy.bind(null, 'error'),\n })\n return\n }\n\n // Ignore common static asset requests when using a built-in strategy.\n // There's a slight overhead here because this utility will create a request URL\n // instance again despite us having done so previously in this function.\n if (!isCommonAssetRequest(request)) {\n applyStrategy(strategy)\n }\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAC5B,SAAS,eAAe,gBAAgB;AACxC,SAAS,4BAA4B;AAkBrC,eAAsB,mBACpB,SACA,WAAqC,QACtB;AACf,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAC/B,QAAM,YAAY,YAAY,GAAG,IAAI,IAAI;AAEzC,QAAM,cACJ,QAAQ,WAAW,UAAU,QAAQ,WAAW,QAC5C,OACA,MAAM,QAAQ,MAAM,EAAE,KAAK;AACjC,QAAM,iBAAiB;AAAA;AAAA,WAAgB,QAAQ,MAAM,IAAI,SAAS;AAAA;AAAA,EAAO,cAAc,0BAA0B,WAAW;AAAA;AAAA,IAAS,EAAE;AACvI,QAAM,0BAA0B,4DAA4D,cAAc;AAAA;AAE1G,WAAS,cAAcA,WAAoC;AACzD,YAAQA,WAAU;AAAA,MAChB,KAAK,SAAS;AAEZ,iBAAS,MAAM,aAAa,uBAAuB;AAGnD,cAAM,IAAI;AAAA,UACR,SAAS;AAAA,YACP;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ;AACX,iBAAS,KAAK,eAAe,uBAAuB;AACpD;AAAA,MACF;AAAA,MAEA,KAAK;AACH;AAAA,MAEF;AACE,cAAM,IAAI;AAAA,UACR,SAAS;AAAA,YACP;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,IACJ;AAAA,EACF;AAEA,MAAI,OAAO,aAAa,YAAY;AAClC,aAAS,SAAS;AAAA,MAChB,SAAS,cAAc,KAAK,MAAM,MAAM;AAAA,MACxC,OAAO,cAAc,KAAK,MAAM,OAAO;AAAA,IACzC,CAAC;AACD;AAAA,EACF;AAKA,MAAI,CAAC,qBAAqB,OAAO,GAAG;AAClC,kBAAc,QAAQ;AAAA,EACxB;AACF;","names":["strategy"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-BRDnWbjc.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/lib/browser/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-Cy7ytzUn.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
|
@@ -13133,6 +13133,7 @@ ${operationTypes.join("\n")}
|
|
|
13133
13133
|
graphql: () => graphql2,
|
|
13134
13134
|
handleRequest: () => handleRequest,
|
|
13135
13135
|
http: () => http,
|
|
13136
|
+
isCommonAssetRequest: () => isCommonAssetRequest,
|
|
13136
13137
|
matchRequestUrl: () => matchRequestUrl,
|
|
13137
13138
|
passthrough: () => passthrough,
|
|
13138
13139
|
setupWorker: () => setupWorker,
|
|
@@ -28497,6 +28498,26 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
28497
28498
|
return null;
|
|
28498
28499
|
};
|
|
28499
28500
|
|
|
28501
|
+
// src/core/isCommonAssetRequest.ts
|
|
28502
|
+
function isCommonAssetRequest(request) {
|
|
28503
|
+
const url = new URL(request.url);
|
|
28504
|
+
if (url.protocol === "file:") {
|
|
28505
|
+
return true;
|
|
28506
|
+
}
|
|
28507
|
+
if (/(fonts\.googleapis\.com)/.test(url.hostname)) {
|
|
28508
|
+
return true;
|
|
28509
|
+
}
|
|
28510
|
+
if (/node_modules/.test(url.pathname)) {
|
|
28511
|
+
return true;
|
|
28512
|
+
}
|
|
28513
|
+
if (url.pathname.includes("@vite")) {
|
|
28514
|
+
return true;
|
|
28515
|
+
}
|
|
28516
|
+
return /\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(
|
|
28517
|
+
url.pathname
|
|
28518
|
+
);
|
|
28519
|
+
}
|
|
28520
|
+
|
|
28500
28521
|
// src/core/utils/request/onUnhandledRequest.ts
|
|
28501
28522
|
async function onUnhandledRequest(request, strategy = "warn") {
|
|
28502
28523
|
const url = new URL(request.url);
|
|
@@ -28543,10 +28564,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
28543
28564
|
});
|
|
28544
28565
|
return;
|
|
28545
28566
|
}
|
|
28546
|
-
if (
|
|
28547
|
-
|
|
28567
|
+
if (!isCommonAssetRequest(request)) {
|
|
28568
|
+
applyStrategy(strategy);
|
|
28548
28569
|
}
|
|
28549
|
-
applyStrategy(strategy);
|
|
28550
28570
|
}
|
|
28551
28571
|
|
|
28552
28572
|
// src/core/utils/HttpResponse/decorators.ts
|
|
@@ -28659,7 +28679,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
28659
28679
|
};
|
|
28660
28680
|
|
|
28661
28681
|
// src/core/HttpResponse.ts
|
|
28682
|
+
var bodyType = Symbol("bodyType");
|
|
28662
28683
|
var HttpResponse = class _HttpResponse extends FetchResponse {
|
|
28684
|
+
[bodyType];
|
|
28663
28685
|
constructor(body, init) {
|
|
28664
28686
|
const responseInit = normalizeResponseInit(init);
|
|
28665
28687
|
super(body, responseInit);
|