msw 3.0.0 → 3.0.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 +1 -3
- package/lib/_chunks/attach-sibling-handlers.js +1 -1
- package/lib/_chunks/cookie-store.js +9 -1
- package/lib/_chunks/cookie-store.js.map +1 -1
- package/lib/_chunks/http-handler.js +14 -9
- package/lib/_chunks/http-handler.js.map +1 -1
- package/lib/_chunks/http-response.js +1 -1
- package/lib/_chunks/interceptor-source.js +15 -1
- package/lib/_chunks/interceptor-source.js.map +1 -1
- package/lib/_chunks/request-handler.js +1 -1
- package/lib/_chunks/sse.js +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/graphql/index.js +1 -1
- package/lib/iife/index.js +37 -10
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/lib/node/index.js +1 -1
- package/package.json +4 -4
- package/src/core/experimental/frames/http-frame.test.ts +49 -0
- package/src/core/experimental/frames/http-frame.ts +19 -0
- package/src/http/http-handler.test.ts +19 -1
- package/src/http/http-handler.ts +13 -0
- package/src/vite/plugin.test.ts +24 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as Handler, d as getRawSetCookie, g as getCallFrame, h as devUtils, l as copyResponseOwnProperties } from "./cookie-store.js";
|
|
2
2
|
import { isNodeProcess } from "is-node-process";
|
|
3
3
|
import { FetchResponse } from "@mswjs/interceptors";
|
|
4
4
|
//#region src/core/utils/internal/is-iterable.ts
|
package/lib/_chunks/sse.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as devUtils, r as toPublicUrl, s as getTimestamp } from "./cookie-store.js";
|
|
2
2
|
import { t as HttpHandler } from "./http-handler.js";
|
|
3
3
|
import { t as colors } from "./colors.js";
|
|
4
4
|
import { delay } from "../utils/delay.js";
|
package/lib/browser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as devUtils } from "../_chunks/cookie-store.js";
|
|
2
2
|
import { t as RequestHandler } from "../_chunks/request-handler.js";
|
|
3
3
|
import { t as isObject } from "../_chunks/is-object.js";
|
|
4
4
|
import { t as HttpResponse } from "../_chunks/http-response.js";
|
package/lib/graphql/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as matchRequestUrl,
|
|
1
|
+
import { a as matchRequestUrl, h as devUtils, n as jsonParse, r as toPublicUrl, s as getTimestamp } from "../_chunks/cookie-store.js";
|
|
2
2
|
import { t as RequestHandler } from "../_chunks/request-handler.js";
|
|
3
3
|
import { a as serializeRequest, i as serializeResponse, o as getStatusCodeColor, r as getAllRequestCookies } from "../_chunks/http-handler.js";
|
|
4
4
|
import { t as http } from "../_chunks/http.js";
|
package/lib/iife/index.js
CHANGED
|
@@ -672,7 +672,7 @@ var MockServiceWorker = (function(exports) {
|
|
|
672
672
|
}
|
|
673
673
|
};
|
|
674
674
|
//#endregion
|
|
675
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
675
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/create-request-id-YobUnJNO.js
|
|
676
676
|
var __create = Object.create;
|
|
677
677
|
var __defProp = Object.defineProperty;
|
|
678
678
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1378,7 +1378,7 @@ var MockServiceWorker = (function(exports) {
|
|
|
1378
1378
|
return Math.random().toString(16).slice(2);
|
|
1379
1379
|
}
|
|
1380
1380
|
//#endregion
|
|
1381
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
1381
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/fetch-utils-C6P6gLLo.js
|
|
1382
1382
|
var InterceptorError = class InterceptorError extends Error {
|
|
1383
1383
|
constructor(message) {
|
|
1384
1384
|
super(message);
|
|
@@ -1785,7 +1785,7 @@ var MockServiceWorker = (function(exports) {
|
|
|
1785
1785
|
}
|
|
1786
1786
|
};
|
|
1787
1787
|
//#endregion
|
|
1788
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
1788
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/buffer-utils-DJj7YzLG.js
|
|
1789
1789
|
const encoder = new TextEncoder();
|
|
1790
1790
|
function encodeBuffer(text) {
|
|
1791
1791
|
return encoder.encode(text);
|
|
@@ -1802,7 +1802,7 @@ var MockServiceWorker = (function(exports) {
|
|
|
1802
1802
|
return array.buffer.slice(array.byteOffset, array.byteOffset + array.byteLength);
|
|
1803
1803
|
}
|
|
1804
1804
|
//#endregion
|
|
1805
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
1805
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/resolve-web-socket-url-CSvNPLGi.js
|
|
1806
1806
|
/**
|
|
1807
1807
|
* Resolve potentially relative WebSocket URLs the same way
|
|
1808
1808
|
* the browser does (replace the protocol, use the origin, etc).
|
|
@@ -1824,7 +1824,7 @@ var MockServiceWorker = (function(exports) {
|
|
|
1824
1824
|
return url.href;
|
|
1825
1825
|
}
|
|
1826
1826
|
//#endregion
|
|
1827
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
1827
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/index.js
|
|
1828
1828
|
function addEventBridge(interceptor, type, listener) {
|
|
1829
1829
|
interceptor.on(type, listener);
|
|
1830
1830
|
}
|
|
@@ -27378,6 +27378,19 @@ var MockServiceWorker = (function(exports) {
|
|
|
27378
27378
|
devUtils.warn(`Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters using "new URL(request.url).searchParams" instead. Learn more: https://mswjs.io/docs/http/intercepting-requests#querysearch-parameters`);
|
|
27379
27379
|
}
|
|
27380
27380
|
async parse(args) {
|
|
27381
|
+
/**
|
|
27382
|
+
* @note CONNECT requests target an authority ("host:port"), not a URL.
|
|
27383
|
+
* HTTP handlers never match them.
|
|
27384
|
+
* @todo Match the authority against the handler path once
|
|
27385
|
+
* `http.connect()` is supported instead of bailing out.
|
|
27386
|
+
*/
|
|
27387
|
+
if (isStringEqual(args.request.method, "CONNECT")) return {
|
|
27388
|
+
match: {
|
|
27389
|
+
matches: false,
|
|
27390
|
+
params: {}
|
|
27391
|
+
},
|
|
27392
|
+
cookies: {}
|
|
27393
|
+
};
|
|
27381
27394
|
const url = new URL(args.request.url);
|
|
27382
27395
|
const cookies = getAllRequestCookies(args.request);
|
|
27383
27396
|
/**
|
|
@@ -27459,7 +27472,7 @@ var MockServiceWorker = (function(exports) {
|
|
|
27459
27472
|
options: createHttpHandler("OPTIONS")
|
|
27460
27473
|
};
|
|
27461
27474
|
//#endregion
|
|
27462
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
27475
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/has-configurable-global-Cew-dYqk.js
|
|
27463
27476
|
var PatchesRegistry = class {
|
|
27464
27477
|
#replacements = /* @__PURE__ */ new Map();
|
|
27465
27478
|
applyPatch(owner, key, getNextValue) {
|
|
@@ -27547,7 +27560,7 @@ var MockServiceWorker = (function(exports) {
|
|
|
27547
27560
|
return true;
|
|
27548
27561
|
}
|
|
27549
27562
|
//#endregion
|
|
27550
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
27563
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.js
|
|
27551
27564
|
var WebSocketConnectionEvent$2 = class extends TypedEvent {
|
|
27552
27565
|
constructor(data) {
|
|
27553
27566
|
super("connection", { data });
|
|
@@ -30438,6 +30451,20 @@ accept: "msw/passthrough" },
|
|
|
30438
30451
|
return null;
|
|
30439
30452
|
}
|
|
30440
30453
|
if (lookupResult == null) {
|
|
30454
|
+
/**
|
|
30455
|
+
* @note Unhandled CONNECT requests establish a tunnel through a proxy.
|
|
30456
|
+
* They are transport, not the request the developer cares about, so
|
|
30457
|
+
* they pass through silently regardless of the unhandled frame strategy.
|
|
30458
|
+
* The request sent through the tunnel gets its own resolution.
|
|
30459
|
+
*/
|
|
30460
|
+
if (isStringEqual(request.method, "CONNECT")) {
|
|
30461
|
+
this.events.emit(new RequestEvent("request:end", {
|
|
30462
|
+
requestId,
|
|
30463
|
+
request
|
|
30464
|
+
}));
|
|
30465
|
+
this.passthrough();
|
|
30466
|
+
return null;
|
|
30467
|
+
}
|
|
30441
30468
|
this.events.emit(new RequestEvent("request:unhandled", {
|
|
30442
30469
|
requestId,
|
|
30443
30470
|
request
|
|
@@ -31233,7 +31260,7 @@ You can also automate this process and make the worker script update automatical
|
|
|
31233
31260
|
}
|
|
31234
31261
|
}
|
|
31235
31262
|
//#endregion
|
|
31236
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
31263
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/handle-request-y7ajyve5.js
|
|
31237
31264
|
var HttpRequestEvent = class extends TypedEvent {
|
|
31238
31265
|
constructor(data) {
|
|
31239
31266
|
super(...["request", {}]);
|
|
@@ -31389,7 +31416,7 @@ You can also automate this process and make the worker script update automatical
|
|
|
31389
31416
|
return options.controller.handled;
|
|
31390
31417
|
}
|
|
31391
31418
|
//#endregion
|
|
31392
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
31419
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/web-CCLERSZF.js
|
|
31393
31420
|
function createNetworkError(cause) {
|
|
31394
31421
|
return Object.assign(/* @__PURE__ */ new TypeError("Failed to fetch"), { cause });
|
|
31395
31422
|
}
|
|
@@ -31702,7 +31729,7 @@ You can also automate this process and make the worker script update automatical
|
|
|
31702
31729
|
}
|
|
31703
31730
|
};
|
|
31704
31731
|
//#endregion
|
|
31705
|
-
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.
|
|
31732
|
+
//#region node_modules/.pnpm/@mswjs+interceptors@0.45.6_supports-color@8.1.1/node_modules/@mswjs/interceptors/lib/browser/web-BRBQ3YPp.js
|
|
31706
31733
|
/**
|
|
31707
31734
|
* Concatenate two `Uint8Array` buffers.
|
|
31708
31735
|
*/
|