Merge pull request #2864 from github/dependabot/npm_and_yarn/npm-cac24ffe08

build(deps): bump the npm group across 1 directory with 7 updates
This commit is contained in:
Henry Mercer 2025-04-28 18:34:13 +01:00 committed by GitHub
commit 83605b3ce2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
649 changed files with 498408 additions and 4224 deletions

669
node_modules/.package-lock.json generated vendored

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
MIT License Copyright (c) 2019 Octokit contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,65 @@
# types.ts
> Shared TypeScript definitions for Octokit projects
[![@latest](https://img.shields.io/npm/v/@octokit/types.svg)](https://www.npmjs.com/package/@octokit/types)
[![Build Status](https://github.com/octokit/types.ts/workflows/Test/badge.svg)](https://github.com/octokit/types.ts/actions?workflow=Test)
<!-- toc -->
- [Usage](#usage)
- [Examples](#examples)
- [Get parameter and response data types for a REST API endpoint](#get-parameter-and-response-data-types-for-a-rest-api-endpoint)
- [Get response types from endpoint methods](#get-response-types-from-endpoint-methods)
- [Contributing](#contributing)
- [License](#license)
<!-- tocstop -->
## Usage
See all exported types at https://octokit.github.io/types.ts
## Examples
### Get parameter and response data types for a REST API endpoint
```ts
import { Endpoints } from "@octokit/types";
type listUserReposParameters =
Endpoints["GET /repos/{owner}/{repo}"]["parameters"];
type listUserReposResponse = Endpoints["GET /repos/{owner}/{repo}"]["response"];
async function listRepos(
options: listUserReposParameters,
): listUserReposResponse["data"] {
// ...
}
```
### Get response types from endpoint methods
```ts
import {
GetResponseTypeFromEndpointMethod,
GetResponseDataTypeFromEndpointMethod,
} from "@octokit/types";
import { Octokit } from "@octokit/rest";
const octokit = new Octokit();
type CreateLabelResponseType = GetResponseTypeFromEndpointMethod<
typeof octokit.issues.createLabel
>;
type CreateLabelResponseDataType = GetResponseDataTypeFromEndpointMethod<
typeof octokit.issues.createLabel
>;
```
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
## License
[MIT](LICENSE)

View file

@ -0,0 +1,31 @@
import type { EndpointOptions } from "./EndpointOptions.js";
import type { OctokitResponse } from "./OctokitResponse.js";
import type { RequestInterface } from "./RequestInterface.js";
import type { RequestParameters } from "./RequestParameters.js";
import type { Route } from "./Route.js";
/**
* Interface to implement complex authentication strategies for Octokit.
* An object Implementing the AuthInterface can directly be passed as the
* `auth` option in the Octokit constructor.
*
* For the official implementations of the most common authentication
* strategies, see https://github.com/octokit/auth.js
*/
export interface AuthInterface<AuthOptions extends any[], Authentication extends any> {
(...args: AuthOptions): Promise<Authentication>;
hook: {
/**
* Sends a request using the passed `request` instance
*
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<T = any>(request: RequestInterface, options: EndpointOptions): Promise<OctokitResponse<T>>;
/**
* Sends a request using the passed `request` instance
*
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<T = any>(request: RequestInterface, route: Route, parameters?: RequestParameters): Promise<OctokitResponse<T>>;
};
}

View file

@ -0,0 +1,21 @@
import type { RequestHeaders } from "./RequestHeaders.js";
import type { RequestMethod } from "./RequestMethod.js";
import type { RequestParameters } from "./RequestParameters.js";
import type { Url } from "./Url.js";
/**
* The `.endpoint()` method is guaranteed to set all keys defined by RequestParameters
* as well as the method property.
*/
export type EndpointDefaults = RequestParameters & {
baseUrl: Url;
method: RequestMethod;
url?: Url;
headers: RequestHeaders & {
accept: string;
"user-agent": string;
};
mediaType: {
format: string;
previews?: string[];
};
};

View file

@ -0,0 +1,65 @@
import type { EndpointDefaults } from "./EndpointDefaults.js";
import type { RequestOptions } from "./RequestOptions.js";
import type { RequestParameters } from "./RequestParameters.js";
import type { Route } from "./Route.js";
import type { Endpoints } from "./generated/Endpoints.js";
export interface EndpointInterface<D extends object = object> {
/**
* Transforms a GitHub REST API endpoint into generic request options
*
* @param {object} endpoint Must set `url` unless it's set defaults. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<O extends RequestParameters = RequestParameters>(options: O & {
method?: string;
} & ("url" extends keyof D ? {
url?: string;
} : {
url: string;
})): RequestOptions & Pick<D & O, keyof RequestOptions>;
/**
* Transforms a GitHub REST API endpoint into generic request options
*
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<R extends Route, P extends RequestParameters = R extends keyof Endpoints ? Endpoints[R]["parameters"] & RequestParameters : RequestParameters>(route: keyof Endpoints | R, parameters?: P): (R extends keyof Endpoints ? Endpoints[R]["request"] : RequestOptions) & Pick<P, keyof RequestOptions>;
/**
* Object with current default route and parameters
*/
DEFAULTS: D & EndpointDefaults;
/**
* Returns a new `endpoint` interface with new defaults
*/
defaults: <O extends RequestParameters = RequestParameters>(newDefaults: O) => EndpointInterface<D & O>;
merge: {
/**
* Merges current endpoint defaults with passed route and parameters,
* without transforming them into request options.
*
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*
*/
<R extends Route, P extends RequestParameters = R extends keyof Endpoints ? Endpoints[R]["parameters"] & RequestParameters : RequestParameters>(route: keyof Endpoints | R, parameters?: P): D & (R extends keyof Endpoints ? Endpoints[R]["request"] & Endpoints[R]["parameters"] : EndpointDefaults) & P;
/**
* Merges current endpoint defaults with passed route and parameters,
* without transforming them into request options.
*
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<P extends RequestParameters = RequestParameters>(options: P): EndpointDefaults & D & P;
/**
* Returns current default options.
*
* @deprecated use endpoint.DEFAULTS instead
*/
(): D & EndpointDefaults;
};
/**
* Stateless method to turn endpoint options into request options.
* Calling `endpoint(options)` is the same as calling `endpoint.parse(endpoint.merge(options))`.
*
* @param {object} options `method`, `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
parse: <O extends EndpointDefaults = EndpointDefaults>(options: O) => RequestOptions & Pick<O, keyof RequestOptions>;
}

View file

@ -0,0 +1,7 @@
import type { RequestMethod } from "./RequestMethod.js";
import type { Url } from "./Url.js";
import type { RequestParameters } from "./RequestParameters.js";
export type EndpointOptions = RequestParameters & {
method: RequestMethod;
url: Url;
};

View file

@ -0,0 +1,4 @@
/**
* Browser's fetch method (or compatible such as fetch-mock)
*/
export type Fetch = any;

View file

@ -0,0 +1,5 @@
type Unwrap<T> = T extends Promise<infer U> ? U : T;
type AnyFunction = (...args: any[]) => any;
export type GetResponseTypeFromEndpointMethod<T extends AnyFunction> = Unwrap<ReturnType<T>>;
export type GetResponseDataTypeFromEndpointMethod<T extends AnyFunction> = Unwrap<ReturnType<T>>["data"];
export {};

View file

@ -0,0 +1,17 @@
import type { ResponseHeaders } from "./ResponseHeaders.js";
import type { Url } from "./Url.js";
export interface OctokitResponse<T, S extends number = number> {
headers: ResponseHeaders;
/**
* http response code
*/
status: S;
/**
* URL of response after all redirects
*/
url: Url;
/**
* Response data as documented in the REST API reference documentation at https://docs.github.com/rest/reference
*/
data: T;
}

View file

@ -0,0 +1,11 @@
export type RequestError = {
name: string;
status: number;
documentation_url: string;
errors?: Array<{
resource: string;
code: string;
field: string;
message?: string;
}>;
};

View file

@ -0,0 +1,15 @@
export type RequestHeaders = {
/**
* Avoid setting `headers.accept`, use `mediaType.{format|previews}` option instead.
*/
accept?: string;
/**
* Use `authorization` to send authenticated request, remember `token ` / `bearer ` prefixes. Example: `token 1234567890abcdef1234567890abcdef12345678`
*/
authorization?: string;
/**
* `user-agent` is set do a default and can be overwritten as needed.
*/
"user-agent"?: string;
[header: string]: string | number | undefined;
};

View file

@ -0,0 +1,34 @@
import type { EndpointInterface } from "./EndpointInterface.js";
import type { OctokitResponse } from "./OctokitResponse.js";
import type { RequestParameters } from "./RequestParameters.js";
import type { Route } from "./Route.js";
import type { Endpoints } from "./generated/Endpoints.js";
export interface RequestInterface<D extends object = object> {
/**
* Sends a request based on endpoint options
*
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<T = any, O extends RequestParameters = RequestParameters>(options: O & {
method?: string;
} & ("url" extends keyof D ? {
url?: string;
} : {
url: string;
})): Promise<OctokitResponse<T>>;
/**
* Sends a request based on endpoint options
*
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<R extends Route>(route: keyof Endpoints | R, options?: R extends keyof Endpoints ? Endpoints[R]["parameters"] & RequestParameters : RequestParameters): R extends keyof Endpoints ? Promise<Endpoints[R]["response"]> : Promise<OctokitResponse<any>>;
/**
* Returns a new `request` with updated route and parameters
*/
defaults: <O extends RequestParameters = RequestParameters>(newDefaults: O) => RequestInterface<D & O>;
/**
* Octokit endpoint API, see {@link https://github.com/octokit/endpoint.js|@octokit/endpoint}
*/
endpoint: EndpointInterface<D>;
}

View file

@ -0,0 +1,4 @@
/**
* HTTP Verb supported by GitHub's REST API
*/
export type RequestMethod = "DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT";

View file

@ -0,0 +1,14 @@
import type { RequestHeaders } from "./RequestHeaders.js";
import type { RequestMethod } from "./RequestMethod.js";
import type { RequestRequestOptions } from "./RequestRequestOptions.js";
import type { Url } from "./Url.js";
/**
* Generic request options as they are returned by the `endpoint()` method
*/
export type RequestOptions = {
method: RequestMethod;
url: Url;
headers: RequestHeaders;
body?: any;
request?: RequestRequestOptions;
};

View file

@ -0,0 +1,55 @@
import type { RequestRequestOptions } from "./RequestRequestOptions.js";
import type { RequestHeaders } from "./RequestHeaders.js";
import type { Url } from "./Url.js";
/**
* Parameters that can be passed into `request(route, parameters)` or `endpoint(route, parameters)` methods
*/
export type RequestParameters = {
/**
* Base URL to be used when a relative URL is passed, such as `/orgs/{org}`.
* If `baseUrl` is `https://enterprise.acme-inc.com/api/v3`, then the request
* will be sent to `https://enterprise.acme-inc.com/api/v3/orgs/{org}`.
*/
baseUrl?: Url;
/**
* HTTP headers. Use lowercase keys.
*/
headers?: RequestHeaders;
/**
* Media type options, see {@link https://developer.github.com/v3/media/|GitHub Developer Guide}
*/
mediaType?: {
/**
* `json` by default. Can be `raw`, `text`, `html`, `full`, `diff`, `patch`, `sha`, `base64`. Depending on endpoint
*/
format?: string;
/**
* Custom media type names of {@link https://docs.github.com/en/graphql/overview/schema-previews|GraphQL API Previews} without the `-preview` suffix.
* Example for single preview: `['squirrel-girl']`.
* Example for multiple previews: `['squirrel-girl', 'mister-fantastic']`.
*/
previews?: string[];
};
/**
* The name of the operation to execute.
* Required only if multiple operations are present in the query document.
*/
operationName?: string;
/**
* The GraphQL query string to be sent in the request.
* This is required and must contain a valid GraphQL document.
*/
query?: string;
/**
* Pass custom meta information for the request. The `request` object will be returned as is.
*/
request?: RequestRequestOptions;
/**
* Any additional parameter will be passed as follows
* 1. URL parameter if `':parameter'` or `{parameter}` is part of `url`
* 2. Query parameter if `method` is `'GET'` or `'HEAD'`
* 3. Request body if `parameter` is `'data'`
* 4. JSON in the request body in the form of `body[parameter]` unless `parameter` key is `'data'`
*/
[parameter: string]: unknown;
};

View file

@ -0,0 +1,20 @@
import type { Fetch } from "./Fetch.js";
/**
* Octokit-specific request options which are ignored for the actual request, but can be used by Octokit or plugins to manipulate how the request is sent or how a response is handled
*/
export type RequestRequestOptions = {
/**
* Custom replacement for built-in fetch method. Useful for testing or request hooks.
*/
fetch?: Fetch;
/**
* Use an `AbortController` instance to cancel a request. In node you can only cancel streamed requests.
*/
signal?: AbortSignal;
/**
* If set to `false`, the response body will not be parsed and will be returned as a stream.
*/
parseSuccessResponseBody?: boolean;
redirect?: "follow" | "error" | "manual";
[option: string]: any;
};

View file

@ -0,0 +1,21 @@
export type ResponseHeaders = {
"cache-control"?: string;
"content-length"?: number;
"content-type"?: string;
date?: string;
etag?: string;
"last-modified"?: string;
link?: string;
location?: string;
server?: string;
status?: string;
vary?: string;
"x-accepted-github-permissions"?: string;
"x-github-mediatype"?: string;
"x-github-request-id"?: string;
"x-oauth-scopes"?: string;
"x-ratelimit-limit"?: string;
"x-ratelimit-remaining"?: string;
"x-ratelimit-reset"?: string;
[header: string]: string | number | undefined;
};

View file

@ -0,0 +1,4 @@
/**
* String consisting of an optional HTTP method and relative path or absolute URL. Examples: `'/orgs/{org}'`, `'PUT /orgs/{org}'`, `GET https://example.com/foo/bar`
*/
export type Route = string;

View file

@ -0,0 +1,4 @@
import type { AuthInterface } from "./AuthInterface.js";
export interface StrategyInterface<StrategyOptions extends any[], AuthOptions extends any[], Authentication extends object> {
(...args: StrategyOptions): AuthInterface<AuthOptions, Authentication>;
}

View file

@ -0,0 +1,4 @@
/**
* Relative or absolute URL. Examples: `'/orgs/{org}'`, `https://example.com/foo/bar`
*/
export type Url = string;

View file

@ -0,0 +1 @@
export declare const VERSION = "13.10.0";

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
export * from "./AuthInterface.js";
export * from "./EndpointDefaults.js";
export * from "./EndpointInterface.js";
export * from "./EndpointOptions.js";
export * from "./Fetch.js";
export * from "./OctokitResponse.js";
export * from "./RequestError.js";
export * from "./RequestHeaders.js";
export * from "./RequestInterface.js";
export * from "./RequestMethod.js";
export * from "./RequestOptions.js";
export * from "./RequestParameters.js";
export * from "./RequestRequestOptions.js";
export * from "./ResponseHeaders.js";
export * from "./Route.js";
export * from "./StrategyInterface.js";
export * from "./Url.js";
export * from "./VERSION.js";
export * from "./GetResponseTypeFromEndpointMethod.js";
export * from "./generated/Endpoints.js";

View file

@ -0,0 +1,7 @@
Copyright 2020 Gregor Martynus
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,17 @@
# @octokit/openapi-types
> Generated TypeScript definitions based on GitHub's OpenAPI spec
This package is continuously updated based on [GitHub's OpenAPI specification](https://github.com/github/rest-api-description/)
## Usage
```ts
import { components } from "@octokit/openapi-types";
type Repository = components["schemas"]["full-repository"];
```
## License
[MIT](LICENSE)

View file

@ -0,0 +1,21 @@
{
"name": "@octokit/openapi-types",
"description": "Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com",
"repository": {
"type": "git",
"url": "https://github.com/octokit/openapi-types.ts.git",
"directory": "packages/openapi-types"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"version": "24.2.0",
"main": "",
"types": "types.d.ts",
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"license": "MIT",
"octokit": {
"openapi-version": "18.2.0"
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,42 @@
{
"name": "@octokit/types",
"version": "13.10.0",
"publishConfig": {
"access": "public",
"provenance": true
},
"description": "Shared TypeScript definitions for Octokit projects",
"dependencies": {
"@octokit/openapi-types": "^24.2.0"
},
"repository": "github:octokit/types.ts",
"keywords": [
"github",
"api",
"sdk",
"toolkit",
"typescript"
],
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"license": "MIT",
"devDependencies": {
"@octokit/tsconfig": "^4.0.0",
"github-openapi-graphql-query": "^4.5.0",
"handlebars": "^4.7.6",
"npm-run-all2": "^7.0.0",
"prettier": "^3.0.0",
"semantic-release": "^24.0.0",
"semantic-release-plugin-update-version-in-files": "^2.0.0",
"sort-keys": "^5.0.0",
"typedoc": "^0.26.0",
"typescript": "^5.0.0"
},
"octokit": {
"openapi-version": "18.2.0"
},
"files": [
"dist-types/**"
],
"types": "dist-types/index.d.ts",
"sideEffects": false
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -4688,9 +4688,12 @@ var sortCalcValues = (values = [], finalize = false) => {
operator = "";
}
}
resolvedValue = finalizedValues.join(" ");
resolvedValue = finalizedValues.join(" ").replace(/\+\s-/g, "- ");
} else {
resolvedValue = sortedValues.join(" ");
resolvedValue = sortedValues.join(" ").replace(/\+\s-/g, "- ");
}
if (resolvedValue.startsWith("(") && resolvedValue.endsWith(")") && resolvedValue.lastIndexOf("(") === 0 && resolvedValue.indexOf(")") === resolvedValue.length - 1) {
resolvedValue = resolvedValue.replace(/^\(/, "").replace(/\)$/, "");
}
return `${start}${resolvedValue}${end}`;
};
@ -4889,6 +4892,9 @@ var cssCalc = (value, opt = {}) => {
resolvedValue = `calc(${resolvedValue})`;
}
}
if (format === VAL_SPEC && /\s[-+*/]\s/.test(resolvedValue) && !resolvedValue.includes("NaN")) {
resolvedValue = serializeCalc(resolvedValue, opt);
}
setCache(cacheKey, resolvedValue);
return resolvedValue;
};

File diff suppressed because one or more lines are too long

View file

@ -633,9 +633,12 @@ const sortCalcValues = (values = [], finalize = false) => {
operator = "";
}
}
resolvedValue = finalizedValues.join(" ");
resolvedValue = finalizedValues.join(" ").replace(/\+\s-/g, "- ");
} else {
resolvedValue = sortedValues.join(" ");
resolvedValue = sortedValues.join(" ").replace(/\+\s-/g, "- ");
}
if (resolvedValue.startsWith("(") && resolvedValue.endsWith(")") && resolvedValue.lastIndexOf("(") === 0 && resolvedValue.indexOf(")") === resolvedValue.length - 1) {
resolvedValue = resolvedValue.replace(/^\(/, "").replace(/\)$/, "");
}
return `${start}${resolvedValue}${end}`;
};
@ -834,6 +837,9 @@ const cssCalc = (value, opt = {}) => {
resolvedValue = `calc(${resolvedValue})`;
}
}
if (format === VAL_SPEC && /\s[-+*/]\s/.test(resolvedValue) && !resolvedValue.includes("NaN")) {
resolvedValue = serializeCalc(resolvedValue, opt);
}
setCache(cacheKey, resolvedValue);
return resolvedValue;
};

File diff suppressed because one or more lines are too long

View file

@ -32,31 +32,30 @@
},
"./package.json": "./package.json"
},
"packageManager": "pnpm@10.6.1",
"packageManager": "pnpm@10.6.3",
"dependencies": {
"@csstools/css-calc": "^2.1.2",
"@csstools/css-color-parser": "^3.0.8",
"@csstools/css-calc": "^2.1.3",
"@csstools/css-color-parser": "^3.0.9",
"@csstools/css-parser-algorithms": "^3.0.4",
"@csstools/css-tokenizer": "^3.0.3",
"lru-cache": "^10.4.3"
},
"devDependencies": {
"@tanstack/vite-config": "^0.1.0",
"@vitest/coverage-istanbul": "^3.0.8",
"esbuild": "^0.25.0",
"eslint": "^9.22.0",
"eslint-plugin-import-x": "^4.6.1",
"@tanstack/vite-config": "^0.2.0",
"@vitest/coverage-istanbul": "^3.1.1",
"esbuild": "^0.25.2",
"eslint": "^9.25.0",
"eslint-plugin-regexp": "^2.7.0",
"globals": "^16.0.0",
"knip": "^5.45.0",
"knip": "^5.50.5",
"neostandard": "^0.12.1",
"prettier": "^3.5.3",
"publint": "^0.3.8",
"publint": "^0.3.12",
"rimraf": "^6.0.1",
"tsup": "^8.4.0",
"typescript": "^5.8.2",
"vite": "^6.2.1",
"vitest": "^3.0.8"
"typescript": "^5.8.3",
"vite": "^6.3.2",
"vitest": "^3.1.1"
},
"scripts": {
"build": "pnpm run clean && pnpm run test && pnpm run knip && pnpm run build:prod && pnpm run build:cjs && pnpm run build:browser && pnpm run publint",
@ -72,5 +71,5 @@
"test:types": "tsc",
"test:unit": "vitest"
},
"version": "3.1.1"
"version": "3.1.3"
}

View file

@ -694,9 +694,17 @@ export const sortCalcValues = (
operator = '';
}
}
resolvedValue = finalizedValues.join(' ');
resolvedValue = finalizedValues.join(' ').replace(/\+\s-/g, '- ');
} else {
resolvedValue = sortedValues.join(' ');
resolvedValue = sortedValues.join(' ').replace(/\+\s-/g, '- ');
}
if (
resolvedValue.startsWith('(') &&
resolvedValue.endsWith(')') &&
resolvedValue.lastIndexOf('(') === 0 &&
resolvedValue.indexOf(')') === resolvedValue.length - 1
) {
resolvedValue = resolvedValue.replace(/^\(/, '').replace(/\)$/, '');
}
return `${start}${resolvedValue}${end}`;
};
@ -943,6 +951,13 @@ export const cssCalc = (value: string, opt: Options = {}): string => {
resolvedValue = `calc(${resolvedValue})`;
}
}
if (
format === VAL_SPEC &&
/\s[-+*/]\s/.test(resolvedValue) &&
!resolvedValue.includes('NaN')
) {
resolvedValue = serializeCalc(resolvedValue, opt);
}
setCache(cacheKey, resolvedValue);
return resolvedValue;
};

View file

@ -1,9 +1,10 @@
# Changes to CSS Calc
### 2.1.2
### 2.1.3
_February 23, 2025_
_April 19, 2025_
- Update `random()` to correctly handle extremely large ranges or extremely tiny steps.
- Update `random()` to better handle floating point errors.
- Update `random()` to match the latest [specification](https://drafts.csswg.org/css-values-5/#randomness)
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md)

View file

@ -1,7 +1,7 @@
# CSS Calc <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-calc.svg" height="20">][npm-url]
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
Implemented from : https://drafts.csswg.org/css-values-4/ on 2023-02-17

File diff suppressed because one or more lines are too long

View file

@ -40,9 +40,28 @@ export declare type conversionOptions = {
*/
rawPercentages?: boolean;
/**
* Seed the pseudo random number generator used in `random()`
* The values used to generate random value cache keys.
*/
randomSeed?: number;
randomCaching?: {
/**
* The name of the property the random function is used in.
*/
propertyName: string;
/**
* N is the index of the random function among other random functions in the same property value.
*/
propertyN: number;
/**
* An element ID identifying the element the style is being applied to.
* When omitted any `random()` call will not be computed.
*/
elementID: string;
/**
* A document ID identifying the Document the styles are from.
* When omitted any `random()` call will not be computed.
*/
documentID: string;
};
};
export declare type GlobalsWithStrings = Map<string, TokenDimension | TokenNumber | TokenPercentage | string>;

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
{
"name": "@csstools/css-calc",
"description": "Solve CSS math expressions",
"version": "2.1.2",
"version": "2.1.3",
"contributors": [
{
"name": "Antonio Laguna",

View file

@ -1,11 +1,10 @@
# Changes to CSS Color Parser
### 3.0.8
### 3.0.9
_February 23, 2025_
_April 19, 2025_
- Use `Number.isNaN` instead of `NaN` for consistency.
- Updated [`@csstools/color-helpers`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers) to [`5.0.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers/CHANGELOG.md#502) (patch)
- Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`2.1.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#212) (patch)
- Drop the `max` keyword for `contrast-color( <color> )`
- Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`2.1.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#213) (patch)
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md)

View file

@ -1,7 +1,7 @@
# CSS Color Parser <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-color-parser.svg" height="20">][npm-url]
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
## Usage

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,7 +1,7 @@
{
"name": "@csstools/css-color-parser",
"description": "Parse CSS color values",
"version": "3.0.8",
"version": "3.0.9",
"contributors": [
{
"name": "Antonio Laguna",
@ -49,7 +49,7 @@
],
"dependencies": {
"@csstools/color-helpers": "^5.0.2",
"@csstools/css-calc": "^2.1.2"
"@csstools/css-calc": "^2.1.3"
},
"peerDependencies": {
"@csstools/css-parser-algorithms": "^3.0.4",

View file

@ -1,6 +1,6 @@
{
"name": "@eslint/js",
"version": "9.24.0",
"version": "9.25.1",
"description": "ESLint JavaScript language implementation",
"main": "./src/index.js",
"types": "./types/index.d.ts",

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

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