@mswjs/interceptors 0.22.3 → 0.22.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/lib/browser/{Interceptor-959f650e.d.ts → Interceptor-c794917d.d.ts} +2 -2
- package/lib/browser/{chunk-IIY3SHU3.js → chunk-2EIH6L6D.js} +25 -25
- package/lib/browser/{chunk-BQYA7ER5.mjs → chunk-2GVXYEMC.mjs} +5 -5
- package/lib/browser/chunk-2Z7B3HL5.js +106 -0
- package/lib/browser/{chunk-5B525MKF.mjs → chunk-65HGG3CV.mjs} +1 -1
- package/lib/browser/chunk-CNZUUPXM.mjs +682 -0
- package/lib/browser/chunk-GL6Y4E24.mjs +106 -0
- package/lib/browser/chunk-KDXWM46S.js +682 -0
- package/lib/browser/{chunk-QWL3EOEY.js → chunk-OK5YCL7L.js} +7 -7
- package/lib/browser/{chunk-ZJOF5MEZ.js → chunk-PCFJD76X.js} +11 -11
- package/lib/browser/{chunk-STA6QBYM.mjs → chunk-RT3ATOJH.mjs} +11 -11
- package/lib/browser/index.d.ts +6 -6
- package/lib/browser/index.js +4 -4
- package/lib/browser/index.mjs +2 -2
- package/lib/browser/interceptors/XMLHttpRequest/index.d.ts +3 -3
- package/lib/browser/interceptors/XMLHttpRequest/index.js +5 -649
- package/lib/browser/interceptors/XMLHttpRequest/index.mjs +5 -649
- package/lib/browser/interceptors/fetch/index.d.ts +2 -2
- package/lib/browser/interceptors/fetch/index.js +4 -90
- package/lib/browser/interceptors/fetch/index.mjs +4 -90
- package/lib/browser/presets/browser.d.ts +13 -0
- package/lib/browser/presets/browser.js +18 -0
- package/lib/browser/presets/browser.mjs +18 -0
- package/lib/node/{BatchInterceptor-a7261b26.d.ts → BatchInterceptor-5c1e5de3.d.ts} +5 -5
- package/lib/node/{Interceptor-997045eb.d.ts → Interceptor-b3a4098c.d.ts} +2 -2
- package/lib/node/RemoteHttpInterceptor.d.ts +3 -3
- package/lib/node/RemoteHttpInterceptor.js +9 -9
- package/lib/node/RemoteHttpInterceptor.mjs +5 -5
- package/lib/node/{chunk-FGPCRIW6.mjs → chunk-53LM4S3X.mjs} +59 -62
- package/lib/node/{chunk-WWHITCCI.js → chunk-62KFIM4W.js} +9 -8
- package/lib/node/{chunk-37CATPNG.mjs → chunk-6CRMKMDL.mjs} +6 -5
- package/lib/node/{chunk-XLZJAPVS.js → chunk-D7MOETL2.js} +59 -62
- package/lib/node/{chunk-CYWTKHFI.mjs → chunk-HGKO2BOA.mjs} +58 -30
- package/lib/node/{chunk-GGD5JOGB.js → chunk-HTLVOEKP.js} +62 -34
- package/lib/node/{chunk-KZEQH4YW.mjs → chunk-IC6Y7RGW.mjs} +1 -1
- package/lib/node/{chunk-SNNL2EXF.js → chunk-MUUQLKVJ.js} +3 -3
- package/lib/node/{chunk-G6ZTHYZQ.mjs → chunk-RFVEKRYP.mjs} +1 -1
- package/lib/node/{chunk-Q56TMOP5.js → chunk-SFLY7F52.js} +2 -2
- package/lib/node/index.d.ts +3 -3
- package/lib/node/index.js +4 -4
- package/lib/node/index.mjs +3 -3
- package/lib/node/interceptors/ClientRequest/index.d.ts +3 -3
- package/lib/node/interceptors/ClientRequest/index.js +3 -3
- package/lib/node/interceptors/ClientRequest/index.mjs +2 -2
- package/lib/node/interceptors/XMLHttpRequest/index.d.ts +3 -3
- package/lib/node/interceptors/XMLHttpRequest/index.js +4 -4
- package/lib/node/interceptors/XMLHttpRequest/index.mjs +3 -3
- package/lib/node/interceptors/fetch/index.d.ts +2 -2
- package/lib/node/interceptors/fetch/index.js +22 -11
- package/lib/node/interceptors/fetch/index.mjs +21 -10
- package/lib/node/presets/node.d.ts +15 -0
- package/lib/node/presets/node.js +19 -0
- package/lib/node/presets/node.mjs +19 -0
- package/package.json +17 -2
- package/src/BatchInterceptor.ts +5 -5
- package/src/Interceptor.ts +2 -2
- package/src/interceptors/ClientRequest/NodeClientRequest.test.ts +1 -1
- package/src/interceptors/ClientRequest/http.request.ts +1 -1
- package/src/interceptors/ClientRequest/index.ts +2 -2
- package/src/interceptors/ClientRequest/utils/createRequest.test.ts +1 -1
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts +1 -1
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts +1 -1
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.ts +5 -3
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.ts +1 -1
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +30 -29
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts +20 -2
- package/src/interceptors/XMLHttpRequest/index.ts +2 -2
- package/src/interceptors/XMLHttpRequest/utils/createResponse.ts +1 -1
- package/src/interceptors/fetch/index.ts +22 -9
- package/src/presets/browser.ts +4 -1
- package/src/presets/node.ts +4 -1
- package/src/utils/AsyncEventEmitter.ts +1 -1
- package/src/utils/cloneObject.ts +8 -6
- package/src/utils/createProxy.test.ts +149 -0
- package/src/utils/createProxy.ts +27 -6
- package/src/utils/debug.ts +4 -0
- package/src/utils/getUrlByRequestOptions.ts +13 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
3
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
4
|
};
|
|
@@ -6,11 +6,7 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
6
6
|
// src/glossary.ts
|
|
7
7
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
8
8
|
|
|
9
|
-
// src/Interceptor.ts
|
|
10
|
-
var _debug = require('debug');
|
|
11
|
-
|
|
12
9
|
// src/utils/AsyncEventEmitter.ts
|
|
13
|
-
|
|
14
10
|
var _stricteventemitter = require('strict-event-emitter');
|
|
15
11
|
|
|
16
12
|
// src/utils/nextTick.ts
|
|
@@ -18,11 +14,15 @@ function nextTick(callback) {
|
|
|
18
14
|
setTimeout(callback, 0);
|
|
19
15
|
}
|
|
20
16
|
|
|
17
|
+
// src/utils/debug.ts
|
|
18
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
19
|
+
var debug = _debug2.default;
|
|
20
|
+
|
|
21
21
|
// src/utils/AsyncEventEmitter.ts
|
|
22
22
|
var AsyncEventEmitter = class extends _stricteventemitter.Emitter {
|
|
23
23
|
constructor() {
|
|
24
24
|
super();
|
|
25
|
-
this.log =
|
|
25
|
+
this.log = debug("async-event-emitter");
|
|
26
26
|
this.queue = /* @__PURE__ */ new Map();
|
|
27
27
|
this.readyState = "ACTIVE" /* ACTIVE */;
|
|
28
28
|
}
|
|
@@ -148,7 +148,7 @@ var Interceptor = class {
|
|
|
148
148
|
this.readyState = "INACTIVE" /* INACTIVE */;
|
|
149
149
|
this.emitter = new AsyncEventEmitter();
|
|
150
150
|
this.subscriptions = [];
|
|
151
|
-
this.log =
|
|
151
|
+
this.log = debug(symbol.description);
|
|
152
152
|
this.emitter.setMaxListeners(0);
|
|
153
153
|
this.log("constructing the interceptor...");
|
|
154
154
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/utils/uuid.ts
|
|
2
|
+
function uuidv4() {
|
|
3
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
4
|
+
const r = Math.random() * 16 | 0;
|
|
5
|
+
const v = c == "x" ? r : r & 3 | 8;
|
|
6
|
+
return v.toString(16);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// src/utils/toInteractiveRequest.ts
|
|
2
11
|
var _outvariant = require('outvariant');
|
|
3
12
|
|
|
4
13
|
// src/utils/createLazyCallback.ts
|
|
@@ -49,16 +58,7 @@ function toInteractiveRequest(request) {
|
|
|
49
58
|
return request;
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
// src/utils/uuid.ts
|
|
53
|
-
function uuidv4() {
|
|
54
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
55
|
-
const r = Math.random() * 16 | 0;
|
|
56
|
-
const v = c == "x" ? r : r & 3 | 8;
|
|
57
|
-
return v.toString(16);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
exports.
|
|
64
|
+
exports.uuidv4 = uuidv4; exports.toInteractiveRequest = toInteractiveRequest;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// src/utils/uuid.ts
|
|
2
|
+
function uuidv4() {
|
|
3
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
4
|
+
const r = Math.random() * 16 | 0;
|
|
5
|
+
const v = c == "x" ? r : r & 3 | 8;
|
|
6
|
+
return v.toString(16);
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
// src/utils/toInteractiveRequest.ts
|
|
2
11
|
import { format } from "outvariant";
|
|
3
12
|
|
|
@@ -49,16 +58,7 @@ function toInteractiveRequest(request) {
|
|
|
49
58
|
return request;
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
// src/utils/uuid.ts
|
|
53
|
-
function uuidv4() {
|
|
54
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
55
|
-
const r = Math.random() * 16 | 0;
|
|
56
|
-
const v = c == "x" ? r : r & 3 | 8;
|
|
57
|
-
return v.toString(16);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
61
|
export {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
uuidv4,
|
|
63
|
+
toInteractiveRequest
|
|
64
64
|
};
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { I as Interceptor, E as ExtractEventNames } from './Interceptor-
|
|
2
|
-
export { E as ExtractEventNames, H as HttpRequestEventMap, a as IS_PATCHED_MODULE, I as Interceptor, b as InterceptorEventMap, e as InterceptorReadyState, c as InterceptorSubscription, R as RequestCredentials, d as deleteGlobalSymbol, g as getGlobalSymbol } from './Interceptor-
|
|
1
|
+
import { I as Interceptor, E as ExtractEventNames } from './Interceptor-c794917d.js';
|
|
2
|
+
export { E as ExtractEventNames, H as HttpRequestEventMap, a as IS_PATCHED_MODULE, I as Interceptor, b as InterceptorEventMap, e as InterceptorReadyState, c as InterceptorSubscription, R as RequestCredentials, d as deleteGlobalSymbol, g as getGlobalSymbol } from './Interceptor-c794917d.js';
|
|
3
3
|
import { EventMap, Listener } from 'strict-event-emitter';
|
|
4
4
|
import 'debug';
|
|
5
5
|
|
|
6
|
-
interface BatchInterceptorOptions<InterceptorList extends
|
|
6
|
+
interface BatchInterceptorOptions<InterceptorList extends ReadonlyArray<Interceptor<any>>> {
|
|
7
7
|
name: string;
|
|
8
8
|
interceptors: InterceptorList;
|
|
9
9
|
}
|
|
10
|
-
type ExtractEventMapType<InterceptorList extends
|
|
10
|
+
type ExtractEventMapType<InterceptorList extends ReadonlyArray<Interceptor<any>>> = InterceptorList extends ReadonlyArray<infer InterceptorType> ? InterceptorType extends Interceptor<infer EventMap> ? EventMap : never : never;
|
|
11
11
|
/**
|
|
12
12
|
* A batch interceptor that exposes a single interface
|
|
13
13
|
* to apply and operate with multiple interceptors at once.
|
|
14
14
|
*/
|
|
15
|
-
declare class BatchInterceptor<InterceptorList extends
|
|
16
|
-
static symbol:
|
|
15
|
+
declare class BatchInterceptor<InterceptorList extends ReadonlyArray<Interceptor<any>>, Events extends EventMap = ExtractEventMapType<InterceptorList>> extends Interceptor<Events> {
|
|
16
|
+
static symbol: symbol;
|
|
17
17
|
private interceptors;
|
|
18
18
|
constructor(options: BatchInterceptorOptions<InterceptorList>);
|
|
19
19
|
protected setup(): void;
|
package/lib/browser/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk2EIH6L6Djs = require('./chunk-2EIH6L6D.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkOK5YCL7Ljs = require('./chunk-OK5YCL7L.js');
|
|
12
12
|
|
|
13
13
|
// src/BatchInterceptor.ts
|
|
14
|
-
var BatchInterceptor = class extends
|
|
14
|
+
var BatchInterceptor = class extends _chunkOK5YCL7Ljs.Interceptor {
|
|
15
15
|
constructor(options) {
|
|
16
16
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
17
17
|
super(BatchInterceptor.symbol);
|
|
@@ -48,4 +48,4 @@ function getCleanUrl(url, isAbsolute = true) {
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
exports.BatchInterceptor = BatchInterceptor; exports.IS_PATCHED_MODULE =
|
|
51
|
+
exports.BatchInterceptor = BatchInterceptor; exports.IS_PATCHED_MODULE = _chunkOK5YCL7Ljs.IS_PATCHED_MODULE; exports.Interceptor = _chunkOK5YCL7Ljs.Interceptor; exports.InterceptorReadyState = _chunkOK5YCL7Ljs.InterceptorReadyState; exports.decodeBuffer = _chunk2EIH6L6Djs.decodeBuffer; exports.deleteGlobalSymbol = _chunkOK5YCL7Ljs.deleteGlobalSymbol; exports.encodeBuffer = _chunk2EIH6L6Djs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkOK5YCL7Ljs.getGlobalSymbol;
|
package/lib/browser/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decodeBuffer,
|
|
3
3
|
encodeBuffer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-65HGG3CV.mjs";
|
|
5
5
|
import {
|
|
6
6
|
IS_PATCHED_MODULE,
|
|
7
7
|
Interceptor,
|
|
8
8
|
InterceptorReadyState,
|
|
9
9
|
deleteGlobalSymbol,
|
|
10
10
|
getGlobalSymbol
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2GVXYEMC.mjs";
|
|
12
12
|
|
|
13
13
|
// src/BatchInterceptor.ts
|
|
14
14
|
var BatchInterceptor = class extends Interceptor {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { f as InteractiveRequest, A as AsyncEventEmitter, H as HttpRequestEventMap, I as Interceptor } from '../../Interceptor-
|
|
2
|
-
import 'debug';
|
|
1
|
+
import { f as InteractiveRequest, A as AsyncEventEmitter, H as HttpRequestEventMap, I as Interceptor } from '../../Interceptor-c794917d.js';
|
|
3
2
|
import 'strict-event-emitter';
|
|
3
|
+
import 'debug';
|
|
4
4
|
|
|
5
5
|
type XMLHttpRequestEventListener = (request: InteractiveRequest, requestId: string) => Promise<void> | void;
|
|
6
6
|
type XMLHttpRequestEmitter = AsyncEventEmitter<HttpRequestEventMap>;
|
|
7
7
|
declare class XMLHttpRequestInterceptor extends Interceptor<HttpRequestEventMap> {
|
|
8
|
-
static
|
|
8
|
+
static interceptorSymbol: symbol;
|
|
9
9
|
constructor();
|
|
10
10
|
protected checkEnvironment(): boolean;
|
|
11
11
|
protected setup(): void;
|