msw 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/index.js +1775 -32
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +1769 -28
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/handlers/GraphQLHandler.js +2 -2
- package/lib/core/handlers/GraphQLHandler.js.map +1 -1
- package/lib/core/handlers/GraphQLHandler.mjs +2 -2
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
- package/lib/core/handlers/HttpHandler.js +2 -2
- package/lib/core/handlers/HttpHandler.js.map +1 -1
- package/lib/core/handlers/HttpHandler.mjs +2 -2
- package/lib/core/handlers/HttpHandler.mjs.map +1 -1
- package/lib/core/sharedOptions.d.mts +0 -2
- package/lib/core/sharedOptions.d.ts +0 -2
- package/lib/core/utils/handleRequest.js +1 -1
- package/lib/core/utils/handleRequest.js.map +1 -1
- package/lib/core/utils/handleRequest.mjs +1 -1
- package/lib/core/utils/handleRequest.mjs.map +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.js +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.js.map +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.mjs +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.mjs.map +1 -1
- package/lib/core/utils/request/onUnhandledRequest.d.mts +1 -4
- package/lib/core/utils/request/onUnhandledRequest.d.ts +1 -4
- package/lib/core/utils/request/onUnhandledRequest.js +14 -115
- package/lib/core/utils/request/onUnhandledRequest.js.map +1 -1
- package/lib/core/utils/request/onUnhandledRequest.mjs +14 -107
- package/lib/core/utils/request/onUnhandledRequest.mjs.map +1 -1
- package/lib/core/utils/request/toPublicUrl.d.mts +7 -0
- package/lib/core/utils/request/toPublicUrl.d.ts +7 -0
- package/lib/core/utils/request/{getPublicUrlFromRequest.js → toPublicUrl.js} +9 -9
- package/lib/core/utils/request/toPublicUrl.js.map +1 -0
- package/lib/core/utils/request/toPublicUrl.mjs +11 -0
- package/lib/core/utils/request/toPublicUrl.mjs.map +1 -0
- package/lib/iife/index.js +46 -233
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +5 -8
- package/src/browser/setupWorker/glossary.ts +1 -0
- package/src/browser/setupWorker/setupWorker.ts +1 -0
- package/src/browser/setupWorker/start/createRequestListener.ts +9 -0
- package/src/browser/setupWorker/start/createResponseListener.ts +9 -7
- package/src/core/handlers/GraphQLHandler.ts +2 -2
- package/src/core/handlers/HttpHandler.ts +2 -2
- package/src/core/utils/handleRequest.ts +1 -1
- package/src/core/utils/internal/parseGraphQLRequest.ts +2 -2
- package/src/core/utils/request/onUnhandledRequest.test.ts +5 -101
- package/src/core/utils/request/onUnhandledRequest.ts +16 -185
- package/src/core/utils/request/toPublicUrl.test.ts +18 -0
- package/src/core/utils/request/toPublicUrl.ts +15 -0
- package/lib/core/utils/request/getPublicUrlFromRequest.d.mts +0 -7
- package/lib/core/utils/request/getPublicUrlFromRequest.d.ts +0 -7
- package/lib/core/utils/request/getPublicUrlFromRequest.js.map +0 -1
- package/lib/core/utils/request/getPublicUrlFromRequest.mjs +0 -11
- package/lib/core/utils/request/getPublicUrlFromRequest.mjs.map +0 -1
- package/src/core/utils/request/getPublicUrlFromRequest.test.ts +0 -26
- package/src/core/utils/request/getPublicUrlFromRequest.ts +0 -15
package/lib/iife/index.js
CHANGED
|
@@ -1107,7 +1107,7 @@ var MockServiceWorker = (() => {
|
|
|
1107
1107
|
return stringToRegexp(path, keys, options);
|
|
1108
1108
|
}
|
|
1109
1109
|
|
|
1110
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.25.
|
|
1110
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.25.15/node_modules/@mswjs/interceptors/lib/browser/chunk-UJZOJSMP.mjs
|
|
1111
1111
|
var encoder = new TextEncoder();
|
|
1112
1112
|
function encodeBuffer(text) {
|
|
1113
1113
|
return encoder.encode(text);
|
|
@@ -1420,7 +1420,7 @@ var MockServiceWorker = (() => {
|
|
|
1420
1420
|
return message3.toString();
|
|
1421
1421
|
}
|
|
1422
1422
|
|
|
1423
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.25.
|
|
1423
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.25.15/node_modules/@mswjs/interceptors/lib/browser/chunk-WZQN3FMY.mjs
|
|
1424
1424
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
1425
1425
|
function getGlobalSymbol(symbol) {
|
|
1426
1426
|
return (
|
|
@@ -1565,7 +1565,7 @@ var MockServiceWorker = (() => {
|
|
|
1565
1565
|
}
|
|
1566
1566
|
};
|
|
1567
1567
|
|
|
1568
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.25.
|
|
1568
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.25.15/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
1569
1569
|
var BatchInterceptor = class extends Interceptor {
|
|
1570
1570
|
constructor(options) {
|
|
1571
1571
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -1674,13 +1674,13 @@ var MockServiceWorker = (() => {
|
|
|
1674
1674
|
};
|
|
1675
1675
|
}
|
|
1676
1676
|
|
|
1677
|
-
// src/core/utils/request/
|
|
1678
|
-
function
|
|
1677
|
+
// src/core/utils/request/toPublicUrl.ts
|
|
1678
|
+
function toPublicUrl(url) {
|
|
1679
1679
|
if (typeof location === "undefined") {
|
|
1680
|
-
return
|
|
1680
|
+
return url.toString();
|
|
1681
1681
|
}
|
|
1682
|
-
const
|
|
1683
|
-
return
|
|
1682
|
+
const urlInstance = url instanceof URL ? url : new URL(url);
|
|
1683
|
+
return urlInstance.origin === location.origin ? urlInstance.pathname : urlInstance.origin + urlInstance.pathname;
|
|
1684
1684
|
}
|
|
1685
1685
|
|
|
1686
1686
|
// node_modules/.pnpm/@bundled-es-modules+cookie@2.0.0/node_modules/@bundled-es-modules/cookie/index-esm.js
|
|
@@ -2300,7 +2300,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
2300
2300
|
};
|
|
2301
2301
|
}
|
|
2302
2302
|
async log(args) {
|
|
2303
|
-
const publicUrl =
|
|
2303
|
+
const publicUrl = toPublicUrl(args.request.url);
|
|
2304
2304
|
const loggedRequest = await serializeRequest(args.request);
|
|
2305
2305
|
const loggedResponse = await serializeResponse(args.response);
|
|
2306
2306
|
const statusColor = getStatusCodeColor(loggedResponse.status);
|
|
@@ -5383,7 +5383,7 @@ spurious results.`);
|
|
|
5383
5383
|
const { query, variables } = input;
|
|
5384
5384
|
const parsedResult = parseQuery(query);
|
|
5385
5385
|
if (parsedResult instanceof Error) {
|
|
5386
|
-
const requestPublicUrl =
|
|
5386
|
+
const requestPublicUrl = toPublicUrl(request.url);
|
|
5387
5387
|
throw new Error(
|
|
5388
5388
|
devUtils.formatMessage(
|
|
5389
5389
|
'Failed to intercept a GraphQL request to "%s %s": cannot parse query. See the error message from the parser below.\n\n%s',
|
|
@@ -5482,7 +5482,7 @@ spurious results.`);
|
|
|
5482
5482
|
return false;
|
|
5483
5483
|
}
|
|
5484
5484
|
if (!args.parsedResult.operationName && this.info.operationType !== "all") {
|
|
5485
|
-
const publicUrl =
|
|
5485
|
+
const publicUrl = toPublicUrl(args.request.url);
|
|
5486
5486
|
devUtils.warn(`Failed to intercept a GraphQL request at "${args.request.method} ${publicUrl}": anonymous GraphQL operations are not supported.
|
|
5487
5487
|
|
|
5488
5488
|
Consider naming this operation or using "graphql.operation()" request handler to intercept GraphQL requests regardless of their operation name/type. Read more: https://mswjs.io/docs/api/graphql/#graphqloperationresolver`);
|
|
@@ -5633,222 +5633,20 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
5633
5633
|
return null;
|
|
5634
5634
|
};
|
|
5635
5635
|
|
|
5636
|
-
// node_modules/.pnpm/@bundled-es-modules+js-levenshtein@2.0.1/node_modules/@bundled-es-modules/js-levenshtein/index-esm.js
|
|
5637
|
-
var __create5 = Object.create;
|
|
5638
|
-
var __defProp7 = Object.defineProperty;
|
|
5639
|
-
var __getOwnPropDesc6 = Object.getOwnPropertyDescriptor;
|
|
5640
|
-
var __getOwnPropNames6 = Object.getOwnPropertyNames;
|
|
5641
|
-
var __getProtoOf5 = Object.getPrototypeOf;
|
|
5642
|
-
var __hasOwnProp6 = Object.prototype.hasOwnProperty;
|
|
5643
|
-
var __commonJS5 = (cb, mod) => function __require() {
|
|
5644
|
-
return mod || (0, cb[__getOwnPropNames6(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5645
|
-
};
|
|
5646
|
-
var __copyProps6 = (to, from, except, desc) => {
|
|
5647
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
5648
|
-
for (let key of __getOwnPropNames6(from))
|
|
5649
|
-
if (!__hasOwnProp6.call(to, key) && key !== except)
|
|
5650
|
-
__defProp7(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc6(from, key)) || desc.enumerable });
|
|
5651
|
-
}
|
|
5652
|
-
return to;
|
|
5653
|
-
};
|
|
5654
|
-
var __toESM5 = (mod, isNodeMode, target) => (target = mod != null ? __create5(__getProtoOf5(mod)) : {}, __copyProps6(
|
|
5655
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
5656
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
5657
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
5658
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
5659
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp7(target, "default", { value: mod, enumerable: true }) : target,
|
|
5660
|
-
mod
|
|
5661
|
-
));
|
|
5662
|
-
var require_js_levenshtein = __commonJS5({
|
|
5663
|
-
"node_modules/js-levenshtein/index.js"(exports, module) {
|
|
5664
|
-
"use strict";
|
|
5665
|
-
module.exports = /* @__PURE__ */ function() {
|
|
5666
|
-
function _min(d0, d1, d2, bx, ay) {
|
|
5667
|
-
return d0 < d1 || d2 < d1 ? d0 > d2 ? d2 + 1 : d0 + 1 : bx === ay ? d1 : d1 + 1;
|
|
5668
|
-
}
|
|
5669
|
-
return function(a, b) {
|
|
5670
|
-
if (a === b) {
|
|
5671
|
-
return 0;
|
|
5672
|
-
}
|
|
5673
|
-
if (a.length > b.length) {
|
|
5674
|
-
var tmp = a;
|
|
5675
|
-
a = b;
|
|
5676
|
-
b = tmp;
|
|
5677
|
-
}
|
|
5678
|
-
var la = a.length;
|
|
5679
|
-
var lb = b.length;
|
|
5680
|
-
while (la > 0 && a.charCodeAt(la - 1) === b.charCodeAt(lb - 1)) {
|
|
5681
|
-
la--;
|
|
5682
|
-
lb--;
|
|
5683
|
-
}
|
|
5684
|
-
var offset = 0;
|
|
5685
|
-
while (offset < la && a.charCodeAt(offset) === b.charCodeAt(offset)) {
|
|
5686
|
-
offset++;
|
|
5687
|
-
}
|
|
5688
|
-
la -= offset;
|
|
5689
|
-
lb -= offset;
|
|
5690
|
-
if (la === 0 || lb < 3) {
|
|
5691
|
-
return lb;
|
|
5692
|
-
}
|
|
5693
|
-
var x = 0;
|
|
5694
|
-
var y;
|
|
5695
|
-
var d0;
|
|
5696
|
-
var d1;
|
|
5697
|
-
var d2;
|
|
5698
|
-
var d3;
|
|
5699
|
-
var dd;
|
|
5700
|
-
var dy;
|
|
5701
|
-
var ay;
|
|
5702
|
-
var bx0;
|
|
5703
|
-
var bx1;
|
|
5704
|
-
var bx2;
|
|
5705
|
-
var bx3;
|
|
5706
|
-
var vector = [];
|
|
5707
|
-
for (y = 0; y < la; y++) {
|
|
5708
|
-
vector.push(y + 1);
|
|
5709
|
-
vector.push(a.charCodeAt(offset + y));
|
|
5710
|
-
}
|
|
5711
|
-
var len = vector.length - 1;
|
|
5712
|
-
for (; x < lb - 3; ) {
|
|
5713
|
-
bx0 = b.charCodeAt(offset + (d0 = x));
|
|
5714
|
-
bx1 = b.charCodeAt(offset + (d1 = x + 1));
|
|
5715
|
-
bx2 = b.charCodeAt(offset + (d2 = x + 2));
|
|
5716
|
-
bx3 = b.charCodeAt(offset + (d3 = x + 3));
|
|
5717
|
-
dd = x += 4;
|
|
5718
|
-
for (y = 0; y < len; y += 2) {
|
|
5719
|
-
dy = vector[y];
|
|
5720
|
-
ay = vector[y + 1];
|
|
5721
|
-
d0 = _min(dy, d0, d1, bx0, ay);
|
|
5722
|
-
d1 = _min(d0, d1, d2, bx1, ay);
|
|
5723
|
-
d2 = _min(d1, d2, d3, bx2, ay);
|
|
5724
|
-
dd = _min(d2, d3, dd, bx3, ay);
|
|
5725
|
-
vector[y] = dd;
|
|
5726
|
-
d3 = d2;
|
|
5727
|
-
d2 = d1;
|
|
5728
|
-
d1 = d0;
|
|
5729
|
-
d0 = dy;
|
|
5730
|
-
}
|
|
5731
|
-
}
|
|
5732
|
-
for (; x < lb; ) {
|
|
5733
|
-
bx0 = b.charCodeAt(offset + (d0 = x));
|
|
5734
|
-
dd = ++x;
|
|
5735
|
-
for (y = 0; y < len; y += 2) {
|
|
5736
|
-
dy = vector[y];
|
|
5737
|
-
vector[y] = dd = _min(dy, d0, dd, bx0, vector[y + 1]);
|
|
5738
|
-
d0 = dy;
|
|
5739
|
-
}
|
|
5740
|
-
}
|
|
5741
|
-
return dd;
|
|
5742
|
-
};
|
|
5743
|
-
}();
|
|
5744
|
-
}
|
|
5745
|
-
});
|
|
5746
|
-
var import_js_levenshtein = __toESM5(require_js_levenshtein(), 1);
|
|
5747
|
-
var source_default3 = import_js_levenshtein.default;
|
|
5748
|
-
|
|
5749
5636
|
// src/core/utils/request/onUnhandledRequest.ts
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
function groupHandlersByType(handlers) {
|
|
5755
|
-
return handlers.reduce(
|
|
5756
|
-
(groups, handler) => {
|
|
5757
|
-
if (handler instanceof HttpHandler) {
|
|
5758
|
-
groups.http.push(handler);
|
|
5759
|
-
}
|
|
5760
|
-
if (handler instanceof GraphQLHandler) {
|
|
5761
|
-
groups.graphql.push(handler);
|
|
5762
|
-
}
|
|
5763
|
-
return groups;
|
|
5764
|
-
},
|
|
5765
|
-
{
|
|
5766
|
-
http: [],
|
|
5767
|
-
graphql: []
|
|
5768
|
-
}
|
|
5769
|
-
);
|
|
5770
|
-
}
|
|
5771
|
-
function getHttpHandlerScore() {
|
|
5772
|
-
return (request, handler) => {
|
|
5773
|
-
const { path, method } = handler.info;
|
|
5774
|
-
if (path instanceof RegExp || method instanceof RegExp) {
|
|
5775
|
-
return Infinity;
|
|
5776
|
-
}
|
|
5777
|
-
const hasSameMethod = isStringEqual(request.method, method);
|
|
5778
|
-
const methodScoreDelta = hasSameMethod ? TYPE_MATCH_DELTA : 0;
|
|
5779
|
-
const requestPublicUrl = getPublicUrlFromRequest(request);
|
|
5780
|
-
const score = getStringMatchScore(requestPublicUrl, path);
|
|
5781
|
-
return score - methodScoreDelta;
|
|
5782
|
-
};
|
|
5783
|
-
}
|
|
5784
|
-
function getGraphQLHandlerScore(parsedQuery) {
|
|
5785
|
-
return (_, handler) => {
|
|
5786
|
-
if (typeof parsedQuery.operationName === "undefined") {
|
|
5787
|
-
return Infinity;
|
|
5788
|
-
}
|
|
5789
|
-
const { operationType, operationName } = handler.info;
|
|
5790
|
-
if (typeof operationName !== "string") {
|
|
5791
|
-
return Infinity;
|
|
5792
|
-
}
|
|
5793
|
-
const hasSameOperationType = parsedQuery.operationType === operationType;
|
|
5794
|
-
const operationTypeScoreDelta = hasSameOperationType ? TYPE_MATCH_DELTA : 0;
|
|
5795
|
-
const score = getStringMatchScore(parsedQuery.operationName, operationName);
|
|
5796
|
-
return score - operationTypeScoreDelta;
|
|
5797
|
-
};
|
|
5798
|
-
}
|
|
5799
|
-
function getSuggestedHandler(request, handlers, getScore) {
|
|
5800
|
-
const suggestedHandlers = handlers.reduce((suggestions, handler) => {
|
|
5801
|
-
const score = getScore(request, handler);
|
|
5802
|
-
return suggestions.concat([[score, handler]]);
|
|
5803
|
-
}, []).sort(([leftScore], [rightScore]) => leftScore - rightScore).filter(([score]) => score <= MAX_MATCH_SCORE).slice(0, MAX_SUGGESTION_COUNT).map(([, handler]) => handler);
|
|
5804
|
-
return suggestedHandlers;
|
|
5805
|
-
}
|
|
5806
|
-
function getSuggestedHandlersMessage(handlers) {
|
|
5807
|
-
if (handlers.length > 1) {
|
|
5808
|
-
return `Did you mean to request one of the following resources instead?
|
|
5637
|
+
async function onUnhandledRequest(request, strategy = "warn") {
|
|
5638
|
+
const url = new URL(request.url);
|
|
5639
|
+
const publicUrl = toPublicUrl(url);
|
|
5640
|
+
const unhandledRequestMessage = `intercepted a request without a matching request handler:
|
|
5809
5641
|
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
async function onUnhandledRequest(request, handlers, strategy = "warn") {
|
|
5815
|
-
const parsedGraphQLQuery = await parseGraphQLRequest(request).catch(
|
|
5816
|
-
() => null
|
|
5817
|
-
);
|
|
5818
|
-
const publicUrl = getPublicUrlFromRequest(request);
|
|
5819
|
-
function generateHandlerSuggestion() {
|
|
5820
|
-
const handlerGroups = groupHandlersByType(handlers);
|
|
5821
|
-
const relevantHandlers = parsedGraphQLQuery ? handlerGroups.graphql : handlerGroups.http;
|
|
5822
|
-
const suggestedHandlers = getSuggestedHandler(
|
|
5823
|
-
request,
|
|
5824
|
-
relevantHandlers,
|
|
5825
|
-
parsedGraphQLQuery ? getGraphQLHandlerScore(parsedGraphQLQuery) : getHttpHandlerScore()
|
|
5826
|
-
);
|
|
5827
|
-
return suggestedHandlers.length > 0 ? getSuggestedHandlersMessage(suggestedHandlers) : "";
|
|
5828
|
-
}
|
|
5829
|
-
function getGraphQLRequestHeader(parsedGraphQLRequest) {
|
|
5830
|
-
if (!parsedGraphQLRequest?.operationName) {
|
|
5831
|
-
return `anonymous ${parsedGraphQLRequest?.operationType} (${request.method} ${publicUrl})`;
|
|
5832
|
-
}
|
|
5833
|
-
return `${parsedGraphQLRequest.operationType} ${parsedGraphQLRequest.operationName} (${request.method} ${publicUrl})`;
|
|
5834
|
-
}
|
|
5835
|
-
function generateUnhandledRequestMessage() {
|
|
5836
|
-
const requestHeader = parsedGraphQLQuery ? getGraphQLRequestHeader(parsedGraphQLQuery) : `${request.method} ${publicUrl}`;
|
|
5837
|
-
const handlerSuggestion = generateHandlerSuggestion();
|
|
5838
|
-
const messageTemplate = [
|
|
5839
|
-
`intercepted a request without a matching request handler:`,
|
|
5840
|
-
` \u2022 ${requestHeader}`,
|
|
5841
|
-
handlerSuggestion,
|
|
5842
|
-
`If you still wish to intercept this unhandled request, please create a request handler for it.
|
|
5843
|
-
Read more: https://mswjs.io/docs/getting-started/mocks`
|
|
5844
|
-
].filter(Boolean);
|
|
5845
|
-
return messageTemplate.join("\n\n");
|
|
5846
|
-
}
|
|
5642
|
+
\u2022 ${request.method} ${publicUrl}
|
|
5643
|
+
|
|
5644
|
+
If you still wish to intercept this unhandled request, please create a request handler for it.
|
|
5645
|
+
Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
5847
5646
|
function applyStrategy(strategy2) {
|
|
5848
|
-
const message3 = generateUnhandledRequestMessage();
|
|
5849
5647
|
switch (strategy2) {
|
|
5850
5648
|
case "error": {
|
|
5851
|
-
devUtils.error("Error: %s",
|
|
5649
|
+
devUtils.error("Error: %s", unhandledRequestMessage);
|
|
5852
5650
|
throw new Error(
|
|
5853
5651
|
devUtils.formatMessage(
|
|
5854
5652
|
'Cannot bypass a request when using the "error" strategy for the "onUnhandledRequest" option.'
|
|
@@ -5856,7 +5654,7 @@ Read more: https://mswjs.io/docs/getting-started/mocks`
|
|
|
5856
5654
|
);
|
|
5857
5655
|
}
|
|
5858
5656
|
case "warn": {
|
|
5859
|
-
devUtils.warn("Warning: %s",
|
|
5657
|
+
devUtils.warn("Warning: %s", unhandledRequestMessage);
|
|
5860
5658
|
break;
|
|
5861
5659
|
}
|
|
5862
5660
|
case "bypass":
|
|
@@ -5877,6 +5675,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`
|
|
|
5877
5675
|
});
|
|
5878
5676
|
return;
|
|
5879
5677
|
}
|
|
5678
|
+
if (url.protocol === "file:") {
|
|
5679
|
+
return;
|
|
5680
|
+
}
|
|
5880
5681
|
applyStrategy(strategy);
|
|
5881
5682
|
}
|
|
5882
5683
|
|
|
@@ -5911,7 +5712,7 @@ Read more: https://mswjs.io/docs/getting-started/mocks`
|
|
|
5911
5712
|
throw lookupResult.error;
|
|
5912
5713
|
}
|
|
5913
5714
|
if (!lookupResult.data) {
|
|
5914
|
-
await onUnhandledRequest(request,
|
|
5715
|
+
await onUnhandledRequest(request, options.onUnhandledRequest);
|
|
5915
5716
|
emitter.emit("request:unhandled", { request, requestId });
|
|
5916
5717
|
emitter.emit("request:end", { request, requestId });
|
|
5917
5718
|
handleRequestOptions?.onPassthroughResponse?.(request);
|
|
@@ -6299,6 +6100,9 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
|
|
|
6299
6100
|
const requestId = message3.payload.id;
|
|
6300
6101
|
const request = parseWorkerRequest(message3.payload);
|
|
6301
6102
|
const requestCloneForLogs = request.clone();
|
|
6103
|
+
const requestClone = request.clone();
|
|
6104
|
+
RequestHandler.cache.set(request, requestClone);
|
|
6105
|
+
context.requests.set(requestId, requestClone);
|
|
6302
6106
|
try {
|
|
6303
6107
|
await handleRequest(
|
|
6304
6108
|
request,
|
|
@@ -6390,6 +6194,9 @@ This exception has been gracefully handled as a 500 response, however, it's stro
|
|
|
6390
6194
|
function createResponseListener(context) {
|
|
6391
6195
|
return (_, message3) => {
|
|
6392
6196
|
const { payload: responseJson } = message3;
|
|
6197
|
+
const { requestId } = responseJson;
|
|
6198
|
+
const request = context.requests.get(requestId);
|
|
6199
|
+
context.requests.delete(requestId);
|
|
6393
6200
|
if (responseJson.type?.includes("opaque")) {
|
|
6394
6201
|
return;
|
|
6395
6202
|
}
|
|
@@ -6407,11 +6214,7 @@ This exception has been gracefully handled as a 500 response, however, it's stro
|
|
|
6407
6214
|
responseJson.isMockedResponse ? "response:mocked" : "response:bypass",
|
|
6408
6215
|
{
|
|
6409
6216
|
response,
|
|
6410
|
-
|
|
6411
|
-
* @todo @fixme In this context, we don't know anything about
|
|
6412
|
-
* the request.
|
|
6413
|
-
*/
|
|
6414
|
-
request: null,
|
|
6217
|
+
request,
|
|
6415
6218
|
requestId: responseJson.requestId
|
|
6416
6219
|
}
|
|
6417
6220
|
);
|
|
@@ -6644,7 +6447,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
6644
6447
|
}
|
|
6645
6448
|
};
|
|
6646
6449
|
|
|
6647
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.25.
|
|
6450
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.25.15/node_modules/@mswjs/interceptors/lib/browser/chunk-72HT65NX.mjs
|
|
6648
6451
|
function uuidv4() {
|
|
6649
6452
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
6650
6453
|
const r = Math.random() * 16 | 0;
|
|
@@ -6689,7 +6492,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
6689
6492
|
}
|
|
6690
6493
|
}
|
|
6691
6494
|
|
|
6692
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.25.
|
|
6495
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.25.15/node_modules/@mswjs/interceptors/lib/browser/chunk-44V5AUD6.mjs
|
|
6693
6496
|
function isPropertyAccessible2(obj, key) {
|
|
6694
6497
|
try {
|
|
6695
6498
|
obj[key];
|
|
@@ -6698,6 +6501,14 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
6698
6501
|
return false;
|
|
6699
6502
|
}
|
|
6700
6503
|
}
|
|
6504
|
+
function canParseUrl(url) {
|
|
6505
|
+
try {
|
|
6506
|
+
new URL(url);
|
|
6507
|
+
return true;
|
|
6508
|
+
} catch (_error) {
|
|
6509
|
+
return false;
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6701
6512
|
var _FetchInterceptor = class extends Interceptor {
|
|
6702
6513
|
constructor() {
|
|
6703
6514
|
super(_FetchInterceptor.symbol);
|
|
@@ -6714,7 +6525,8 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
6714
6525
|
globalThis.fetch = async (input, init) => {
|
|
6715
6526
|
var _a2;
|
|
6716
6527
|
const requestId = uuidv4();
|
|
6717
|
-
const
|
|
6528
|
+
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !canParseUrl(input) ? new URL(input, location.origin) : input;
|
|
6529
|
+
const request = new Request(resolvedInput, init);
|
|
6718
6530
|
this.logger.info("[%s] %s", request.method, request.url);
|
|
6719
6531
|
const { interactiveRequest, requestController } = toInteractiveRequest(request);
|
|
6720
6532
|
this.logger.info(
|
|
@@ -6826,7 +6638,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
6826
6638
|
});
|
|
6827
6639
|
}
|
|
6828
6640
|
|
|
6829
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.25.
|
|
6641
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.25.15/node_modules/@mswjs/interceptors/lib/browser/chunk-DZVB7JEV.mjs
|
|
6830
6642
|
function concatArrayBuffer(left, right) {
|
|
6831
6643
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
6832
6644
|
result.set(left, 0);
|
|
@@ -7670,6 +7482,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
7670
7482
|
worker: null,
|
|
7671
7483
|
registration: null,
|
|
7672
7484
|
requestHandlers: this.currentHandlers,
|
|
7485
|
+
requests: /* @__PURE__ */ new Map(),
|
|
7673
7486
|
emitter: this.emitter,
|
|
7674
7487
|
workerChannel: {
|
|
7675
7488
|
on: (eventType, callback) => {
|