@mswjs/interceptors 0.25.7 → 0.25.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-KITNLK66.js → chunk-ECJJD4T6.js} +5 -5
- package/lib/browser/{chunk-CWVY2E3W.js → chunk-G5ORGOKH.js} +1 -1
- package/lib/browser/{chunk-AN3YI76R.mjs → chunk-NJQK65MD.mjs} +5 -7
- package/lib/browser/{chunk-QPMXOLDO.mjs → chunk-S72SKXXQ.mjs} +1 -1
- package/lib/browser/{chunk-HXJPKJY3.mjs → chunk-XIF5PZER.mjs} +1 -1
- package/lib/browser/{chunk-FFBQOFWV.js → chunk-Y4VZR7HZ.js} +9 -11
- package/lib/browser/index.js +3 -3
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/interceptors/XMLHttpRequest/index.js +3 -3
- package/lib/browser/interceptors/XMLHttpRequest/index.mjs +2 -2
- package/lib/browser/interceptors/fetch/index.js +3 -3
- package/lib/browser/interceptors/fetch/index.mjs +2 -2
- package/lib/browser/presets/browser.js +5 -5
- package/lib/browser/presets/browser.mjs +3 -3
- package/lib/node/RemoteHttpInterceptor.js +8 -8
- package/lib/node/RemoteHttpInterceptor.mjs +4 -4
- package/lib/node/{chunk-UF7QIAQ5.js → chunk-AA4NWHDY.js} +2 -2
- package/lib/node/{chunk-YVNH3GJ5.js → chunk-FWLJEVDW.js} +2 -2
- package/lib/node/{chunk-JCWVLTP7.js → chunk-HNNMWWZ6.js} +6 -8
- package/lib/node/{chunk-GM3YBSM3.mjs → chunk-JAW6F2FR.mjs} +1 -1
- package/lib/node/{chunk-FB53TMYN.mjs → chunk-JX6GSWVV.mjs} +5 -7
- package/lib/node/{chunk-UBEFEZXT.mjs → chunk-LNYHQTKT.mjs} +1 -1
- package/lib/node/{chunk-G5IEXC7T.mjs → chunk-P4CPJLJS.mjs} +1 -1
- package/lib/node/{chunk-3XFLRXRY.js → chunk-UZM2Y7WJ.js} +1 -1
- package/lib/node/index.js +3 -3
- package/lib/node/index.mjs +2 -2
- package/lib/node/interceptors/ClientRequest/index.js +3 -3
- package/lib/node/interceptors/ClientRequest/index.mjs +2 -2
- package/lib/node/interceptors/XMLHttpRequest/index.js +3 -3
- package/lib/node/interceptors/XMLHttpRequest/index.mjs +2 -2
- package/lib/node/interceptors/fetch/index.js +2 -2
- package/lib/node/interceptors/fetch/index.mjs +1 -1
- package/lib/node/presets/node.js +5 -5
- package/lib/node/presets/node.mjs +3 -3
- package/package.json +3 -2
- package/src/Interceptor.ts +1 -1
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +2 -2
- package/src/utils/createProxy.ts +4 -4
|
@@ -6,13 +6,13 @@ var _chunkX3NRJIZWjs = require('./chunk-X3NRJIZW.js');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkG5ORGOKHjs = require('./chunk-G5ORGOKH.js');
|
|
10
10
|
|
|
11
11
|
// src/interceptors/fetch/index.ts
|
|
12
12
|
var _outvariant = require('outvariant');
|
|
13
13
|
var _deferredpromise = require('@open-draft/deferred-promise');
|
|
14
14
|
var _until = require('@open-draft/until');
|
|
15
|
-
var _FetchInterceptor = class extends
|
|
15
|
+
var _FetchInterceptor = class extends _chunkG5ORGOKHjs.Interceptor {
|
|
16
16
|
constructor() {
|
|
17
17
|
super(_FetchInterceptor.symbol);
|
|
18
18
|
}
|
|
@@ -22,7 +22,7 @@ var _FetchInterceptor = class extends _chunkCWVY2E3Wjs.Interceptor {
|
|
|
22
22
|
setup() {
|
|
23
23
|
const pureFetch = globalThis.fetch;
|
|
24
24
|
_outvariant.invariant.call(void 0,
|
|
25
|
-
!pureFetch[
|
|
25
|
+
!pureFetch[_chunkG5ORGOKHjs.IS_PATCHED_MODULE],
|
|
26
26
|
'Failed to patch the "fetch" module: already patched.'
|
|
27
27
|
);
|
|
28
28
|
globalThis.fetch = async (input, init) => {
|
|
@@ -115,13 +115,13 @@ var _FetchInterceptor = class extends _chunkCWVY2E3Wjs.Interceptor {
|
|
|
115
115
|
return response;
|
|
116
116
|
});
|
|
117
117
|
};
|
|
118
|
-
Object.defineProperty(globalThis.fetch,
|
|
118
|
+
Object.defineProperty(globalThis.fetch, _chunkG5ORGOKHjs.IS_PATCHED_MODULE, {
|
|
119
119
|
enumerable: true,
|
|
120
120
|
configurable: true,
|
|
121
121
|
value: true
|
|
122
122
|
});
|
|
123
123
|
this.subscriptions.push(() => {
|
|
124
|
-
Object.defineProperty(globalThis.fetch,
|
|
124
|
+
Object.defineProperty(globalThis.fetch, _chunkG5ORGOKHjs.IS_PATCHED_MODULE, {
|
|
125
125
|
value: void 0
|
|
126
126
|
});
|
|
127
127
|
globalThis.fetch = pureFetch;
|
|
@@ -94,7 +94,7 @@ var Interceptor = class {
|
|
|
94
94
|
logger.info("cannot listen to events, already disposed!");
|
|
95
95
|
return this;
|
|
96
96
|
}
|
|
97
|
-
logger.info('adding "%s" event listener:', event, listener
|
|
97
|
+
logger.info('adding "%s" event listener:', event, listener);
|
|
98
98
|
this.emitter.on(event, listener);
|
|
99
99
|
return this;
|
|
100
100
|
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
IS_PATCHED_MODULE,
|
|
13
13
|
Interceptor
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-S72SKXXQ.mjs";
|
|
15
15
|
|
|
16
16
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
17
17
|
import { invariant as invariant2 } from "outvariant";
|
|
@@ -136,11 +136,9 @@ function optionsToProxyHandler(options) {
|
|
|
136
136
|
return constructorCall.call(newTarget, args, next);
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
handler.set = function(target, propertyName, nextValue
|
|
139
|
+
handler.set = function(target, propertyName, nextValue) {
|
|
140
140
|
const next = () => {
|
|
141
|
-
const propertySource = findPropertySource(target, propertyName);
|
|
142
|
-
if (propertySource === null)
|
|
143
|
-
return false;
|
|
141
|
+
const propertySource = findPropertySource(target, propertyName) || target;
|
|
144
142
|
const ownDescriptors = Reflect.getOwnPropertyDescriptor(
|
|
145
143
|
propertySource,
|
|
146
144
|
propertyName
|
|
@@ -279,7 +277,7 @@ var XMLHttpRequestController = class {
|
|
|
279
277
|
case "addEventListener": {
|
|
280
278
|
const [eventName, listener] = args;
|
|
281
279
|
this.registerEvent(eventName, listener);
|
|
282
|
-
this.logger.info("addEventListener", eventName, listener
|
|
280
|
+
this.logger.info("addEventListener", eventName, listener);
|
|
283
281
|
return invoke();
|
|
284
282
|
}
|
|
285
283
|
case "setRequestHeader": {
|
|
@@ -342,7 +340,7 @@ var XMLHttpRequestController = class {
|
|
|
342
340
|
const prevEvents = this.events.get(eventName) || [];
|
|
343
341
|
const nextEvents = prevEvents.concat(listener);
|
|
344
342
|
this.events.set(eventName, nextEvents);
|
|
345
|
-
this.logger.info('registered event "%s"', eventName, listener
|
|
343
|
+
this.logger.info('registered event "%s"', eventName, listener);
|
|
346
344
|
}
|
|
347
345
|
/**
|
|
348
346
|
* Responds to the current request with the given
|
|
@@ -94,7 +94,7 @@ var Interceptor = class {
|
|
|
94
94
|
logger.info("cannot listen to events, already disposed!");
|
|
95
95
|
return this;
|
|
96
96
|
}
|
|
97
|
-
logger.info('adding "%s" event listener:', event, listener
|
|
97
|
+
logger.info('adding "%s" event listener:', event, listener);
|
|
98
98
|
this.emitter.on(event, listener);
|
|
99
99
|
return this;
|
|
100
100
|
}
|
|
@@ -11,7 +11,7 @@ var _chunkX3NRJIZWjs = require('./chunk-X3NRJIZW.js');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkG5ORGOKHjs = require('./chunk-G5ORGOKH.js');
|
|
15
15
|
|
|
16
16
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
17
17
|
var _outvariant = require('outvariant');
|
|
@@ -136,11 +136,9 @@ function optionsToProxyHandler(options) {
|
|
|
136
136
|
return constructorCall.call(newTarget, args, next);
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
handler.set = function(target, propertyName, nextValue
|
|
139
|
+
handler.set = function(target, propertyName, nextValue) {
|
|
140
140
|
const next = () => {
|
|
141
|
-
const propertySource = findPropertySource(target, propertyName);
|
|
142
|
-
if (propertySource === null)
|
|
143
|
-
return false;
|
|
141
|
+
const propertySource = findPropertySource(target, propertyName) || target;
|
|
144
142
|
const ownDescriptors = Reflect.getOwnPropertyDescriptor(
|
|
145
143
|
propertySource,
|
|
146
144
|
propertyName
|
|
@@ -279,7 +277,7 @@ var XMLHttpRequestController = class {
|
|
|
279
277
|
case "addEventListener": {
|
|
280
278
|
const [eventName, listener] = args;
|
|
281
279
|
this.registerEvent(eventName, listener);
|
|
282
|
-
this.logger.info("addEventListener", eventName, listener
|
|
280
|
+
this.logger.info("addEventListener", eventName, listener);
|
|
283
281
|
return invoke();
|
|
284
282
|
}
|
|
285
283
|
case "setRequestHeader": {
|
|
@@ -342,7 +340,7 @@ var XMLHttpRequestController = class {
|
|
|
342
340
|
const prevEvents = this.events.get(eventName) || [];
|
|
343
341
|
const nextEvents = prevEvents.concat(listener);
|
|
344
342
|
this.events.set(eventName, nextEvents);
|
|
345
|
-
this.logger.info('registered event "%s"', eventName, listener
|
|
343
|
+
this.logger.info('registered event "%s"', eventName, listener);
|
|
346
344
|
}
|
|
347
345
|
/**
|
|
348
346
|
* Responds to the current request with the given
|
|
@@ -738,7 +736,7 @@ function createXMLHttpRequestProxy({
|
|
|
738
736
|
}
|
|
739
737
|
|
|
740
738
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
741
|
-
var _XMLHttpRequestInterceptor = class extends
|
|
739
|
+
var _XMLHttpRequestInterceptor = class extends _chunkG5ORGOKHjs.Interceptor {
|
|
742
740
|
constructor() {
|
|
743
741
|
super(_XMLHttpRequestInterceptor.interceptorSymbol);
|
|
744
742
|
}
|
|
@@ -750,7 +748,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkCWVY2E3Wjs.Interceptor {
|
|
|
750
748
|
logger.info('patching "XMLHttpRequest" module...');
|
|
751
749
|
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
|
|
752
750
|
_outvariant.invariant.call(void 0,
|
|
753
|
-
!PureXMLHttpRequest[
|
|
751
|
+
!PureXMLHttpRequest[_chunkG5ORGOKHjs.IS_PATCHED_MODULE],
|
|
754
752
|
'Failed to patch the "XMLHttpRequest" module: already patched.'
|
|
755
753
|
);
|
|
756
754
|
globalThis.XMLHttpRequest = createXMLHttpRequestProxy({
|
|
@@ -761,13 +759,13 @@ var _XMLHttpRequestInterceptor = class extends _chunkCWVY2E3Wjs.Interceptor {
|
|
|
761
759
|
'native "XMLHttpRequest" module patched!',
|
|
762
760
|
globalThis.XMLHttpRequest.name
|
|
763
761
|
);
|
|
764
|
-
Object.defineProperty(globalThis.XMLHttpRequest,
|
|
762
|
+
Object.defineProperty(globalThis.XMLHttpRequest, _chunkG5ORGOKHjs.IS_PATCHED_MODULE, {
|
|
765
763
|
enumerable: true,
|
|
766
764
|
configurable: true,
|
|
767
765
|
value: true
|
|
768
766
|
});
|
|
769
767
|
this.subscriptions.push(() => {
|
|
770
|
-
Object.defineProperty(globalThis.XMLHttpRequest,
|
|
768
|
+
Object.defineProperty(globalThis.XMLHttpRequest, _chunkG5ORGOKHjs.IS_PATCHED_MODULE, {
|
|
771
769
|
value: void 0
|
|
772
770
|
});
|
|
773
771
|
globalThis.XMLHttpRequest = PureXMLHttpRequest;
|
package/lib/browser/index.js
CHANGED
|
@@ -8,10 +8,10 @@ var _chunk3LFH2WCFjs = require('./chunk-3LFH2WCF.js');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkG5ORGOKHjs = require('./chunk-G5ORGOKH.js');
|
|
12
12
|
|
|
13
13
|
// src/BatchInterceptor.ts
|
|
14
|
-
var BatchInterceptor = class extends
|
|
14
|
+
var BatchInterceptor = class extends _chunkG5ORGOKHjs.Interceptor {
|
|
15
15
|
constructor(options) {
|
|
16
16
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
17
17
|
super(BatchInterceptor.symbol);
|
|
@@ -67,4 +67,4 @@ function getCleanUrl(url, isAbsolute = true) {
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
exports.BatchInterceptor = BatchInterceptor; exports.IS_PATCHED_MODULE =
|
|
70
|
+
exports.BatchInterceptor = BatchInterceptor; exports.IS_PATCHED_MODULE = _chunkG5ORGOKHjs.IS_PATCHED_MODULE; exports.Interceptor = _chunkG5ORGOKHjs.Interceptor; exports.InterceptorReadyState = _chunkG5ORGOKHjs.InterceptorReadyState; exports.decodeBuffer = _chunk3LFH2WCFjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkG5ORGOKHjs.deleteGlobalSymbol; exports.encodeBuffer = _chunk3LFH2WCFjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkG5ORGOKHjs.getGlobalSymbol;
|
package/lib/browser/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkY4VZR7HZjs = require('../../chunk-Y4VZR7HZ.js');
|
|
4
4
|
require('../../chunk-3LFH2WCF.js');
|
|
5
5
|
require('../../chunk-X3NRJIZW.js');
|
|
6
|
-
require('../../chunk-
|
|
6
|
+
require('../../chunk-G5ORGOKH.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports.XMLHttpRequestInterceptor =
|
|
9
|
+
exports.XMLHttpRequestInterceptor = _chunkY4VZR7HZjs.XMLHttpRequestInterceptor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-NJQK65MD.mjs";
|
|
4
4
|
import "../../chunk-7II4SWKS.mjs";
|
|
5
5
|
import "../../chunk-KK6APRON.mjs";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-S72SKXXQ.mjs";
|
|
7
7
|
export {
|
|
8
8
|
XMLHttpRequestInterceptor
|
|
9
9
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkECJJD4T6js = require('../../chunk-ECJJD4T6.js');
|
|
4
4
|
require('../../chunk-X3NRJIZW.js');
|
|
5
|
-
require('../../chunk-
|
|
5
|
+
require('../../chunk-G5ORGOKH.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.FetchInterceptor =
|
|
8
|
+
exports.FetchInterceptor = _chunkECJJD4T6js.FetchInterceptor;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkY4VZR7HZjs = require('../chunk-Y4VZR7HZ.js');
|
|
4
4
|
require('../chunk-3LFH2WCF.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkECJJD4T6js = require('../chunk-ECJJD4T6.js');
|
|
8
8
|
require('../chunk-X3NRJIZW.js');
|
|
9
|
-
require('../chunk-
|
|
9
|
+
require('../chunk-G5ORGOKH.js');
|
|
10
10
|
|
|
11
11
|
// src/presets/browser.ts
|
|
12
12
|
var browser_default = [
|
|
13
|
-
new (0,
|
|
14
|
-
new (0,
|
|
13
|
+
new (0, _chunkECJJD4T6js.FetchInterceptor)(),
|
|
14
|
+
new (0, _chunkY4VZR7HZjs.XMLHttpRequestInterceptor)()
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-NJQK65MD.mjs";
|
|
4
4
|
import "../chunk-7II4SWKS.mjs";
|
|
5
5
|
import {
|
|
6
6
|
FetchInterceptor
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-XIF5PZER.mjs";
|
|
8
8
|
import "../chunk-KK6APRON.mjs";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-S72SKXXQ.mjs";
|
|
10
10
|
|
|
11
11
|
// src/presets/browser.ts
|
|
12
12
|
var browser_default = [
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkAA4NWHDYjs = require('./chunk-AA4NWHDY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkFWLJEVDWjs = require('./chunk-FWLJEVDW.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkHNNMWWZ6js = require('./chunk-HNNMWWZ6.js');
|
|
10
10
|
require('./chunk-3LFH2WCF.js');
|
|
11
11
|
require('./chunk-OGN3ZR35.js');
|
|
12
12
|
require('./chunk-VQ4DZOBB.js');
|
|
@@ -16,16 +16,16 @@ require('./chunk-VQ4DZOBB.js');
|
|
|
16
16
|
var _chunk5PTPJLB7js = require('./chunk-5PTPJLB7.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkUZM2Y7WJjs = require('./chunk-UZM2Y7WJ.js');
|
|
20
20
|
|
|
21
21
|
// src/RemoteHttpInterceptor.ts
|
|
22
|
-
var RemoteHttpInterceptor = class extends
|
|
22
|
+
var RemoteHttpInterceptor = class extends _chunkAA4NWHDYjs.BatchInterceptor {
|
|
23
23
|
constructor() {
|
|
24
24
|
super({
|
|
25
25
|
name: "remote-interceptor",
|
|
26
26
|
interceptors: [
|
|
27
|
-
new (0,
|
|
28
|
-
new (0,
|
|
27
|
+
new (0, _chunkFWLJEVDWjs.ClientRequestInterceptor)(),
|
|
28
|
+
new (0, _chunkHNNMWWZ6js.XMLHttpRequestInterceptor)()
|
|
29
29
|
]
|
|
30
30
|
});
|
|
31
31
|
}
|
|
@@ -92,7 +92,7 @@ function requestReviver(key, value) {
|
|
|
92
92
|
return value;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
var _RemoteHttpResolver = class extends
|
|
95
|
+
var _RemoteHttpResolver = class extends _chunkUZM2Y7WJjs.Interceptor {
|
|
96
96
|
constructor(options) {
|
|
97
97
|
super(_RemoteHttpResolver.symbol);
|
|
98
98
|
this.process = options.process;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchInterceptor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LNYHQTKT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ClientRequestInterceptor
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-P4CPJLJS.mjs";
|
|
7
7
|
import {
|
|
8
8
|
XMLHttpRequestInterceptor
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JX6GSWVV.mjs";
|
|
10
10
|
import "./chunk-7II4SWKS.mjs";
|
|
11
11
|
import "./chunk-3IYIKC3X.mjs";
|
|
12
12
|
import "./chunk-GFH37L5D.mjs";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-YQGTMMOZ.mjs";
|
|
17
17
|
import {
|
|
18
18
|
Interceptor
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JAW6F2FR.mjs";
|
|
20
20
|
|
|
21
21
|
// src/RemoteHttpInterceptor.ts
|
|
22
22
|
var RemoteHttpInterceptor = class extends BatchInterceptor {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkUZM2Y7WJjs = require('./chunk-UZM2Y7WJ.js');
|
|
4
4
|
|
|
5
5
|
// src/BatchInterceptor.ts
|
|
6
|
-
var BatchInterceptor = class extends
|
|
6
|
+
var BatchInterceptor = class extends _chunkUZM2Y7WJjs.Interceptor {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
9
9
|
super(BatchInterceptor.symbol);
|
|
@@ -8,7 +8,7 @@ var _chunkOGN3ZR35js = require('./chunk-OGN3ZR35.js');
|
|
|
8
8
|
var _chunk5PTPJLB7js = require('./chunk-5PTPJLB7.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkUZM2Y7WJjs = require('./chunk-UZM2Y7WJ.js');
|
|
12
12
|
|
|
13
13
|
// src/interceptors/ClientRequest/index.ts
|
|
14
14
|
var _http = require('http'); var _http2 = _interopRequireDefault(_http);
|
|
@@ -821,7 +821,7 @@ function request(protocol, options) {
|
|
|
821
821
|
}
|
|
822
822
|
|
|
823
823
|
// src/interceptors/ClientRequest/index.ts
|
|
824
|
-
var _ClientRequestInterceptor = class extends
|
|
824
|
+
var _ClientRequestInterceptor = class extends _chunkUZM2Y7WJjs.Interceptor {
|
|
825
825
|
constructor() {
|
|
826
826
|
super(_ClientRequestInterceptor.interceptorSymbol);
|
|
827
827
|
this.modules = /* @__PURE__ */ new Map();
|
|
@@ -16,7 +16,7 @@ var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
|
16
16
|
var _chunk5PTPJLB7js = require('./chunk-5PTPJLB7.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkUZM2Y7WJjs = require('./chunk-UZM2Y7WJ.js');
|
|
20
20
|
|
|
21
21
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
22
22
|
var _outvariant = require('outvariant');
|
|
@@ -141,11 +141,9 @@ function optionsToProxyHandler(options) {
|
|
|
141
141
|
return constructorCall.call(newTarget, args, next);
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
handler.set = function(target, propertyName, nextValue
|
|
144
|
+
handler.set = function(target, propertyName, nextValue) {
|
|
145
145
|
const next = () => {
|
|
146
|
-
const propertySource = findPropertySource(target, propertyName);
|
|
147
|
-
if (propertySource === null)
|
|
148
|
-
return false;
|
|
146
|
+
const propertySource = findPropertySource(target, propertyName) || target;
|
|
149
147
|
const ownDescriptors = Reflect.getOwnPropertyDescriptor(
|
|
150
148
|
propertySource,
|
|
151
149
|
propertyName
|
|
@@ -281,7 +279,7 @@ var XMLHttpRequestController = class {
|
|
|
281
279
|
case "addEventListener": {
|
|
282
280
|
const [eventName, listener] = args;
|
|
283
281
|
this.registerEvent(eventName, listener);
|
|
284
|
-
this.logger.info("addEventListener", eventName, listener
|
|
282
|
+
this.logger.info("addEventListener", eventName, listener);
|
|
285
283
|
return invoke();
|
|
286
284
|
}
|
|
287
285
|
case "setRequestHeader": {
|
|
@@ -344,7 +342,7 @@ var XMLHttpRequestController = class {
|
|
|
344
342
|
const prevEvents = this.events.get(eventName) || [];
|
|
345
343
|
const nextEvents = prevEvents.concat(listener);
|
|
346
344
|
this.events.set(eventName, nextEvents);
|
|
347
|
-
this.logger.info('registered event "%s"', eventName, listener
|
|
345
|
+
this.logger.info('registered event "%s"', eventName, listener);
|
|
348
346
|
}
|
|
349
347
|
/**
|
|
350
348
|
* Responds to the current request with the given
|
|
@@ -740,7 +738,7 @@ function createXMLHttpRequestProxy({
|
|
|
740
738
|
}
|
|
741
739
|
|
|
742
740
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
743
|
-
var _XMLHttpRequestInterceptor = class extends
|
|
741
|
+
var _XMLHttpRequestInterceptor = class extends _chunkUZM2Y7WJjs.Interceptor {
|
|
744
742
|
constructor() {
|
|
745
743
|
super(_XMLHttpRequestInterceptor.interceptorSymbol);
|
|
746
744
|
}
|
|
@@ -91,7 +91,7 @@ var Interceptor = class {
|
|
|
91
91
|
logger.info("cannot listen to events, already disposed!");
|
|
92
92
|
return this;
|
|
93
93
|
}
|
|
94
|
-
logger.info('adding "%s" event listener:', event, listener
|
|
94
|
+
logger.info('adding "%s" event listener:', event, listener);
|
|
95
95
|
this.emitter.on(event, listener);
|
|
96
96
|
return this;
|
|
97
97
|
}
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-YQGTMMOZ.mjs";
|
|
17
17
|
import {
|
|
18
18
|
Interceptor
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-JAW6F2FR.mjs";
|
|
20
20
|
|
|
21
21
|
// src/interceptors/XMLHttpRequest/index.ts
|
|
22
22
|
import { invariant as invariant2 } from "outvariant";
|
|
@@ -141,11 +141,9 @@ function optionsToProxyHandler(options) {
|
|
|
141
141
|
return constructorCall.call(newTarget, args, next);
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
-
handler.set = function(target, propertyName, nextValue
|
|
144
|
+
handler.set = function(target, propertyName, nextValue) {
|
|
145
145
|
const next = () => {
|
|
146
|
-
const propertySource = findPropertySource(target, propertyName);
|
|
147
|
-
if (propertySource === null)
|
|
148
|
-
return false;
|
|
146
|
+
const propertySource = findPropertySource(target, propertyName) || target;
|
|
149
147
|
const ownDescriptors = Reflect.getOwnPropertyDescriptor(
|
|
150
148
|
propertySource,
|
|
151
149
|
propertyName
|
|
@@ -281,7 +279,7 @@ var XMLHttpRequestController = class {
|
|
|
281
279
|
case "addEventListener": {
|
|
282
280
|
const [eventName, listener] = args;
|
|
283
281
|
this.registerEvent(eventName, listener);
|
|
284
|
-
this.logger.info("addEventListener", eventName, listener
|
|
282
|
+
this.logger.info("addEventListener", eventName, listener);
|
|
285
283
|
return invoke();
|
|
286
284
|
}
|
|
287
285
|
case "setRequestHeader": {
|
|
@@ -344,7 +342,7 @@ var XMLHttpRequestController = class {
|
|
|
344
342
|
const prevEvents = this.events.get(eventName) || [];
|
|
345
343
|
const nextEvents = prevEvents.concat(listener);
|
|
346
344
|
this.events.set(eventName, nextEvents);
|
|
347
|
-
this.logger.info('registered event "%s"', eventName, listener
|
|
345
|
+
this.logger.info('registered event "%s"', eventName, listener);
|
|
348
346
|
}
|
|
349
347
|
/**
|
|
350
348
|
* Responds to the current request with the given
|
|
@@ -91,7 +91,7 @@ var Interceptor = class {
|
|
|
91
91
|
logger.info("cannot listen to events, already disposed!");
|
|
92
92
|
return this;
|
|
93
93
|
}
|
|
94
|
-
logger.info('adding "%s" event listener:', event, listener
|
|
94
|
+
logger.info('adding "%s" event listener:', event, listener);
|
|
95
95
|
this.emitter.on(event, listener);
|
|
96
96
|
return this;
|
|
97
97
|
}
|
package/lib/node/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkAA4NWHDYjs = require('./chunk-AA4NWHDY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ var _chunkVQ4DZOBBjs = require('./chunk-VQ4DZOBB.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkUZM2Y7WJjs = require('./chunk-UZM2Y7WJ.js');
|
|
17
17
|
|
|
18
18
|
// src/utils/getCleanUrl.ts
|
|
19
19
|
function getCleanUrl(url, isAbsolute = true) {
|
|
@@ -29,4 +29,4 @@ function getCleanUrl(url, isAbsolute = true) {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
exports.BatchInterceptor =
|
|
32
|
+
exports.BatchInterceptor = _chunkAA4NWHDYjs.BatchInterceptor; exports.IS_PATCHED_MODULE = _chunkVQ4DZOBBjs.IS_PATCHED_MODULE; exports.Interceptor = _chunkUZM2Y7WJjs.Interceptor; exports.InterceptorReadyState = _chunkUZM2Y7WJjs.InterceptorReadyState; exports.decodeBuffer = _chunk3LFH2WCFjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkUZM2Y7WJjs.deleteGlobalSymbol; exports.encodeBuffer = _chunk3LFH2WCFjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkUZM2Y7WJjs.getGlobalSymbol;
|
package/lib/node/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchInterceptor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LNYHQTKT.mjs";
|
|
4
4
|
import {
|
|
5
5
|
decodeBuffer,
|
|
6
6
|
encodeBuffer
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
InterceptorReadyState,
|
|
14
14
|
deleteGlobalSymbol,
|
|
15
15
|
getGlobalSymbol
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JAW6F2FR.mjs";
|
|
17
17
|
|
|
18
18
|
// src/utils/getCleanUrl.ts
|
|
19
19
|
function getCleanUrl(url, isAbsolute = true) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkFWLJEVDWjs = require('../../chunk-FWLJEVDW.js');
|
|
4
4
|
require('../../chunk-OGN3ZR35.js');
|
|
5
5
|
require('../../chunk-5PTPJLB7.js');
|
|
6
|
-
require('../../chunk-
|
|
6
|
+
require('../../chunk-UZM2Y7WJ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports.ClientRequestInterceptor =
|
|
9
|
+
exports.ClientRequestInterceptor = _chunkFWLJEVDWjs.ClientRequestInterceptor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-P4CPJLJS.mjs";
|
|
4
4
|
import "../../chunk-3IYIKC3X.mjs";
|
|
5
5
|
import "../../chunk-YQGTMMOZ.mjs";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-JAW6F2FR.mjs";
|
|
7
7
|
export {
|
|
8
8
|
ClientRequestInterceptor
|
|
9
9
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHNNMWWZ6js = require('../../chunk-HNNMWWZ6.js');
|
|
4
4
|
require('../../chunk-3LFH2WCF.js');
|
|
5
5
|
require('../../chunk-OGN3ZR35.js');
|
|
6
6
|
require('../../chunk-VQ4DZOBB.js');
|
|
7
7
|
require('../../chunk-5PTPJLB7.js');
|
|
8
|
-
require('../../chunk-
|
|
8
|
+
require('../../chunk-UZM2Y7WJ.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.XMLHttpRequestInterceptor =
|
|
11
|
+
exports.XMLHttpRequestInterceptor = _chunkHNNMWWZ6js.XMLHttpRequestInterceptor;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-JX6GSWVV.mjs";
|
|
4
4
|
import "../../chunk-7II4SWKS.mjs";
|
|
5
5
|
import "../../chunk-3IYIKC3X.mjs";
|
|
6
6
|
import "../../chunk-GFH37L5D.mjs";
|
|
7
7
|
import "../../chunk-YQGTMMOZ.mjs";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-JAW6F2FR.mjs";
|
|
9
9
|
export {
|
|
10
10
|
XMLHttpRequestInterceptor
|
|
11
11
|
};
|
|
@@ -8,13 +8,13 @@ var _chunkVQ4DZOBBjs = require('../../chunk-VQ4DZOBB.js');
|
|
|
8
8
|
var _chunk5PTPJLB7js = require('../../chunk-5PTPJLB7.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkUZM2Y7WJjs = require('../../chunk-UZM2Y7WJ.js');
|
|
12
12
|
|
|
13
13
|
// src/interceptors/fetch/index.ts
|
|
14
14
|
var _outvariant = require('outvariant');
|
|
15
15
|
var _deferredpromise = require('@open-draft/deferred-promise');
|
|
16
16
|
var _until = require('@open-draft/until');
|
|
17
|
-
var _FetchInterceptor = class extends
|
|
17
|
+
var _FetchInterceptor = class extends _chunkUZM2Y7WJjs.Interceptor {
|
|
18
18
|
constructor() {
|
|
19
19
|
super(_FetchInterceptor.symbol);
|
|
20
20
|
}
|
package/lib/node/presets/node.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkFWLJEVDWjs = require('../chunk-FWLJEVDW.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkHNNMWWZ6js = require('../chunk-HNNMWWZ6.js');
|
|
7
7
|
require('../chunk-3LFH2WCF.js');
|
|
8
8
|
require('../chunk-OGN3ZR35.js');
|
|
9
9
|
require('../chunk-VQ4DZOBB.js');
|
|
10
10
|
require('../chunk-5PTPJLB7.js');
|
|
11
|
-
require('../chunk-
|
|
11
|
+
require('../chunk-UZM2Y7WJ.js');
|
|
12
12
|
|
|
13
13
|
// src/presets/node.ts
|
|
14
14
|
var node_default = [
|
|
15
|
-
new (0,
|
|
16
|
-
new (0,
|
|
15
|
+
new (0, _chunkFWLJEVDWjs.ClientRequestInterceptor)(),
|
|
16
|
+
new (0, _chunkHNNMWWZ6js.XMLHttpRequestInterceptor)()
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientRequestInterceptor
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-P4CPJLJS.mjs";
|
|
4
4
|
import {
|
|
5
5
|
XMLHttpRequestInterceptor
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-JX6GSWVV.mjs";
|
|
7
7
|
import "../chunk-7II4SWKS.mjs";
|
|
8
8
|
import "../chunk-3IYIKC3X.mjs";
|
|
9
9
|
import "../chunk-GFH37L5D.mjs";
|
|
10
10
|
import "../chunk-YQGTMMOZ.mjs";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-JAW6F2FR.mjs";
|
|
12
12
|
|
|
13
13
|
// src/presets/node.ts
|
|
14
14
|
var node_default = [
|
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.25.
|
|
4
|
+
"version": "0.25.9",
|
|
5
5
|
"main": "./lib/node/index.js",
|
|
6
6
|
"module": "./lib/node/index.mjs",
|
|
7
7
|
"types": "./lib/node/index.d.ts",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"@types/node": "^16.11.26",
|
|
99
99
|
"@types/node-fetch": "2.5.12",
|
|
100
100
|
"@types/supertest": "^2.0.11",
|
|
101
|
-
"axios": "^
|
|
101
|
+
"axios": "^1.6.0",
|
|
102
102
|
"body-parser": "^1.19.0",
|
|
103
103
|
"commitizen": "^4.2.4",
|
|
104
104
|
"cors": "^2.8.5",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"express-rate-limit": "^6.3.0",
|
|
109
109
|
"follow-redirects": "^1.15.1",
|
|
110
110
|
"got": "^11.8.3",
|
|
111
|
+
"happy-dom": "^12.10.3",
|
|
111
112
|
"jest": "^27.4.3",
|
|
112
113
|
"node-fetch": "2.6.7",
|
|
113
114
|
"rimraf": "^3.0.2",
|
package/src/Interceptor.ts
CHANGED
|
@@ -149,7 +149,7 @@ export class Interceptor<Events extends InterceptorEventMap> {
|
|
|
149
149
|
return this
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
logger.info('adding "%s" event listener:', event, listener
|
|
152
|
+
logger.info('adding "%s" event listener:', event, listener)
|
|
153
153
|
|
|
154
154
|
this.emitter.on(event, listener)
|
|
155
155
|
return this
|
|
@@ -103,7 +103,7 @@ export class XMLHttpRequestController {
|
|
|
103
103
|
]
|
|
104
104
|
|
|
105
105
|
this.registerEvent(eventName, listener)
|
|
106
|
-
this.logger.info('addEventListener', eventName, listener
|
|
106
|
+
this.logger.info('addEventListener', eventName, listener)
|
|
107
107
|
|
|
108
108
|
return invoke()
|
|
109
109
|
}
|
|
@@ -206,7 +206,7 @@ export class XMLHttpRequestController {
|
|
|
206
206
|
const nextEvents = prevEvents.concat(listener)
|
|
207
207
|
this.events.set(eventName, nextEvents)
|
|
208
208
|
|
|
209
|
-
this.logger.info('registered event "%s"', eventName, listener
|
|
209
|
+
this.logger.info('registered event "%s"', eventName, listener)
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
/**
|
package/src/utils/createProxy.ts
CHANGED
|
@@ -44,21 +44,21 @@ function optionsToProxyHandler<T extends Record<string, any>>(
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
handler.set = function (target, propertyName, nextValue
|
|
47
|
+
handler.set = function (target, propertyName, nextValue) {
|
|
48
48
|
const next = () => {
|
|
49
|
-
const propertySource = findPropertySource(target, propertyName)
|
|
50
|
-
if (propertySource === null) return false
|
|
51
|
-
|
|
49
|
+
const propertySource = findPropertySource(target, propertyName) || target
|
|
52
50
|
const ownDescriptors = Reflect.getOwnPropertyDescriptor(
|
|
53
51
|
propertySource,
|
|
54
52
|
propertyName
|
|
55
53
|
)
|
|
56
54
|
|
|
55
|
+
// Respect any custom setters present for this property.
|
|
57
56
|
if (typeof ownDescriptors?.set !== 'undefined') {
|
|
58
57
|
ownDescriptors.set.apply(target, [nextValue])
|
|
59
58
|
return true
|
|
60
59
|
}
|
|
61
60
|
|
|
61
|
+
// Otherwise, set the property on the source.
|
|
62
62
|
return Reflect.defineProperty(propertySource, propertyName, {
|
|
63
63
|
writable: true,
|
|
64
64
|
enumerable: true,
|