Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2025-04-21 18:01:41 +00:00
parent c9f0d30a86
commit 95d52b7807
647 changed files with 498055 additions and 3880 deletions

View file

@ -104,6 +104,21 @@ You can respond to the intercepted HTTP request by constructing a Fetch API Resp
- Does **not** provide any request matching logic;
- Does **not** handle requests by default.
## Limitations
- Interceptors will hang indefinitely if you call `req.end()` in the `connect` event listener of the respective `socket`:
```ts
req.on('socket', (socket) => {
socket.on('connect', () => {
// ❌ While this is allowed in Node.js, this cannot be handled in Interceptors.
req.end()
})
})
```
> This limitation is intrinsic to the interception algorithm used by the library. In order for it to emit the `connect` event on the socket, the library must know if you've handled the request in any way (e.g. responded with a mocked response or errored it). For that, it emits the `request` event on the interceptor where you can handle the request. Since you can consume the request stream in the `request` event, it waits until the request body stream is complete (i.e. until `req.end()` is called). This creates a catch 22 that causes this limitation.
## Getting started
```bash

File diff suppressed because one or more lines are too long

View file

@ -6,11 +6,12 @@ import {
import {
RequestController,
handleRequest
} from "./chunk-H5O73WD2.mjs";
} from "./chunk-L37TY7LC.mjs";
import {
FetchResponse,
IS_PATCHED_MODULE
} from "./chunk-FK37CTPH.mjs";
IS_PATCHED_MODULE,
setRawRequest
} from "./chunk-CNX33NZA.mjs";
import {
hasConfigurableGlobal
} from "./chunk-TX5GBTFY.mjs";
@ -693,6 +694,7 @@ var XMLHttpRequestController = class {
}
});
define(fetchRequest, "headers", proxyHeaders);
setRawRequest(fetchRequest, this.request);
this.logger.info("converted request to a Fetch API Request!", fetchRequest);
return fetchRequest;
}
@ -841,4 +843,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
export {
XMLHttpRequestInterceptor
};
//# sourceMappingURL=chunk-E2WFHJX6.mjs.map
//# sourceMappingURL=chunk-7RPAMWJ6.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -97,9 +97,20 @@ var FetchResponse = _FetchResponse;
FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
// src/getRawRequest.ts
var kRawRequest = Symbol("kRawRequest");
function getRawRequest(request) {
return Reflect.get(request, kRawRequest);
}
function setRawRequest(request, rawRequest) {
Reflect.set(request, kRawRequest, rawRequest);
}
export {
IS_PATCHED_MODULE,
canParseUrl,
FetchResponse
FetchResponse,
getRawRequest,
setRawRequest
};
//# sourceMappingURL=chunk-FK37CTPH.mjs.map
//# sourceMappingURL=chunk-CNX33NZA.mjs.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -39,12 +39,14 @@ var RequestController = class {
this[kResponsePromise].resolve(response);
}
/**
* Error this request with the given error.
* Error this request with the given reason.
*
* @example
* controller.errorWith()
* controller.errorWith(new Error('Oops!'))
* controller.errorWith({ message: 'Oops!'})
*/
errorWith(error) {
errorWith(reason) {
_outvariant.invariant.as(
InterceptorError,
!this[kRequestHandled],
@ -53,7 +55,7 @@ var RequestController = class {
this.request.url
);
this[kRequestHandled] = true;
this[kResponsePromise].resolve(error);
this[kResponsePromise].resolve(reason);
}
};
kResponsePromise, kRequestHandled;
@ -73,6 +75,11 @@ async function emitAsync(emitter, eventName, ...data) {
var _until = require('@open-draft/until');
// src/utils/isObject.ts
function isObject(value, loose = false) {
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
}
// src/utils/isPropertyAccessible.ts
function isPropertyAccessible(obj, key) {
try {
@ -103,7 +110,10 @@ function createServerErrorResponse(body) {
);
}
function isResponseError(response) {
return isPropertyAccessible(response, "type") && response.type === "error";
return response != null && response instanceof Response && isPropertyAccessible(response, "type") && response.type === "error";
}
function isResponseLike(value) {
return isObject(value, true) && isPropertyAccessible(value, "status") && isPropertyAccessible(value, "statusText") && isPropertyAccessible(value, "bodyUsed");
}
// src/utils/isNodeLikeError.ts
@ -122,12 +132,21 @@ async function handleRequest(options) {
const handleResponse = async (response) => {
if (response instanceof Error) {
options.onError(response);
} else if (isResponseError(response)) {
options.onRequestError(response);
} else {
await options.onResponse(response);
return true;
}
return true;
if (isResponseError(response)) {
options.onRequestError(response);
return true;
}
if (isResponseLike(response)) {
await options.onResponse(response);
return true;
}
if (isObject(response)) {
options.onError(response);
return true;
}
return false;
};
const handleResponseError = async (error) => {
if (error instanceof InterceptorError) {
@ -165,7 +184,7 @@ async function handleRequest(options) {
}
}
const result = await _until.until.call(void 0, async () => {
const requestListtenersPromise = emitAsync(options.emitter, "request", {
const requestListenersPromise = emitAsync(options.emitter, "request", {
requestId: options.requestId,
request: options.request,
controller: options.controller
@ -173,11 +192,10 @@ async function handleRequest(options) {
await Promise.race([
// Short-circuit the request handling promise if the request gets aborted.
requestAbortPromise,
requestListtenersPromise,
requestListenersPromise,
options.controller[kResponsePromise]
]);
const mockedResponse = await options.controller[kResponsePromise];
return mockedResponse;
return await options.controller[kResponsePromise];
});
if (requestAbortPromise.state === "rejected") {
options.onError(requestAbortPromise.rejectionReason);
@ -225,4 +243,4 @@ async function handleRequest(options) {
exports.RequestController = RequestController; exports.emitAsync = emitAsync; exports.handleRequest = handleRequest;
//# sourceMappingURL=chunk-FGSEOIC4.js.map
//# sourceMappingURL=chunk-GTJ35JP4.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -39,12 +39,14 @@ var RequestController = class {
this[kResponsePromise].resolve(response);
}
/**
* Error this request with the given error.
* Error this request with the given reason.
*
* @example
* controller.errorWith()
* controller.errorWith(new Error('Oops!'))
* controller.errorWith({ message: 'Oops!'})
*/
errorWith(error) {
errorWith(reason) {
invariant.as(
InterceptorError,
!this[kRequestHandled],
@ -53,7 +55,7 @@ var RequestController = class {
this.request.url
);
this[kRequestHandled] = true;
this[kResponsePromise].resolve(error);
this[kResponsePromise].resolve(reason);
}
};
kResponsePromise, kRequestHandled;
@ -73,6 +75,11 @@ async function emitAsync(emitter, eventName, ...data) {
import { DeferredPromise as DeferredPromise2 } from "@open-draft/deferred-promise";
import { until } from "@open-draft/until";
// src/utils/isObject.ts
function isObject(value, loose = false) {
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
}
// src/utils/isPropertyAccessible.ts
function isPropertyAccessible(obj, key) {
try {
@ -103,7 +110,10 @@ function createServerErrorResponse(body) {
);
}
function isResponseError(response) {
return isPropertyAccessible(response, "type") && response.type === "error";
return response != null && response instanceof Response && isPropertyAccessible(response, "type") && response.type === "error";
}
function isResponseLike(value) {
return isObject(value, true) && isPropertyAccessible(value, "status") && isPropertyAccessible(value, "statusText") && isPropertyAccessible(value, "bodyUsed");
}
// src/utils/isNodeLikeError.ts
@ -122,12 +132,21 @@ async function handleRequest(options) {
const handleResponse = async (response) => {
if (response instanceof Error) {
options.onError(response);
} else if (isResponseError(response)) {
options.onRequestError(response);
} else {
await options.onResponse(response);
return true;
}
return true;
if (isResponseError(response)) {
options.onRequestError(response);
return true;
}
if (isResponseLike(response)) {
await options.onResponse(response);
return true;
}
if (isObject(response)) {
options.onError(response);
return true;
}
return false;
};
const handleResponseError = async (error) => {
if (error instanceof InterceptorError) {
@ -165,7 +184,7 @@ async function handleRequest(options) {
}
}
const result = await until(async () => {
const requestListtenersPromise = emitAsync(options.emitter, "request", {
const requestListenersPromise = emitAsync(options.emitter, "request", {
requestId: options.requestId,
request: options.request,
controller: options.controller
@ -173,11 +192,10 @@ async function handleRequest(options) {
await Promise.race([
// Short-circuit the request handling promise if the request gets aborted.
requestAbortPromise,
requestListtenersPromise,
requestListenersPromise,
options.controller[kResponsePromise]
]);
const mockedResponse = await options.controller[kResponsePromise];
return mockedResponse;
return await options.controller[kResponsePromise];
});
if (requestAbortPromise.state === "rejected") {
options.onError(requestAbortPromise.rejectionReason);
@ -221,10 +239,8 @@ async function handleRequest(options) {
}
export {
isPropertyAccessible,
createServerErrorResponse,
RequestController,
emitAsync,
handleRequest
};
//# sourceMappingURL=chunk-5KMS5CTP.mjs.map
//# sourceMappingURL=chunk-L37TY7LC.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -97,9 +97,20 @@ var FetchResponse = _FetchResponse;
FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
// src/getRawRequest.ts
var kRawRequest = Symbol("kRawRequest");
function getRawRequest(request) {
return Reflect.get(request, kRawRequest);
}
function setRawRequest(request, rawRequest) {
Reflect.set(request, kRawRequest, rawRequest);
}
exports.IS_PATCHED_MODULE = IS_PATCHED_MODULE; exports.canParseUrl = canParseUrl; exports.FetchResponse = FetchResponse;
//# sourceMappingURL=chunk-F7RG3QQH.js.map
exports.IS_PATCHED_MODULE = IS_PATCHED_MODULE; exports.canParseUrl = canParseUrl; exports.FetchResponse = FetchResponse; exports.getRawRequest = getRawRequest; exports.setRawRequest = setRawRequest;
//# sourceMappingURL=chunk-MSUVVHIG.js.map

File diff suppressed because one or more lines are too long

View file

@ -6,11 +6,12 @@ var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
var _chunkFGSEOIC4js = require('./chunk-FGSEOIC4.js');
var _chunkGTJ35JP4js = require('./chunk-GTJ35JP4.js');
var _chunkF7RG3QQHjs = require('./chunk-F7RG3QQH.js');
var _chunkMSUVVHIGjs = require('./chunk-MSUVVHIG.js');
var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
@ -206,8 +207,8 @@ function parseJson(data) {
// src/interceptors/XMLHttpRequest/utils/createResponse.ts
function createResponse(request, body) {
const responseBodyOrNull = _chunkF7RG3QQHjs.FetchResponse.isResponseWithBody(request.status) ? body : null;
return new (0, _chunkF7RG3QQHjs.FetchResponse)(responseBodyOrNull, {
const responseBodyOrNull = _chunkMSUVVHIGjs.FetchResponse.isResponseWithBody(request.status) ? body : null;
return new (0, _chunkMSUVVHIGjs.FetchResponse)(responseBodyOrNull, {
url: request.responseURL,
status: request.status,
statusText: request.statusText,
@ -693,6 +694,7 @@ var XMLHttpRequestController = class {
}
});
define(fetchRequest, "headers", proxyHeaders);
_chunkMSUVVHIGjs.setRawRequest.call(void 0, fetchRequest, this.request);
this.logger.info("converted request to a Fetch API Request!", fetchRequest);
return fetchRequest;
}
@ -741,13 +743,13 @@ function createXMLHttpRequestProxy({
logger
);
xhrRequestController.onRequest = async function({ request, requestId }) {
const controller = new (0, _chunkFGSEOIC4js.RequestController)(request);
const controller = new (0, _chunkGTJ35JP4js.RequestController)(request);
this.logger.info("awaiting mocked response...");
this.logger.info(
'emitting the "request" event for %s listener(s)...',
emitter.listenerCount("request")
);
const isRequestHandled = await _chunkFGSEOIC4js.handleRequest.call(void 0, {
const isRequestHandled = await _chunkGTJ35JP4js.handleRequest.call(void 0, {
request,
requestId,
controller,
@ -807,7 +809,7 @@ var _XMLHttpRequestInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
logger.info('patching "XMLHttpRequest" module...');
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
_outvariant.invariant.call(void 0,
!PureXMLHttpRequest[_chunkF7RG3QQHjs.IS_PATCHED_MODULE],
!PureXMLHttpRequest[_chunkMSUVVHIGjs.IS_PATCHED_MODULE],
'Failed to patch the "XMLHttpRequest" module: already patched.'
);
globalThis.XMLHttpRequest = createXMLHttpRequestProxy({
@ -818,13 +820,13 @@ var _XMLHttpRequestInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
'native "XMLHttpRequest" module patched!',
globalThis.XMLHttpRequest.name
);
Object.defineProperty(globalThis.XMLHttpRequest, _chunkF7RG3QQHjs.IS_PATCHED_MODULE, {
Object.defineProperty(globalThis.XMLHttpRequest, _chunkMSUVVHIGjs.IS_PATCHED_MODULE, {
enumerable: true,
configurable: true,
value: true
});
this.subscriptions.push(() => {
Object.defineProperty(globalThis.XMLHttpRequest, _chunkF7RG3QQHjs.IS_PATCHED_MODULE, {
Object.defineProperty(globalThis.XMLHttpRequest, _chunkMSUVVHIGjs.IS_PATCHED_MODULE, {
value: void 0
});
globalThis.XMLHttpRequest = PureXMLHttpRequest;
@ -841,4 +843,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
exports.XMLHttpRequestInterceptor = XMLHttpRequestInterceptor;
//# sourceMappingURL=chunk-J2HDR5D7.js.map
//# sourceMappingURL=chunk-O2RCNIMR.js.map

File diff suppressed because one or more lines are too long

View file

@ -2,12 +2,13 @@ import {
RequestController,
emitAsync,
handleRequest
} from "./chunk-H5O73WD2.mjs";
} from "./chunk-L37TY7LC.mjs";
import {
FetchResponse,
IS_PATCHED_MODULE,
canParseUrl
} from "./chunk-FK37CTPH.mjs";
canParseUrl,
setRawRequest
} from "./chunk-CNX33NZA.mjs";
import {
hasConfigurableGlobal
} from "./chunk-TX5GBTFY.mjs";
@ -176,8 +177,11 @@ var _FetchInterceptor = class extends Interceptor {
);
globalThis.fetch = async (input, init) => {
const requestId = createRequestId();
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !canParseUrl(input) ? new URL(input, location.origin) : input;
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !canParseUrl(input) ? new URL(input, location.href) : input;
const request = new Request(resolvedInput, init);
if (input instanceof Request) {
setRawRequest(request, input);
}
const responsePromise = new DeferredPromise();
const controller = new RequestController(request);
this.logger.info("[%s] %s", request.method, request.url);
@ -284,4 +288,4 @@ FetchInterceptor.symbol = Symbol("fetch");
export {
FetchInterceptor
};
//# sourceMappingURL=chunk-3NVFHQ5L.mjs.map
//# sourceMappingURL=chunk-SKG3GP7X.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -2,12 +2,13 @@
var _chunkFGSEOIC4js = require('./chunk-FGSEOIC4.js');
var _chunkGTJ35JP4js = require('./chunk-GTJ35JP4.js');
var _chunkF7RG3QQHjs = require('./chunk-F7RG3QQH.js');
var _chunkMSUVVHIGjs = require('./chunk-MSUVVHIG.js');
var _chunkPFGO5BSMjs = require('./chunk-PFGO5BSM.js');
@ -171,22 +172,25 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
async setup() {
const pureFetch = globalThis.fetch;
_outvariant.invariant.call(void 0,
!pureFetch[_chunkF7RG3QQHjs.IS_PATCHED_MODULE],
!pureFetch[_chunkMSUVVHIGjs.IS_PATCHED_MODULE],
'Failed to patch the "fetch" module: already patched.'
);
globalThis.fetch = async (input, init) => {
const requestId = _chunkTIPR373Rjs.createRequestId.call(void 0, );
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !_chunkF7RG3QQHjs.canParseUrl.call(void 0, input) ? new URL(input, location.origin) : input;
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !_chunkMSUVVHIGjs.canParseUrl.call(void 0, input) ? new URL(input, location.href) : input;
const request = new Request(resolvedInput, init);
if (input instanceof Request) {
_chunkMSUVVHIGjs.setRawRequest.call(void 0, request, input);
}
const responsePromise = new (0, _deferredpromise.DeferredPromise)();
const controller = new (0, _chunkFGSEOIC4js.RequestController)(request);
const controller = new (0, _chunkGTJ35JP4js.RequestController)(request);
this.logger.info("[%s] %s", request.method, request.url);
this.logger.info("awaiting for the mocked response...");
this.logger.info(
'emitting the "request" event for %s listener(s)...',
this.emitter.listenerCount("request")
);
const isRequestHandled = await _chunkFGSEOIC4js.handleRequest.call(void 0, {
const isRequestHandled = await _chunkGTJ35JP4js.handleRequest.call(void 0, {
request,
requestId,
emitter: this.emitter,
@ -196,9 +200,9 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
rawResponse
});
const decompressedStream = decompressResponse(rawResponse);
const response = decompressedStream === null ? rawResponse : new (0, _chunkF7RG3QQHjs.FetchResponse)(decompressedStream, rawResponse);
_chunkF7RG3QQHjs.FetchResponse.setUrl(request.url, response);
if (_chunkF7RG3QQHjs.FetchResponse.isRedirectResponse(response.status)) {
const response = decompressedStream === null ? rawResponse : new (0, _chunkMSUVVHIGjs.FetchResponse)(decompressedStream, rawResponse);
_chunkMSUVVHIGjs.FetchResponse.setUrl(request.url, response);
if (_chunkMSUVVHIGjs.FetchResponse.isRedirectResponse(response.status)) {
if (request.redirect === "error") {
responsePromise.reject(createNetworkError("unexpected redirect"));
return;
@ -217,7 +221,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
}
if (this.emitter.listenerCount("response") > 0) {
this.logger.info('emitting the "response" event...');
await _chunkFGSEOIC4js.emitAsync.call(void 0, this.emitter, "response", {
await _chunkGTJ35JP4js.emitAsync.call(void 0, this.emitter, "response", {
// Clone the mocked response for the "response" event listener.
// This way, the listener can read the response and not lock its body
// for the actual fetch consumer.
@ -251,7 +255,7 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
if (this.emitter.listenerCount("response") > 0) {
this.logger.info('emitting the "response" event...');
const responseClone = response.clone();
await _chunkFGSEOIC4js.emitAsync.call(void 0, this.emitter, "response", {
await _chunkGTJ35JP4js.emitAsync.call(void 0, this.emitter, "response", {
response: responseClone,
isMockedResponse: false,
request: requestCloneForResponseEvent,
@ -261,13 +265,13 @@ var _FetchInterceptor = class extends _chunkTIPR373Rjs.Interceptor {
return response;
});
};
Object.defineProperty(globalThis.fetch, _chunkF7RG3QQHjs.IS_PATCHED_MODULE, {
Object.defineProperty(globalThis.fetch, _chunkMSUVVHIGjs.IS_PATCHED_MODULE, {
enumerable: true,
configurable: true,
value: true
});
this.subscriptions.push(() => {
Object.defineProperty(globalThis.fetch, _chunkF7RG3QQHjs.IS_PATCHED_MODULE, {
Object.defineProperty(globalThis.fetch, _chunkMSUVVHIGjs.IS_PATCHED_MODULE, {
value: void 0
});
globalThis.fetch = pureFetch;
@ -284,4 +288,4 @@ FetchInterceptor.symbol = Symbol("fetch");
exports.FetchInterceptor = FetchInterceptor;
//# sourceMappingURL=chunk-H4LFCCBA.js.map
//# sourceMappingURL=chunk-UY4VLZVB.js.map

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,7 @@ declare class RequestController {
* @note This promise cannot be rejected. It's either infinitely
* pending or resolved with whichever Response was passed to `respondWith()`.
*/
[kResponsePromise]: DeferredPromise<Response | Error | undefined>;
[kResponsePromise]: DeferredPromise<Response | Record<string, any> | undefined>;
/**
* Internal flag indicating if this request has been handled.
* @note The response promise becomes "fulfilled" on the next tick.
@ -27,12 +27,14 @@ declare class RequestController {
*/
respondWith(response: Response): void;
/**
* Error this request with the given error.
* Error this request with the given reason.
*
* @example
* controller.errorWith()
* controller.errorWith(new Error('Oops!'))
* controller.errorWith({ message: 'Oops!'})
*/
errorWith(error?: Error): void;
errorWith(reason?: Error | Record<string, any>): void;
}
declare const IS_PATCHED_MODULE: unique symbol;

View file

@ -1,4 +1,4 @@
export { H as HttpRequestEventMap, I as IS_PATCHED_MODULE, R as RequestController, a as RequestCredentials } from './glossary-6564c252.js';
export { H as HttpRequestEventMap, I as IS_PATCHED_MODULE, R as RequestController, a as RequestCredentials } from './glossary-7152281e.js';
import { I as Interceptor, E as ExtractEventNames } from './Interceptor-af98b768.js';
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';
import { EventMap, Listener } from 'strict-event-emitter';
@ -66,4 +66,18 @@ declare class FetchResponse extends Response {
constructor(body?: BodyInit | null, init?: FetchResponseInit);
}
export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchResponse, Interceptor, createRequestId, decodeBuffer, encodeBuffer, getCleanUrl };
/**
* Returns a raw request instance associated with this request.
*
* @example
* interceptor.on('request', ({ request }) => {
* const rawRequest = getRawRequest(request)
*
* if (rawRequest instanceof http.ClientRequest) {
* console.log(rawRequest.rawHeaders)
* }
* })
*/
declare function getRawRequest(request: Request): unknown | undefined;
export { BatchInterceptor, BatchInterceptorOptions, ExtractEventMapType, ExtractEventNames, FetchResponse, Interceptor, createRequestId, decodeBuffer, encodeBuffer, getCleanUrl, getRawRequest };

View file

@ -5,7 +5,8 @@ var _chunkLK6DILFKjs = require('./chunk-LK6DILFK.js');
var _chunkF7RG3QQHjs = require('./chunk-F7RG3QQH.js');
var _chunkMSUVVHIGjs = require('./chunk-MSUVVHIG.js');
@ -75,5 +76,6 @@ function getCleanUrl(url, isAbsolute = true) {
exports.BatchInterceptor = BatchInterceptor; exports.FetchResponse = _chunkF7RG3QQHjs.FetchResponse; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkTIPR373Rjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunkF7RG3QQHjs.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.BatchInterceptor = BatchInterceptor; exports.FetchResponse = _chunkMSUVVHIGjs.FetchResponse; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkTIPR373Rjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunkMSUVVHIGjs.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.getRawRequest = _chunkMSUVVHIGjs.getRawRequest;
//# sourceMappingURL=index.js.map

View file

@ -1 +1 @@
{"version":3,"sources":["../../src/BatchInterceptor.ts","../../src/utils/getCleanUrl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAsBO,IAAM,mBAAN,cAGG,YAAoB;AAAA,EAK5B,YAAY,SAAmD;AAC7D,qBAAiB,SAAS,OAAO,QAAQ,IAAI;AAC7C,UAAM,iBAAiB,MAAM;AAC7B,SAAK,eAAe,QAAQ;AAAA,EAC9B;AAAA,EAEU,QAAQ;AAChB,UAAM,SAAS,KAAK,OAAO,OAAO,OAAO;AAEzC,WAAO,KAAK,mCAAmC,KAAK,aAAa,MAAM;AAEvE,eAAW,eAAe,KAAK,cAAc;AAC3C,aAAO,KAAK,gCAAgC,YAAY,YAAY,IAAI;AACxE,kBAAY,MAAM;AAElB,aAAO,KAAK,yCAAyC;AACrD,WAAK,cAAc,KAAK,MAAM,YAAY,QAAQ,CAAC;AAAA,IACrD;AAAA,EACF;AAAA,EAEO,GACL,OACA,UACM;AAGN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,GAAG,OAAO,QAAQ;AAAA,IAChC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,KACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,KAAK,OAAO,QAAQ;AAAA,IAClC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,IACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,IAAI,OAAO,QAAQ;AAAA,IACjC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,mBACL,OACM;AACN,eAAW,gBAAgB,KAAK,cAAc;AAC5C,mBAAa,mBAAmB,KAAK;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AACF;;;AC3FO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE","sourcesContent":["import { EventMap, Listener } from 'strict-event-emitter'\nimport { Interceptor, ExtractEventNames } from './Interceptor'\n\nexport interface BatchInterceptorOptions<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> {\n name: string\n interceptors: InterceptorList\n}\n\nexport type ExtractEventMapType<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> = InterceptorList extends ReadonlyArray<infer InterceptorType>\n ? InterceptorType extends Interceptor<infer EventMap>\n ? EventMap\n : never\n : never\n\n/**\n * A batch interceptor that exposes a single interface\n * to apply and operate with multiple interceptors at once.\n */\nexport class BatchInterceptor<\n InterceptorList extends ReadonlyArray<Interceptor<any>>,\n Events extends EventMap = ExtractEventMapType<InterceptorList>\n> extends Interceptor<Events> {\n static symbol: symbol\n\n private interceptors: InterceptorList\n\n constructor(options: BatchInterceptorOptions<InterceptorList>) {\n BatchInterceptor.symbol = Symbol(options.name)\n super(BatchInterceptor.symbol)\n this.interceptors = options.interceptors\n }\n\n protected setup() {\n const logger = this.logger.extend('setup')\n\n logger.info('applying all %d interceptors...', this.interceptors.length)\n\n for (const interceptor of this.interceptors) {\n logger.info('applying \"%s\" interceptor...', interceptor.constructor.name)\n interceptor.apply()\n\n logger.info('adding interceptor dispose subscription')\n this.subscriptions.push(() => interceptor.dispose())\n }\n }\n\n public on<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n // Instead of adding a listener to the batch interceptor,\n // propagate the listener to each of the individual interceptors.\n for (const interceptor of this.interceptors) {\n interceptor.on(event, listener)\n }\n\n return this\n }\n\n public once<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.once(event, listener)\n }\n\n return this\n }\n\n public off<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.off(event, listener)\n }\n\n return this\n }\n\n public removeAllListeners<EventName extends ExtractEventNames<Events>>(\n event?: EventName | undefined\n ): this {\n for (const interceptors of this.interceptors) {\n interceptors.removeAllListeners(event)\n }\n\n return this\n }\n}\n","/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"]}
{"version":3,"sources":["../../src/BatchInterceptor.ts","../../src/utils/getCleanUrl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAsBO,IAAM,mBAAN,cAGG,YAAoB;AAAA,EAK5B,YAAY,SAAmD;AAC7D,qBAAiB,SAAS,OAAO,QAAQ,IAAI;AAC7C,UAAM,iBAAiB,MAAM;AAC7B,SAAK,eAAe,QAAQ;AAAA,EAC9B;AAAA,EAEU,QAAQ;AAChB,UAAM,SAAS,KAAK,OAAO,OAAO,OAAO;AAEzC,WAAO,KAAK,mCAAmC,KAAK,aAAa,MAAM;AAEvE,eAAW,eAAe,KAAK,cAAc;AAC3C,aAAO,KAAK,gCAAgC,YAAY,YAAY,IAAI;AACxE,kBAAY,MAAM;AAElB,aAAO,KAAK,yCAAyC;AACrD,WAAK,cAAc,KAAK,MAAM,YAAY,QAAQ,CAAC;AAAA,IACrD;AAAA,EACF;AAAA,EAEO,GACL,OACA,UACM;AAGN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,GAAG,OAAO,QAAQ;AAAA,IAChC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,KACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,KAAK,OAAO,QAAQ;AAAA,IAClC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,IACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,IAAI,OAAO,QAAQ;AAAA,IACjC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,mBACL,OACM;AACN,eAAW,gBAAgB,KAAK,cAAc;AAC5C,mBAAa,mBAAmB,KAAK;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AACF;;;AC3FO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE","sourcesContent":["import { EventMap, Listener } from 'strict-event-emitter'\nimport { Interceptor, ExtractEventNames } from './Interceptor'\n\nexport interface BatchInterceptorOptions<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> {\n name: string\n interceptors: InterceptorList\n}\n\nexport type ExtractEventMapType<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> = InterceptorList extends ReadonlyArray<infer InterceptorType>\n ? InterceptorType extends Interceptor<infer EventMap>\n ? EventMap\n : never\n : never\n\n/**\n * A batch interceptor that exposes a single interface\n * to apply and operate with multiple interceptors at once.\n */\nexport class BatchInterceptor<\n InterceptorList extends ReadonlyArray<Interceptor<any>>,\n Events extends EventMap = ExtractEventMapType<InterceptorList>\n> extends Interceptor<Events> {\n static symbol: symbol\n\n private interceptors: InterceptorList\n\n constructor(options: BatchInterceptorOptions<InterceptorList>) {\n BatchInterceptor.symbol = Symbol(options.name)\n super(BatchInterceptor.symbol)\n this.interceptors = options.interceptors\n }\n\n protected setup() {\n const logger = this.logger.extend('setup')\n\n logger.info('applying all %d interceptors...', this.interceptors.length)\n\n for (const interceptor of this.interceptors) {\n logger.info('applying \"%s\" interceptor...', interceptor.constructor.name)\n interceptor.apply()\n\n logger.info('adding interceptor dispose subscription')\n this.subscriptions.push(() => interceptor.dispose())\n }\n }\n\n public on<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n // Instead of adding a listener to the batch interceptor,\n // propagate the listener to each of the individual interceptors.\n for (const interceptor of this.interceptors) {\n interceptor.on(event, listener)\n }\n\n return this\n }\n\n public once<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.once(event, listener)\n }\n\n return this\n }\n\n public off<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.off(event, listener)\n }\n\n return this\n }\n\n public removeAllListeners<EventName extends ExtractEventNames<Events>>(\n event?: EventName | undefined\n ): this {\n for (const interceptors of this.interceptors) {\n interceptors.removeAllListeners(event)\n }\n\n return this\n }\n}\n","/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"]}

View file

@ -4,8 +4,9 @@ import {
} from "./chunk-6HYIRFX2.mjs";
import {
FetchResponse,
IS_PATCHED_MODULE
} from "./chunk-FK37CTPH.mjs";
IS_PATCHED_MODULE,
getRawRequest
} from "./chunk-CNX33NZA.mjs";
import {
INTERNAL_REQUEST_ID_HEADER_NAME,
Interceptor,
@ -74,6 +75,7 @@ export {
deleteGlobalSymbol,
encodeBuffer,
getCleanUrl,
getGlobalSymbol
getGlobalSymbol,
getRawRequest
};
//# sourceMappingURL=index.mjs.map

View file

@ -1 +1 @@
{"version":3,"sources":["../../src/BatchInterceptor.ts","../../src/utils/getCleanUrl.ts"],"sourcesContent":["import { EventMap, Listener } from 'strict-event-emitter'\nimport { Interceptor, ExtractEventNames } from './Interceptor'\n\nexport interface BatchInterceptorOptions<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> {\n name: string\n interceptors: InterceptorList\n}\n\nexport type ExtractEventMapType<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> = InterceptorList extends ReadonlyArray<infer InterceptorType>\n ? InterceptorType extends Interceptor<infer EventMap>\n ? EventMap\n : never\n : never\n\n/**\n * A batch interceptor that exposes a single interface\n * to apply and operate with multiple interceptors at once.\n */\nexport class BatchInterceptor<\n InterceptorList extends ReadonlyArray<Interceptor<any>>,\n Events extends EventMap = ExtractEventMapType<InterceptorList>\n> extends Interceptor<Events> {\n static symbol: symbol\n\n private interceptors: InterceptorList\n\n constructor(options: BatchInterceptorOptions<InterceptorList>) {\n BatchInterceptor.symbol = Symbol(options.name)\n super(BatchInterceptor.symbol)\n this.interceptors = options.interceptors\n }\n\n protected setup() {\n const logger = this.logger.extend('setup')\n\n logger.info('applying all %d interceptors...', this.interceptors.length)\n\n for (const interceptor of this.interceptors) {\n logger.info('applying \"%s\" interceptor...', interceptor.constructor.name)\n interceptor.apply()\n\n logger.info('adding interceptor dispose subscription')\n this.subscriptions.push(() => interceptor.dispose())\n }\n }\n\n public on<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n // Instead of adding a listener to the batch interceptor,\n // propagate the listener to each of the individual interceptors.\n for (const interceptor of this.interceptors) {\n interceptor.on(event, listener)\n }\n\n return this\n }\n\n public once<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.once(event, listener)\n }\n\n return this\n }\n\n public off<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.off(event, listener)\n }\n\n return this\n }\n\n public removeAllListeners<EventName extends ExtractEventNames<Events>>(\n event?: EventName | undefined\n ): this {\n for (const interceptors of this.interceptors) {\n interceptors.removeAllListeners(event)\n }\n\n return this\n }\n}\n","/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBO,IAAM,mBAAN,cAGG,YAAoB;AAAA,EAK5B,YAAY,SAAmD;AAC7D,qBAAiB,SAAS,OAAO,QAAQ,IAAI;AAC7C,UAAM,iBAAiB,MAAM;AAC7B,SAAK,eAAe,QAAQ;AAAA,EAC9B;AAAA,EAEU,QAAQ;AAChB,UAAM,SAAS,KAAK,OAAO,OAAO,OAAO;AAEzC,WAAO,KAAK,mCAAmC,KAAK,aAAa,MAAM;AAEvE,eAAW,eAAe,KAAK,cAAc;AAC3C,aAAO,KAAK,gCAAgC,YAAY,YAAY,IAAI;AACxE,kBAAY,MAAM;AAElB,aAAO,KAAK,yCAAyC;AACrD,WAAK,cAAc,KAAK,MAAM,YAAY,QAAQ,CAAC;AAAA,IACrD;AAAA,EACF;AAAA,EAEO,GACL,OACA,UACM;AAGN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,GAAG,OAAO,QAAQ;AAAA,IAChC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,KACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,KAAK,OAAO,QAAQ;AAAA,IAClC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,IACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,IAAI,OAAO,QAAQ;AAAA,IACjC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,mBACL,OACM;AACN,eAAW,gBAAgB,KAAK,cAAc;AAC5C,mBAAa,mBAAmB,KAAK;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AACF;;;AC3FO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE;","names":[]}
{"version":3,"sources":["../../src/BatchInterceptor.ts","../../src/utils/getCleanUrl.ts"],"sourcesContent":["import { EventMap, Listener } from 'strict-event-emitter'\nimport { Interceptor, ExtractEventNames } from './Interceptor'\n\nexport interface BatchInterceptorOptions<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> {\n name: string\n interceptors: InterceptorList\n}\n\nexport type ExtractEventMapType<\n InterceptorList extends ReadonlyArray<Interceptor<any>>\n> = InterceptorList extends ReadonlyArray<infer InterceptorType>\n ? InterceptorType extends Interceptor<infer EventMap>\n ? EventMap\n : never\n : never\n\n/**\n * A batch interceptor that exposes a single interface\n * to apply and operate with multiple interceptors at once.\n */\nexport class BatchInterceptor<\n InterceptorList extends ReadonlyArray<Interceptor<any>>,\n Events extends EventMap = ExtractEventMapType<InterceptorList>\n> extends Interceptor<Events> {\n static symbol: symbol\n\n private interceptors: InterceptorList\n\n constructor(options: BatchInterceptorOptions<InterceptorList>) {\n BatchInterceptor.symbol = Symbol(options.name)\n super(BatchInterceptor.symbol)\n this.interceptors = options.interceptors\n }\n\n protected setup() {\n const logger = this.logger.extend('setup')\n\n logger.info('applying all %d interceptors...', this.interceptors.length)\n\n for (const interceptor of this.interceptors) {\n logger.info('applying \"%s\" interceptor...', interceptor.constructor.name)\n interceptor.apply()\n\n logger.info('adding interceptor dispose subscription')\n this.subscriptions.push(() => interceptor.dispose())\n }\n }\n\n public on<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n // Instead of adding a listener to the batch interceptor,\n // propagate the listener to each of the individual interceptors.\n for (const interceptor of this.interceptors) {\n interceptor.on(event, listener)\n }\n\n return this\n }\n\n public once<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.once(event, listener)\n }\n\n return this\n }\n\n public off<EventName extends ExtractEventNames<Events>>(\n event: EventName,\n listener: Listener<Events[EventName]>\n ): this {\n for (const interceptor of this.interceptors) {\n interceptor.off(event, listener)\n }\n\n return this\n }\n\n public removeAllListeners<EventName extends ExtractEventNames<Events>>(\n event?: EventName | undefined\n ): this {\n for (const interceptors of this.interceptors) {\n interceptors.removeAllListeners(event)\n }\n\n return this\n }\n}\n","/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBO,IAAM,mBAAN,cAGG,YAAoB;AAAA,EAK5B,YAAY,SAAmD;AAC7D,qBAAiB,SAAS,OAAO,QAAQ,IAAI;AAC7C,UAAM,iBAAiB,MAAM;AAC7B,SAAK,eAAe,QAAQ;AAAA,EAC9B;AAAA,EAEU,QAAQ;AAChB,UAAM,SAAS,KAAK,OAAO,OAAO,OAAO;AAEzC,WAAO,KAAK,mCAAmC,KAAK,aAAa,MAAM;AAEvE,eAAW,eAAe,KAAK,cAAc;AAC3C,aAAO,KAAK,gCAAgC,YAAY,YAAY,IAAI;AACxE,kBAAY,MAAM;AAElB,aAAO,KAAK,yCAAyC;AACrD,WAAK,cAAc,KAAK,MAAM,YAAY,QAAQ,CAAC;AAAA,IACrD;AAAA,EACF;AAAA,EAEO,GACL,OACA,UACM;AAGN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,GAAG,OAAO,QAAQ;AAAA,IAChC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,KACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,KAAK,OAAO,QAAQ;AAAA,IAClC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,IACL,OACA,UACM;AACN,eAAW,eAAe,KAAK,cAAc;AAC3C,kBAAY,IAAI,OAAO,QAAQ;AAAA,IACjC;AAEA,WAAO;AAAA,EACT;AAAA,EAEO,mBACL,OACM;AACN,eAAW,gBAAgB,KAAK,cAAc;AAC5C,mBAAa,mBAAmB,KAAK;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AACF;;;AC3FO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE;","names":[]}

View file

@ -1,5 +1,5 @@
import { Emitter } from 'strict-event-emitter';
import { H as HttpRequestEventMap } from '../../glossary-6564c252.js';
import { H as HttpRequestEventMap } from '../../glossary-7152281e.js';
import { I as Interceptor } from '../../Interceptor-af98b768.js';
import '@open-draft/deferred-promise';
import '@open-draft/logger';

View file

@ -1,12 +1,12 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkJ2HDR5D7js = require('../../chunk-J2HDR5D7.js');
var _chunkO2RCNIMRjs = require('../../chunk-O2RCNIMR.js');
require('../../chunk-LK6DILFK.js');
require('../../chunk-FGSEOIC4.js');
require('../../chunk-F7RG3QQH.js');
require('../../chunk-GTJ35JP4.js');
require('../../chunk-MSUVVHIG.js');
require('../../chunk-PFGO5BSM.js');
require('../../chunk-TIPR373R.js');
exports.XMLHttpRequestInterceptor = _chunkJ2HDR5D7js.XMLHttpRequestInterceptor;
exports.XMLHttpRequestInterceptor = _chunkO2RCNIMRjs.XMLHttpRequestInterceptor;
//# sourceMappingURL=index.js.map

View file

@ -1,9 +1,9 @@
import {
XMLHttpRequestInterceptor
} from "../../chunk-E2WFHJX6.mjs";
} from "../../chunk-7RPAMWJ6.mjs";
import "../../chunk-6HYIRFX2.mjs";
import "../../chunk-H5O73WD2.mjs";
import "../../chunk-FK37CTPH.mjs";
import "../../chunk-L37TY7LC.mjs";
import "../../chunk-CNX33NZA.mjs";
import "../../chunk-TX5GBTFY.mjs";
import "../../chunk-QED3Q6Z2.mjs";
export {

View file

@ -1,4 +1,4 @@
import { H as HttpRequestEventMap } from '../../glossary-6564c252.js';
import { H as HttpRequestEventMap } from '../../glossary-7152281e.js';
import { I as Interceptor } from '../../Interceptor-af98b768.js';
import '@open-draft/deferred-promise';
import '@open-draft/logger';

View file

@ -1,11 +1,11 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkH4LFCCBAjs = require('../../chunk-H4LFCCBA.js');
require('../../chunk-FGSEOIC4.js');
require('../../chunk-F7RG3QQH.js');
var _chunkUY4VLZVBjs = require('../../chunk-UY4VLZVB.js');
require('../../chunk-GTJ35JP4.js');
require('../../chunk-MSUVVHIG.js');
require('../../chunk-PFGO5BSM.js');
require('../../chunk-TIPR373R.js');
exports.FetchInterceptor = _chunkH4LFCCBAjs.FetchInterceptor;
exports.FetchInterceptor = _chunkUY4VLZVBjs.FetchInterceptor;
//# sourceMappingURL=index.js.map

View file

@ -1,8 +1,8 @@
import {
FetchInterceptor
} from "../../chunk-3NVFHQ5L.mjs";
import "../../chunk-H5O73WD2.mjs";
import "../../chunk-FK37CTPH.mjs";
} from "../../chunk-SKG3GP7X.mjs";
import "../../chunk-L37TY7LC.mjs";
import "../../chunk-CNX33NZA.mjs";
import "../../chunk-TX5GBTFY.mjs";
import "../../chunk-QED3Q6Z2.mjs";
export {

View file

@ -1,6 +1,6 @@
import { FetchInterceptor } from '../interceptors/fetch/index.js';
import { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest/index.js';
import '../glossary-6564c252.js';
import '../glossary-7152281e.js';
import '@open-draft/deferred-promise';
import '../Interceptor-af98b768.js';
import '@open-draft/logger';

View file

@ -1,19 +1,19 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkJ2HDR5D7js = require('../chunk-J2HDR5D7.js');
var _chunkO2RCNIMRjs = require('../chunk-O2RCNIMR.js');
require('../chunk-LK6DILFK.js');
var _chunkH4LFCCBAjs = require('../chunk-H4LFCCBA.js');
require('../chunk-FGSEOIC4.js');
require('../chunk-F7RG3QQH.js');
var _chunkUY4VLZVBjs = require('../chunk-UY4VLZVB.js');
require('../chunk-GTJ35JP4.js');
require('../chunk-MSUVVHIG.js');
require('../chunk-PFGO5BSM.js');
require('../chunk-TIPR373R.js');
// src/presets/browser.ts
var browser_default = [
new (0, _chunkH4LFCCBAjs.FetchInterceptor)(),
new (0, _chunkJ2HDR5D7js.XMLHttpRequestInterceptor)()
new (0, _chunkUY4VLZVBjs.FetchInterceptor)(),
new (0, _chunkO2RCNIMRjs.XMLHttpRequestInterceptor)()
];

View file

@ -1,12 +1,12 @@
import {
XMLHttpRequestInterceptor
} from "../chunk-E2WFHJX6.mjs";
} from "../chunk-7RPAMWJ6.mjs";
import "../chunk-6HYIRFX2.mjs";
import {
FetchInterceptor
} from "../chunk-3NVFHQ5L.mjs";
import "../chunk-H5O73WD2.mjs";
import "../chunk-FK37CTPH.mjs";
} from "../chunk-SKG3GP7X.mjs";
import "../chunk-L37TY7LC.mjs";
import "../chunk-CNX33NZA.mjs";
import "../chunk-TX5GBTFY.mjs";
import "../chunk-QED3Q6Z2.mjs";

View file

@ -1,5 +1,5 @@
import { EventMap, Listener } from 'strict-event-emitter';
import { h as Interceptor, E as ExtractEventNames } from './Interceptor-436630be.js';
import { h as Interceptor, E as ExtractEventNames } from './Interceptor-bc5a9d8e.js';
interface BatchInterceptorOptions<InterceptorList extends ReadonlyArray<Interceptor<any>>> {
name: string;

View file

@ -13,7 +13,7 @@ declare class RequestController {
* @note This promise cannot be rejected. It's either infinitely
* pending or resolved with whichever Response was passed to `respondWith()`.
*/
[kResponsePromise]: DeferredPromise<Response | Error | undefined>;
[kResponsePromise]: DeferredPromise<Response | Record<string, any> | undefined>;
/**
* Internal flag indicating if this request has been handled.
* @note The response promise becomes "fulfilled" on the next tick.
@ -29,12 +29,14 @@ declare class RequestController {
*/
respondWith(response: Response): void;
/**
* Error this request with the given error.
* Error this request with the given reason.
*
* @example
* controller.errorWith()
* controller.errorWith(new Error('Oops!'))
* controller.errorWith({ message: 'Oops!'})
*/
errorWith(error?: Error): void;
errorWith(reason?: Error | Record<string, any>): void;
}
declare const IS_PATCHED_MODULE: unique symbol;

View file

@ -1,6 +1,6 @@
import { ChildProcess } from 'child_process';
import { h as Interceptor, H as HttpRequestEventMap } from './Interceptor-436630be.js';
import { a as BatchInterceptor } from './BatchInterceptor-67bf41ba.js';
import { h as Interceptor, H as HttpRequestEventMap } from './Interceptor-bc5a9d8e.js';
import { a as BatchInterceptor } from './BatchInterceptor-5b72232f.js';
import { ClientRequestInterceptor } from './interceptors/ClientRequest/index.js';
import { XMLHttpRequestInterceptor } from './interceptors/XMLHttpRequest/index.js';
import { FetchInterceptor } from './interceptors/fetch/index.js';

View file

@ -3,24 +3,26 @@
var _chunkMCB574K6js = require('./chunk-MCB574K6.js');
var _chunkGO7ZOUKBjs = require('./chunk-GO7ZOUKB.js');
var _chunkRA7KLLRDjs = require('./chunk-RA7KLLRD.js');
require('./chunk-4YBV77DG.js');
var _chunk2R5JZR3Ljs = require('./chunk-2R5JZR3L.js');
var _chunkR7MWIVYWjs = require('./chunk-R7MWIVYW.js');
require('./chunk-LK6DILFK.js');
var _chunkDPVSIR6Jjs = require('./chunk-DPVSIR6J.js');
var _chunkK4I5GNXUjs = require('./chunk-K4I5GNXU.js');
require('./chunk-PFGO5BSM.js');
require('./chunk-73NOP3T5.js');
var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
var _chunkC2JSMMHYjs = require('./chunk-C2JSMMHY.js');
var _chunkDLID3GDGjs = require('./chunk-DLID3GDG.js');
require('./chunk-SMXZPJEA.js');
// src/RemoteHttpInterceptor.ts
var RemoteHttpInterceptor = class extends _chunkMCB574K6js.BatchInterceptor {
@ -28,9 +30,9 @@ var RemoteHttpInterceptor = class extends _chunkMCB574K6js.BatchInterceptor {
super({
name: "remote-interceptor",
interceptors: [
new (0, _chunkGO7ZOUKBjs.ClientRequestInterceptor)(),
new (0, _chunk2R5JZR3Ljs.XMLHttpRequestInterceptor)(),
new (0, _chunkDPVSIR6Jjs.FetchInterceptor)()
new (0, _chunkRA7KLLRDjs.ClientRequestInterceptor)(),
new (0, _chunkR7MWIVYWjs.XMLHttpRequestInterceptor)(),
new (0, _chunkK4I5GNXUjs.FetchInterceptor)()
]
});
}
@ -126,8 +128,8 @@ var _RemoteHttpResolver = class extends _chunkDLID3GDGjs.Interceptor {
credentials: requestJson.credentials,
body: requestJson.body
});
const controller = new (0, _chunk6L3PFBGTjs.RequestController)(request);
await _chunk6L3PFBGTjs.handleRequest.call(void 0, {
const controller = new (0, _chunkC2JSMMHYjs.RequestController)(request);
await _chunkC2JSMMHYjs.handleRequest.call(void 0, {
request,
requestId: requestJson.id,
controller,

File diff suppressed because one or more lines are too long

View file

@ -3,24 +3,26 @@ import {
} from "./chunk-TBU3WLO3.mjs";
import {
ClientRequestInterceptor
} from "./chunk-JDAAQ7RU.mjs";
} from "./chunk-FHLAZ57F.mjs";
import "./chunk-TJDMZZXE.mjs";
import {
XMLHttpRequestInterceptor
} from "./chunk-RXMZLFWG.mjs";
} from "./chunk-3HLZLASJ.mjs";
import "./chunk-6HYIRFX2.mjs";
import {
FetchInterceptor
} from "./chunk-NIASNH2Q.mjs";
} from "./chunk-3TXENUZY.mjs";
import "./chunk-TX5GBTFY.mjs";
import "./chunk-6YM4PLBI.mjs";
import {
RequestController,
handleRequest
} from "./chunk-5KMS5CTP.mjs";
} from "./chunk-LGXJ3UUF.mjs";
import {
FetchResponse,
Interceptor
} from "./chunk-YM42IU6M.mjs";
import "./chunk-3GJB4JDF.mjs";
// src/RemoteHttpInterceptor.ts
var RemoteHttpInterceptor = class extends BatchInterceptor {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,14 @@
// src/getRawRequest.ts
var kRawRequest = Symbol("kRawRequest");
function getRawRequest(request) {
return Reflect.get(request, kRawRequest);
}
function setRawRequest(request, rawRequest) {
Reflect.set(request, kRawRequest, rawRequest);
}
export {
getRawRequest,
setRawRequest
};
//# sourceMappingURL=chunk-3GJB4JDF.mjs.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../../src/getRawRequest.ts"],"sourcesContent":["const kRawRequest = Symbol('kRawRequest')\n\n/**\n * Returns a raw request instance associated with this request.\n *\n * @example\n * interceptor.on('request', ({ request }) => {\n * const rawRequest = getRawRequest(request)\n *\n * if (rawRequest instanceof http.ClientRequest) {\n * console.log(rawRequest.rawHeaders)\n * }\n * })\n */\nexport function getRawRequest(request: Request): unknown | undefined {\n return Reflect.get(request, kRawRequest)\n}\n\nexport function setRawRequest(request: Request, rawRequest: unknown): void {\n Reflect.set(request, kRawRequest, rawRequest)\n}\n"],"mappings":";AAAA,IAAM,cAAc,OAAO,aAAa;AAcjC,SAAS,cAAc,SAAuC;AACnE,SAAO,QAAQ,IAAI,SAAS,WAAW;AACzC;AAEO,SAAS,cAAc,SAAkB,YAA2B;AACzE,UAAQ,IAAI,SAAS,aAAa,UAAU;AAC9C;","names":[]}

View file

@ -12,13 +12,16 @@ import {
import {
RequestController,
handleRequest
} from "./chunk-5KMS5CTP.mjs";
} from "./chunk-LGXJ3UUF.mjs";
import {
FetchResponse,
INTERNAL_REQUEST_ID_HEADER_NAME,
Interceptor,
createRequestId
} from "./chunk-YM42IU6M.mjs";
import {
setRawRequest
} from "./chunk-3GJB4JDF.mjs";
// src/interceptors/XMLHttpRequest/index.ts
import { invariant as invariant2 } from "outvariant";
@ -693,6 +696,7 @@ var XMLHttpRequestController = class {
}
});
define(fetchRequest, "headers", proxyHeaders);
setRawRequest(fetchRequest, this.request);
this.logger.info("converted request to a Fetch API Request!", fetchRequest);
return fetchRequest;
}
@ -841,4 +845,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
export {
XMLHttpRequestInterceptor
};
//# sourceMappingURL=chunk-RXMZLFWG.mjs.map
//# sourceMappingURL=chunk-3HLZLASJ.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -8,13 +8,16 @@ import {
RequestController,
emitAsync,
handleRequest
} from "./chunk-5KMS5CTP.mjs";
} from "./chunk-LGXJ3UUF.mjs";
import {
FetchResponse,
Interceptor,
canParseUrl,
createRequestId
} from "./chunk-YM42IU6M.mjs";
import {
setRawRequest
} from "./chunk-3GJB4JDF.mjs";
// src/interceptors/fetch/index.ts
import { invariant } from "outvariant";
@ -191,8 +194,11 @@ var _FetchInterceptor = class extends Interceptor {
);
globalThis.fetch = async (input, init) => {
const requestId = createRequestId();
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !canParseUrl(input) ? new URL(input, location.origin) : input;
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !canParseUrl(input) ? new URL(input, location.href) : input;
const request = new Request(resolvedInput, init);
if (input instanceof Request) {
setRawRequest(request, input);
}
const responsePromise = new DeferredPromise();
const controller = new RequestController(request);
this.logger.info("[%s] %s", request.method, request.url);
@ -299,4 +305,4 @@ FetchInterceptor.symbol = Symbol("fetch");
export {
FetchInterceptor
};
//# sourceMappingURL=chunk-NIASNH2Q.mjs.map
//# sourceMappingURL=chunk-3TXENUZY.mjs.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,32 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkSMXZPJEAjs = require('./chunk-SMXZPJEA.js');
// src/utils/node/index.ts
var _http = require('http');
var _stream = require('stream');
var _outvariant = require('outvariant');
var kRawRequestBodyStream = Symbol("kRawRequestBodyStream");
function getClientRequestBodyStream(request) {
const rawRequest = _chunkSMXZPJEAjs.getRawRequest.call(void 0, request);
_outvariant.invariant.call(void 0,
rawRequest instanceof _http.ClientRequest,
`Failed to retrieve raw request body stream: request is not an instance of "http.ClientRequest". Note that you can only use the "getClientRequestBodyStream" function with the requests issued by "http.clientRequest".`
);
const requestBodyStream = Reflect.get(request, kRawRequestBodyStream);
_outvariant.invariant.call(void 0,
requestBodyStream instanceof _stream.Readable,
"Failed to retrieve raw request body stream: corrupted stream (%s)",
typeof requestBodyStream
);
return requestBodyStream;
}
function setRawRequestBodyStream(request, stream) {
Reflect.set(request, kRawRequestBodyStream, stream);
}
exports.getClientRequestBodyStream = getClientRequestBodyStream; exports.setRawRequestBodyStream = setRawRequestBodyStream;
//# sourceMappingURL=chunk-4YBV77DG.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/node/index.ts"],"names":[],"mappings":";;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,IAAM,wBAAwB,OAAO,uBAAuB;AASrD,SAAS,2BAA2B,SAA4B;AACrE,QAAM,aAAa,cAAc,OAAO;AAExC;AAAA,IACE,sBAAsB;AAAA,IACtB;AAAA,EACF;AAEA,QAAM,oBAAoB,QAAQ,IAAI,SAAS,qBAAqB;AAEpE;AAAA,IACE,6BAA6B;AAAA,IAC7B;AAAA,IACA,OAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,wBACd,SACA,QACM;AACN,UAAQ,IAAI,SAAS,uBAAuB,MAAM;AACpD","sourcesContent":["import { ClientRequest } from 'node:http'\nimport { Readable } from 'node:stream'\nimport { invariant } from 'outvariant'\nimport { getRawRequest } from '../../getRawRequest'\n\nconst kRawRequestBodyStream = Symbol('kRawRequestBodyStream')\n\n/**\n * Returns the request body stream of the given request.\n * @note This is only relevant in the context of `http.ClientRequest`.\n * This function will throw if the given `request` wasn't created based on\n * the `http.ClientRequest` instance.\n * You must rely on the web stream consumers for other request clients.\n */\nexport function getClientRequestBodyStream(request: Request): Readable {\n const rawRequest = getRawRequest(request)\n\n invariant(\n rawRequest instanceof ClientRequest,\n `Failed to retrieve raw request body stream: request is not an instance of \"http.ClientRequest\". Note that you can only use the \"getClientRequestBodyStream\" function with the requests issued by \"http.clientRequest\".`\n )\n\n const requestBodyStream = Reflect.get(request, kRawRequestBodyStream)\n\n invariant(\n requestBodyStream instanceof Readable,\n 'Failed to retrieve raw request body stream: corrupted stream (%s)',\n typeof requestBodyStream\n )\n\n return requestBodyStream\n}\n\nexport function setRawRequestBodyStream(\n request: Request,\n stream: Readable\n): void {\n Reflect.set(request, kRawRequestBodyStream, stream)\n}\n"]}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -39,12 +39,14 @@ var RequestController = class {
this[kResponsePromise].resolve(response);
}
/**
* Error this request with the given error.
* Error this request with the given reason.
*
* @example
* controller.errorWith()
* controller.errorWith(new Error('Oops!'))
* controller.errorWith({ message: 'Oops!'})
*/
errorWith(error) {
errorWith(reason) {
_outvariant.invariant.as(
InterceptorError,
!this[kRequestHandled],
@ -53,7 +55,7 @@ var RequestController = class {
this.request.url
);
this[kRequestHandled] = true;
this[kResponsePromise].resolve(error);
this[kResponsePromise].resolve(reason);
}
};
kResponsePromise, kRequestHandled;
@ -73,6 +75,11 @@ async function emitAsync(emitter, eventName, ...data) {
var _until = require('@open-draft/until');
// src/utils/isObject.ts
function isObject(value, loose = false) {
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
}
// src/utils/isPropertyAccessible.ts
function isPropertyAccessible(obj, key) {
try {
@ -103,7 +110,10 @@ function createServerErrorResponse(body) {
);
}
function isResponseError(response) {
return isPropertyAccessible(response, "type") && response.type === "error";
return response != null && response instanceof Response && isPropertyAccessible(response, "type") && response.type === "error";
}
function isResponseLike(value) {
return isObject(value, true) && isPropertyAccessible(value, "status") && isPropertyAccessible(value, "statusText") && isPropertyAccessible(value, "bodyUsed");
}
// src/utils/isNodeLikeError.ts
@ -122,12 +132,21 @@ async function handleRequest(options) {
const handleResponse = async (response) => {
if (response instanceof Error) {
options.onError(response);
} else if (isResponseError(response)) {
options.onRequestError(response);
} else {
await options.onResponse(response);
return true;
}
return true;
if (isResponseError(response)) {
options.onRequestError(response);
return true;
}
if (isResponseLike(response)) {
await options.onResponse(response);
return true;
}
if (isObject(response)) {
options.onError(response);
return true;
}
return false;
};
const handleResponseError = async (error) => {
if (error instanceof InterceptorError) {
@ -165,7 +184,7 @@ async function handleRequest(options) {
}
}
const result = await _until.until.call(void 0, async () => {
const requestListtenersPromise = emitAsync(options.emitter, "request", {
const requestListenersPromise = emitAsync(options.emitter, "request", {
requestId: options.requestId,
request: options.request,
controller: options.controller
@ -173,11 +192,10 @@ async function handleRequest(options) {
await Promise.race([
// Short-circuit the request handling promise if the request gets aborted.
requestAbortPromise,
requestListtenersPromise,
requestListenersPromise,
options.controller[kResponsePromise]
]);
const mockedResponse = await options.controller[kResponsePromise];
return mockedResponse;
return await options.controller[kResponsePromise];
});
if (requestAbortPromise.state === "rejected") {
options.onError(requestAbortPromise.rejectionReason);
@ -226,5 +244,6 @@ async function handleRequest(options) {
exports.isPropertyAccessible = isPropertyAccessible; exports.createServerErrorResponse = createServerErrorResponse; exports.RequestController = RequestController; exports.emitAsync = emitAsync; exports.handleRequest = handleRequest;
//# sourceMappingURL=chunk-6L3PFBGT.js.map
exports.isPropertyAccessible = isPropertyAccessible; exports.isObject = isObject; exports.createServerErrorResponse = createServerErrorResponse; exports.RequestController = RequestController; exports.emitAsync = emitAsync; exports.handleRequest = handleRequest;
//# sourceMappingURL=chunk-C2JSMMHY.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,16 +1,23 @@
import {
setRawRequestBodyStream
} from "./chunk-TJDMZZXE.mjs";
import {
RequestController,
createServerErrorResponse,
emitAsync,
handleRequest,
isObject,
isPropertyAccessible
} from "./chunk-5KMS5CTP.mjs";
} from "./chunk-LGXJ3UUF.mjs";
import {
FetchResponse,
INTERNAL_REQUEST_ID_HEADER_NAME,
Interceptor,
createRequestId
} from "./chunk-YM42IU6M.mjs";
import {
setRawRequest
} from "./chunk-3GJB4JDF.mjs";
// src/interceptors/ClientRequest/index.ts
import http2 from "http";
@ -313,18 +320,16 @@ var MockHttpSocket = class extends MockSocket {
url.username = "";
url.password = "";
}
if (canHaveBody) {
this.requestStream = new Readable({
/**
* @note Provide the `read()` method so a `Readable` could be
* used as the actual request body (the stream calls "read()").
* We control the queue in the onRequestBody/End functions.
*/
read: () => {
this.flushWriteBuffer();
}
});
}
this.requestStream = new Readable({
/**
* @note Provide the `read()` method so a `Readable` could be
* used as the actual request body (the stream calls "read()").
* We control the queue in the onRequestBody/End functions.
*/
read: () => {
this.flushWriteBuffer();
}
});
const requestId = createRequestId();
this.request = new Request(url, {
method,
@ -335,6 +340,8 @@ var MockHttpSocket = class extends MockSocket {
body: canHaveBody ? Readable.toWeb(this.requestStream) : null
});
Reflect.set(this.request, kRequestId, requestId);
setRawRequest(this.request, Reflect.get(this, "_httpMessage"));
setRawRequestBodyStream(this.request, this.requestStream);
if (this.request.headers.has(INTERNAL_REQUEST_ID_HEADER_NAME)) {
this.passthrough();
return;
@ -805,11 +812,6 @@ function cloneObject(obj) {
return isPlainObject(obj) ? enumerableProperties : Object.assign(Object.getPrototypeOf(obj), enumerableProperties);
}
// src/utils/isObject.ts
function isObject(value, loose = false) {
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
}
// src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts
var logger3 = new Logger3("http normalizeClientRequestArgs");
function resolveRequestOptions(args, url) {
@ -1062,4 +1064,4 @@ ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
export {
ClientRequestInterceptor
};
//# sourceMappingURL=chunk-JDAAQ7RU.mjs.map
//# sourceMappingURL=chunk-FHLAZ57F.mjs.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@ var _chunk73NOP3T5js = require('./chunk-73NOP3T5.js');
var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
var _chunkC2JSMMHYjs = require('./chunk-C2JSMMHY.js');
@ -16,6 +16,9 @@ var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
var _chunkDLID3GDGjs = require('./chunk-DLID3GDG.js');
var _chunkSMXZPJEAjs = require('./chunk-SMXZPJEA.js');
// src/interceptors/fetch/index.ts
var _outvariant = require('outvariant');
var _deferredpromise = require('@open-draft/deferred-promise');
@ -191,17 +194,20 @@ var _FetchInterceptor = class extends _chunkDLID3GDGjs.Interceptor {
);
globalThis.fetch = async (input, init) => {
const requestId = _chunkDLID3GDGjs.createRequestId.call(void 0, );
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !_chunkDLID3GDGjs.canParseUrl.call(void 0, input) ? new URL(input, location.origin) : input;
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !_chunkDLID3GDGjs.canParseUrl.call(void 0, input) ? new URL(input, location.href) : input;
const request = new Request(resolvedInput, init);
if (input instanceof Request) {
_chunkSMXZPJEAjs.setRawRequest.call(void 0, request, input);
}
const responsePromise = new (0, _deferredpromise.DeferredPromise)();
const controller = new (0, _chunk6L3PFBGTjs.RequestController)(request);
const controller = new (0, _chunkC2JSMMHYjs.RequestController)(request);
this.logger.info("[%s] %s", request.method, request.url);
this.logger.info("awaiting for the mocked response...");
this.logger.info(
'emitting the "request" event for %s listener(s)...',
this.emitter.listenerCount("request")
);
const isRequestHandled = await _chunk6L3PFBGTjs.handleRequest.call(void 0, {
const isRequestHandled = await _chunkC2JSMMHYjs.handleRequest.call(void 0, {
request,
requestId,
emitter: this.emitter,
@ -232,7 +238,7 @@ var _FetchInterceptor = class extends _chunkDLID3GDGjs.Interceptor {
}
if (this.emitter.listenerCount("response") > 0) {
this.logger.info('emitting the "response" event...');
await _chunk6L3PFBGTjs.emitAsync.call(void 0, this.emitter, "response", {
await _chunkC2JSMMHYjs.emitAsync.call(void 0, this.emitter, "response", {
// Clone the mocked response for the "response" event listener.
// This way, the listener can read the response and not lock its body
// for the actual fetch consumer.
@ -266,7 +272,7 @@ var _FetchInterceptor = class extends _chunkDLID3GDGjs.Interceptor {
if (this.emitter.listenerCount("response") > 0) {
this.logger.info('emitting the "response" event...');
const responseClone = response.clone();
await _chunk6L3PFBGTjs.emitAsync.call(void 0, this.emitter, "response", {
await _chunkC2JSMMHYjs.emitAsync.call(void 0, this.emitter, "response", {
response: responseClone,
isMockedResponse: false,
request: requestCloneForResponseEvent,
@ -299,4 +305,4 @@ FetchInterceptor.symbol = Symbol("fetch");
exports.FetchInterceptor = FetchInterceptor;
//# sourceMappingURL=chunk-DPVSIR6J.js.map
//# sourceMappingURL=chunk-K4I5GNXU.js.map

File diff suppressed because one or more lines are too long

View file

@ -39,12 +39,14 @@ var RequestController = class {
this[kResponsePromise].resolve(response);
}
/**
* Error this request with the given error.
* Error this request with the given reason.
*
* @example
* controller.errorWith()
* controller.errorWith(new Error('Oops!'))
* controller.errorWith({ message: 'Oops!'})
*/
errorWith(error) {
errorWith(reason) {
invariant.as(
InterceptorError,
!this[kRequestHandled],
@ -53,7 +55,7 @@ var RequestController = class {
this.request.url
);
this[kRequestHandled] = true;
this[kResponsePromise].resolve(error);
this[kResponsePromise].resolve(reason);
}
};
kResponsePromise, kRequestHandled;
@ -73,6 +75,11 @@ async function emitAsync(emitter, eventName, ...data) {
import { DeferredPromise as DeferredPromise2 } from "@open-draft/deferred-promise";
import { until } from "@open-draft/until";
// src/utils/isObject.ts
function isObject(value, loose = false) {
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
}
// src/utils/isPropertyAccessible.ts
function isPropertyAccessible(obj, key) {
try {
@ -103,7 +110,10 @@ function createServerErrorResponse(body) {
);
}
function isResponseError(response) {
return isPropertyAccessible(response, "type") && response.type === "error";
return response != null && response instanceof Response && isPropertyAccessible(response, "type") && response.type === "error";
}
function isResponseLike(value) {
return isObject(value, true) && isPropertyAccessible(value, "status") && isPropertyAccessible(value, "statusText") && isPropertyAccessible(value, "bodyUsed");
}
// src/utils/isNodeLikeError.ts
@ -122,12 +132,21 @@ async function handleRequest(options) {
const handleResponse = async (response) => {
if (response instanceof Error) {
options.onError(response);
} else if (isResponseError(response)) {
options.onRequestError(response);
} else {
await options.onResponse(response);
return true;
}
return true;
if (isResponseError(response)) {
options.onRequestError(response);
return true;
}
if (isResponseLike(response)) {
await options.onResponse(response);
return true;
}
if (isObject(response)) {
options.onError(response);
return true;
}
return false;
};
const handleResponseError = async (error) => {
if (error instanceof InterceptorError) {
@ -165,7 +184,7 @@ async function handleRequest(options) {
}
}
const result = await until(async () => {
const requestListtenersPromise = emitAsync(options.emitter, "request", {
const requestListenersPromise = emitAsync(options.emitter, "request", {
requestId: options.requestId,
request: options.request,
controller: options.controller
@ -173,11 +192,10 @@ async function handleRequest(options) {
await Promise.race([
// Short-circuit the request handling promise if the request gets aborted.
requestAbortPromise,
requestListtenersPromise,
requestListenersPromise,
options.controller[kResponsePromise]
]);
const mockedResponse = await options.controller[kResponsePromise];
return mockedResponse;
return await options.controller[kResponsePromise];
});
if (requestAbortPromise.state === "rejected") {
options.onError(requestAbortPromise.rejectionReason);
@ -221,8 +239,11 @@ async function handleRequest(options) {
}
export {
isPropertyAccessible,
isObject,
createServerErrorResponse,
RequestController,
emitAsync,
handleRequest
};
//# sourceMappingURL=chunk-H5O73WD2.mjs.map
//# sourceMappingURL=chunk-LGXJ3UUF.mjs.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -12,7 +12,7 @@ var _chunk73NOP3T5js = require('./chunk-73NOP3T5.js');
var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
var _chunkC2JSMMHYjs = require('./chunk-C2JSMMHY.js');
@ -20,6 +20,9 @@ var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
var _chunkDLID3GDGjs = require('./chunk-DLID3GDG.js');
var _chunkSMXZPJEAjs = require('./chunk-SMXZPJEA.js');
// src/interceptors/XMLHttpRequest/index.ts
var _outvariant = require('outvariant');
@ -693,6 +696,7 @@ var XMLHttpRequestController = class {
}
});
define(fetchRequest, "headers", proxyHeaders);
_chunkSMXZPJEAjs.setRawRequest.call(void 0, fetchRequest, this.request);
this.logger.info("converted request to a Fetch API Request!", fetchRequest);
return fetchRequest;
}
@ -741,13 +745,13 @@ function createXMLHttpRequestProxy({
logger
);
xhrRequestController.onRequest = async function({ request, requestId }) {
const controller = new (0, _chunk6L3PFBGTjs.RequestController)(request);
const controller = new (0, _chunkC2JSMMHYjs.RequestController)(request);
this.logger.info("awaiting mocked response...");
this.logger.info(
'emitting the "request" event for %s listener(s)...',
emitter.listenerCount("request")
);
const isRequestHandled = await _chunk6L3PFBGTjs.handleRequest.call(void 0, {
const isRequestHandled = await _chunkC2JSMMHYjs.handleRequest.call(void 0, {
request,
requestId,
controller,
@ -841,4 +845,4 @@ XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
exports.XMLHttpRequestInterceptor = XMLHttpRequestInterceptor;
//# sourceMappingURL=chunk-2R5JZR3L.js.map
//# sourceMappingURL=chunk-R7MWIVYW.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,10 +1,14 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _chunk4YBV77DGjs = require('./chunk-4YBV77DG.js');
var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
var _chunkC2JSMMHYjs = require('./chunk-C2JSMMHY.js');
@ -12,6 +16,9 @@ var _chunk6L3PFBGTjs = require('./chunk-6L3PFBGT.js');
var _chunkDLID3GDGjs = require('./chunk-DLID3GDG.js');
var _chunkSMXZPJEAjs = require('./chunk-SMXZPJEA.js');
// src/interceptors/ClientRequest/index.ts
var _http = require('http'); var _http2 = _interopRequireDefault(_http);
var _https = require('https'); var _https2 = _interopRequireDefault(_https);
@ -313,18 +320,16 @@ var MockHttpSocket = class extends MockSocket {
url.username = "";
url.password = "";
}
if (canHaveBody) {
this.requestStream = new (0, _stream.Readable)({
/**
* @note Provide the `read()` method so a `Readable` could be
* used as the actual request body (the stream calls "read()").
* We control the queue in the onRequestBody/End functions.
*/
read: () => {
this.flushWriteBuffer();
}
});
}
this.requestStream = new (0, _stream.Readable)({
/**
* @note Provide the `read()` method so a `Readable` could be
* used as the actual request body (the stream calls "read()").
* We control the queue in the onRequestBody/End functions.
*/
read: () => {
this.flushWriteBuffer();
}
});
const requestId = _chunkDLID3GDGjs.createRequestId.call(void 0, );
this.request = new Request(url, {
method,
@ -335,6 +340,8 @@ var MockHttpSocket = class extends MockSocket {
body: canHaveBody ? _stream.Readable.toWeb(this.requestStream) : null
});
Reflect.set(this.request, kRequestId, requestId);
_chunkSMXZPJEAjs.setRawRequest.call(void 0, this.request, Reflect.get(this, "_httpMessage"));
_chunk4YBV77DGjs.setRawRequestBodyStream.call(void 0, this.request, this.requestStream);
if (this.request.headers.has(_chunkDLID3GDGjs.INTERNAL_REQUEST_ID_HEADER_NAME)) {
this.passthrough();
return;
@ -499,7 +506,7 @@ var MockHttpSocket = class extends MockSocket {
if (this.destroyed) {
return;
}
if (_chunk6L3PFBGTjs.isPropertyAccessible.call(void 0, response, "type") && response.type === "error") {
if (_chunkC2JSMMHYjs.isPropertyAccessible.call(void 0, response, "type") && response.type === "error") {
this.errorWith(new TypeError("Network error"));
return;
}
@ -540,7 +547,7 @@ var MockHttpSocket = class extends MockSocket {
serverResponse.write(value);
}
} catch (error) {
this.respondWith(_chunk6L3PFBGTjs.createServerErrorResponse.call(void 0, error));
this.respondWith(_chunkC2JSMMHYjs.createServerErrorResponse.call(void 0, error));
return;
}
} else {
@ -805,11 +812,6 @@ function cloneObject(obj) {
return isPlainObject(obj) ? enumerableProperties : Object.assign(Object.getPrototypeOf(obj), enumerableProperties);
}
// src/utils/isObject.ts
function isObject(value, loose = false) {
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
}
// src/interceptors/ClientRequest/utils/normalizeClientRequestArgs.ts
var logger3 = new (0, _logger.Logger)("http normalizeClientRequestArgs");
function resolveRequestOptions(args, url) {
@ -869,7 +871,7 @@ function normalizeClientRequestArgs(defaultProtocol, args) {
} else if (args[0] instanceof _url.URL) {
url = args[0];
logger3.info("first argument is a URL:", url);
if (typeof args[1] !== "undefined" && isObject(args[1])) {
if (typeof args[1] !== "undefined" && _chunkC2JSMMHYjs.isObject.call(void 0, args[1])) {
url = overrideUrlByRequestOptions(url, args[1]);
}
options = resolveRequestOptions(args, url);
@ -880,7 +882,7 @@ function normalizeClientRequestArgs(defaultProtocol, args) {
logger3.info("first argument is a legacy URL:", legacyUrl);
if (legacyUrl.hostname === null) {
logger3.info("given legacy URL is relative (no hostname)");
return isObject(args[1]) ? normalizeClientRequestArgs(defaultProtocol, [
return _chunkC2JSMMHYjs.isObject.call(void 0, args[1]) ? normalizeClientRequestArgs(defaultProtocol, [
{ path: legacyUrl.path, ...args[1] },
args[2]
]) : normalizeClientRequestArgs(defaultProtocol, [
@ -895,7 +897,7 @@ function normalizeClientRequestArgs(defaultProtocol, args) {
args[1],
args[2]
]);
} else if (isObject(args[0])) {
} else if (_chunkC2JSMMHYjs.isObject.call(void 0, args[0])) {
options = { ...args[0] };
logger3.info("first argument is RequestOptions:", options);
options.protocol = options.protocol || defaultProtocol;
@ -945,8 +947,8 @@ var _ClientRequestInterceptor = class extends _chunkDLID3GDGjs.Interceptor {
socket
}) => {
const requestId = Reflect.get(request, kRequestId);
const controller = new (0, _chunk6L3PFBGTjs.RequestController)(request);
const isRequestHandled = await _chunk6L3PFBGTjs.handleRequest.call(void 0, {
const controller = new (0, _chunkC2JSMMHYjs.RequestController)(request);
const isRequestHandled = await _chunkC2JSMMHYjs.handleRequest.call(void 0, {
request,
requestId,
controller,
@ -973,7 +975,7 @@ var _ClientRequestInterceptor = class extends _chunkDLID3GDGjs.Interceptor {
response,
isMockedResponse
}) => {
return _chunk6L3PFBGTjs.emitAsync.call(void 0, this.emitter, "response", {
return _chunkC2JSMMHYjs.emitAsync.call(void 0, this.emitter, "response", {
requestId,
request,
response,
@ -1062,4 +1064,4 @@ ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
exports.ClientRequestInterceptor = ClientRequestInterceptor;
//# sourceMappingURL=chunk-GO7ZOUKB.js.map
//# sourceMappingURL=chunk-RA7KLLRD.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,14 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/getRawRequest.ts
var kRawRequest = Symbol("kRawRequest");
function getRawRequest(request) {
return Reflect.get(request, kRawRequest);
}
function setRawRequest(request, rawRequest) {
Reflect.set(request, kRawRequest, rawRequest);
}
exports.getRawRequest = getRawRequest; exports.setRawRequest = setRawRequest;
//# sourceMappingURL=chunk-SMXZPJEA.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../../src/getRawRequest.ts"],"names":[],"mappings":";AAAA,IAAM,cAAc,OAAO,aAAa;AAcjC,SAAS,cAAc,SAAuC;AACnE,SAAO,QAAQ,IAAI,SAAS,WAAW;AACzC;AAEO,SAAS,cAAc,SAAkB,YAA2B;AACzE,UAAQ,IAAI,SAAS,aAAa,UAAU;AAC9C","sourcesContent":["const kRawRequest = Symbol('kRawRequest')\n\n/**\n * Returns a raw request instance associated with this request.\n *\n * @example\n * interceptor.on('request', ({ request }) => {\n * const rawRequest = getRawRequest(request)\n *\n * if (rawRequest instanceof http.ClientRequest) {\n * console.log(rawRequest.rawHeaders)\n * }\n * })\n */\nexport function getRawRequest(request: Request): unknown | undefined {\n return Reflect.get(request, kRawRequest)\n}\n\nexport function setRawRequest(request: Request, rawRequest: unknown): void {\n Reflect.set(request, kRawRequest, rawRequest)\n}\n"]}

View file

@ -0,0 +1,32 @@
import {
getRawRequest
} from "./chunk-3GJB4JDF.mjs";
// src/utils/node/index.ts
import { ClientRequest } from "http";
import { Readable } from "stream";
import { invariant } from "outvariant";
var kRawRequestBodyStream = Symbol("kRawRequestBodyStream");
function getClientRequestBodyStream(request) {
const rawRequest = getRawRequest(request);
invariant(
rawRequest instanceof ClientRequest,
`Failed to retrieve raw request body stream: request is not an instance of "http.ClientRequest". Note that you can only use the "getClientRequestBodyStream" function with the requests issued by "http.clientRequest".`
);
const requestBodyStream = Reflect.get(request, kRawRequestBodyStream);
invariant(
requestBodyStream instanceof Readable,
"Failed to retrieve raw request body stream: corrupted stream (%s)",
typeof requestBodyStream
);
return requestBodyStream;
}
function setRawRequestBodyStream(request, stream) {
Reflect.set(request, kRawRequestBodyStream, stream);
}
export {
getClientRequestBodyStream,
setRawRequestBodyStream
};
//# sourceMappingURL=chunk-TJDMZZXE.mjs.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["../../src/utils/node/index.ts"],"sourcesContent":["import { ClientRequest } from 'node:http'\nimport { Readable } from 'node:stream'\nimport { invariant } from 'outvariant'\nimport { getRawRequest } from '../../getRawRequest'\n\nconst kRawRequestBodyStream = Symbol('kRawRequestBodyStream')\n\n/**\n * Returns the request body stream of the given request.\n * @note This is only relevant in the context of `http.ClientRequest`.\n * This function will throw if the given `request` wasn't created based on\n * the `http.ClientRequest` instance.\n * You must rely on the web stream consumers for other request clients.\n */\nexport function getClientRequestBodyStream(request: Request): Readable {\n const rawRequest = getRawRequest(request)\n\n invariant(\n rawRequest instanceof ClientRequest,\n `Failed to retrieve raw request body stream: request is not an instance of \"http.ClientRequest\". Note that you can only use the \"getClientRequestBodyStream\" function with the requests issued by \"http.clientRequest\".`\n )\n\n const requestBodyStream = Reflect.get(request, kRawRequestBodyStream)\n\n invariant(\n requestBodyStream instanceof Readable,\n 'Failed to retrieve raw request body stream: corrupted stream (%s)',\n typeof requestBodyStream\n )\n\n return requestBodyStream\n}\n\nexport function setRawRequestBodyStream(\n request: Request,\n stream: Readable\n): void {\n Reflect.set(request, kRawRequestBodyStream, stream)\n}\n"],"mappings":";;;;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAG1B,IAAM,wBAAwB,OAAO,uBAAuB;AASrD,SAAS,2BAA2B,SAA4B;AACrE,QAAM,aAAa,cAAc,OAAO;AAExC;AAAA,IACE,sBAAsB;AAAA,IACtB;AAAA,EACF;AAEA,QAAM,oBAAoB,QAAQ,IAAI,SAAS,qBAAqB;AAEpE;AAAA,IACE,6BAA6B;AAAA,IAC7B;AAAA,IACA,OAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,wBACd,SACA,QACM;AACN,UAAQ,IAAI,SAAS,uBAAuB,MAAM;AACpD;","names":[]}

View file

@ -1,5 +1,5 @@
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';
export { a as BatchInterceptor, B as BatchInterceptorOptions, E as ExtractEventMapType } from './BatchInterceptor-67bf41ba.js';
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-bc5a9d8e.js';
export { a as BatchInterceptor, B as BatchInterceptorOptions, E as ExtractEventMapType } from './BatchInterceptor-5b72232f.js';
import '@open-draft/deferred-promise';
import '@open-draft/logger';
import 'strict-event-emitter';
@ -45,4 +45,18 @@ declare class FetchResponse extends Response {
constructor(body?: BodyInit | null, init?: FetchResponseInit);
}
export { FetchResponse, createRequestId, decodeBuffer, encodeBuffer, getCleanUrl };
/**
* Returns a raw request instance associated with this request.
*
* @example
* interceptor.on('request', ({ request }) => {
* const rawRequest = getRawRequest(request)
*
* if (rawRequest instanceof http.ClientRequest) {
* console.log(rawRequest.rawHeaders)
* }
* })
*/
declare function getRawRequest(request: Request): unknown | undefined;
export { FetchResponse, createRequestId, decodeBuffer, encodeBuffer, getCleanUrl, getRawRequest };

View file

@ -18,6 +18,9 @@ var _chunk73NOP3T5js = require('./chunk-73NOP3T5.js');
var _chunkDLID3GDGjs = require('./chunk-DLID3GDG.js');
var _chunkSMXZPJEAjs = require('./chunk-SMXZPJEA.js');
// src/utils/getCleanUrl.ts
function getCleanUrl(url, isAbsolute = true) {
return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
@ -35,5 +38,6 @@ function getCleanUrl(url, isAbsolute = true) {
exports.BatchInterceptor = _chunkMCB574K6js.BatchInterceptor; exports.FetchResponse = _chunkDLID3GDGjs.FetchResponse; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkDLID3GDGjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunk73NOP3T5js.IS_PATCHED_MODULE; exports.Interceptor = _chunkDLID3GDGjs.Interceptor; exports.InterceptorReadyState = _chunkDLID3GDGjs.InterceptorReadyState; exports.createRequestId = _chunkDLID3GDGjs.createRequestId; exports.decodeBuffer = _chunkLK6DILFKjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkDLID3GDGjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkLK6DILFKjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkDLID3GDGjs.getGlobalSymbol;
exports.BatchInterceptor = _chunkMCB574K6js.BatchInterceptor; exports.FetchResponse = _chunkDLID3GDGjs.FetchResponse; exports.INTERNAL_REQUEST_ID_HEADER_NAME = _chunkDLID3GDGjs.INTERNAL_REQUEST_ID_HEADER_NAME; exports.IS_PATCHED_MODULE = _chunk73NOP3T5js.IS_PATCHED_MODULE; exports.Interceptor = _chunkDLID3GDGjs.Interceptor; exports.InterceptorReadyState = _chunkDLID3GDGjs.InterceptorReadyState; exports.createRequestId = _chunkDLID3GDGjs.createRequestId; exports.decodeBuffer = _chunkLK6DILFKjs.decodeBuffer; exports.deleteGlobalSymbol = _chunkDLID3GDGjs.deleteGlobalSymbol; exports.encodeBuffer = _chunkLK6DILFKjs.encodeBuffer; exports.getCleanUrl = getCleanUrl; exports.getGlobalSymbol = _chunkDLID3GDGjs.getGlobalSymbol; exports.getRawRequest = _chunkSMXZPJEAjs.getRawRequest;
//# sourceMappingURL=index.js.map

View file

@ -1 +1 @@
{"version":3,"sources":["../../src/utils/getCleanUrl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE","sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"]}
{"version":3,"sources":["../../src/utils/getCleanUrl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE","sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"]}

View file

@ -17,6 +17,9 @@ import {
deleteGlobalSymbol,
getGlobalSymbol
} from "./chunk-YM42IU6M.mjs";
import {
getRawRequest
} from "./chunk-3GJB4JDF.mjs";
// src/utils/getCleanUrl.ts
function getCleanUrl(url, isAbsolute = true) {
@ -34,6 +37,7 @@ export {
deleteGlobalSymbol,
encodeBuffer,
getCleanUrl,
getGlobalSymbol
getGlobalSymbol,
getRawRequest
};
//# sourceMappingURL=index.mjs.map

View file

@ -1 +1 @@
{"version":3,"sources":["../../src/utils/getCleanUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE;","names":[]}
{"version":3,"sources":["../../src/utils/getCleanUrl.ts"],"sourcesContent":["/**\n * Removes query parameters and hashes from a given URL.\n */\nexport function getCleanUrl(url: URL, isAbsolute: boolean = true): string {\n return [isAbsolute && url.origin, url.pathname].filter(Boolean).join('')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,YAAY,KAAU,aAAsB,MAAc;AACxE,SAAO,CAAC,cAAc,IAAI,QAAQ,IAAI,QAAQ,EAAE,OAAO,OAAO,EAAE,KAAK,EAAE;AACzE;","names":[]}

View file

@ -1,4 +1,4 @@
import { h as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-436630be.js';
import { h as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-bc5a9d8e.js';
import net from 'node:net';
import '@open-draft/deferred-promise';
import '@open-draft/logger';

View file

@ -1,9 +1,11 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkGO7ZOUKBjs = require('../../chunk-GO7ZOUKB.js');
require('../../chunk-6L3PFBGT.js');
var _chunkRA7KLLRDjs = require('../../chunk-RA7KLLRD.js');
require('../../chunk-4YBV77DG.js');
require('../../chunk-C2JSMMHY.js');
require('../../chunk-DLID3GDG.js');
require('../../chunk-SMXZPJEA.js');
exports.ClientRequestInterceptor = _chunkGO7ZOUKBjs.ClientRequestInterceptor;
exports.ClientRequestInterceptor = _chunkRA7KLLRDjs.ClientRequestInterceptor;
//# sourceMappingURL=index.js.map

View file

@ -1,8 +1,10 @@
import {
ClientRequestInterceptor
} from "../../chunk-JDAAQ7RU.mjs";
import "../../chunk-5KMS5CTP.mjs";
} from "../../chunk-FHLAZ57F.mjs";
import "../../chunk-TJDMZZXE.mjs";
import "../../chunk-LGXJ3UUF.mjs";
import "../../chunk-YM42IU6M.mjs";
import "../../chunk-3GJB4JDF.mjs";
export {
ClientRequestInterceptor
};

View file

@ -1,5 +1,5 @@
import { Emitter } from 'strict-event-emitter';
import { H as HttpRequestEventMap, h as Interceptor } from '../../Interceptor-436630be.js';
import { H as HttpRequestEventMap, h as Interceptor } from '../../Interceptor-bc5a9d8e.js';
import '@open-draft/deferred-promise';
import '@open-draft/logger';

View file

@ -1,12 +1,13 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunk2R5JZR3Ljs = require('../../chunk-2R5JZR3L.js');
var _chunkR7MWIVYWjs = require('../../chunk-R7MWIVYW.js');
require('../../chunk-LK6DILFK.js');
require('../../chunk-PFGO5BSM.js');
require('../../chunk-73NOP3T5.js');
require('../../chunk-6L3PFBGT.js');
require('../../chunk-C2JSMMHY.js');
require('../../chunk-DLID3GDG.js');
require('../../chunk-SMXZPJEA.js');
exports.XMLHttpRequestInterceptor = _chunk2R5JZR3Ljs.XMLHttpRequestInterceptor;
exports.XMLHttpRequestInterceptor = _chunkR7MWIVYWjs.XMLHttpRequestInterceptor;
//# sourceMappingURL=index.js.map

View file

@ -1,11 +1,12 @@
import {
XMLHttpRequestInterceptor
} from "../../chunk-RXMZLFWG.mjs";
} from "../../chunk-3HLZLASJ.mjs";
import "../../chunk-6HYIRFX2.mjs";
import "../../chunk-TX5GBTFY.mjs";
import "../../chunk-6YM4PLBI.mjs";
import "../../chunk-5KMS5CTP.mjs";
import "../../chunk-LGXJ3UUF.mjs";
import "../../chunk-YM42IU6M.mjs";
import "../../chunk-3GJB4JDF.mjs";
export {
XMLHttpRequestInterceptor
};

View file

@ -1,4 +1,4 @@
import { h as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-436630be.js';
import { h as Interceptor, H as HttpRequestEventMap } from '../../Interceptor-bc5a9d8e.js';
import '@open-draft/deferred-promise';
import '@open-draft/logger';
import 'strict-event-emitter';

View file

@ -1,11 +1,12 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkDPVSIR6Jjs = require('../../chunk-DPVSIR6J.js');
var _chunkK4I5GNXUjs = require('../../chunk-K4I5GNXU.js');
require('../../chunk-PFGO5BSM.js');
require('../../chunk-73NOP3T5.js');
require('../../chunk-6L3PFBGT.js');
require('../../chunk-C2JSMMHY.js');
require('../../chunk-DLID3GDG.js');
require('../../chunk-SMXZPJEA.js');
exports.FetchInterceptor = _chunkDPVSIR6Jjs.FetchInterceptor;
exports.FetchInterceptor = _chunkK4I5GNXUjs.FetchInterceptor;
//# sourceMappingURL=index.js.map

View file

@ -1,10 +1,11 @@
import {
FetchInterceptor
} from "../../chunk-NIASNH2Q.mjs";
} from "../../chunk-3TXENUZY.mjs";
import "../../chunk-TX5GBTFY.mjs";
import "../../chunk-6YM4PLBI.mjs";
import "../../chunk-5KMS5CTP.mjs";
import "../../chunk-LGXJ3UUF.mjs";
import "../../chunk-YM42IU6M.mjs";
import "../../chunk-3GJB4JDF.mjs";
export {
FetchInterceptor
};

View file

@ -1,7 +1,7 @@
import { ClientRequestInterceptor } from '../interceptors/ClientRequest/index.js';
import { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest/index.js';
import { FetchInterceptor } from '../interceptors/fetch/index.js';
import '../Interceptor-436630be.js';
import '../Interceptor-bc5a9d8e.js';
import '@open-draft/deferred-promise';
import '@open-draft/logger';
import 'strict-event-emitter';

View file

@ -1,23 +1,25 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkGO7ZOUKBjs = require('../chunk-GO7ZOUKB.js');
var _chunkRA7KLLRDjs = require('../chunk-RA7KLLRD.js');
require('../chunk-4YBV77DG.js');
var _chunk2R5JZR3Ljs = require('../chunk-2R5JZR3L.js');
var _chunkR7MWIVYWjs = require('../chunk-R7MWIVYW.js');
require('../chunk-LK6DILFK.js');
var _chunkDPVSIR6Jjs = require('../chunk-DPVSIR6J.js');
var _chunkK4I5GNXUjs = require('../chunk-K4I5GNXU.js');
require('../chunk-PFGO5BSM.js');
require('../chunk-73NOP3T5.js');
require('../chunk-6L3PFBGT.js');
require('../chunk-C2JSMMHY.js');
require('../chunk-DLID3GDG.js');
require('../chunk-SMXZPJEA.js');
// src/presets/node.ts
var node_default = [
new (0, _chunkGO7ZOUKBjs.ClientRequestInterceptor)(),
new (0, _chunk2R5JZR3Ljs.XMLHttpRequestInterceptor)(),
new (0, _chunkDPVSIR6Jjs.FetchInterceptor)()
new (0, _chunkRA7KLLRDjs.ClientRequestInterceptor)(),
new (0, _chunkR7MWIVYWjs.XMLHttpRequestInterceptor)(),
new (0, _chunkK4I5GNXUjs.FetchInterceptor)()
];

View file

@ -1 +1 @@
{"version":3,"sources":["../../../src/presets/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAQA,IAAO,eAAQ;AAAA,EACb,IAAI,yBAAyB;AAAA,EAC7B,IAAI,0BAA0B;AAAA,EAC9B,IAAI,iBAAiB;AACvB","sourcesContent":["import { ClientRequestInterceptor } from '../interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '../interceptors/fetch'\n\n/**\n * The default preset provisions the interception of requests\n * regardless of their type (http/https/XMLHttpRequest).\n */\nexport default [\n new ClientRequestInterceptor(),\n new XMLHttpRequestInterceptor(),\n new FetchInterceptor(),\n] as const\n"]}
{"version":3,"sources":["../../../src/presets/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAQA,IAAO,eAAQ;AAAA,EACb,IAAI,yBAAyB;AAAA,EAC7B,IAAI,0BAA0B;AAAA,EAC9B,IAAI,iBAAiB;AACvB","sourcesContent":["import { ClientRequestInterceptor } from '../interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '../interceptors/fetch'\n\n/**\n * The default preset provisions the interception of requests\n * regardless of their type (http/https/XMLHttpRequest).\n */\nexport default [\n new ClientRequestInterceptor(),\n new XMLHttpRequestInterceptor(),\n new FetchInterceptor(),\n] as const\n"]}

View file

@ -1,17 +1,19 @@
import {
ClientRequestInterceptor
} from "../chunk-JDAAQ7RU.mjs";
} from "../chunk-FHLAZ57F.mjs";
import "../chunk-TJDMZZXE.mjs";
import {
XMLHttpRequestInterceptor
} from "../chunk-RXMZLFWG.mjs";
} from "../chunk-3HLZLASJ.mjs";
import "../chunk-6HYIRFX2.mjs";
import {
FetchInterceptor
} from "../chunk-NIASNH2Q.mjs";
} from "../chunk-3TXENUZY.mjs";
import "../chunk-TX5GBTFY.mjs";
import "../chunk-6YM4PLBI.mjs";
import "../chunk-5KMS5CTP.mjs";
import "../chunk-LGXJ3UUF.mjs";
import "../chunk-YM42IU6M.mjs";
import "../chunk-3GJB4JDF.mjs";
// src/presets/node.ts
var node_default = [

View file

@ -1 +1 @@
{"version":3,"sources":["../../../src/presets/node.ts"],"sourcesContent":["import { ClientRequestInterceptor } from '../interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '../interceptors/fetch'\n\n/**\n * The default preset provisions the interception of requests\n * regardless of their type (http/https/XMLHttpRequest).\n */\nexport default [\n new ClientRequestInterceptor(),\n new XMLHttpRequestInterceptor(),\n new FetchInterceptor(),\n] as const\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,IAAO,eAAQ;AAAA,EACb,IAAI,yBAAyB;AAAA,EAC7B,IAAI,0BAA0B;AAAA,EAC9B,IAAI,iBAAiB;AACvB;","names":[]}
{"version":3,"sources":["../../../src/presets/node.ts"],"sourcesContent":["import { ClientRequestInterceptor } from '../interceptors/ClientRequest'\nimport { XMLHttpRequestInterceptor } from '../interceptors/XMLHttpRequest'\nimport { FetchInterceptor } from '../interceptors/fetch'\n\n/**\n * The default preset provisions the interception of requests\n * regardless of their type (http/https/XMLHttpRequest).\n */\nexport default [\n new ClientRequestInterceptor(),\n new XMLHttpRequestInterceptor(),\n new FetchInterceptor(),\n] as const\n"],"mappings":";;;;;;;;;;;;;;;;;;AAQA,IAAO,eAAQ;AAAA,EACb,IAAI,yBAAyB;AAAA,EAC7B,IAAI,0BAA0B;AAAA,EAC9B,IAAI,iBAAiB;AACvB;","names":[]}

View file

@ -0,0 +1,13 @@
import { Readable } from 'node:stream';
/**
* Returns the request body stream of the given request.
* @note This is only relevant in the context of `http.ClientRequest`.
* This function will throw if the given `request` wasn't created based on
* the `http.ClientRequest` instance.
* You must rely on the web stream consumers for other request clients.
*/
declare function getClientRequestBodyStream(request: Request): Readable;
declare function setRawRequestBodyStream(request: Request, stream: Readable): void;
export { getClientRequestBodyStream, setRawRequestBodyStream };

View file

@ -0,0 +1,10 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunk4YBV77DGjs = require('../../chunk-4YBV77DG.js');
require('../../chunk-SMXZPJEA.js');
exports.getClientRequestBodyStream = _chunk4YBV77DGjs.getClientRequestBodyStream; exports.setRawRequestBodyStream = _chunk4YBV77DGjs.setRawRequestBodyStream;
//# sourceMappingURL=index.js.map

Some files were not shown because too many files have changed in this diff Show more