@mswjs/interceptors 0.36.8 → 0.36.9
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/{chunk-THPGBWJQ.mjs → chunk-4K55BZMG.mjs} +2 -2
- package/lib/browser/{chunk-XVPRNJO7.mjs → chunk-6MOMO77R.mjs} +1 -1
- package/lib/browser/chunk-6MOMO77R.mjs.map +1 -0
- package/lib/browser/{chunk-2CAGU4FT.js → chunk-7TPGF5DM.js} +1 -1
- package/lib/browser/chunk-7TPGF5DM.js.map +1 -0
- package/lib/browser/{chunk-DZYTPQEW.mjs → chunk-C6BKAAQW.mjs} +3 -3
- package/lib/browser/{chunk-6QUU6UER.js → chunk-LMBCDE7C.js} +11 -11
- package/lib/browser/{chunk-45ALW4JK.mjs → chunk-Q7PXVXSL.mjs} +3 -3
- package/lib/browser/{chunk-6CHFD3BW.js → chunk-RKQSZCUD.js} +9 -9
- package/lib/browser/{chunk-FYSUKT3F.js → chunk-UXPG527I.js} +4 -4
- package/lib/browser/{glossary-7d7adb4b.d.ts → glossary-6564c252.d.ts} +2 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +2 -2
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/interceptors/XMLHttpRequest/index.d.ts +1 -1
- package/lib/browser/interceptors/XMLHttpRequest/index.js +4 -4
- package/lib/browser/interceptors/XMLHttpRequest/index.mjs +3 -3
- package/lib/browser/interceptors/fetch/index.d.ts +1 -1
- package/lib/browser/interceptors/fetch/index.js +4 -4
- package/lib/browser/interceptors/fetch/index.mjs +3 -3
- package/lib/browser/presets/browser.d.ts +1 -1
- package/lib/browser/presets/browser.js +6 -6
- package/lib/browser/presets/browser.mjs +4 -4
- package/lib/node/{BatchInterceptor-13d40c95.d.ts → BatchInterceptor-67bf41ba.d.ts} +1 -1
- package/lib/node/{Interceptor-a31b1217.d.ts → Interceptor-436630be.d.ts} +2 -1
- package/lib/node/RemoteHttpInterceptor.d.ts +2 -2
- package/lib/node/RemoteHttpInterceptor.js +3 -3
- package/lib/node/RemoteHttpInterceptor.mjs +2 -2
- package/lib/node/{chunk-CR4RBHMG.js → chunk-4YT2XSVO.js} +5 -5
- package/lib/node/{chunk-GD7YWPFZ.mjs → chunk-6DIWEMO7.mjs} +2 -2
- package/lib/node/{chunk-BZ3Y7YV5.mjs → chunk-6YM4PLBI.mjs} +1 -1
- package/lib/node/chunk-6YM4PLBI.mjs.map +1 -0
- package/lib/node/{chunk-IDEEMJ3F.js → chunk-73NOP3T5.js} +1 -1
- package/lib/node/chunk-73NOP3T5.js.map +1 -0
- package/lib/node/{chunk-EV33OS3A.mjs → chunk-EBDS6VMR.mjs} +2 -2
- package/lib/node/{chunk-FLQK3CSL.js → chunk-X2CFRRWY.js} +5 -5
- package/lib/node/index.d.ts +2 -2
- package/lib/node/index.js +2 -2
- package/lib/node/index.mjs +1 -1
- package/lib/node/interceptors/ClientRequest/index.d.ts +1 -1
- package/lib/node/interceptors/XMLHttpRequest/index.d.ts +1 -1
- package/lib/node/interceptors/XMLHttpRequest/index.js +3 -3
- package/lib/node/interceptors/XMLHttpRequest/index.mjs +2 -2
- package/lib/node/interceptors/fetch/index.d.ts +1 -1
- package/lib/node/interceptors/fetch/index.js +3 -3
- package/lib/node/interceptors/fetch/index.mjs +2 -2
- package/lib/node/presets/node.d.ts +1 -1
- package/lib/node/presets/node.js +5 -5
- package/lib/node/presets/node.mjs +3 -3
- package/package.json +1 -1
- package/src/glossary.ts +6 -0
- package/lib/browser/chunk-2CAGU4FT.js.map +0 -1
- package/lib/browser/chunk-XVPRNJO7.mjs.map +0 -1
- package/lib/node/chunk-BZ3Y7YV5.mjs.map +0 -1
- package/lib/node/chunk-IDEEMJ3F.js.map +0 -1
- /package/lib/browser/{chunk-THPGBWJQ.mjs.map → chunk-4K55BZMG.mjs.map} +0 -0
- /package/lib/browser/{chunk-DZYTPQEW.mjs.map → chunk-C6BKAAQW.mjs.map} +0 -0
- /package/lib/browser/{chunk-6QUU6UER.js.map → chunk-LMBCDE7C.js.map} +0 -0
- /package/lib/browser/{chunk-45ALW4JK.mjs.map → chunk-Q7PXVXSL.mjs.map} +0 -0
- /package/lib/browser/{chunk-6CHFD3BW.js.map → chunk-RKQSZCUD.js.map} +0 -0
- /package/lib/browser/{chunk-FYSUKT3F.js.map → chunk-UXPG527I.js.map} +0 -0
- /package/lib/node/{chunk-CR4RBHMG.js.map → chunk-4YT2XSVO.js.map} +0 -0
- /package/lib/node/{chunk-GD7YWPFZ.mjs.map → chunk-6DIWEMO7.mjs.map} +0 -0
- /package/lib/node/{chunk-EV33OS3A.mjs.map → chunk-EBDS6VMR.mjs.map} +0 -0
- /package/lib/node/{chunk-FLQK3CSL.js.map → chunk-X2CFRRWY.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServerErrorResponse,
|
|
3
3
|
isResponseError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6MOMO77R.mjs";
|
|
5
5
|
|
|
6
6
|
// src/RequestController.ts
|
|
7
7
|
import { invariant } from "outvariant";
|
|
@@ -193,4 +193,4 @@ export {
|
|
|
193
193
|
emitAsync,
|
|
194
194
|
handleRequest
|
|
195
195
|
};
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
196
|
+
//# sourceMappingURL=chunk-4K55BZMG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/glossary.ts","../../src/utils/isPropertyAccessible.ts","../../src/utils/responseUtils.ts"],"sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\nexport const RESPONSE_STATUS_CODES_WITHOUT_BODY = new Set([\n 101, 103, 204, 205, 304,\n])\n\nexport const RESPONSE_STATUS_CODES_WITH_REDIRECT = new Set([\n 301, 302, 303, 307, 308,\n])\n\n/**\n * Returns a boolean indicating whether the given response status\n * code represents a response that cannot have a body.\n */\nexport function isResponseWithoutBody(status: number): boolean {\n return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status)\n}\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: Response): response is ResponseError {\n return isPropertyAccessible(response, 'type') && response.type === 'error'\n}\n"],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;;;ACMjE,SAAS,qBACd,KACA,KACA;AACA,MAAI;AACF,QAAI,GAAG;AACP,WAAO;AAAA,EACT,SAAQ,GAAN;AACA,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,qCAAqC,oBAAI,IAAI;AAAA,EACxD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAEM,IAAM,sCAAsC,oBAAI,IAAI;AAAA,EACzD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAMM,SAAS,sBAAsB,QAAyB;AAC7D,SAAO,mCAAmC,IAAI,MAAM;AACtD;AAKO,SAAS,0BAA0B,MAAyB;AACjE,SAAO,IAAI;AAAA,IACT,KAAK;AAAA,MACH,gBAAgB,QACZ;AAAA,QACE,MAAM,KAAK;AAAA,QACX,SAAS,KAAK;AAAA,QACd,OAAO,KAAK;AAAA,MACd,IACA;AAAA,IACN;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB,UAA+C;AAC7E,SAAO,qBAAqB,UAAU,MAAM,KAAK,SAAS,SAAS;AACrE;","names":[]}
|
|
@@ -58,4 +58,4 @@ function isResponseError(response) {
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
exports.IS_PATCHED_MODULE = IS_PATCHED_MODULE; exports.RESPONSE_STATUS_CODES_WITH_REDIRECT = RESPONSE_STATUS_CODES_WITH_REDIRECT; exports.isResponseWithoutBody = isResponseWithoutBody; exports.createServerErrorResponse = createServerErrorResponse; exports.isResponseError = isResponseError;
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-7TPGF5DM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/glossary.ts","../../src/utils/isPropertyAccessible.ts","../../src/utils/responseUtils.ts"],"names":[],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;;;ACMjE,SAAS,qBACd,KACA,KACA;AACA,MAAI;AACF,QAAI,GAAG;AACP,WAAO;AAAA,EACT,SAAQ,GAAN;AACA,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,qCAAqC,oBAAI,IAAI;AAAA,EACxD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAEM,IAAM,sCAAsC,oBAAI,IAAI;AAAA,EACzD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAMM,SAAS,sBAAsB,QAAyB;AAC7D,SAAO,mCAAmC,IAAI,MAAM;AACtD;AAKO,SAAS,0BAA0B,MAAyB;AACjE,SAAO,IAAI;AAAA,IACT,KAAK;AAAA,MACH,gBAAgB,QACZ;AAAA,QACE,MAAM,KAAK;AAAA,QACX,SAAS,KAAK;AAAA,QACd,OAAO,KAAK;AAAA,MACd,IACA;AAAA,IACN;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB,UAA+C;AAC7E,SAAO,qBAAqB,UAAU,MAAM,KAAK,SAAS,SAAS;AACrE","sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\nexport const RESPONSE_STATUS_CODES_WITHOUT_BODY = new Set([\n 101, 103, 204, 205, 304,\n])\n\nexport const RESPONSE_STATUS_CODES_WITH_REDIRECT = new Set([\n 301, 302, 303, 307, 308,\n])\n\n/**\n * Returns a boolean indicating whether the given response status\n * code represents a response that cannot have a body.\n */\nexport function isResponseWithoutBody(status: number): boolean {\n return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status)\n}\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: Response): response is ResponseError {\n return isPropertyAccessible(response, 'type') && response.type === 'error'\n}\n"]}
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
RequestController,
|
|
3
3
|
emitAsync,
|
|
4
4
|
handleRequest
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-4K55BZMG.mjs";
|
|
6
6
|
import {
|
|
7
7
|
IS_PATCHED_MODULE,
|
|
8
8
|
RESPONSE_STATUS_CODES_WITH_REDIRECT
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6MOMO77R.mjs";
|
|
10
10
|
import {
|
|
11
11
|
hasConfigurableGlobal
|
|
12
12
|
} from "./chunk-TX5GBTFY.mjs";
|
|
@@ -297,4 +297,4 @@ FetchInterceptor.symbol = Symbol("fetch");
|
|
|
297
297
|
export {
|
|
298
298
|
FetchInterceptor
|
|
299
299
|
};
|
|
300
|
-
//# sourceMappingURL=chunk-
|
|
300
|
+
//# sourceMappingURL=chunk-C6BKAAQW.mjs.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkUXPG527Ijs = require('./chunk-UXPG527I.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunk7TPGF5DMjs = require('./chunk-7TPGF5DM.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
|
|
@@ -180,7 +180,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
180
180
|
async setup() {
|
|
181
181
|
const pureFetch = globalThis.fetch;
|
|
182
182
|
_outvariant.invariant.call(void 0,
|
|
183
|
-
!pureFetch[
|
|
183
|
+
!pureFetch[_chunk7TPGF5DMjs.IS_PATCHED_MODULE],
|
|
184
184
|
'Failed to patch the "fetch" module: already patched.'
|
|
185
185
|
);
|
|
186
186
|
globalThis.fetch = async (input, init) => {
|
|
@@ -188,14 +188,14 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
188
188
|
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !canParseUrl(input) ? new URL(input, location.origin) : input;
|
|
189
189
|
const request = new Request(resolvedInput, init);
|
|
190
190
|
const responsePromise = new (0, _deferredpromise.DeferredPromise)();
|
|
191
|
-
const controller = new (0,
|
|
191
|
+
const controller = new (0, _chunkUXPG527Ijs.RequestController)(request);
|
|
192
192
|
this.logger.info("[%s] %s", request.method, request.url);
|
|
193
193
|
this.logger.info("awaiting for the mocked response...");
|
|
194
194
|
this.logger.info(
|
|
195
195
|
'emitting the "request" event for %s listener(s)...',
|
|
196
196
|
this.emitter.listenerCount("request")
|
|
197
197
|
);
|
|
198
|
-
const isRequestHandled = await
|
|
198
|
+
const isRequestHandled = await _chunkUXPG527Ijs.handleRequest.call(void 0, {
|
|
199
199
|
request,
|
|
200
200
|
requestId,
|
|
201
201
|
emitter: this.emitter,
|
|
@@ -206,7 +206,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
206
206
|
});
|
|
207
207
|
const decompressedStream = decompressResponse(rawResponse);
|
|
208
208
|
const response = decompressedStream === null ? rawResponse : new Response(decompressedStream, rawResponse);
|
|
209
|
-
if (
|
|
209
|
+
if (_chunk7TPGF5DMjs.RESPONSE_STATUS_CODES_WITH_REDIRECT.has(response.status)) {
|
|
210
210
|
if (request.redirect === "error") {
|
|
211
211
|
responsePromise.reject(createNetworkError("unexpected redirect"));
|
|
212
212
|
return;
|
|
@@ -231,7 +231,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
231
231
|
});
|
|
232
232
|
if (this.emitter.listenerCount("response") > 0) {
|
|
233
233
|
this.logger.info('emitting the "response" event...');
|
|
234
|
-
await
|
|
234
|
+
await _chunkUXPG527Ijs.emitAsync.call(void 0, this.emitter, "response", {
|
|
235
235
|
// Clone the mocked response for the "response" event listener.
|
|
236
236
|
// This way, the listener can read the response and not lock its body
|
|
237
237
|
// for the actual fetch consumer.
|
|
@@ -264,7 +264,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
264
264
|
if (this.emitter.listenerCount("response") > 0) {
|
|
265
265
|
this.logger.info('emitting the "response" event...');
|
|
266
266
|
const responseClone = response.clone();
|
|
267
|
-
await
|
|
267
|
+
await _chunkUXPG527Ijs.emitAsync.call(void 0, this.emitter, "response", {
|
|
268
268
|
response: responseClone,
|
|
269
269
|
isMockedResponse: false,
|
|
270
270
|
request,
|
|
@@ -274,13 +274,13 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
274
274
|
return response;
|
|
275
275
|
});
|
|
276
276
|
};
|
|
277
|
-
Object.defineProperty(globalThis.fetch,
|
|
277
|
+
Object.defineProperty(globalThis.fetch, _chunk7TPGF5DMjs.IS_PATCHED_MODULE, {
|
|
278
278
|
enumerable: true,
|
|
279
279
|
configurable: true,
|
|
280
280
|
value: true
|
|
281
281
|
});
|
|
282
282
|
this.subscriptions.push(() => {
|
|
283
|
-
Object.defineProperty(globalThis.fetch,
|
|
283
|
+
Object.defineProperty(globalThis.fetch, _chunk7TPGF5DMjs.IS_PATCHED_MODULE, {
|
|
284
284
|
value: void 0
|
|
285
285
|
});
|
|
286
286
|
globalThis.fetch = pureFetch;
|
|
@@ -297,4 +297,4 @@ FetchInterceptor.symbol = Symbol("fetch");
|
|
|
297
297
|
|
|
298
298
|
|
|
299
299
|
exports.FetchInterceptor = FetchInterceptor;
|
|
300
|
-
//# sourceMappingURL=chunk-
|
|
300
|
+
//# sourceMappingURL=chunk-LMBCDE7C.js.map
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
RequestController,
|
|
8
8
|
handleRequest
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4K55BZMG.mjs";
|
|
10
10
|
import {
|
|
11
11
|
IS_PATCHED_MODULE,
|
|
12
12
|
isResponseWithoutBody
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-6MOMO77R.mjs";
|
|
14
14
|
import {
|
|
15
15
|
hasConfigurableGlobal
|
|
16
16
|
} from "./chunk-TX5GBTFY.mjs";
|
|
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
|
|
840
840
|
export {
|
|
841
841
|
XMLHttpRequestInterceptor
|
|
842
842
|
};
|
|
843
|
-
//# sourceMappingURL=chunk-
|
|
843
|
+
//# sourceMappingURL=chunk-Q7PXVXSL.mjs.map
|
|
@@ -6,11 +6,11 @@ var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkUXPG527Ijs = require('./chunk-UXPG527I.js');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunk7TPGF5DMjs = require('./chunk-7TPGF5DM.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
|
|
@@ -206,7 +206,7 @@ function parseJson(data) {
|
|
|
206
206
|
|
|
207
207
|
// src/interceptors/XMLHttpRequest/utils/createResponse.ts
|
|
208
208
|
function createResponse(request, body) {
|
|
209
|
-
const responseBodyOrNull =
|
|
209
|
+
const responseBodyOrNull = _chunk7TPGF5DMjs.isResponseWithoutBody.call(void 0, request.status) ? null : body;
|
|
210
210
|
return new Response(responseBodyOrNull, {
|
|
211
211
|
status: request.status,
|
|
212
212
|
statusText: request.statusText,
|
|
@@ -740,13 +740,13 @@ function createXMLHttpRequestProxy({
|
|
|
740
740
|
logger
|
|
741
741
|
);
|
|
742
742
|
xhrRequestController.onRequest = async function({ request, requestId }) {
|
|
743
|
-
const controller = new (0,
|
|
743
|
+
const controller = new (0, _chunkUXPG527Ijs.RequestController)(request);
|
|
744
744
|
this.logger.info("awaiting mocked response...");
|
|
745
745
|
this.logger.info(
|
|
746
746
|
'emitting the "request" event for %s listener(s)...',
|
|
747
747
|
emitter.listenerCount("request")
|
|
748
748
|
);
|
|
749
|
-
const isRequestHandled = await
|
|
749
|
+
const isRequestHandled = await _chunkUXPG527Ijs.handleRequest.call(void 0, {
|
|
750
750
|
request,
|
|
751
751
|
requestId,
|
|
752
752
|
controller,
|
|
@@ -806,7 +806,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
806
806
|
logger.info('patching "XMLHttpRequest" module...');
|
|
807
807
|
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
|
|
808
808
|
_outvariant.invariant.call(void 0,
|
|
809
|
-
!PureXMLHttpRequest[
|
|
809
|
+
!PureXMLHttpRequest[_chunk7TPGF5DMjs.IS_PATCHED_MODULE],
|
|
810
810
|
'Failed to patch the "XMLHttpRequest" module: already patched.'
|
|
811
811
|
);
|
|
812
812
|
globalThis.XMLHttpRequest = createXMLHttpRequestProxy({
|
|
@@ -817,13 +817,13 @@ var _XMLHttpRequestInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
|
|
|
817
817
|
'native "XMLHttpRequest" module patched!',
|
|
818
818
|
globalThis.XMLHttpRequest.name
|
|
819
819
|
);
|
|
820
|
-
Object.defineProperty(globalThis.XMLHttpRequest,
|
|
820
|
+
Object.defineProperty(globalThis.XMLHttpRequest, _chunk7TPGF5DMjs.IS_PATCHED_MODULE, {
|
|
821
821
|
enumerable: true,
|
|
822
822
|
configurable: true,
|
|
823
823
|
value: true
|
|
824
824
|
});
|
|
825
825
|
this.subscriptions.push(() => {
|
|
826
|
-
Object.defineProperty(globalThis.XMLHttpRequest,
|
|
826
|
+
Object.defineProperty(globalThis.XMLHttpRequest, _chunk7TPGF5DMjs.IS_PATCHED_MODULE, {
|
|
827
827
|
value: void 0
|
|
828
828
|
});
|
|
829
829
|
globalThis.XMLHttpRequest = PureXMLHttpRequest;
|
|
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
|
|
840
840
|
|
|
841
841
|
|
|
842
842
|
exports.XMLHttpRequestInterceptor = XMLHttpRequestInterceptor;
|
|
843
|
-
//# sourceMappingURL=chunk-
|
|
843
|
+
//# sourceMappingURL=chunk-RKQSZCUD.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk7TPGF5DMjs = require('./chunk-7TPGF5DM.js');
|
|
5
5
|
|
|
6
6
|
// src/RequestController.ts
|
|
7
7
|
var _outvariant = require('outvariant');
|
|
@@ -94,7 +94,7 @@ async function handleRequest(options) {
|
|
|
94
94
|
const handleResponse = async (response) => {
|
|
95
95
|
if (response instanceof Error) {
|
|
96
96
|
options.onError(response);
|
|
97
|
-
} else if (
|
|
97
|
+
} else if (_chunk7TPGF5DMjs.isResponseError.call(void 0, response)) {
|
|
98
98
|
options.onRequestError(response);
|
|
99
99
|
} else {
|
|
100
100
|
await options.onResponse(response);
|
|
@@ -179,7 +179,7 @@ async function handleRequest(options) {
|
|
|
179
179
|
return handleResponse(nextResult.data);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
options.onResponse(
|
|
182
|
+
options.onResponse(_chunk7TPGF5DMjs.createServerErrorResponse.call(void 0, result.error));
|
|
183
183
|
return true;
|
|
184
184
|
}
|
|
185
185
|
if (result.data) {
|
|
@@ -193,4 +193,4 @@ async function handleRequest(options) {
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
exports.RequestController = RequestController; exports.emitAsync = emitAsync; exports.handleRequest = handleRequest;
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
196
|
+
//# sourceMappingURL=chunk-UXPG527I.js.map
|
|
@@ -36,6 +36,7 @@ declare class RequestController {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
declare const IS_PATCHED_MODULE: unique symbol;
|
|
39
|
+
|
|
39
40
|
type RequestCredentials = 'omit' | 'include' | 'same-origin';
|
|
40
41
|
type HttpRequestEventMap = {
|
|
41
42
|
request: [
|
|
@@ -63,4 +64,4 @@ type HttpRequestEventMap = {
|
|
|
63
64
|
];
|
|
64
65
|
};
|
|
65
66
|
|
|
66
|
-
export { HttpRequestEventMap as H, IS_PATCHED_MODULE as I,
|
|
67
|
+
export { HttpRequestEventMap as H, IS_PATCHED_MODULE as I, RequestController as R, RequestCredentials as a };
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { H as HttpRequestEventMap, I as IS_PATCHED_MODULE, R as RequestCredentials } from './glossary-
|
|
1
|
+
export { H as HttpRequestEventMap, I as IS_PATCHED_MODULE, R as RequestController, a as RequestCredentials } from './glossary-6564c252.js';
|
|
2
2
|
import { I as Interceptor, E as ExtractEventNames } from './Interceptor-af98b768.js';
|
|
3
3
|
export { c as INTERNAL_REQUEST_ID_HEADER_NAME, a as InterceptorEventMap, e as InterceptorReadyState, b as InterceptorSubscription, d as deleteGlobalSymbol, g as getGlobalSymbol } from './Interceptor-af98b768.js';
|
|
4
4
|
import { EventMap, Listener } from 'strict-event-emitter';
|
package/lib/browser/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk7TPGF5DMjs = require('./chunk-7TPGF5DM.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -75,5 +75,5 @@ function getCleanUrl(url, isAbsolute = true) {
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
exports.BatchInterceptor = BatchInterceptor; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkTIPR373Rjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE =
|
|
78
|
+
exports.BatchInterceptor = BatchInterceptor; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkTIPR373Rjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunk7TPGF5DMjs.IS_PATCHED_MODULE; exports.Interceptor = _chunkTIPR373Rjs.Interceptor; exports.InterceptorReadyState = _chunkTIPR373Rjs.InterceptorReadyState; exports.createRequestId = _chunkTIPR373Rjs.createRequestId; exports.decodeBuffer = _chunkLK6DILFKjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkTIPR373Rjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkLK6DILFKjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkTIPR373Rjs.getGlobalSymbol; exports.isResponseWithoutBody = _chunk7TPGF5DMjs.isResponseWithoutBody;
|
|
79
79
|
//# sourceMappingURL=index.js.map
|
package/lib/browser/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { H as HttpRequestEventMap } from '../../glossary-
|
|
2
|
+
import { H as HttpRequestEventMap } from '../../glossary-6564c252.js';
|
|
3
3
|
import { I as Interceptor } from '../../Interceptor-af98b768.js';
|
|
4
4
|
import '@open-draft/deferred-promise';
|
|
5
5
|
import '@open-draft/logger';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRKQSZCUDjs = require('../../chunk-RKQSZCUD.js');
|
|
4
4
|
require('../../chunk-LK6DILFK.js');
|
|
5
|
-
require('../../chunk-
|
|
6
|
-
require('../../chunk-
|
|
5
|
+
require('../../chunk-UXPG527I.js');
|
|
6
|
+
require('../../chunk-7TPGF5DM.js');
|
|
7
7
|
require('../../chunk-PFGO5BSM.js');
|
|
8
8
|
require('../../chunk-TIPR373R.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.XMLHttpRequestInterceptor =
|
|
11
|
+
exports.XMLHttpRequestInterceptor = _chunkRKQSZCUDjs.XMLHttpRequestInterceptor;
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-Q7PXVXSL.mjs";
|
|
4
4
|
import "../../chunk-6HYIRFX2.mjs";
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-4K55BZMG.mjs";
|
|
6
|
+
import "../../chunk-6MOMO77R.mjs";
|
|
7
7
|
import "../../chunk-TX5GBTFY.mjs";
|
|
8
8
|
import "../../chunk-QED3Q6Z2.mjs";
|
|
9
9
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HttpRequestEventMap } from '../../glossary-
|
|
1
|
+
import { H as HttpRequestEventMap } from '../../glossary-6564c252.js';
|
|
2
2
|
import { I as Interceptor } from '../../Interceptor-af98b768.js';
|
|
3
3
|
import '@open-draft/deferred-promise';
|
|
4
4
|
import '@open-draft/logger';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
5
|
-
require('../../chunk-
|
|
3
|
+
var _chunkLMBCDE7Cjs = require('../../chunk-LMBCDE7C.js');
|
|
4
|
+
require('../../chunk-UXPG527I.js');
|
|
5
|
+
require('../../chunk-7TPGF5DM.js');
|
|
6
6
|
require('../../chunk-PFGO5BSM.js');
|
|
7
7
|
require('../../chunk-TIPR373R.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.FetchInterceptor =
|
|
10
|
+
exports.FetchInterceptor = _chunkLMBCDE7Cjs.FetchInterceptor;
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FetchInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-C6BKAAQW.mjs";
|
|
4
|
+
import "../../chunk-4K55BZMG.mjs";
|
|
5
|
+
import "../../chunk-6MOMO77R.mjs";
|
|
6
6
|
import "../../chunk-TX5GBTFY.mjs";
|
|
7
7
|
import "../../chunk-QED3Q6Z2.mjs";
|
|
8
8
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FetchInterceptor } from '../interceptors/fetch/index.js';
|
|
2
2
|
import { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest/index.js';
|
|
3
|
-
import '../glossary-
|
|
3
|
+
import '../glossary-6564c252.js';
|
|
4
4
|
import '@open-draft/deferred-promise';
|
|
5
5
|
import '../Interceptor-af98b768.js';
|
|
6
6
|
import '@open-draft/logger';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRKQSZCUDjs = require('../chunk-RKQSZCUD.js');
|
|
4
4
|
require('../chunk-LK6DILFK.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
7
|
+
var _chunkLMBCDE7Cjs = require('../chunk-LMBCDE7C.js');
|
|
8
|
+
require('../chunk-UXPG527I.js');
|
|
9
|
+
require('../chunk-7TPGF5DM.js');
|
|
10
10
|
require('../chunk-PFGO5BSM.js');
|
|
11
11
|
require('../chunk-TIPR373R.js');
|
|
12
12
|
|
|
13
13
|
// src/presets/browser.ts
|
|
14
14
|
var browser_default = [
|
|
15
|
-
new (0,
|
|
16
|
-
new (0,
|
|
15
|
+
new (0, _chunkLMBCDE7Cjs.FetchInterceptor)(),
|
|
16
|
+
new (0, _chunkRKQSZCUDjs.XMLHttpRequestInterceptor)()
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-Q7PXVXSL.mjs";
|
|
4
4
|
import "../chunk-6HYIRFX2.mjs";
|
|
5
5
|
import {
|
|
6
6
|
FetchInterceptor
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-C6BKAAQW.mjs";
|
|
8
|
+
import "../chunk-4K55BZMG.mjs";
|
|
9
|
+
import "../chunk-6MOMO77R.mjs";
|
|
10
10
|
import "../chunk-TX5GBTFY.mjs";
|
|
11
11
|
import "../chunk-QED3Q6Z2.mjs";
|
|
12
12
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventMap, Listener } from 'strict-event-emitter';
|
|
2
|
-
import {
|
|
2
|
+
import { h as Interceptor, E as ExtractEventNames } from './Interceptor-436630be.js';
|
|
3
3
|
|
|
4
4
|
interface BatchInterceptorOptions<InterceptorList extends ReadonlyArray<Interceptor<any>>> {
|
|
5
5
|
name: string;
|
|
@@ -38,6 +38,7 @@ declare class RequestController {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
declare const IS_PATCHED_MODULE: unique symbol;
|
|
41
|
+
|
|
41
42
|
type RequestCredentials = 'omit' | 'include' | 'same-origin';
|
|
42
43
|
type HttpRequestEventMap = {
|
|
43
44
|
request: [
|
|
@@ -124,4 +125,4 @@ declare class Interceptor<Events extends InterceptorEventMap> {
|
|
|
124
125
|
private clearInstance;
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
export { ExtractEventNames as E, HttpRequestEventMap as H, IS_PATCHED_MODULE as I,
|
|
128
|
+
export { ExtractEventNames as E, HttpRequestEventMap as H, IS_PATCHED_MODULE as I, RequestController as R, RequestCredentials as a, InterceptorEventMap as b, InterceptorSubscription as c, INTERNAL_REQUEST_ID_HEADER_NAME as d, deleteGlobalSymbol as e, InterceptorReadyState as f, getGlobalSymbol as g, Interceptor as h };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChildProcess } from 'child_process';
|
|
2
|
-
import {
|
|
3
|
-
import { a as BatchInterceptor } from './BatchInterceptor-
|
|
2
|
+
import { h as Interceptor, H as HttpRequestEventMap } from './Interceptor-436630be.js';
|
|
3
|
+
import { a as BatchInterceptor } from './BatchInterceptor-67bf41ba.js';
|
|
4
4
|
import { ClientRequestInterceptor } from './interceptors/ClientRequest/index.js';
|
|
5
5
|
import { XMLHttpRequestInterceptor } from './interceptors/XMLHttpRequest/index.js';
|
|
6
6
|
import '@open-draft/deferred-promise';
|
|
@@ -6,10 +6,10 @@ var _chunkPGTBKPWNjs = require('./chunk-PGTBKPWN.js');
|
|
|
6
6
|
var _chunkFPLETXGAjs = require('./chunk-FPLETXGA.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkX2CFRRWYjs = require('./chunk-X2CFRRWY.js');
|
|
10
10
|
require('./chunk-LK6DILFK.js');
|
|
11
11
|
require('./chunk-PFGO5BSM.js');
|
|
12
|
-
require('./chunk-
|
|
12
|
+
require('./chunk-73NOP3T5.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -25,7 +25,7 @@ var RemoteHttpInterceptor = class extends _chunkPGTBKPWNjs.BatchInterceptor {
|
|
|
25
25
|
name: "remote-interceptor",
|
|
26
26
|
interceptors: [
|
|
27
27
|
new (0, _chunkFPLETXGAjs.ClientRequestInterceptor)(),
|
|
28
|
-
new (0,
|
|
28
|
+
new (0, _chunkX2CFRRWYjs.XMLHttpRequestInterceptor)()
|
|
29
29
|
]
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from "./chunk-MG3S53QP.mjs";
|
|
7
7
|
import {
|
|
8
8
|
XMLHttpRequestInterceptor
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EBDS6VMR.mjs";
|
|
10
10
|
import "./chunk-6HYIRFX2.mjs";
|
|
11
11
|
import "./chunk-TX5GBTFY.mjs";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-6YM4PLBI.mjs";
|
|
13
13
|
import {
|
|
14
14
|
RequestController,
|
|
15
15
|
handleRequest
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk73NOP3T5js = require('./chunk-73NOP3T5.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -195,7 +195,7 @@ var _FetchInterceptor = class extends _chunkAABH3XLQjs.Interceptor {
|
|
|
195
195
|
async setup() {
|
|
196
196
|
const pureFetch = globalThis.fetch;
|
|
197
197
|
_outvariant.invariant.call(void 0,
|
|
198
|
-
!pureFetch[
|
|
198
|
+
!pureFetch[_chunk73NOP3T5js.IS_PATCHED_MODULE],
|
|
199
199
|
'Failed to patch the "fetch" module: already patched.'
|
|
200
200
|
);
|
|
201
201
|
globalThis.fetch = async (input, init) => {
|
|
@@ -289,13 +289,13 @@ var _FetchInterceptor = class extends _chunkAABH3XLQjs.Interceptor {
|
|
|
289
289
|
return response;
|
|
290
290
|
});
|
|
291
291
|
};
|
|
292
|
-
Object.defineProperty(globalThis.fetch,
|
|
292
|
+
Object.defineProperty(globalThis.fetch, _chunk73NOP3T5js.IS_PATCHED_MODULE, {
|
|
293
293
|
enumerable: true,
|
|
294
294
|
configurable: true,
|
|
295
295
|
value: true
|
|
296
296
|
});
|
|
297
297
|
this.subscriptions.push(() => {
|
|
298
|
-
Object.defineProperty(globalThis.fetch,
|
|
298
|
+
Object.defineProperty(globalThis.fetch, _chunk73NOP3T5js.IS_PATCHED_MODULE, {
|
|
299
299
|
value: void 0
|
|
300
300
|
});
|
|
301
301
|
globalThis.fetch = pureFetch;
|
|
@@ -312,4 +312,4 @@ FetchInterceptor.symbol = Symbol("fetch");
|
|
|
312
312
|
|
|
313
313
|
|
|
314
314
|
exports.FetchInterceptor = FetchInterceptor;
|
|
315
|
-
//# sourceMappingURL=chunk-
|
|
315
|
+
//# sourceMappingURL=chunk-4YT2XSVO.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-TX5GBTFY.mjs";
|
|
4
4
|
import {
|
|
5
5
|
IS_PATCHED_MODULE
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6YM4PLBI.mjs";
|
|
7
7
|
import {
|
|
8
8
|
RequestController,
|
|
9
9
|
emitAsync,
|
|
@@ -312,4 +312,4 @@ FetchInterceptor.symbol = Symbol("fetch");
|
|
|
312
312
|
export {
|
|
313
313
|
FetchInterceptor
|
|
314
314
|
};
|
|
315
|
-
//# sourceMappingURL=chunk-
|
|
315
|
+
//# sourceMappingURL=chunk-6DIWEMO7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/glossary.ts"],"sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n"],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/glossary.ts"],"names":[],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB","sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\n/**\n * @note Export `RequestController` as a type only.\n * It's never meant to be created in the userland.\n */\nexport type { RequestController }\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n"]}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-TX5GBTFY.mjs";
|
|
9
9
|
import {
|
|
10
10
|
IS_PATCHED_MODULE
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6YM4PLBI.mjs";
|
|
12
12
|
import {
|
|
13
13
|
RequestController,
|
|
14
14
|
handleRequest
|
|
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
|
|
840
840
|
export {
|
|
841
841
|
XMLHttpRequestInterceptor
|
|
842
842
|
};
|
|
843
|
-
//# sourceMappingURL=chunk-
|
|
843
|
+
//# sourceMappingURL=chunk-EBDS6VMR.mjs.map
|
|
@@ -8,7 +8,7 @@ var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
|
|
|
8
8
|
var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk73NOP3T5js = require('./chunk-73NOP3T5.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -806,7 +806,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkAABH3XLQjs.Interceptor {
|
|
|
806
806
|
logger.info('patching "XMLHttpRequest" module...');
|
|
807
807
|
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
|
|
808
808
|
_outvariant.invariant.call(void 0,
|
|
809
|
-
!PureXMLHttpRequest[
|
|
809
|
+
!PureXMLHttpRequest[_chunk73NOP3T5js.IS_PATCHED_MODULE],
|
|
810
810
|
'Failed to patch the "XMLHttpRequest" module: already patched.'
|
|
811
811
|
);
|
|
812
812
|
globalThis.XMLHttpRequest = createXMLHttpRequestProxy({
|
|
@@ -817,13 +817,13 @@ var _XMLHttpRequestInterceptor = class extends _chunkAABH3XLQjs.Interceptor {
|
|
|
817
817
|
'native "XMLHttpRequest" module patched!',
|
|
818
818
|
globalThis.XMLHttpRequest.name
|
|
819
819
|
);
|
|
820
|
-
Object.defineProperty(globalThis.XMLHttpRequest,
|
|
820
|
+
Object.defineProperty(globalThis.XMLHttpRequest, _chunk73NOP3T5js.IS_PATCHED_MODULE, {
|
|
821
821
|
enumerable: true,
|
|
822
822
|
configurable: true,
|
|
823
823
|
value: true
|
|
824
824
|
});
|
|
825
825
|
this.subscriptions.push(() => {
|
|
826
|
-
Object.defineProperty(globalThis.XMLHttpRequest,
|
|
826
|
+
Object.defineProperty(globalThis.XMLHttpRequest, _chunk73NOP3T5js.IS_PATCHED_MODULE, {
|
|
827
827
|
value: void 0
|
|
828
828
|
});
|
|
829
829
|
globalThis.XMLHttpRequest = PureXMLHttpRequest;
|
|
@@ -840,4 +840,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
|
|
840
840
|
|
|
841
841
|
|
|
842
842
|
exports.XMLHttpRequestInterceptor = XMLHttpRequestInterceptor;
|
|
843
|
-
//# sourceMappingURL=chunk-
|
|
843
|
+
//# sourceMappingURL=chunk-X2CFRRWY.js.map
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { E as ExtractEventNames, H as HttpRequestEventMap,
|
|
2
|
-
export { a as BatchInterceptor, B as BatchInterceptorOptions, E as ExtractEventMapType } from './BatchInterceptor-
|
|
1
|
+
export { E as ExtractEventNames, H as HttpRequestEventMap, d as INTERNAL_REQUEST_ID_HEADER_NAME, I as IS_PATCHED_MODULE, h as Interceptor, b as InterceptorEventMap, f as InterceptorReadyState, c as InterceptorSubscription, R as RequestController, a as RequestCredentials, e as deleteGlobalSymbol, g as getGlobalSymbol } from './Interceptor-436630be.js';
|
|
2
|
+
export { a as BatchInterceptor, B as BatchInterceptorOptions, E as ExtractEventMapType } from './BatchInterceptor-67bf41ba.js';
|
|
3
3
|
import '@open-draft/deferred-promise';
|
|
4
4
|
import '@open-draft/logger';
|
|
5
5
|
import 'strict-event-emitter';
|
package/lib/node/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var _chunkPGTBKPWNjs = require('./chunk-PGTBKPWN.js');
|
|
|
7
7
|
var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk73NOP3T5js = require('./chunk-73NOP3T5.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -35,5 +35,5 @@ function getCleanUrl(url, isAbsolute = true) {
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
exports.BatchInterceptor = _chunkPGTBKPWNjs.BatchInterceptor; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkAABH3XLQjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE =
|
|
38
|
+
exports.BatchInterceptor = _chunkPGTBKPWNjs.BatchInterceptor; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkAABH3XLQjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunk73NOP3T5js.IS_PATCHED_MODULE; exports.Interceptor = _chunkAABH3XLQjs.Interceptor; exports.InterceptorReadyState = _chunkAABH3XLQjs.InterceptorReadyState; exports.createRequestId = _chunkAABH3XLQjs.createRequestId; exports.decodeBuffer = _chunkLK6DILFKjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkAABH3XLQjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkLK6DILFKjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkAABH3XLQjs.getGlobalSymbol; exports.isResponseWithoutBody = _chunkAABH3XLQjs.isResponseWithoutBody;
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-436630be.js';
|
|
2
2
|
import net from 'node:net';
|
|
3
3
|
import '@open-draft/deferred-promise';
|
|
4
4
|
import '@open-draft/logger';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { H as HttpRequestEventMap,
|
|
2
|
+
import { H as HttpRequestEventMap, h as Interceptor } from '../../Interceptor-436630be.js';
|
|
3
3
|
import '@open-draft/deferred-promise';
|
|
4
4
|
import '@open-draft/logger';
|
|
5
5
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkX2CFRRWYjs = require('../../chunk-X2CFRRWY.js');
|
|
4
4
|
require('../../chunk-LK6DILFK.js');
|
|
5
5
|
require('../../chunk-PFGO5BSM.js');
|
|
6
|
-
require('../../chunk-
|
|
6
|
+
require('../../chunk-73NOP3T5.js');
|
|
7
7
|
require('../../chunk-VCUEA4PL.js');
|
|
8
8
|
require('../../chunk-AABH3XLQ.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.XMLHttpRequestInterceptor =
|
|
11
|
+
exports.XMLHttpRequestInterceptor = _chunkX2CFRRWYjs.XMLHttpRequestInterceptor;
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-EBDS6VMR.mjs";
|
|
4
4
|
import "../../chunk-6HYIRFX2.mjs";
|
|
5
5
|
import "../../chunk-TX5GBTFY.mjs";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-6YM4PLBI.mjs";
|
|
7
7
|
import "../../chunk-M4WQE4TR.mjs";
|
|
8
8
|
import "../../chunk-FQQAJBI2.mjs";
|
|
9
9
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-436630be.js';
|
|
2
2
|
import '@open-draft/deferred-promise';
|
|
3
3
|
import '@open-draft/logger';
|
|
4
4
|
import 'strict-event-emitter';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk4YT2XSVOjs = require('../../chunk-4YT2XSVO.js');
|
|
4
4
|
require('../../chunk-PFGO5BSM.js');
|
|
5
|
-
require('../../chunk-
|
|
5
|
+
require('../../chunk-73NOP3T5.js');
|
|
6
6
|
require('../../chunk-VCUEA4PL.js');
|
|
7
7
|
require('../../chunk-AABH3XLQ.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
exports.FetchInterceptor =
|
|
10
|
+
exports.FetchInterceptor = _chunk4YT2XSVOjs.FetchInterceptor;
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FetchInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-6DIWEMO7.mjs";
|
|
4
4
|
import "../../chunk-TX5GBTFY.mjs";
|
|
5
|
-
import "../../chunk-
|
|
5
|
+
import "../../chunk-6YM4PLBI.mjs";
|
|
6
6
|
import "../../chunk-M4WQE4TR.mjs";
|
|
7
7
|
import "../../chunk-FQQAJBI2.mjs";
|
|
8
8
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientRequestInterceptor } from '../interceptors/ClientRequest/index.js';
|
|
2
2
|
import { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest/index.js';
|
|
3
3
|
import { FetchInterceptor } from '../interceptors/fetch/index.js';
|
|
4
|
-
import '../Interceptor-
|
|
4
|
+
import '../Interceptor-436630be.js';
|
|
5
5
|
import '@open-draft/deferred-promise';
|
|
6
6
|
import '@open-draft/logger';
|
|
7
7
|
import 'strict-event-emitter';
|
package/lib/node/presets/node.js
CHANGED
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
var _chunkFPLETXGAjs = require('../chunk-FPLETXGA.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkX2CFRRWYjs = require('../chunk-X2CFRRWY.js');
|
|
7
7
|
require('../chunk-LK6DILFK.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunk4YT2XSVOjs = require('../chunk-4YT2XSVO.js');
|
|
11
11
|
require('../chunk-PFGO5BSM.js');
|
|
12
|
-
require('../chunk-
|
|
12
|
+
require('../chunk-73NOP3T5.js');
|
|
13
13
|
require('../chunk-VCUEA4PL.js');
|
|
14
14
|
require('../chunk-AABH3XLQ.js');
|
|
15
15
|
|
|
16
16
|
// src/presets/node.ts
|
|
17
17
|
var node_default = [
|
|
18
18
|
new (0, _chunkFPLETXGAjs.ClientRequestInterceptor)(),
|
|
19
|
-
new (0,
|
|
20
|
-
new (0,
|
|
19
|
+
new (0, _chunkX2CFRRWYjs.XMLHttpRequestInterceptor)(),
|
|
20
|
+
new (0, _chunk4YT2XSVOjs.FetchInterceptor)()
|
|
21
21
|
];
|
|
22
22
|
|
|
23
23
|
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "../chunk-MG3S53QP.mjs";
|
|
4
4
|
import {
|
|
5
5
|
XMLHttpRequestInterceptor
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-EBDS6VMR.mjs";
|
|
7
7
|
import "../chunk-6HYIRFX2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
FetchInterceptor
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-6DIWEMO7.mjs";
|
|
11
11
|
import "../chunk-TX5GBTFY.mjs";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-6YM4PLBI.mjs";
|
|
13
13
|
import "../chunk-M4WQE4TR.mjs";
|
|
14
14
|
import "../chunk-FQQAJBI2.mjs";
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mswjs/interceptors",
|
|
3
3
|
"description": "Low-level HTTP/HTTPS/XHR/fetch request interception library.",
|
|
4
|
-
"version": "0.36.
|
|
4
|
+
"version": "0.36.9",
|
|
5
5
|
"main": "./lib/node/index.js",
|
|
6
6
|
"module": "./lib/node/index.mjs",
|
|
7
7
|
"types": "./lib/node/index.d.ts",
|
package/src/glossary.ts
CHANGED
|
@@ -2,6 +2,12 @@ import type { RequestController } from './RequestController'
|
|
|
2
2
|
|
|
3
3
|
export const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @note Export `RequestController` as a type only.
|
|
7
|
+
* It's never meant to be created in the userland.
|
|
8
|
+
*/
|
|
9
|
+
export type { RequestController }
|
|
10
|
+
|
|
5
11
|
export type RequestCredentials = 'omit' | 'include' | 'same-origin'
|
|
6
12
|
|
|
7
13
|
export type HttpRequestEventMap = {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/glossary.ts","../../src/utils/isPropertyAccessible.ts","../../src/utils/responseUtils.ts"],"names":[],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;;;ACMjE,SAAS,qBACd,KACA,KACA;AACA,MAAI;AACF,QAAI,GAAG;AACP,WAAO;AAAA,EACT,SAAQ,GAAN;AACA,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,qCAAqC,oBAAI,IAAI;AAAA,EACxD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAEM,IAAM,sCAAsC,oBAAI,IAAI;AAAA,EACzD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAMM,SAAS,sBAAsB,QAAyB;AAC7D,SAAO,mCAAmC,IAAI,MAAM;AACtD;AAKO,SAAS,0BAA0B,MAAyB;AACjE,SAAO,IAAI;AAAA,IACT,KAAK;AAAA,MACH,gBAAgB,QACZ;AAAA,QACE,MAAM,KAAK;AAAA,QACX,SAAS,KAAK;AAAA,QACd,OAAO,KAAK;AAAA,MACd,IACA;AAAA,IACN;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB,UAA+C;AAC7E,SAAO,qBAAqB,UAAU,MAAM,KAAK,SAAS,SAAS;AACrE","sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\nexport const RESPONSE_STATUS_CODES_WITHOUT_BODY = new Set([\n 101, 103, 204, 205, 304,\n])\n\nexport const RESPONSE_STATUS_CODES_WITH_REDIRECT = new Set([\n 301, 302, 303, 307, 308,\n])\n\n/**\n * Returns a boolean indicating whether the given response status\n * code represents a response that cannot have a body.\n */\nexport function isResponseWithoutBody(status: number): boolean {\n return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status)\n}\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: Response): response is ResponseError {\n return isPropertyAccessible(response, 'type') && response.type === 'error'\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/glossary.ts","../../src/utils/isPropertyAccessible.ts","../../src/utils/responseUtils.ts"],"sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n","/**\n * A function that validates if property access is possible on an object\n * without throwing. It returns `true` if the property access is possible\n * and `false` otherwise.\n *\n * Environments like miniflare will throw on property access on certain objects\n * like Request and Response, for unimplemented properties.\n */\nexport function isPropertyAccessible<Obj extends Record<string, any>>(\n obj: Obj,\n key: keyof Obj\n) {\n try {\n obj[key]\n return true\n } catch {\n return false\n }\n}\n","import { isPropertyAccessible } from './isPropertyAccessible'\n\n/**\n * Response status codes for responses that cannot have body.\n * @see https://fetch.spec.whatwg.org/#statuses\n */\nexport const RESPONSE_STATUS_CODES_WITHOUT_BODY = new Set([\n 101, 103, 204, 205, 304,\n])\n\nexport const RESPONSE_STATUS_CODES_WITH_REDIRECT = new Set([\n 301, 302, 303, 307, 308,\n])\n\n/**\n * Returns a boolean indicating whether the given response status\n * code represents a response that cannot have a body.\n */\nexport function isResponseWithoutBody(status: number): boolean {\n return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status)\n}\n\n/**\n * Creates a generic 500 Unhandled Exception response.\n */\nexport function createServerErrorResponse(body: unknown): Response {\n return new Response(\n JSON.stringify(\n body instanceof Error\n ? {\n name: body.name,\n message: body.message,\n stack: body.stack,\n }\n : body\n ),\n {\n status: 500,\n statusText: 'Unhandled Exception',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n}\n\nexport type ResponseError = Response & { type: 'error' }\n\n/**\n * Check if the given response is a `Response.error()`.\n *\n * @note Some environments, like Miniflare (Cloudflare) do not\n * implement the \"Response.type\" property and throw on its access.\n * Safely check if we can access \"type\" on \"Response\" before continuing.\n * @see https://github.com/mswjs/msw/issues/1834\n */\nexport function isResponseError(response: Response): response is ResponseError {\n return isPropertyAccessible(response, 'type') && response.type === 'error'\n}\n"],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;;;ACMjE,SAAS,qBACd,KACA,KACA;AACA,MAAI;AACF,QAAI,GAAG;AACP,WAAO;AAAA,EACT,SAAQ,GAAN;AACA,WAAO;AAAA,EACT;AACF;;;ACZO,IAAM,qCAAqC,oBAAI,IAAI;AAAA,EACxD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAEM,IAAM,sCAAsC,oBAAI,IAAI;AAAA,EACzD;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AAAA,EAAK;AACtB,CAAC;AAMM,SAAS,sBAAsB,QAAyB;AAC7D,SAAO,mCAAmC,IAAI,MAAM;AACtD;AAKO,SAAS,0BAA0B,MAAyB;AACjE,SAAO,IAAI;AAAA,IACT,KAAK;AAAA,MACH,gBAAgB,QACZ;AAAA,QACE,MAAM,KAAK;AAAA,QACX,SAAS,KAAK;AAAA,QACd,OAAO,KAAK;AAAA,MACd,IACA;AAAA,IACN;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB,UAA+C;AAC7E,SAAO,qBAAqB,UAAU,MAAM,KAAK,SAAS,SAAS;AACrE;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/glossary.ts"],"sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n"],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/glossary.ts"],"names":[],"mappings":";AAEO,IAAM,oBAAmC,OAAO,iBAAiB","sourcesContent":["import type { RequestController } from './RequestController'\n\nexport const IS_PATCHED_MODULE: unique symbol = Symbol('isPatchedModule')\n\nexport type RequestCredentials = 'omit' | 'include' | 'same-origin'\n\nexport type HttpRequestEventMap = {\n request: [\n args: {\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n response: [\n args: {\n response: Response\n isMockedResponse: boolean\n request: Request\n requestId: string\n }\n ]\n unhandledException: [\n args: {\n error: unknown\n request: Request\n requestId: string\n controller: RequestController\n }\n ]\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|