From dd5fefbe63cdf5217e6b8598b52bd7d20d648f51 Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Thu, 14 Mar 2024 09:02:13 +0000 Subject: [PATCH] npm libs --- lib/axios.d.ts | 35 ++++++++++++++++++++++------------- lib/htmlparser2.d.ts | 30 ++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/lib/axios.d.ts b/lib/axios.d.ts index e8a97d47..cfd7c15f 100644 --- a/lib/axios.d.ts +++ b/lib/axios.d.ts @@ -10,22 +10,24 @@ type MethodsHeaders = Partial<{ [Key in Method as Lowercase]: AxiosHeaders; } & {common: AxiosHeaders}>; -type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean; +type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean); + +type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any; export class AxiosHeaders { constructor( - headers?: RawAxiosHeaders | AxiosHeaders + headers?: RawAxiosHeaders | AxiosHeaders | string ); [key: string]: any; set(headerName?: string, value?: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; - set(headers?: RawAxiosHeaders | AxiosHeaders, rewrite?: boolean): AxiosHeaders; + set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders; get(headerName: string, parser: RegExp): RegExpExecArray | null; - get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue; + get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue; - has(header: string, matcher?: true | AxiosHeaderMatcher): boolean; + has(header: string, matcher?: AxiosHeaderMatcher): boolean; delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; @@ -120,10 +122,7 @@ export interface AxiosBasicCredentials { export interface AxiosProxyConfig { host: string; port: number; - auth?: { - username: string; - password: string; - }; + auth?: AxiosBasicCredentials; protocol?: string; } @@ -304,6 +303,15 @@ type AxiosAdapterName = 'xhr' | 'http' | string; type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName; +export type AddressFamily = 4 | 6 | undefined; + +export interface LookupAddressEntry { + address: string; + family?: AddressFamily; +} + +export type LookupAddress = string | LookupAddressEntry; + export interface AxiosRequestConfig { url?: string; method?: Method | string; @@ -330,7 +338,7 @@ export interface AxiosRequestConfig { maxBodyLength?: number; maxRedirects?: number; maxRate?: number | [MaxUploadRate, MaxDownloadRate]; - beforeRedirect?: (options: Record, responseDetails: { headers: Record }) => void; + beforeRedirect?: (options: Record, responseDetails: {headers: Record, statusCode: HttpStatusCode}) => void; socketPath?: string | null; transport?: any; httpAgent?: any; @@ -345,9 +353,10 @@ export interface AxiosRequestConfig { FormData?: new (...args: any[]) => object; }; formSerializer?: FormSerializerOptions; - family?: 4 | 6 | undefined; - lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: string, family: number) => void) => void) | - ((hostname: string, options: object) => Promise<[address: string, family: number] | string>); + family?: AddressFamily; + lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) | + ((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>); + withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined); } // Alias diff --git a/lib/htmlparser2.d.ts b/lib/htmlparser2.d.ts index 77aee4f8..e33a50a9 100644 --- a/lib/htmlparser2.d.ts +++ b/lib/htmlparser2.d.ts @@ -1,14 +1,15 @@ /* eslint-disable */ -import { Parser, ParserOptions } from "./Parser.js"; -export { Parser, type ParserOptions } from "./Parser.js"; -import { DomHandlerOptions, ChildNode, Element, Document } from "domhandler"; +import { Parser, type ParserOptions } from "./Parser.js"; +export type { Handler, ParserOptions } from "./Parser.js"; +export { Parser } from "./Parser.js"; +import { type DomHandlerOptions, type ChildNode, type Element, type Document } from "domhandler"; export { DomHandler, DomHandler as DefaultHandler, type DomHandlerOptions, } from "domhandler"; export type Options = ParserOptions & DomHandlerOptions; /** * Parses the data, returns the resulting document. * * @param data The data that should be parsed. - * @param options Optional options for the parser and DOM builder. + * @param options Optional options for the parser and DOM handler. */ export declare function parseDocument(data: string, options?: Options): Document; /** @@ -18,22 +19,31 @@ export declare function parseDocument(data: string, options?: Options): Document * Use `parseDocument` to get the `Document` node instead. * * @param data The data that should be parsed. - * @param options Optional options for the parser and DOM builder. + * @param options Optional options for the parser and DOM handler. * @deprecated Use `parseDocument` instead. */ export declare function parseDOM(data: string, options?: Options): ChildNode[]; /** * Creates a parser instance, with an attached DOM handler. * - * @param callback A callback that will be called once parsing has been completed. - * @param options Optional options for the parser and DOM builder. + * @param callback A callback that will be called once parsing has been completed, with the resulting document. + * @param options Optional options for the parser and DOM handler. * @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM. */ +export declare function createDocumentStream(callback: (error: Error | null, document: Document) => void, options?: Options, elementCallback?: (element: Element) => void): Parser; +/** + * Creates a parser instance, with an attached DOM handler. + * + * @param callback A callback that will be called once parsing has been completed, with an array of root nodes. + * @param options Optional options for the parser and DOM handler. + * @param elementCallback An optional callback that will be called every time a tag has been completed inside of the DOM. + * @deprecated Use `createDocumentStream` instead. + */ export declare function createDomStream(callback: (error: Error | null, dom: ChildNode[]) => void, options?: Options, elementCallback?: (element: Element) => void): Parser; -export { default as Tokenizer, type Callbacks as TokenizerCallbacks, } from "./Tokenizer.js"; +export { default as Tokenizer, type Callbacks as TokenizerCallbacks, QuoteType, } from "./Tokenizer.js"; export * as ElementType from "domelementtype"; -import { Feed } from "domutils"; -export { getFeed } from "domutils"; +import { type Feed } from "domutils"; +export { getFeed, type Feed } from "domutils"; /** * Parse a feed. *