msw 2.6.0 → 2.6.2
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 +121 -30
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +121 -30
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{GraphQLHandler-Doool6Q_.d.mts → GraphQLHandler-B6uni-E_.d.mts} +1 -1
- package/lib/core/{GraphQLHandler-udzgBRPf.d.ts → GraphQLHandler-Cjm7JNGi.d.ts} +1 -1
- package/lib/core/{HttpResponse-BLGmJolh.d.mts → HttpResponse-63H9vVoL.d.mts} +2 -1
- package/lib/core/{HttpResponse-Cgbkdkje.d.ts → HttpResponse-DzhqZzTK.d.ts} +2 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +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/handlers/RequestHandler.js +2 -0
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs +2 -0
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/handlers/WebSocketHandler.d.mts +1 -0
- package/lib/core/handlers/WebSocketHandler.d.ts +1 -0
- package/lib/core/handlers/WebSocketHandler.js +2 -0
- package/lib/core/handlers/WebSocketHandler.js.map +1 -1
- package/lib/core/handlers/WebSocketHandler.mjs +2 -0
- package/lib/core/handlers/WebSocketHandler.mjs.map +1 -1
- package/lib/core/handlers/common.d.mts +3 -0
- package/lib/core/handlers/common.d.ts +3 -0
- package/lib/core/handlers/common.js +17 -0
- package/lib/core/handlers/common.js.map +1 -0
- package/lib/core/handlers/common.mjs +1 -0
- package/lib/core/handlers/common.mjs.map +1 -0
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +2 -2
- package/lib/core/index.d.ts +2 -2
- 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 +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.mts +17 -0
- package/lib/core/utils/internal/isHandlerKind.d.ts +17 -0
- package/lib/core/utils/internal/isHandlerKind.js +29 -0
- package/lib/core/utils/internal/isHandlerKind.js.map +1 -0
- package/lib/core/utils/internal/isHandlerKind.mjs +9 -0
- package/lib/core/utils/internal/isHandlerKind.mjs.map +1 -0
- 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/getRequestCookies.js +12 -2
- package/lib/core/utils/request/getRequestCookies.js.map +1 -1
- package/lib/core/utils/request/getRequestCookies.mjs +12 -2
- package/lib/core/utils/request/getRequestCookies.mjs.map +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.ts +1 -1
- package/lib/core/ws/handleWebSocketEvent.js +2 -1
- package/lib/core/ws/handleWebSocketEvent.js.map +1 -1
- package/lib/core/ws/handleWebSocketEvent.mjs +3 -2
- package/lib/core/ws/handleWebSocketEvent.mjs.map +1 -1
- package/lib/iife/index.js +216 -73
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/lib/native/index.js +2 -5
- package/lib/native/index.js.map +1 -1
- package/lib/native/index.mjs +2 -5
- package/lib/native/index.mjs.map +1 -1
- package/lib/node/index.js +2 -5
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +2 -5
- package/lib/node/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/browser/setupWorker/start/createFallbackRequestListener.ts +2 -1
- package/src/browser/setupWorker/start/createRequestListener.ts +2 -7
- package/src/core/handlers/RequestHandler.ts +4 -0
- package/src/core/handlers/WebSocketHandler.ts +4 -0
- package/src/core/handlers/common.ts +1 -0
- package/src/core/utils/executeHandlers.ts +1 -5
- package/src/core/utils/internal/isHandlerKind.test.ts +64 -0
- package/src/core/utils/internal/isHandlerKind.ts +21 -0
- package/src/core/utils/request/getRequestCookies.ts +15 -2
- package/src/core/ws/handleWebSocketEvent.ts +2 -1
- package/src/node/SetupServerCommonApi.ts +4 -8
package/lib/iife/index.js
CHANGED
|
@@ -13775,6 +13775,7 @@ ${operationTypes.join("\n")}
|
|
|
13775
13775
|
// src/core/handlers/RequestHandler.ts
|
|
13776
13776
|
var RequestHandler = class _RequestHandler {
|
|
13777
13777
|
static cache = /* @__PURE__ */ new WeakMap();
|
|
13778
|
+
__kind;
|
|
13778
13779
|
info;
|
|
13779
13780
|
/**
|
|
13780
13781
|
* Indicates whether this request handler has been used
|
|
@@ -13794,6 +13795,7 @@ ${operationTypes.join("\n")}
|
|
|
13794
13795
|
callFrame
|
|
13795
13796
|
};
|
|
13796
13797
|
this.isUsed = false;
|
|
13798
|
+
this.__kind = "RequestHandler";
|
|
13797
13799
|
}
|
|
13798
13800
|
/**
|
|
13799
13801
|
* Parse the intercepted request to extract additional information from it.
|
|
@@ -14454,7 +14456,7 @@ ${operationTypes.join("\n")}
|
|
|
14454
14456
|
return stringToRegexp(path, keys, options);
|
|
14455
14457
|
}
|
|
14456
14458
|
|
|
14457
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14459
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
14458
14460
|
var encoder = new TextEncoder();
|
|
14459
14461
|
function encodeBuffer(text) {
|
|
14460
14462
|
return encoder.encode(text);
|
|
@@ -14470,7 +14472,7 @@ ${operationTypes.join("\n")}
|
|
|
14470
14472
|
);
|
|
14471
14473
|
}
|
|
14472
14474
|
|
|
14473
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14475
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-6MOMO77R.mjs
|
|
14474
14476
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
14475
14477
|
function isPropertyAccessible(obj, key) {
|
|
14476
14478
|
try {
|
|
@@ -14806,7 +14808,7 @@ ${operationTypes.join("\n")}
|
|
|
14806
14808
|
return message3.toString();
|
|
14807
14809
|
}
|
|
14808
14810
|
|
|
14809
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14811
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
|
14810
14812
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
14811
14813
|
function getGlobalSymbol(symbol) {
|
|
14812
14814
|
return (
|
|
@@ -14954,7 +14956,7 @@ ${operationTypes.join("\n")}
|
|
|
14954
14956
|
return Math.random().toString(16).slice(2);
|
|
14955
14957
|
}
|
|
14956
14958
|
|
|
14957
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14959
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
14958
14960
|
var BatchInterceptor = class extends Interceptor {
|
|
14959
14961
|
constructor(options) {
|
|
14960
14962
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -15078,7 +15080,7 @@ ${operationTypes.join("\n")}
|
|
|
15078
15080
|
return urlInstance.origin === location.origin ? urlInstance.pathname : urlInstance.origin + urlInstance.pathname;
|
|
15079
15081
|
}
|
|
15080
15082
|
|
|
15081
|
-
// node_modules/.pnpm/@bundled-es-modules+cookie@2.0.
|
|
15083
|
+
// node_modules/.pnpm/@bundled-es-modules+cookie@2.0.1/node_modules/@bundled-es-modules/cookie/index-esm.js
|
|
15082
15084
|
var __create2 = Object.create;
|
|
15083
15085
|
var __defProp4 = Object.defineProperty;
|
|
15084
15086
|
var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
|
|
@@ -15110,68 +15112,92 @@ ${operationTypes.join("\n")}
|
|
|
15110
15112
|
exports.parse = parse3;
|
|
15111
15113
|
exports.serialize = serialize;
|
|
15112
15114
|
var __toString = Object.prototype.toString;
|
|
15113
|
-
var
|
|
15114
|
-
|
|
15115
|
+
var __hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
15116
|
+
var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
15117
|
+
var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
|
|
15118
|
+
var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
|
15119
|
+
var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
|
15120
|
+
function parse3(str, opt) {
|
|
15115
15121
|
if (typeof str !== "string") {
|
|
15116
15122
|
throw new TypeError("argument str must be a string");
|
|
15117
15123
|
}
|
|
15118
15124
|
var obj = {};
|
|
15119
|
-
var
|
|
15120
|
-
|
|
15125
|
+
var len = str.length;
|
|
15126
|
+
if (len < 2) return obj;
|
|
15127
|
+
var dec = opt && opt.decode || decode;
|
|
15121
15128
|
var index = 0;
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15129
|
+
var eqIdx = 0;
|
|
15130
|
+
var endIdx = 0;
|
|
15131
|
+
do {
|
|
15132
|
+
eqIdx = str.indexOf("=", index);
|
|
15133
|
+
if (eqIdx === -1) break;
|
|
15134
|
+
endIdx = str.indexOf(";", index);
|
|
15128
15135
|
if (endIdx === -1) {
|
|
15129
|
-
endIdx =
|
|
15130
|
-
} else if (
|
|
15136
|
+
endIdx = len;
|
|
15137
|
+
} else if (eqIdx > endIdx) {
|
|
15131
15138
|
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
|
15132
15139
|
continue;
|
|
15133
15140
|
}
|
|
15134
|
-
var
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15141
|
+
var keyStartIdx = startIndex(str, index, eqIdx);
|
|
15142
|
+
var keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
|
|
15143
|
+
var key = str.slice(keyStartIdx, keyEndIdx);
|
|
15144
|
+
if (!__hasOwnProperty.call(obj, key)) {
|
|
15145
|
+
var valStartIdx = startIndex(str, eqIdx + 1, endIdx);
|
|
15146
|
+
var valEndIdx = endIndex(str, endIdx, valStartIdx);
|
|
15147
|
+
if (str.charCodeAt(valStartIdx) === 34 && str.charCodeAt(valEndIdx - 1) === 34) {
|
|
15148
|
+
valStartIdx++;
|
|
15149
|
+
valEndIdx--;
|
|
15139
15150
|
}
|
|
15151
|
+
var val = str.slice(valStartIdx, valEndIdx);
|
|
15140
15152
|
obj[key] = tryDecode(val, dec);
|
|
15141
15153
|
}
|
|
15142
15154
|
index = endIdx + 1;
|
|
15143
|
-
}
|
|
15155
|
+
} while (index < len);
|
|
15144
15156
|
return obj;
|
|
15145
15157
|
}
|
|
15146
|
-
function
|
|
15147
|
-
|
|
15148
|
-
|
|
15158
|
+
function startIndex(str, index, max) {
|
|
15159
|
+
do {
|
|
15160
|
+
var code = str.charCodeAt(index);
|
|
15161
|
+
if (code !== 32 && code !== 9) return index;
|
|
15162
|
+
} while (++index < max);
|
|
15163
|
+
return max;
|
|
15164
|
+
}
|
|
15165
|
+
function endIndex(str, index, min) {
|
|
15166
|
+
while (index > min) {
|
|
15167
|
+
var code = str.charCodeAt(--index);
|
|
15168
|
+
if (code !== 32 && code !== 9) return index + 1;
|
|
15169
|
+
}
|
|
15170
|
+
return min;
|
|
15171
|
+
}
|
|
15172
|
+
function serialize(name, val, opt) {
|
|
15173
|
+
var enc = opt && opt.encode || encodeURIComponent;
|
|
15149
15174
|
if (typeof enc !== "function") {
|
|
15150
15175
|
throw new TypeError("option encode is invalid");
|
|
15151
15176
|
}
|
|
15152
|
-
if (!
|
|
15177
|
+
if (!cookieNameRegExp.test(name)) {
|
|
15153
15178
|
throw new TypeError("argument name is invalid");
|
|
15154
15179
|
}
|
|
15155
15180
|
var value = enc(val);
|
|
15156
|
-
if (
|
|
15181
|
+
if (!cookieValueRegExp.test(value)) {
|
|
15157
15182
|
throw new TypeError("argument val is invalid");
|
|
15158
15183
|
}
|
|
15159
15184
|
var str = name + "=" + value;
|
|
15185
|
+
if (!opt) return str;
|
|
15160
15186
|
if (null != opt.maxAge) {
|
|
15161
|
-
var maxAge = opt.maxAge
|
|
15162
|
-
if (
|
|
15187
|
+
var maxAge = Math.floor(opt.maxAge);
|
|
15188
|
+
if (!isFinite(maxAge)) {
|
|
15163
15189
|
throw new TypeError("option maxAge is invalid");
|
|
15164
15190
|
}
|
|
15165
|
-
str += "; Max-Age=" +
|
|
15191
|
+
str += "; Max-Age=" + maxAge;
|
|
15166
15192
|
}
|
|
15167
15193
|
if (opt.domain) {
|
|
15168
|
-
if (!
|
|
15194
|
+
if (!domainValueRegExp.test(opt.domain)) {
|
|
15169
15195
|
throw new TypeError("option domain is invalid");
|
|
15170
15196
|
}
|
|
15171
15197
|
str += "; Domain=" + opt.domain;
|
|
15172
15198
|
}
|
|
15173
15199
|
if (opt.path) {
|
|
15174
|
-
if (!
|
|
15200
|
+
if (!pathValueRegExp.test(opt.path)) {
|
|
15175
15201
|
throw new TypeError("option path is invalid");
|
|
15176
15202
|
}
|
|
15177
15203
|
str += "; Path=" + opt.path;
|
|
@@ -15189,6 +15215,9 @@ ${operationTypes.join("\n")}
|
|
|
15189
15215
|
if (opt.secure) {
|
|
15190
15216
|
str += "; Secure";
|
|
15191
15217
|
}
|
|
15218
|
+
if (opt.partitioned) {
|
|
15219
|
+
str += "; Partitioned";
|
|
15220
|
+
}
|
|
15192
15221
|
if (opt.priority) {
|
|
15193
15222
|
var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
|
|
15194
15223
|
switch (priority) {
|
|
@@ -15229,11 +15258,8 @@ ${operationTypes.join("\n")}
|
|
|
15229
15258
|
function decode(str) {
|
|
15230
15259
|
return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
|
|
15231
15260
|
}
|
|
15232
|
-
function encode(val) {
|
|
15233
|
-
return encodeURIComponent(val);
|
|
15234
|
-
}
|
|
15235
15261
|
function isDate(val) {
|
|
15236
|
-
return __toString.call(val) === "[object Date]"
|
|
15262
|
+
return __toString.call(val) === "[object Date]";
|
|
15237
15263
|
}
|
|
15238
15264
|
function tryDecode(str, decode2) {
|
|
15239
15265
|
try {
|
|
@@ -27213,8 +27239,18 @@ ${operationTypes.join("\n")}
|
|
|
27213
27239
|
var cookieStore = new CookieJar(store);
|
|
27214
27240
|
|
|
27215
27241
|
// src/core/utils/request/getRequestCookies.ts
|
|
27242
|
+
function parseCookies(input) {
|
|
27243
|
+
const parsedCookies = source_default2.parse(input);
|
|
27244
|
+
const cookies = {};
|
|
27245
|
+
for (const cookieName in parsedCookies) {
|
|
27246
|
+
if (typeof parsedCookies[cookieName] !== "undefined") {
|
|
27247
|
+
cookies[cookieName] = parsedCookies[cookieName];
|
|
27248
|
+
}
|
|
27249
|
+
}
|
|
27250
|
+
return cookies;
|
|
27251
|
+
}
|
|
27216
27252
|
function getAllDocumentCookies() {
|
|
27217
|
-
return
|
|
27253
|
+
return parseCookies(document.cookie);
|
|
27218
27254
|
}
|
|
27219
27255
|
function getDocumentCookies(request) {
|
|
27220
27256
|
if (typeof document === "undefined" || typeof location === "undefined") {
|
|
@@ -27235,7 +27271,7 @@ ${operationTypes.join("\n")}
|
|
|
27235
27271
|
}
|
|
27236
27272
|
function getAllRequestCookies(request) {
|
|
27237
27273
|
const requestCookieHeader = request.headers.get("cookie");
|
|
27238
|
-
const cookiesFromHeaders = requestCookieHeader ?
|
|
27274
|
+
const cookiesFromHeaders = requestCookieHeader ? parseCookies(requestCookieHeader) : {};
|
|
27239
27275
|
const cookiesFromDocument = getDocumentCookies(request);
|
|
27240
27276
|
for (const name in cookiesFromDocument) {
|
|
27241
27277
|
request.headers.append(
|
|
@@ -28177,7 +28213,9 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
28177
28213
|
this.id = createRequestId();
|
|
28178
28214
|
this[kEmitter] = new Emitter();
|
|
28179
28215
|
this.callFrame = getCallFrame(new Error());
|
|
28216
|
+
this.__kind = "EventHandler";
|
|
28180
28217
|
}
|
|
28218
|
+
__kind;
|
|
28181
28219
|
id;
|
|
28182
28220
|
callFrame;
|
|
28183
28221
|
[kEmitter];
|
|
@@ -28639,9 +28677,6 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
28639
28677
|
let matchingHandler = null;
|
|
28640
28678
|
let result = null;
|
|
28641
28679
|
for (const handler of handlers) {
|
|
28642
|
-
if (!(handler instanceof RequestHandler)) {
|
|
28643
|
-
continue;
|
|
28644
|
-
}
|
|
28645
28680
|
result = await handler.run({ request, requestId, resolutionContext });
|
|
28646
28681
|
if (result !== null) {
|
|
28647
28682
|
matchingHandler = handler;
|
|
@@ -29166,6 +29201,13 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
|
|
|
29166
29201
|
};
|
|
29167
29202
|
}
|
|
29168
29203
|
|
|
29204
|
+
// src/core/utils/internal/isHandlerKind.ts
|
|
29205
|
+
function isHandlerKind(kind) {
|
|
29206
|
+
return (input) => {
|
|
29207
|
+
return input != null && typeof input === "object" && "__kind" in input && input.__kind === kind;
|
|
29208
|
+
};
|
|
29209
|
+
}
|
|
29210
|
+
|
|
29169
29211
|
// src/browser/setupWorker/start/createRequestListener.ts
|
|
29170
29212
|
var createRequestListener = (context, options) => {
|
|
29171
29213
|
return async (event, message3) => {
|
|
@@ -29180,9 +29222,7 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
|
|
|
29180
29222
|
await handleRequest(
|
|
29181
29223
|
request,
|
|
29182
29224
|
requestId,
|
|
29183
|
-
context.getRequestHandlers().filter((
|
|
29184
|
-
return handler instanceof HttpHandler || handler instanceof GraphQLHandler;
|
|
29185
|
-
}),
|
|
29225
|
+
context.getRequestHandlers().filter(isHandlerKind("RequestHandler")),
|
|
29186
29226
|
options,
|
|
29187
29227
|
context.emitter,
|
|
29188
29228
|
{
|
|
@@ -29464,7 +29504,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29464
29504
|
}
|
|
29465
29505
|
};
|
|
29466
29506
|
|
|
29467
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
29507
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-4RQHC4IY.mjs
|
|
29468
29508
|
var InterceptorError = class extends Error {
|
|
29469
29509
|
constructor(message3) {
|
|
29470
29510
|
super(message3);
|
|
@@ -29568,13 +29608,17 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29568
29608
|
});
|
|
29569
29609
|
const requestAbortPromise = new DeferredPromise();
|
|
29570
29610
|
if (options.request.signal) {
|
|
29571
|
-
options.request.signal.
|
|
29572
|
-
|
|
29573
|
-
|
|
29574
|
-
|
|
29575
|
-
|
|
29576
|
-
|
|
29577
|
-
|
|
29611
|
+
if (options.request.signal.aborted) {
|
|
29612
|
+
requestAbortPromise.reject(options.request.signal.reason);
|
|
29613
|
+
} else {
|
|
29614
|
+
options.request.signal.addEventListener(
|
|
29615
|
+
"abort",
|
|
29616
|
+
() => {
|
|
29617
|
+
requestAbortPromise.reject(options.request.signal.reason);
|
|
29618
|
+
},
|
|
29619
|
+
{ once: true }
|
|
29620
|
+
);
|
|
29621
|
+
}
|
|
29578
29622
|
}
|
|
29579
29623
|
const result = await until(async () => {
|
|
29580
29624
|
const requestListtenersPromise = emitAsync(options.emitter, "request", {
|
|
@@ -29632,7 +29676,28 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29632
29676
|
return false;
|
|
29633
29677
|
}
|
|
29634
29678
|
|
|
29635
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
29679
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-TX5GBTFY.mjs
|
|
29680
|
+
function hasConfigurableGlobal(propertyName) {
|
|
29681
|
+
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
|
29682
|
+
if (typeof descriptor === "undefined") {
|
|
29683
|
+
return false;
|
|
29684
|
+
}
|
|
29685
|
+
if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") {
|
|
29686
|
+
return false;
|
|
29687
|
+
}
|
|
29688
|
+
if (typeof descriptor.get === "undefined" && descriptor.value == null) {
|
|
29689
|
+
return false;
|
|
29690
|
+
}
|
|
29691
|
+
if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
|
|
29692
|
+
console.error(
|
|
29693
|
+
`[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`
|
|
29694
|
+
);
|
|
29695
|
+
return false;
|
|
29696
|
+
}
|
|
29697
|
+
return true;
|
|
29698
|
+
}
|
|
29699
|
+
|
|
29700
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-VXLPKFY4.mjs
|
|
29636
29701
|
function canParseUrl(url) {
|
|
29637
29702
|
try {
|
|
29638
29703
|
new URL(url);
|
|
@@ -29707,12 +29772,78 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29707
29772
|
}
|
|
29708
29773
|
return false;
|
|
29709
29774
|
}
|
|
29775
|
+
var BrotliDecompressionStream = class extends TransformStream {
|
|
29776
|
+
constructor() {
|
|
29777
|
+
console.warn(
|
|
29778
|
+
"[Interceptors]: Brotli decompression of response streams is not supported in the browser"
|
|
29779
|
+
);
|
|
29780
|
+
super({
|
|
29781
|
+
transform(chunk, controller) {
|
|
29782
|
+
controller.enqueue(chunk);
|
|
29783
|
+
}
|
|
29784
|
+
});
|
|
29785
|
+
}
|
|
29786
|
+
};
|
|
29787
|
+
var PipelineStream = class extends TransformStream {
|
|
29788
|
+
constructor(transformStreams, ...strategies) {
|
|
29789
|
+
super({}, ...strategies);
|
|
29790
|
+
const readable = [super.readable, ...transformStreams].reduce(
|
|
29791
|
+
(readable2, transform) => readable2.pipeThrough(transform)
|
|
29792
|
+
);
|
|
29793
|
+
Object.defineProperty(this, "readable", {
|
|
29794
|
+
get() {
|
|
29795
|
+
return readable;
|
|
29796
|
+
}
|
|
29797
|
+
});
|
|
29798
|
+
}
|
|
29799
|
+
};
|
|
29800
|
+
function parseContentEncoding(contentEncoding) {
|
|
29801
|
+
return contentEncoding.toLowerCase().split(",").map((coding) => coding.trim());
|
|
29802
|
+
}
|
|
29803
|
+
function createDecompressionStream(contentEncoding) {
|
|
29804
|
+
if (contentEncoding === "") {
|
|
29805
|
+
return null;
|
|
29806
|
+
}
|
|
29807
|
+
const codings = parseContentEncoding(contentEncoding);
|
|
29808
|
+
if (codings.length === 0) {
|
|
29809
|
+
return null;
|
|
29810
|
+
}
|
|
29811
|
+
const transformers = codings.reduceRight(
|
|
29812
|
+
(transformers2, coding) => {
|
|
29813
|
+
if (coding === "gzip" || coding === "x-gzip") {
|
|
29814
|
+
return transformers2.concat(new DecompressionStream("gzip"));
|
|
29815
|
+
} else if (coding === "deflate") {
|
|
29816
|
+
return transformers2.concat(new DecompressionStream("deflate"));
|
|
29817
|
+
} else if (coding === "br") {
|
|
29818
|
+
return transformers2.concat(new BrotliDecompressionStream());
|
|
29819
|
+
} else {
|
|
29820
|
+
transformers2.length = 0;
|
|
29821
|
+
}
|
|
29822
|
+
return transformers2;
|
|
29823
|
+
},
|
|
29824
|
+
[]
|
|
29825
|
+
);
|
|
29826
|
+
return new PipelineStream(transformers);
|
|
29827
|
+
}
|
|
29828
|
+
function decompressResponse(response) {
|
|
29829
|
+
if (response.body === null) {
|
|
29830
|
+
return null;
|
|
29831
|
+
}
|
|
29832
|
+
const decompressionStream = createDecompressionStream(
|
|
29833
|
+
response.headers.get("content-encoding") || ""
|
|
29834
|
+
);
|
|
29835
|
+
if (!decompressionStream) {
|
|
29836
|
+
return null;
|
|
29837
|
+
}
|
|
29838
|
+
response.body.pipeTo(decompressionStream.writable);
|
|
29839
|
+
return decompressionStream.readable;
|
|
29840
|
+
}
|
|
29710
29841
|
var _FetchInterceptor = class extends Interceptor {
|
|
29711
29842
|
constructor() {
|
|
29712
29843
|
super(_FetchInterceptor.symbol);
|
|
29713
29844
|
}
|
|
29714
29845
|
checkEnvironment() {
|
|
29715
|
-
return
|
|
29846
|
+
return hasConfigurableGlobal("fetch");
|
|
29716
29847
|
}
|
|
29717
29848
|
async setup() {
|
|
29718
29849
|
const pureFetch = globalThis.fetch;
|
|
@@ -29737,10 +29868,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29737
29868
|
requestId,
|
|
29738
29869
|
emitter: this.emitter,
|
|
29739
29870
|
controller,
|
|
29740
|
-
onResponse: async (
|
|
29871
|
+
onResponse: async (rawResponse) => {
|
|
29741
29872
|
this.logger.info("received mocked response!", {
|
|
29742
|
-
|
|
29873
|
+
rawResponse
|
|
29743
29874
|
});
|
|
29875
|
+
const decompressedStream = decompressResponse(rawResponse);
|
|
29876
|
+
const response = decompressedStream === null ? rawResponse : new Response(decompressedStream, rawResponse);
|
|
29744
29877
|
if (RESPONSE_STATUS_CODES_WITH_REDIRECT.has(response.status)) {
|
|
29745
29878
|
if (request.redirect === "error") {
|
|
29746
29879
|
responsePromise.reject(createNetworkError("unexpected redirect"));
|
|
@@ -29758,6 +29891,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29758
29891
|
return;
|
|
29759
29892
|
}
|
|
29760
29893
|
}
|
|
29894
|
+
Object.defineProperty(response, "url", {
|
|
29895
|
+
writable: false,
|
|
29896
|
+
enumerable: true,
|
|
29897
|
+
configurable: false,
|
|
29898
|
+
value: request.url
|
|
29899
|
+
});
|
|
29761
29900
|
if (this.emitter.listenerCount("response") > 0) {
|
|
29762
29901
|
this.logger.info('emitting the "response" event...');
|
|
29763
29902
|
await emitAsync(this.emitter, "response", {
|
|
@@ -29770,12 +29909,6 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29770
29909
|
requestId
|
|
29771
29910
|
});
|
|
29772
29911
|
}
|
|
29773
|
-
Object.defineProperty(response, "url", {
|
|
29774
|
-
writable: false,
|
|
29775
|
-
enumerable: true,
|
|
29776
|
-
configurable: false,
|
|
29777
|
-
value: request.url
|
|
29778
|
-
});
|
|
29779
29912
|
responsePromise.resolve(response);
|
|
29780
29913
|
},
|
|
29781
29914
|
onRequestError: (response) => {
|
|
@@ -29829,7 +29962,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29829
29962
|
var FetchInterceptor = _FetchInterceptor;
|
|
29830
29963
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
29831
29964
|
|
|
29832
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
29965
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-MMAVIMED.mjs
|
|
29833
29966
|
function concatArrayBuffer(left, right) {
|
|
29834
29967
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
29835
29968
|
result.set(left, 0);
|
|
@@ -30576,7 +30709,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
30576
30709
|
super(_XMLHttpRequestInterceptor.interceptorSymbol);
|
|
30577
30710
|
}
|
|
30578
30711
|
checkEnvironment() {
|
|
30579
|
-
return
|
|
30712
|
+
return hasConfigurableGlobal("XMLHttpRequest");
|
|
30580
30713
|
}
|
|
30581
30714
|
setup() {
|
|
30582
30715
|
const logger = this.logger.extend("setup");
|
|
@@ -30625,7 +30758,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
30625
30758
|
const response = await handleRequest(
|
|
30626
30759
|
request,
|
|
30627
30760
|
requestId,
|
|
30628
|
-
context.getRequestHandlers(),
|
|
30761
|
+
context.getRequestHandlers().filter(isHandlerKind("RequestHandler")),
|
|
30629
30762
|
options,
|
|
30630
30763
|
context.emitter,
|
|
30631
30764
|
{
|
|
@@ -30700,7 +30833,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
30700
30833
|
}
|
|
30701
30834
|
}
|
|
30702
30835
|
|
|
30703
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
30836
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
|
|
30704
30837
|
function bindEvent(target, event) {
|
|
30705
30838
|
Object.defineProperties(event, {
|
|
30706
30839
|
target: {
|
|
@@ -31291,11 +31424,14 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31291
31424
|
super(_WebSocketInterceptor.symbol);
|
|
31292
31425
|
}
|
|
31293
31426
|
checkEnvironment() {
|
|
31294
|
-
return
|
|
31427
|
+
return hasConfigurableGlobal("WebSocket");
|
|
31295
31428
|
}
|
|
31296
31429
|
setup() {
|
|
31297
|
-
const
|
|
31298
|
-
|
|
31430
|
+
const originalWebSocketDescriptor = Object.getOwnPropertyDescriptor(
|
|
31431
|
+
globalThis,
|
|
31432
|
+
"WebSocket"
|
|
31433
|
+
);
|
|
31434
|
+
const WebSocketProxy = new Proxy(globalThis.WebSocket, {
|
|
31299
31435
|
construct: (target, args, newTarget) => {
|
|
31300
31436
|
const [url, protocols] = args;
|
|
31301
31437
|
const createConnection = () => {
|
|
@@ -31342,9 +31478,16 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31342
31478
|
return socket;
|
|
31343
31479
|
}
|
|
31344
31480
|
});
|
|
31345
|
-
globalThis
|
|
31481
|
+
Object.defineProperty(globalThis, "WebSocket", {
|
|
31482
|
+
value: WebSocketProxy,
|
|
31483
|
+
configurable: true
|
|
31484
|
+
});
|
|
31346
31485
|
this.subscriptions.push(() => {
|
|
31347
|
-
|
|
31486
|
+
Object.defineProperty(
|
|
31487
|
+
globalThis,
|
|
31488
|
+
"WebSocket",
|
|
31489
|
+
originalWebSocketDescriptor
|
|
31490
|
+
);
|
|
31348
31491
|
});
|
|
31349
31492
|
}
|
|
31350
31493
|
};
|
|
@@ -31363,7 +31506,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31363
31506
|
});
|
|
31364
31507
|
const matchingHandlers = [];
|
|
31365
31508
|
for (const handler of handlers) {
|
|
31366
|
-
if (handler
|
|
31509
|
+
if (isHandlerKind("EventHandler")(handler) && handler.predicate({
|
|
31367
31510
|
event: connectionEvent,
|
|
31368
31511
|
parsedResult: handler.parse({
|
|
31369
31512
|
event: connectionEvent
|