@mswjs/interceptors 0.22.10 → 0.22.12
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/{Interceptor-c794917d.d.ts → Interceptor-c8fc448a.d.ts} +3 -3
- package/lib/browser/{chunk-KX4GZMPY.mjs → chunk-4W72RMFC.mjs} +15 -11
- package/lib/browser/{chunk-OK5YCL7L.js → chunk-ECRLBCQN.js} +55 -55
- package/lib/browser/{chunk-KQGVZIDK.js → chunk-EGQUVEJ3.js} +19 -15
- package/lib/browser/{chunk-2EIH6L6D.js → chunk-KCAWLR7J.js} +25 -25
- package/lib/browser/{chunk-CKVJ2NZB.mjs → chunk-MJZRQFUP.mjs} +67 -54
- package/lib/browser/{chunk-H4SFMU2L.js → chunk-NHFEA72Q.js} +74 -61
- package/lib/browser/{chunk-2GVXYEMC.mjs → chunk-O7B67YBY.mjs} +54 -54
- package/lib/browser/{chunk-65HGG3CV.mjs → chunk-UYUNRMLU.mjs} +1 -1
- package/lib/browser/index.d.ts +3 -3
- package/lib/browser/index.js +8 -8
- package/lib/browser/index.mjs +6 -6
- package/lib/browser/interceptors/XMLHttpRequest/index.d.ts +2 -2
- 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 +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.d.ts +2 -2
- package/lib/browser/presets/browser.js +6 -6
- package/lib/browser/presets/browser.mjs +4 -4
- package/lib/node/{BatchInterceptor-5c1e5de3.d.ts → BatchInterceptor-fe69020d.d.ts} +1 -1
- package/lib/node/{Interceptor-b3a4098c.d.ts → Interceptor-f9dfe016.d.ts} +3 -3
- package/lib/node/RemoteHttpInterceptor.d.ts +3 -3
- package/lib/node/RemoteHttpInterceptor.js +25 -19
- package/lib/node/RemoteHttpInterceptor.mjs +21 -15
- package/lib/node/{chunk-VTP5KY7W.js → chunk-2OJRZCGS.js} +71 -58
- package/lib/node/{chunk-6CRMKMDL.mjs → chunk-3V5OWTY7.mjs} +54 -55
- package/lib/node/{chunk-62KFIM4W.js → chunk-6KJ5M2VR.js} +56 -57
- package/lib/node/{chunk-A3X67VOL.js → chunk-7XU7Q63W.js} +111 -94
- package/lib/node/{chunk-MUUQLKVJ.js → chunk-PKB2CXQV.js} +3 -3
- package/lib/node/{chunk-SFLY7F52.js → chunk-RJMXHEGJ.js} +6 -6
- package/lib/node/{chunk-EHQJSMSD.mjs → chunk-RL5IV5PL.mjs} +67 -54
- package/lib/node/{chunk-RFVEKRYP.mjs → chunk-S5A4P4BZ.mjs} +1 -1
- package/lib/node/{chunk-IC6Y7RGW.mjs → chunk-SBAVVQIW.mjs} +5 -5
- package/lib/node/{chunk-W27FTX2A.mjs → chunk-XVHIXGXD.mjs} +111 -94
- 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 +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.d.ts +2 -2
- 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 +16 -12
- package/lib/node/interceptors/fetch/index.mjs +15 -11
- package/lib/node/presets/node.d.ts +2 -2
- package/lib/node/presets/node.js +6 -6
- package/lib/node/presets/node.mjs +4 -4
- package/package.json +2 -3
- package/src/BatchInterceptor.ts +4 -4
- package/src/Interceptor.ts +27 -27
- package/src/RemoteHttpInterceptor.ts +16 -10
- package/src/interceptors/ClientRequest/NodeClientRequest.test.ts +11 -11
- package/src/interceptors/ClientRequest/NodeClientRequest.ts +47 -38
- package/src/interceptors/ClientRequest/http.request.ts +3 -3
- package/src/interceptors/ClientRequest/index.ts +4 -4
- package/src/interceptors/ClientRequest/utils/createRequest.test.ts +5 -5
- package/src/interceptors/ClientRequest/utils/getIncomingMessageBody.ts +7 -7
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts +27 -27
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestEndArgs.ts +4 -4
- package/src/interceptors/ClientRequest/utils/normalizeClientRequestWriteArgs.ts +7 -4
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestController.ts +47 -36
- package/src/interceptors/XMLHttpRequest/XMLHttpRequestProxy.ts +15 -13
- package/src/interceptors/XMLHttpRequest/index.ts +5 -5
- package/src/interceptors/fetch/index.ts +14 -11
- package/src/utils/AsyncEventEmitter.ts +27 -27
- package/src/utils/cloneObject.ts +7 -7
- package/src/utils/getUrlByRequestOptions.ts +13 -13
- package/src/utils/debug.ts +0 -4
package/lib/browser/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-c8fc448a.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-c8fc448a.js';
|
|
3
3
|
import { EventMap, Listener } from 'strict-event-emitter';
|
|
4
|
-
import '
|
|
4
|
+
import '@open-draft/logger';
|
|
5
5
|
|
|
6
6
|
interface BatchInterceptorOptions<InterceptorList extends ReadonlyArray<Interceptor<any>>> {
|
|
7
7
|
name: string;
|
package/lib/browser/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkKCAWLR7Jjs = require('./chunk-KCAWLR7J.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkECRLBCQNjs = require('./chunk-ECRLBCQN.js');
|
|
12
12
|
|
|
13
13
|
// src/BatchInterceptor.ts
|
|
14
|
-
var BatchInterceptor = class extends
|
|
14
|
+
var BatchInterceptor = class extends _chunkECRLBCQNjs.Interceptor {
|
|
15
15
|
constructor(options) {
|
|
16
16
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
17
17
|
super(BatchInterceptor.symbol);
|
|
18
18
|
this.interceptors = options.interceptors;
|
|
19
19
|
}
|
|
20
20
|
setup() {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const logger = this.logger.extend("setup");
|
|
22
|
+
logger.info("applying all %d interceptors...", this.interceptors.length);
|
|
23
23
|
for (const interceptor of this.interceptors) {
|
|
24
|
-
|
|
24
|
+
logger.info('applying "%s" interceptor...', interceptor.constructor.name);
|
|
25
25
|
interceptor.apply();
|
|
26
|
-
|
|
26
|
+
logger.info("adding interceptor dispose subscription");
|
|
27
27
|
this.subscriptions.push(() => interceptor.dispose());
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -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 = _chunkECRLBCQNjs.IS_PATCHED_MODULE; exports.Interceptor = _chunkECRLBCQNjs.Interceptor; exports.InterceptorReadyState = _chunkECRLBCQNjs.InterceptorReadyState; exports.decodeBuffer = _chunkKCAWLR7Jjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkECRLBCQNjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkKCAWLR7Jjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkECRLBCQNjs.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-UYUNRMLU.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-O7B67YBY.mjs";
|
|
12
12
|
|
|
13
13
|
// src/BatchInterceptor.ts
|
|
14
14
|
var BatchInterceptor = class extends Interceptor {
|
|
@@ -18,12 +18,12 @@ var BatchInterceptor = class extends Interceptor {
|
|
|
18
18
|
this.interceptors = options.interceptors;
|
|
19
19
|
}
|
|
20
20
|
setup() {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const logger = this.logger.extend("setup");
|
|
22
|
+
logger.info("applying all %d interceptors...", this.interceptors.length);
|
|
23
23
|
for (const interceptor of this.interceptors) {
|
|
24
|
-
|
|
24
|
+
logger.info('applying "%s" interceptor...', interceptor.constructor.name);
|
|
25
25
|
interceptor.apply();
|
|
26
|
-
|
|
26
|
+
logger.info("adding interceptor dispose subscription");
|
|
27
27
|
this.subscriptions.push(() => interceptor.dispose());
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as InteractiveRequest, A as AsyncEventEmitter, H as HttpRequestEventMap, I as Interceptor } from '../../Interceptor-
|
|
1
|
+
import { f as InteractiveRequest, A as AsyncEventEmitter, H as HttpRequestEventMap, I as Interceptor } from '../../Interceptor-c8fc448a.js';
|
|
2
|
+
import '@open-draft/logger';
|
|
2
3
|
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>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var _chunkNHFEA72Qjs = require('../../chunk-NHFEA72Q.js');
|
|
4
|
+
require('../../chunk-KCAWLR7J.js');
|
|
5
5
|
require('../../chunk-PCFJD76X.js');
|
|
6
|
-
require('../../chunk-
|
|
6
|
+
require('../../chunk-ECRLBCQN.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports.XMLHttpRequestInterceptor =
|
|
9
|
+
exports.XMLHttpRequestInterceptor = _chunkNHFEA72Qjs.XMLHttpRequestInterceptor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-MJZRQFUP.mjs";
|
|
4
|
+
import "../../chunk-UYUNRMLU.mjs";
|
|
5
5
|
import "../../chunk-RT3ATOJH.mjs";
|
|
6
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-O7B67YBY.mjs";
|
|
7
7
|
export {
|
|
8
8
|
XMLHttpRequestInterceptor
|
|
9
9
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-
|
|
1
|
+
import { I as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-c8fc448a.js';
|
|
2
|
+
import '@open-draft/logger';
|
|
2
3
|
import 'strict-event-emitter';
|
|
3
|
-
import 'debug';
|
|
4
4
|
|
|
5
5
|
declare class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
|
|
6
6
|
static symbol: symbol;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkEGQUVEJ3js = require('../../chunk-EGQUVEJ3.js');
|
|
4
4
|
require('../../chunk-PCFJD76X.js');
|
|
5
|
-
require('../../chunk-
|
|
5
|
+
require('../../chunk-ECRLBCQN.js');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
exports.FetchInterceptor =
|
|
8
|
+
exports.FetchInterceptor = _chunkEGQUVEJ3js.FetchInterceptor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FetchInterceptor } from '../interceptors/fetch/index.js';
|
|
2
2
|
import { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest/index.js';
|
|
3
|
-
import '../Interceptor-
|
|
3
|
+
import '../Interceptor-c8fc448a.js';
|
|
4
|
+
import '@open-draft/logger';
|
|
4
5
|
import 'strict-event-emitter';
|
|
5
|
-
import 'debug';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The default preset provisions the interception of requests
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var _chunkNHFEA72Qjs = require('../chunk-NHFEA72Q.js');
|
|
4
|
+
require('../chunk-KCAWLR7J.js');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkEGQUVEJ3js = require('../chunk-EGQUVEJ3.js');
|
|
8
8
|
require('../chunk-PCFJD76X.js');
|
|
9
|
-
require('../chunk-
|
|
9
|
+
require('../chunk-ECRLBCQN.js');
|
|
10
10
|
|
|
11
11
|
// src/presets/browser.ts
|
|
12
12
|
var browser_default = [
|
|
13
|
-
new (0,
|
|
14
|
-
new (0,
|
|
13
|
+
new (0, _chunkEGQUVEJ3js.FetchInterceptor)(),
|
|
14
|
+
new (0, _chunkNHFEA72Qjs.XMLHttpRequestInterceptor)()
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
XMLHttpRequestInterceptor
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-MJZRQFUP.mjs";
|
|
4
|
+
import "../chunk-UYUNRMLU.mjs";
|
|
5
5
|
import {
|
|
6
6
|
FetchInterceptor
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-4W72RMFC.mjs";
|
|
8
8
|
import "../chunk-RT3ATOJH.mjs";
|
|
9
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-O7B67YBY.mjs";
|
|
10
10
|
|
|
11
11
|
// src/presets/browser.ts
|
|
12
12
|
var browser_default = [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventMap, Listener } from 'strict-event-emitter';
|
|
2
|
-
import { e as Interceptor, E as ExtractEventNames } from './Interceptor-
|
|
2
|
+
import { e as Interceptor, E as ExtractEventNames } from './Interceptor-f9dfe016.js';
|
|
3
3
|
|
|
4
4
|
interface BatchInterceptorOptions<InterceptorList extends ReadonlyArray<Interceptor<any>>> {
|
|
5
5
|
name: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Logger } from '@open-draft/logger';
|
|
1
2
|
import { EventMap, Emitter, Listener } from 'strict-event-emitter';
|
|
2
|
-
import { Debugger } from 'debug';
|
|
3
3
|
|
|
4
4
|
type AnyFunction = (...args: any[]) => any;
|
|
5
5
|
type LazyCallbackReturnType<FnType extends AnyFunction> = Parameters<FnType> | [];
|
|
@@ -30,7 +30,7 @@ declare enum AsyncEventEmitterReadyState {
|
|
|
30
30
|
}
|
|
31
31
|
declare class AsyncEventEmitter<Events extends EventMap> extends Emitter<Events> {
|
|
32
32
|
readyState: AsyncEventEmitterReadyState;
|
|
33
|
-
private
|
|
33
|
+
private logger;
|
|
34
34
|
protected queue: Map<keyof Events, Array<QueueItem<Events[any]>>>;
|
|
35
35
|
constructor();
|
|
36
36
|
on<EventName extends keyof Events>(eventName: EventName, listener: Listener<any>): this;
|
|
@@ -69,7 +69,7 @@ declare class Interceptor<Events extends InterceptorEventMap> {
|
|
|
69
69
|
private readonly symbol;
|
|
70
70
|
protected emitter: AsyncEventEmitter<Events>;
|
|
71
71
|
protected subscriptions: Array<InterceptorSubscription>;
|
|
72
|
-
protected
|
|
72
|
+
protected logger: Logger;
|
|
73
73
|
readyState: InterceptorReadyState;
|
|
74
74
|
constructor(symbol: symbol);
|
|
75
75
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ChildProcess } from 'child_process';
|
|
2
2
|
import { HeadersObject } from 'headers-polyfill';
|
|
3
|
-
import { e as Interceptor, H as HttpRequestEventMap } from './Interceptor-
|
|
4
|
-
import { a as BatchInterceptor } from './BatchInterceptor-
|
|
3
|
+
import { e as Interceptor, H as HttpRequestEventMap } from './Interceptor-f9dfe016.js';
|
|
4
|
+
import { a as BatchInterceptor } from './BatchInterceptor-fe69020d.js';
|
|
5
5
|
import { ClientRequestInterceptor } from './interceptors/ClientRequest/index.js';
|
|
6
6
|
import { XMLHttpRequestInterceptor } from './interceptors/XMLHttpRequest/index.js';
|
|
7
|
+
import '@open-draft/logger';
|
|
7
8
|
import 'strict-event-emitter';
|
|
8
|
-
import 'debug';
|
|
9
9
|
import 'http';
|
|
10
10
|
import 'https';
|
|
11
11
|
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRJMXHEGJjs = require('./chunk-RJMXHEGJ.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7XU7Q63Wjs = require('./chunk-7XU7Q63W.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
10
|
-
require('./chunk-
|
|
9
|
+
var _chunk2OJRZCGSjs = require('./chunk-2OJRZCGS.js');
|
|
10
|
+
require('./chunk-PKB2CXQV.js');
|
|
11
11
|
require('./chunk-VQ4DZOBB.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkZJOF5MEZjs = require('./chunk-ZJOF5MEZ.js');
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _chunk6KJ5M2VRjs = require('./chunk-6KJ5M2VR.js');
|
|
18
18
|
|
|
19
19
|
// src/RemoteHttpInterceptor.ts
|
|
20
20
|
var _headerspolyfill = require('headers-polyfill');
|
|
21
|
-
var RemoteHttpInterceptor = class extends
|
|
21
|
+
var RemoteHttpInterceptor = class extends _chunkRJMXHEGJjs.BatchInterceptor {
|
|
22
22
|
constructor() {
|
|
23
23
|
super({
|
|
24
24
|
name: "remote-interceptor",
|
|
25
25
|
interceptors: [
|
|
26
|
-
new (0,
|
|
27
|
-
new (0,
|
|
26
|
+
new (0, _chunk7XU7Q63Wjs.ClientRequestInterceptor)(),
|
|
27
|
+
new (0, _chunk2OJRZCGSjs.XMLHttpRequestInterceptor)()
|
|
28
28
|
]
|
|
29
29
|
});
|
|
30
30
|
}
|
|
@@ -41,7 +41,10 @@ var RemoteHttpInterceptor = class extends _chunkSFLY7F52js.BatchInterceptor {
|
|
|
41
41
|
credentials: request.credentials,
|
|
42
42
|
body: ["GET", "HEAD"].includes(request.method) ? null : await request.text()
|
|
43
43
|
});
|
|
44
|
-
this.
|
|
44
|
+
this.logger.info(
|
|
45
|
+
"sent serialized request to the child:",
|
|
46
|
+
serializedRequest
|
|
47
|
+
);
|
|
45
48
|
(_a = process.send) == null ? void 0 : _a.call(process, `request:${serializedRequest}`);
|
|
46
49
|
const responsePromise = new Promise((resolve) => {
|
|
47
50
|
handleParentMessage = (message) => {
|
|
@@ -66,7 +69,7 @@ var RemoteHttpInterceptor = class extends _chunkSFLY7F52js.BatchInterceptor {
|
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
});
|
|
69
|
-
this.
|
|
72
|
+
this.logger.info(
|
|
70
73
|
'add "message" listener to the parent process',
|
|
71
74
|
handleParentMessage
|
|
72
75
|
);
|
|
@@ -88,17 +91,17 @@ function requestReviver(key, value) {
|
|
|
88
91
|
return value;
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
|
-
var _RemoteHttpResolver = class extends
|
|
94
|
+
var _RemoteHttpResolver = class extends _chunk6KJ5M2VRjs.Interceptor {
|
|
92
95
|
constructor(options) {
|
|
93
96
|
super(_RemoteHttpResolver.symbol);
|
|
94
97
|
this.process = options.process;
|
|
95
98
|
}
|
|
96
99
|
setup() {
|
|
97
|
-
const
|
|
100
|
+
const logger = this.logger.extend("setup");
|
|
98
101
|
const handleChildMessage = async (message) => {
|
|
99
|
-
|
|
102
|
+
logger.info("received message from child!", message);
|
|
100
103
|
if (typeof message !== "string" || !message.startsWith("request:")) {
|
|
101
|
-
|
|
104
|
+
logger.info("unknown message, ignoring...");
|
|
102
105
|
return;
|
|
103
106
|
}
|
|
104
107
|
const [, serializedRequest] = message.match(/^request:(.+)$/) || [];
|
|
@@ -109,7 +112,7 @@ var _RemoteHttpResolver = class extends _chunk62KFIM4Wjs.Interceptor {
|
|
|
109
112
|
serializedRequest,
|
|
110
113
|
requestReviver
|
|
111
114
|
);
|
|
112
|
-
|
|
115
|
+
logger.info("parsed intercepted request", requestJson);
|
|
113
116
|
const capturedRequest = new Request(requestJson.url, {
|
|
114
117
|
method: requestJson.method,
|
|
115
118
|
headers: new (0, _headerspolyfill.Headers)(requestJson.headers),
|
|
@@ -128,7 +131,7 @@ var _RemoteHttpResolver = class extends _chunk62KFIM4Wjs.Interceptor {
|
|
|
128
131
|
if (!mockedResponse) {
|
|
129
132
|
return;
|
|
130
133
|
}
|
|
131
|
-
|
|
134
|
+
logger.info("event.respondWith called with:", mockedResponse);
|
|
132
135
|
const responseClone = mockedResponse.clone();
|
|
133
136
|
const responseText = await mockedResponse.text();
|
|
134
137
|
const serializedResponse = JSON.stringify({
|
|
@@ -151,13 +154,16 @@ var _RemoteHttpResolver = class extends _chunk62KFIM4Wjs.Interceptor {
|
|
|
151
154
|
);
|
|
152
155
|
}
|
|
153
156
|
);
|
|
154
|
-
|
|
157
|
+
logger.info(
|
|
158
|
+
"sent serialized mocked response to the parent:",
|
|
159
|
+
serializedResponse
|
|
160
|
+
);
|
|
155
161
|
};
|
|
156
162
|
this.subscriptions.push(() => {
|
|
157
163
|
this.process.removeListener("message", handleChildMessage);
|
|
158
|
-
|
|
164
|
+
logger.info('removed the "message" listener from the child process!');
|
|
159
165
|
});
|
|
160
|
-
|
|
166
|
+
logger.info('adding a "message" listener to the child process');
|
|
161
167
|
this.process.addListener("message", handleChildMessage);
|
|
162
168
|
this.process.once("error", () => this.dispose());
|
|
163
169
|
this.process.once("exit", () => this.dispose());
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchInterceptor
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SBAVVQIW.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ClientRequestInterceptor
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XVHIXGXD.mjs";
|
|
7
7
|
import {
|
|
8
8
|
XMLHttpRequestInterceptor
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-RL5IV5PL.mjs";
|
|
10
|
+
import "./chunk-S5A4P4BZ.mjs";
|
|
11
11
|
import "./chunk-GFH37L5D.mjs";
|
|
12
12
|
import {
|
|
13
13
|
toInteractiveRequest
|
|
14
14
|
} from "./chunk-STA6QBYM.mjs";
|
|
15
15
|
import {
|
|
16
16
|
Interceptor
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-3V5OWTY7.mjs";
|
|
18
18
|
|
|
19
19
|
// src/RemoteHttpInterceptor.ts
|
|
20
20
|
import { Headers, headersToObject } from "headers-polyfill";
|
|
@@ -41,7 +41,10 @@ var RemoteHttpInterceptor = class extends BatchInterceptor {
|
|
|
41
41
|
credentials: request.credentials,
|
|
42
42
|
body: ["GET", "HEAD"].includes(request.method) ? null : await request.text()
|
|
43
43
|
});
|
|
44
|
-
this.
|
|
44
|
+
this.logger.info(
|
|
45
|
+
"sent serialized request to the child:",
|
|
46
|
+
serializedRequest
|
|
47
|
+
);
|
|
45
48
|
(_a = process.send) == null ? void 0 : _a.call(process, `request:${serializedRequest}`);
|
|
46
49
|
const responsePromise = new Promise((resolve) => {
|
|
47
50
|
handleParentMessage = (message) => {
|
|
@@ -66,7 +69,7 @@ var RemoteHttpInterceptor = class extends BatchInterceptor {
|
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
});
|
|
69
|
-
this.
|
|
72
|
+
this.logger.info(
|
|
70
73
|
'add "message" listener to the parent process',
|
|
71
74
|
handleParentMessage
|
|
72
75
|
);
|
|
@@ -94,11 +97,11 @@ var _RemoteHttpResolver = class extends Interceptor {
|
|
|
94
97
|
this.process = options.process;
|
|
95
98
|
}
|
|
96
99
|
setup() {
|
|
97
|
-
const
|
|
100
|
+
const logger = this.logger.extend("setup");
|
|
98
101
|
const handleChildMessage = async (message) => {
|
|
99
|
-
|
|
102
|
+
logger.info("received message from child!", message);
|
|
100
103
|
if (typeof message !== "string" || !message.startsWith("request:")) {
|
|
101
|
-
|
|
104
|
+
logger.info("unknown message, ignoring...");
|
|
102
105
|
return;
|
|
103
106
|
}
|
|
104
107
|
const [, serializedRequest] = message.match(/^request:(.+)$/) || [];
|
|
@@ -109,7 +112,7 @@ var _RemoteHttpResolver = class extends Interceptor {
|
|
|
109
112
|
serializedRequest,
|
|
110
113
|
requestReviver
|
|
111
114
|
);
|
|
112
|
-
|
|
115
|
+
logger.info("parsed intercepted request", requestJson);
|
|
113
116
|
const capturedRequest = new Request(requestJson.url, {
|
|
114
117
|
method: requestJson.method,
|
|
115
118
|
headers: new Headers(requestJson.headers),
|
|
@@ -128,7 +131,7 @@ var _RemoteHttpResolver = class extends Interceptor {
|
|
|
128
131
|
if (!mockedResponse) {
|
|
129
132
|
return;
|
|
130
133
|
}
|
|
131
|
-
|
|
134
|
+
logger.info("event.respondWith called with:", mockedResponse);
|
|
132
135
|
const responseClone = mockedResponse.clone();
|
|
133
136
|
const responseText = await mockedResponse.text();
|
|
134
137
|
const serializedResponse = JSON.stringify({
|
|
@@ -151,13 +154,16 @@ var _RemoteHttpResolver = class extends Interceptor {
|
|
|
151
154
|
);
|
|
152
155
|
}
|
|
153
156
|
);
|
|
154
|
-
|
|
157
|
+
logger.info(
|
|
158
|
+
"sent serialized mocked response to the parent:",
|
|
159
|
+
serializedResponse
|
|
160
|
+
);
|
|
155
161
|
};
|
|
156
162
|
this.subscriptions.push(() => {
|
|
157
163
|
this.process.removeListener("message", handleChildMessage);
|
|
158
|
-
|
|
164
|
+
logger.info('removed the "message" listener from the child process!');
|
|
159
165
|
});
|
|
160
|
-
|
|
166
|
+
logger.info('adding a "message" listener to the child process');
|
|
161
167
|
this.process.addListener("message", handleChildMessage);
|
|
162
168
|
this.process.once("error", () => this.dispose());
|
|
163
169
|
this.process.once("exit", () => this.dispose());
|