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,CAAC;SACD,CAAC,EACF;YACC,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,OAAO,EAAE,QAAQ,CAAC,OAAO;SACzB,CACD,CAAC;IACH,CAAC;CACD","sourcesContent":["import {HTTPError} from '../errors/HTTPError.js';\nimport {TimeoutError} from '../errors/TimeoutError.js';\nimport type {Hooks} from '../types/hooks.js';\nimport type {Input, InternalOptions, NormalizedOptions, Options, SearchParamsInit} from '../types/options.js';\nimport {ResponsePromise} from '../types/ResponsePromise.js';\nimport {deepMerge, mergeHeaders} from '../utils/merge.js';\nimport {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';\nimport timeout, {TimeoutOptions} from '../utils/timeout.js';\nimport delay from '../utils/delay.js';\nimport {ObjectEntries} from '../utils/types.js';\nimport {\n\tmaxSafeTimeout,\n\tresponseTypes,\n\tstop,\n\tsupportsAbortController,\n\tsupportsFormData,\n\tsupportsResponseStreams,\n\tsupportsRequestStreams,\n} from './constants.js';\n\nexport class Ky {\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\tstatic create(input: Input, options: Options): ResponsePromise {\n\t\tconst ky = new Ky(input, options);\n\n\t\tconst fn = async (): Promise => {\n\t\t\tif (ky._options.timeout > maxSafeTimeout) {\n\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t}\n\n\t\t\t// Delay the fetch so that body method shortcuts can set the Accept header\n\t\t\tawait Promise.resolve();\n\t\t\tlet response = await ky._fetch();\n\n\t\t\tfor (const hook of ky._options.hooks.afterResponse) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\tky.request,\n\t\t\t\t\tky._options as NormalizedOptions,\n\t\t\t\t\tky._decorateResponse(response.clone()),\n\t\t\t\t);\n\n\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tky._decorateResponse(response);\n\n\t\t\tif (!response.ok && ky._options.throwHttpErrors) {\n\t\t\t\tlet error = new HTTPError(response, ky.request, (ky._options as unknown) as NormalizedOptions);\n\n\t\t\t\tfor (const hook of ky._options.hooks.beforeError) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\terror = await hook(error);\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t/* istanbul ignore next */\n\t\t\tif (ky._options.onDownloadProgress) {\n\t\t\t\tif (typeof ky._options.onDownloadProgress !== 'function') {\n\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t}\n\n\t\t\t\tif (!supportsResponseStreams) {\n\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t}\n\n\t\t\t\treturn ky._stream(response.clone(), ky._options.onDownloadProgress);\n\t\t\t}\n\n\t\t\treturn response;\n\t\t};\n\n\t\tconst isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n\t\tconst result = (isRetriableMethod ? ky._retry(fn) : fn()) as ResponsePromise;\n\n\t\tfor (const [type, mimeType] of Object.entries(responseTypes) as ObjectEntries) {\n\t\t\tresult[type] = async () => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\t\tky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n\n\t\t\t\tconst awaitedResult = await result;\n\t\t\t\tconst response = awaitedResult.clone();\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst arrayBuffer = await response.clone().arrayBuffer();\n\t\t\t\t\tconst responseSize = arrayBuffer.byteLength;\n\t\t\t\t\tif (responseSize === 0) {\n\t\t\t\t\t\treturn '';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn response[type]();\n\t\t\t};\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tpublic request: Request;\n\tprotected abortController?: AbortController;\n\tprotected _retryCount = 0;\n\tprotected _input: Input;\n\tprotected _options: InternalOptions;\n\n\t// eslint-disable-next-line complexity\n\tconstructor(input: Input, options: Options = {}) {\n\t\tthis._input = input;\n\t\tthis._options = {\n\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\tcredentials: (this._input as Request).credentials || 'same-origin',\n\t\t\t...options,\n\t\t\theaders: mergeHeaders((this._input as Request).headers, options.headers),\n\t\t\thooks: deepMerge>(\n\t\t\t\t{\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tbeforeError: [],\n\t\t\t\t\tafterResponse: [],\n\t\t\t\t},\n\t\t\t\toptions.hooks,\n\t\t\t),\n\t\t\tmethod: normalizeRequestMethod(options.method ?? (this._input as Request).method),\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\ttimeout: typeof options.timeout === 'undefined' ? 10_000 : options.timeout,\n\t\t\tfetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n\t\t};\n\n\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t}\n\n\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t}\n\n\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t}\n\n\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t}\n\n\t\tif (supportsAbortController) {\n\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\tif (this._options.signal) {\n\t\t\t\tconst originalSignal = this._options.signal;\n\n\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\tthis.abortController!.abort(originalSignal.reason);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._options.signal = this.abortController.signal;\n\t\t}\n\n\t\tif (supportsRequestStreams) {\n\t\t\t// @ts-expect-error - Types are outdated.\n\t\t\tthis._options.duplex = 'half';\n\t\t}\n\n\t\tthis.request = new globalThis.Request(this._input as RequestInfo, this._options as RequestInit);\n\n\t\tif (this._options.searchParams) {\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string'\n\t\t\t\t? this._options.searchParams.replace(/^\\?/, '')\n\t\t\t\t: new URLSearchParams(this._options.searchParams as unknown as SearchParamsInit).toString();\n\t\t\t// eslint-disable-next-line unicorn/prevent-abbreviations\n\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\tif (\n\t\t\t\t((supportsFormData && this._options.body instanceof globalThis.FormData)\n\t\t\t\t\t|| this._options.body instanceof URLSearchParams) && !(this._options.headers && (this._options.headers as Record)['content-type'])\n\t\t\t) {\n\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t}\n\n\t\t\t// The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, {...this.request}), this._options as RequestInit);\n\t\t}\n\n\t\tif (this._options.json !== undefined) {\n\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\tthis.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t}\n\t}\n\n\tprotected _calculateRetryDelay(error: unknown) {\n\t\tthis._retryCount++;\n\n\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\tif (error instanceof HTTPError) {\n\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (typeof this._options.retry.maxRetryAfter !== 'undefined' && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn after;\n\t\t\t\t}\n\n\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst BACKOFF_FACTOR = 0.3;\n\t\t\treturn Math.min(this._options.retry.backoffLimit, BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000);\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprotected _decorateResponse(response: Response): Response {\n\t\tif (this._options.parseJson) {\n\t\t\tresponse.json = async () => this._options.parseJson!(await response.text());\n\t\t}\n\n\t\treturn response;\n\t}\n\n\tprotected async _retry Promise>(fn: T): Promise | void> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-implicit-any-catch\n\t\t} catch (error) {\n\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\tawait delay(ms, {signal: this._options.signal});\n\n\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\toptions: (this._options as unknown) as NormalizedOptions,\n\t\t\t\t\t\terror: error as Error,\n\t\t\t\t\t\tretryCount: this._retryCount,\n\t\t\t\t\t});\n\n\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn this._retry(fn);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprotected async _fetch(): Promise {\n\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tconst result = await hook(this.request, (this._options as unknown) as NormalizedOptions);\n\n\t\t\tif (result instanceof Request) {\n\t\t\t\tthis.request = result;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (result instanceof Response) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\n\t\tif (this._options.timeout === false) {\n\t\t\treturn this._options.fetch(this.request.clone());\n\t\t}\n\n\t\treturn timeout(this.request.clone(), this.abortController, this._options as TimeoutOptions);\n\t}\n\n\t/* istanbul ignore next */\n\tprotected _stream(response: Response, onDownloadProgress: Options['onDownloadProgress']) {\n\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\tlet transferredBytes = 0;\n\n\t\tif (response.status === 204) {\n\t\t\tif (onDownloadProgress) {\n\t\t\t\tonDownloadProgress({percent: 1, totalBytes, transferredBytes}, new Uint8Array());\n\t\t\t}\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\treturn new globalThis.Response(\n\t\t\tnew globalThis.ReadableStream({\n\t\t\t\tasync start(controller) {\n\t\t\t\t\tconst reader = response.body!.getReader();\n\n\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t}\n\n\t\t\t\t\tasync function read() {\n\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\n\t\t\t\t\tawait read();\n\t\t\t\t},\n\t\t\t}),\n\t\t\t{\n\t\t\t\tstatus: response.status,\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\theaders: response.headers,\n\t\t\t},\n\t\t);\n\t}\n}\n"]}