@microlink/mql 0.10.32 → 0.10.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"mql.min.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
1
+ {"version":3,"file":"mql.min.mjs","sources":["../node_modules/.pnpm/url-http@1.0.14/node_modules/url-http/lightweight.js","../node_modules/.pnpm/flattie@1.1.0/node_modules/flattie/dist/index.js","../src/factory.js","../src/ky.js","../src/browser.js"],"sourcesContent":["'use strict'\n\nconst URL = globalThis ? globalThis.URL : require('url').URL\n\nconst REGEX_HTTP_PROTOCOL = /^https?:\\/\\//i\n\nmodule.exports = url => {\n try {\n const { href } = new URL(url)\n return REGEX_HTTP_PROTOCOL.test(href) && href\n } catch (err) {\n return false\n }\n}\n","function iter(output, nullish, sep, val, key) {\n\tvar k, pfx = key ? (key + sep) : key;\n\n\tif (val == null) {\n\t\tif (nullish) output[key] = val;\n\t} else if (typeof val != 'object') {\n\t\toutput[key] = val;\n\t} else if (Array.isArray(val)) {\n\t\tfor (k=0; k < val.length; k++) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t} else {\n\t\tfor (k in val) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t}\n}\n\nfunction flattie(input, glue, toNull) {\n\tvar output = {};\n\tif (typeof input == 'object') {\n\t\titer(output, !!toNull, glue || '.', input, '');\n\t}\n\treturn output;\n}\n\nexports.flattie = flattie;","const ENDPOINT = {\n FREE: 'https://api.microlink.io/',\n PRO: 'https://pro.microlink.io/'\n}\n\nconst isObject = input => input !== null && typeof input === 'object'\n\nconst isBuffer = input =>\n input != null &&\n input.constructor != null &&\n typeof input.constructor.isBuffer === 'function' &&\n input.constructor.isBuffer(input)\n\nconst parseBody = (input, error, url) => {\n try {\n return JSON.parse(input)\n } catch (_) {\n const message = input || error.message\n\n return {\n status: 'error',\n data: { url: message },\n more: 'https://microlink.io/efatalclient',\n code: 'EFATALCLIENT',\n message,\n url\n }\n }\n}\n\nconst factory = ({ VERSION, MicrolinkError, urlHttp, got, flatten }) => {\n const assertUrl = (url = '') => {\n if (!urlHttp(url)) {\n const message = `The \\`url\\` as \\`${url}\\` is not valid. Ensure it has protocol (http or https) and hostname.`\n throw new MicrolinkError({\n status: 'fail',\n data: { url: message },\n more: 'https://microlink.io/docs/api/api-parameters/url',\n code: 'EINVALURLCLIENT',\n message,\n url\n })\n }\n }\n\n const mapRules = rules => {\n if (!isObject(rules)) return\n const flatRules = flatten(rules)\n return Object.keys(flatRules).reduce((acc, key) => {\n acc[`data.${key}`] = flatRules[key].toString()\n return acc\n }, {})\n }\n\n const fetchFromApi = async (apiUrl, opts = {}) => {\n try {\n const response = await got(apiUrl, opts)\n return opts.responseType === 'buffer'\n ? { body: response.body, response }\n : { ...response.body, response }\n } catch (err) {\n const { response = {} } = err\n const {\n statusCode,\n body: rawBody,\n headers = {},\n url: uri = apiUrl\n } = response\n const isBodyBuffer = isBuffer(rawBody)\n\n const body =\n isObject(rawBody) && !isBodyBuffer\n ? rawBody\n : parseBody(isBodyBuffer ? rawBody.toString() : rawBody, err, uri)\n\n throw new MicrolinkError({\n ...body,\n message: body.message,\n url: uri,\n statusCode,\n headers\n })\n }\n }\n\n const getApiUrl = (\n url,\n { data, apiKey, endpoint, retry, cache, ...opts } = {},\n { responseType = 'json', headers: gotHeaders, ...gotOpts } = {}\n ) => {\n const isPro = !!apiKey\n const apiEndpoint = endpoint || ENDPOINT[isPro ? 'PRO' : 'FREE']\n\n const apiUrl = `${apiEndpoint}?${new URLSearchParams({\n url,\n ...mapRules(data),\n ...flatten(opts)\n }).toString()}`\n\n const headers = isPro\n ? { ...gotHeaders, 'x-api-key': apiKey }\n : { ...gotHeaders }\n return [apiUrl, { ...gotOpts, responseType, cache, retry, headers }]\n }\n\n const createMql = defaultOpts => async (url, opts, gotOpts) => {\n assertUrl(url)\n const [apiUrl, fetchOpts] = getApiUrl(url, opts, {\n ...defaultOpts,\n ...gotOpts\n })\n return fetchFromApi(apiUrl, fetchOpts)\n }\n\n const mql = createMql()\n mql.MicrolinkError = MicrolinkError\n mql.getApiUrl = getApiUrl\n mql.fetchFromApi = fetchFromApi\n mql.mapRules = mapRules\n mql.version = VERSION\n mql.stream = got.stream\n mql.buffer = createMql({ responseType: 'buffer' })\n\n return mql\n}\n\nmodule.exports = factory\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ky = {}));\n})(this, (function (exports) { 'use strict';\n\n // eslint-lint-disable-next-line @typescript-eslint/naming-convention\n class HTTPError extends Error {\n constructor(response, request, options) {\n const code = (response.status || response.status === 0) ? response.status : '';\n const title = response.statusText || '';\n const status = `${code} ${title}`.trim();\n const reason = status ? `status code ${status}` : 'an unknown error';\n super(`Request failed with ${reason}`);\n Object.defineProperty(this, \"response\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"request\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"options\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = 'HTTPError';\n this.response = response;\n this.request = request;\n this.options = options;\n }\n }\n\n class TimeoutError extends Error {\n constructor(request) {\n super('Request timed out');\n Object.defineProperty(this, \"request\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = 'TimeoutError';\n this.request = request;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n const isObject = (value) => value !== null && typeof value === 'object';\n\n const validateAndMerge = (...sources) => {\n for (const source of sources) {\n if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {\n throw new TypeError('The `options` argument must be an object');\n }\n }\n return deepMerge({}, ...sources);\n };\n const mergeHeaders = (source1 = {}, source2 = {}) => {\n const result = new globalThis.Headers(source1);\n const isHeadersInstance = source2 instanceof globalThis.Headers;\n const source = new globalThis.Headers(source2);\n for (const [key, value] of source.entries()) {\n if ((isHeadersInstance && value === 'undefined') || value === undefined) {\n result.delete(key);\n }\n else {\n result.set(key, value);\n }\n }\n return result;\n };\n // TODO: Make this strongly-typed (no `any`).\n const deepMerge = (...sources) => {\n let returnValue = {};\n let headers = {};\n for (const source of sources) {\n if (Array.isArray(source)) {\n if (!Array.isArray(returnValue)) {\n returnValue = [];\n }\n returnValue = [...returnValue, ...source];\n }\n else if (isObject(source)) {\n for (let [key, value] of Object.entries(source)) {\n if (isObject(value) && key in returnValue) {\n value = deepMerge(returnValue[key], value);\n }\n returnValue = { ...returnValue, [key]: value };\n }\n if (isObject(source.headers)) {\n headers = mergeHeaders(headers, source.headers);\n returnValue.headers = headers;\n }\n }\n }\n return returnValue;\n };\n\n const supportsRequestStreams = (() => {\n let duplexAccessed = false;\n let hasContentType = false;\n const supportsReadableStream = typeof globalThis.ReadableStream === 'function';\n const supportsRequest = typeof globalThis.Request === 'function';\n if (supportsReadableStream && supportsRequest) {\n hasContentType = new globalThis.Request('https://empty.invalid', {\n body: new globalThis.ReadableStream(),\n method: 'POST',\n // @ts-expect-error - Types are outdated.\n get duplex() {\n duplexAccessed = true;\n return 'half';\n },\n }).headers.has('Content-Type');\n }\n return duplexAccessed && !hasContentType;\n })();\n const supportsAbortController = typeof globalThis.AbortController === 'function';\n const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';\n const supportsFormData = typeof globalThis.FormData === 'function';\n const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'];\n const responseTypes = {\n json: 'application/json',\n text: 'text/*',\n formData: 'multipart/form-data',\n arrayBuffer: '*/*',\n blob: '*/*',\n };\n // The maximum value of a 32bit int (see issue #117)\n const maxSafeTimeout = 2147483647;\n const stop = Symbol('stop');\n\n const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;\n const retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n const retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n const retryAfterStatusCodes = [413, 429, 503];\n const defaultRetryOptions = {\n limit: 2,\n methods: retryMethods,\n statusCodes: retryStatusCodes,\n afterStatusCodes: retryAfterStatusCodes,\n maxRetryAfter: Number.POSITIVE_INFINITY,\n backoffLimit: Number.POSITIVE_INFINITY,\n };\n const normalizeRetryOptions = (retry = {}) => {\n if (typeof retry === 'number') {\n return {\n ...defaultRetryOptions,\n limit: retry,\n };\n }\n if (retry.methods && !Array.isArray(retry.methods)) {\n throw new Error('retry.methods must be an array');\n }\n if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n throw new Error('retry.statusCodes must be an array');\n }\n return {\n ...defaultRetryOptions,\n ...retry,\n afterStatusCodes: retryAfterStatusCodes,\n };\n };\n\n // `Promise.race()` workaround (#91)\n async function timeout(request, abortController, options) {\n return new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n if (abortController) {\n abortController.abort();\n }\n reject(new TimeoutError(request));\n }, options.timeout);\n void options\n .fetch(request)\n .then(resolve)\n .catch(reject)\n .then(() => {\n clearTimeout(timeoutId);\n });\n });\n }\n\n // https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111\n async function delay(ms, { signal }) {\n return new Promise((resolve, reject) => {\n if (signal) {\n signal.throwIfAborted();\n signal.addEventListener('abort', abortHandler, { once: true });\n }\n function abortHandler() {\n clearTimeout(timeoutId);\n reject(signal.reason);\n }\n const timeoutId = setTimeout(() => {\n signal?.removeEventListener('abort', abortHandler);\n resolve();\n }, ms);\n });\n }\n\n class Ky {\n static create(input, options) {\n const ky = new Ky(input, options);\n const fn = async () => {\n if (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {\n throw new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n }\n // Delay the fetch so that body method shortcuts can set the Accept header\n await Promise.resolve();\n let response = await ky._fetch();\n for (const hook of ky._options.hooks.afterResponse) {\n // eslint-disable-next-line no-await-in-loop\n const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));\n if (modifiedResponse instanceof globalThis.Response) {\n response = modifiedResponse;\n }\n }\n ky._decorateResponse(response);\n if (!response.ok && ky._options.throwHttpErrors) {\n let error = new HTTPError(response, ky.request, ky._options);\n for (const hook of ky._options.hooks.beforeError) {\n // eslint-disable-next-line no-await-in-loop\n error = await hook(error);\n }\n throw error;\n }\n // If `onDownloadProgress` is passed, it uses the stream API internally\n /* istanbul ignore next */\n if (ky._options.onDownloadProgress) {\n if (typeof ky._options.onDownloadProgress !== 'function') {\n throw new TypeError('The `onDownloadProgress` option must be a function');\n }\n if (!supportsResponseStreams) {\n throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n }\n return ky._stream(response.clone(), ky._options.onDownloadProgress);\n }\n return response;\n };\n const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n const result = (isRetriableMethod ? ky._retry(fn) : fn());\n for (const [type, mimeType] of Object.entries(responseTypes)) {\n result[type] = async () => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n const awaitedResult = await result;\n const response = awaitedResult.clone();\n if (type === 'json') {\n if (response.status === 204) {\n return '';\n }\n const arrayBuffer = await response.clone().arrayBuffer();\n const responseSize = arrayBuffer.byteLength;\n if (responseSize === 0) {\n return '';\n }\n if (options.parseJson) {\n return options.parseJson(await response.text());\n }\n }\n return response[type]();\n };\n }\n return result;\n }\n // eslint-disable-next-line complexity\n constructor(input, options = {}) {\n Object.defineProperty(this, \"request\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"abortController\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"_retryCount\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 0\n });\n Object.defineProperty(this, \"_input\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"_options\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this._input = input;\n this._options = {\n // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n credentials: this._input.credentials || 'same-origin',\n ...options,\n headers: mergeHeaders(this._input.headers, options.headers),\n hooks: deepMerge({\n beforeRequest: [],\n beforeRetry: [],\n beforeError: [],\n afterResponse: [],\n }, options.hooks),\n method: normalizeRequestMethod(options.method ?? this._input.method),\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n prefixUrl: String(options.prefixUrl || ''),\n retry: normalizeRetryOptions(options.retry),\n throwHttpErrors: options.throwHttpErrors !== false,\n timeout: options.timeout ?? 10000,\n fetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n };\n if (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n throw new TypeError('`input` must be a string, URL, or Request');\n }\n if (this._options.prefixUrl && typeof this._input === 'string') {\n if (this._input.startsWith('/')) {\n throw new Error('`input` must not begin with a slash when using `prefixUrl`');\n }\n if (!this._options.prefixUrl.endsWith('/')) {\n this._options.prefixUrl += '/';\n }\n this._input = this._options.prefixUrl + this._input;\n }\n if (supportsAbortController) {\n this.abortController = new globalThis.AbortController();\n if (this._options.signal) {\n const originalSignal = this._options.signal;\n this._options.signal.addEventListener('abort', () => {\n this.abortController.abort(originalSignal.reason);\n });\n }\n this._options.signal = this.abortController.signal;\n }\n if (supportsRequestStreams) {\n // @ts-expect-error - Types are outdated.\n this._options.duplex = 'half';\n }\n this.request = new globalThis.Request(this._input, this._options);\n if (this._options.searchParams) {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const textSearchParams = typeof this._options.searchParams === 'string'\n ? this._options.searchParams.replace(/^\\?/, '')\n : new URLSearchParams(this._options.searchParams).toString();\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const searchParams = '?' + textSearchParams;\n const url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n // To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n if (((supportsFormData && this._options.body instanceof globalThis.FormData)\n || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {\n this.request.headers.delete('content-type');\n }\n // The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.\n this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);\n }\n if (this._options.json !== undefined) {\n this._options.body = JSON.stringify(this._options.json);\n this.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');\n this.request = new globalThis.Request(this.request, { body: this._options.body });\n }\n }\n _calculateRetryDelay(error) {\n this._retryCount++;\n if (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n if (error instanceof HTTPError) {\n if (!this._options.retry.statusCodes.includes(error.response.status)) {\n return 0;\n }\n const retryAfter = error.response.headers.get('Retry-After');\n if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n let after = Number(retryAfter);\n if (Number.isNaN(after)) {\n after = Date.parse(retryAfter) - Date.now();\n }\n else {\n after *= 1000;\n }\n if (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {\n return 0;\n }\n return after;\n }\n if (error.response.status === 413) {\n return 0;\n }\n }\n const BACKOFF_FACTOR = 0.3;\n return Math.min(this._options.retry.backoffLimit, BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000);\n }\n return 0;\n }\n _decorateResponse(response) {\n if (this._options.parseJson) {\n response.json = async () => this._options.parseJson(await response.text());\n }\n return response;\n }\n async _retry(fn) {\n try {\n return await fn();\n }\n catch (error) {\n const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n if (ms !== 0 && this._retryCount > 0) {\n await delay(ms, { signal: this._options.signal });\n for (const hook of this._options.hooks.beforeRetry) {\n // eslint-disable-next-line no-await-in-loop\n const hookResult = await hook({\n request: this.request,\n options: this._options,\n error: error,\n retryCount: this._retryCount,\n });\n // If `stop` is returned from the hook, the retry process is stopped\n if (hookResult === stop) {\n return;\n }\n }\n return this._retry(fn);\n }\n throw error;\n }\n }\n async _fetch() {\n for (const hook of this._options.hooks.beforeRequest) {\n // eslint-disable-next-line no-await-in-loop\n const result = await hook(this.request, this._options);\n if (result instanceof Request) {\n this.request = result;\n break;\n }\n if (result instanceof Response) {\n return result;\n }\n }\n if (this._options.timeout === false) {\n return this._options.fetch(this.request.clone());\n }\n return timeout(this.request.clone(), this.abortController, this._options);\n }\n /* istanbul ignore next */\n _stream(response, onDownloadProgress) {\n const totalBytes = Number(response.headers.get('content-length')) || 0;\n let transferredBytes = 0;\n if (response.status === 204) {\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());\n }\n return new globalThis.Response(null, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n return new globalThis.Response(new globalThis.ReadableStream({\n async start(controller) {\n const reader = response.body.getReader();\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());\n }\n async function read() {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n return;\n }\n if (onDownloadProgress) {\n transferredBytes += value.byteLength;\n const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n onDownloadProgress({ percent, transferredBytes, totalBytes }, value);\n }\n controller.enqueue(value);\n await read();\n }\n await read();\n },\n }), {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n }\n\n /*! MIT License © Sindre Sorhus */\n const createInstance = (defaults) => {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));\n for (const method of requestMethods) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));\n }\n ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));\n ky.extend = (newDefaults) => createInstance(validateAndMerge(defaults, newDefaults));\n ky.stop = stop;\n return ky;\n };\n const ky = createInstance();\n\n exports.HTTPError = HTTPError;\n exports.TimeoutError = TimeoutError;\n exports.default = ky;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n}));\n","'use strict'\n\nconst urlHttp = require('url-http/lightweight')\nconst { flattie: flatten } = require('flattie')\n\nconst factory = require('./factory')\nconst { default: ky } = require('./ky')\n\nclass MicrolinkError extends Error {\n constructor (props) {\n super()\n this.name = 'MicrolinkError'\n Object.assign(this, props)\n this.description = this.message\n this.message = this.code\n ? `${this.code}, ${this.description}`\n : this.description\n }\n}\n\nconst got = async (url, opts) => {\n try {\n if (opts.retry > 0) opts.retry = opts.retry + 1\n if (opts.timeout === undefined) opts.timeout = false\n const response = await ky(url, opts)\n const body = await response.json()\n const { headers, status: statusCode } = response\n return { url: response.url, body, headers, statusCode }\n } catch (err) {\n if (err.response) {\n const { response } = err\n err.response = {\n ...response,\n headers: Array.from(response.headers.entries()).reduce(\n (acc, [key, value]) => {\n acc[key] = value\n return acc\n },\n {}\n ),\n statusCode: response.status,\n body: await response.text()\n }\n }\n throw err\n }\n}\n\nmodule.exports = factory({\n MicrolinkError,\n urlHttp,\n got,\n flatten,\n VERSION: '__MQL_VERSION__'\n})\n"],"names":["URL","globalThis","REGEX_HTTP_PROTOCOL","iter","output","nullish","sep","val","key","k","pfx","Array","isArray","length","dist","flattie","input","glue","toNull","ENDPOINT","FREE","PRO","isObject","factory_1","VERSION","MicrolinkError","urlHttp","got","flatten","mapRules","rules","flatRules","Object","keys","reduce","acc","toString","fetchFromApi","async","apiUrl","opts","response","responseType","body","err","statusCode","rawBody","headers","url","uri","isBodyBuffer","constructor","isBuffer","error","JSON","parse","_","message","status","data","more","code","parseBody","getApiUrl","apiKey","endpoint","retry","cache","gotHeaders","gotOpts","isPro","URLSearchParams","createMql","defaultOpts","assertUrl","fetchOpts","mql","version","stream","buffer","exports","HTTPError","Error","request","options","statusText","trim","super","defineProperty","this","enumerable","configurable","writable","value","name","TimeoutError","validateAndMerge","sources","source","undefined","TypeError","deepMerge","mergeHeaders","source1","source2","result","Headers","isHeadersInstance","entries","delete","set","returnValue","supportsRequestStreams","duplexAccessed","hasContentType","supportsReadableStream","ReadableStream","supportsRequest","Request","method","duplex","has","supportsAbortController","AbortController","supportsResponseStreams","supportsFormData","FormData","requestMethods","responseTypes","json","text","formData","arrayBuffer","blob","maxSafeTimeout","stop","Symbol","normalizeRequestMethod","includes","toUpperCase","retryAfterStatusCodes","defaultRetryOptions","limit","methods","statusCodes","afterStatusCodes","maxRetryAfter","Number","POSITIVE_INFINITY","backoffLimit","normalizeRetryOptions","timeout","abortController","Promise","resolve","reject","timeoutId","setTimeout","abort","fetch","then","catch","clearTimeout","delay","ms","signal","abortHandler","reason","throwIfAborted","addEventListener","once","removeEventListener","Ky","create","ky","fn","_options","RangeError","_fetch","hook","hooks","afterResponse","modifiedResponse","_decorateResponse","clone","Response","ok","throwHttpErrors","beforeError","onDownloadProgress","_stream","toLowerCase","_retry","type","mimeType","get","byteLength","parseJson","_input","credentials","beforeRequest","beforeRetry","prefixUrl","String","bind","startsWith","endsWith","originalSignal","searchParams","replace","stringify","_calculateRetryDelay","_retryCount","retryAfter","after","isNaN","Date","now","BACKOFF_FACTOR","Math","min","retryCount","totalBytes","transferredBytes","percent","Uint8Array","start","controller","reader","getReader","read","done","close","enqueue","createInstance","defaults","newDefaults","extend","default","factory","href","test","require$$1","require$$2","require$$3","props","assign","description","from"],"mappings":"iPAEA,MAA4DA,EAAAC,WAAAD,IAEtDE,EAAsB,yBCJ5B,SAASC,EAAKC,EAAQC,EAASC,EAAKC,EAAKC,GACxC,IAAIC,EAAGC,EAAMF,EAAOA,EAAMF,EAAOE,EAEjC,GAAW,MAAPD,EACCF,IAASD,EAAOI,GAAOD,QACrB,GAAkB,iBAAPA,EACjBH,EAAOI,GAAOD,OACR,GAAII,MAA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OsE,EAExB,MAAM3N,UAAuByD,MAC3B,WAAA/B,CAAakM,GACX9J,QACAE,KAAKK,KAAO,iBACZ9D,OAAOsN,OAAO7J,KAAM4J,GACpB5J,KAAK8J,YAAc9J,KAAKhC,QACxBgC,KAAKhC,QAAUgC,KAAK5B,KAChB,GAAG4B,KAAK5B,SAAS4B,KAAK8J,cACtB9J,KAAK8J,WACV,UA+BcR,EAAQ,CACvBtN,iBACAC,UACAC,IA/BUW,MAAOU,EAAKR,KACtB,IACMA,EAAK0B,MAAQ,IAAG1B,EAAK0B,MAAQ1B,EAAK0B,MAAQ,QACzBiC,IAAjB3D,EAAK+G,UAAuB/G,EAAK+G,SAAU,GAC/C,MAAM9G,QAAiBqI,EAAG9H,EAAKR,GACzBG,QAAaF,EAASwF,QACtBlF,QAAEA,EAASW,OAAQb,GAAeJ,EACxC,MAAO,CAAEO,IAAKP,EAASO,IAAKL,OAAMI,UAASF,aAC5C,CAAC,MAAOD,GACP,GAAIA,EAAIH,SAAU,CAChB,MAAMA,SAAEA,GAAaG,EACrBA,EAAIH,SAAW,IACVA,EACHM,QAASpC,MAAM6O,KAAK/M,EAASM,QAAQ6D,WAAW1E,QAC9C,CAACC,GAAM3B,EAAKqF,MACV1D,EAAI3B,GAAOqF,EACJ1D,IAET,CAAE,GAEJU,WAAYJ,EAASiB,OACrBf,WAAYF,EAASyF,OAExB,CACD,MAAMtF,CACP,GAODhB,UACAJ,QAAS","x_google_ignoreList":[0,1]}
package/dist/mql.mjs CHANGED
@@ -1,5 +1,9 @@
1
1
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
2
 
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
3
7
  const URL$1 = globalThis.URL;
4
8
 
5
9
  const REGEX_HTTP_PROTOCOL = /^https?:\/\//i;
@@ -73,14 +77,7 @@ const parseBody = (input, error, url) => {
73
77
  }
74
78
  };
75
79
 
76
- const factory$1 = ({
77
- VERSION,
78
- MicrolinkError,
79
- urlHttp,
80
- stringify,
81
- got,
82
- flatten
83
- }) => {
80
+ const factory$1 = ({ VERSION, MicrolinkError, urlHttp, got, flatten }) => {
84
81
  const assertUrl = (url = '') => {
85
82
  if (!urlHttp(url)) {
86
83
  const message = `The \`url\` as \`${url}\` is not valid. Ensure it has protocol (http or https) and hostname.`;
@@ -104,7 +101,7 @@ const factory$1 = ({
104
101
  }, {})
105
102
  };
106
103
 
107
- const fetchFromApi = async (apiUrl, opts = {}, retryCount = 0) => {
104
+ const fetchFromApi = async (apiUrl, opts = {}) => {
108
105
  try {
109
106
  const response = await got(apiUrl, opts);
110
107
  return opts.responseType === 'buffer'
@@ -125,10 +122,6 @@ const factory$1 = ({
125
122
  ? rawBody
126
123
  : parseBody(isBodyBuffer ? rawBody.toString() : rawBody, err, uri);
127
124
 
128
- if (body.code === 'EFATALCLIENT' && retryCount++ < 2) {
129
- return fetchFromApi(apiUrl, opts, retryCount)
130
- }
131
-
132
125
  throw new MicrolinkError({
133
126
  ...body,
134
127
  message: body.message,
@@ -182,11 +175,7 @@ const factory$1 = ({
182
175
 
183
176
  var factory_1 = factory$1;
184
177
 
185
- var kyExports = {};
186
- var ky$1 = {
187
- get exports(){ return kyExports; },
188
- set exports(v){ kyExports = v; },
189
- };
178
+ var ky$1 = {exports: {}};
190
179
 
191
180
  (function (module, exports) {
192
181
  (function (global, factory) {
@@ -200,6 +189,24 @@ var ky$1 = {
200
189
  const status = `${code} ${title}`.trim();
201
190
  const reason = status ? `status code ${status}` : 'an unknown error';
202
191
  super(`Request failed with ${reason}`);
192
+ Object.defineProperty(this, "response", {
193
+ enumerable: true,
194
+ configurable: true,
195
+ writable: true,
196
+ value: void 0
197
+ });
198
+ Object.defineProperty(this, "request", {
199
+ enumerable: true,
200
+ configurable: true,
201
+ writable: true,
202
+ value: void 0
203
+ });
204
+ Object.defineProperty(this, "options", {
205
+ enumerable: true,
206
+ configurable: true,
207
+ writable: true,
208
+ value: void 0
209
+ });
203
210
  this.name = 'HTTPError';
204
211
  this.response = response;
205
212
  this.request = request;
@@ -210,6 +217,12 @@ var ky$1 = {
210
217
  class TimeoutError extends Error {
211
218
  constructor(request) {
212
219
  super('Request timed out');
220
+ Object.defineProperty(this, "request", {
221
+ enumerable: true,
222
+ configurable: true,
223
+ writable: true,
224
+ value: void 0
225
+ });
213
226
  this.name = 'TimeoutError';
214
227
  this.request = request;
215
228
  }
@@ -220,7 +233,7 @@ var ky$1 = {
220
233
 
221
234
  const validateAndMerge = (...sources) => {
222
235
  for (const source of sources) {
223
- if ((!isObject(source) || Array.isArray(source)) && typeof source !== 'undefined') {
236
+ if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {
224
237
  throw new TypeError('The `options` argument must be an object');
225
238
  }
226
239
  }
@@ -267,8 +280,26 @@ var ky$1 = {
267
280
  return returnValue;
268
281
  };
269
282
 
283
+ const supportsRequestStreams = (() => {
284
+ let duplexAccessed = false;
285
+ let hasContentType = false;
286
+ const supportsReadableStream = typeof globalThis.ReadableStream === 'function';
287
+ const supportsRequest = typeof globalThis.Request === 'function';
288
+ if (supportsReadableStream && supportsRequest) {
289
+ hasContentType = new globalThis.Request('https://empty.invalid', {
290
+ body: new globalThis.ReadableStream(),
291
+ method: 'POST',
292
+ // @ts-expect-error - Types are outdated.
293
+ get duplex() {
294
+ duplexAccessed = true;
295
+ return 'half';
296
+ },
297
+ }).headers.has('Content-Type');
298
+ }
299
+ return duplexAccessed && !hasContentType;
300
+ })();
270
301
  const supportsAbortController = typeof globalThis.AbortController === 'function';
271
- const supportsStreams = typeof globalThis.ReadableStream === 'function';
302
+ const supportsResponseStreams = typeof globalThis.ReadableStream === 'function';
272
303
  const supportsFormData = typeof globalThis.FormData === 'function';
273
304
  const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'];
274
305
  const responseTypes = {
@@ -292,6 +323,7 @@ var ky$1 = {
292
323
  statusCodes: retryStatusCodes,
293
324
  afterStatusCodes: retryAfterStatusCodes,
294
325
  maxRetryAfter: Number.POSITIVE_INFINITY,
326
+ backoffLimit: Number.POSITIVE_INFINITY,
295
327
  };
296
328
  const normalizeRetryOptions = (retry = {}) => {
297
329
  if (typeof retry === 'number') {
@@ -314,30 +346,139 @@ var ky$1 = {
314
346
  };
315
347
 
316
348
  // `Promise.race()` workaround (#91)
317
- const timeout = async (request, abortController, options) => new Promise((resolve, reject) => {
318
- const timeoutId = setTimeout(() => {
319
- if (abortController) {
320
- abortController.abort();
349
+ async function timeout(request, abortController, options) {
350
+ return new Promise((resolve, reject) => {
351
+ const timeoutId = setTimeout(() => {
352
+ if (abortController) {
353
+ abortController.abort();
354
+ }
355
+ reject(new TimeoutError(request));
356
+ }, options.timeout);
357
+ void options
358
+ .fetch(request)
359
+ .then(resolve)
360
+ .catch(reject)
361
+ .then(() => {
362
+ clearTimeout(timeoutId);
363
+ });
364
+ });
365
+ }
366
+
367
+ // https://github.com/sindresorhus/delay/tree/ab98ae8dfcb38e1593286c94d934e70d14a4e111
368
+ async function delay(ms, { signal }) {
369
+ return new Promise((resolve, reject) => {
370
+ if (signal) {
371
+ signal.throwIfAborted();
372
+ signal.addEventListener('abort', abortHandler, { once: true });
373
+ }
374
+ function abortHandler() {
375
+ clearTimeout(timeoutId);
376
+ reject(signal.reason);
321
377
  }
322
- reject(new TimeoutError(request));
323
- }, options.timeout);
324
- void options
325
- .fetch(request)
326
- .then(resolve)
327
- .catch(reject)
328
- .then(() => {
329
- clearTimeout(timeoutId);
378
+ const timeoutId = setTimeout(() => {
379
+ signal?.removeEventListener('abort', abortHandler);
380
+ resolve();
381
+ }, ms);
330
382
  });
331
- });
332
- const delay = async (ms) => new Promise(resolve => {
333
- setTimeout(resolve, ms);
334
- });
383
+ }
335
384
 
336
385
  class Ky {
386
+ static create(input, options) {
387
+ const ky = new Ky(input, options);
388
+ const fn = async () => {
389
+ if (typeof ky._options.timeout === 'number' && ky._options.timeout > maxSafeTimeout) {
390
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
391
+ }
392
+ // Delay the fetch so that body method shortcuts can set the Accept header
393
+ await Promise.resolve();
394
+ let response = await ky._fetch();
395
+ for (const hook of ky._options.hooks.afterResponse) {
396
+ // eslint-disable-next-line no-await-in-loop
397
+ const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));
398
+ if (modifiedResponse instanceof globalThis.Response) {
399
+ response = modifiedResponse;
400
+ }
401
+ }
402
+ ky._decorateResponse(response);
403
+ if (!response.ok && ky._options.throwHttpErrors) {
404
+ let error = new HTTPError(response, ky.request, ky._options);
405
+ for (const hook of ky._options.hooks.beforeError) {
406
+ // eslint-disable-next-line no-await-in-loop
407
+ error = await hook(error);
408
+ }
409
+ throw error;
410
+ }
411
+ // If `onDownloadProgress` is passed, it uses the stream API internally
412
+ /* istanbul ignore next */
413
+ if (ky._options.onDownloadProgress) {
414
+ if (typeof ky._options.onDownloadProgress !== 'function') {
415
+ throw new TypeError('The `onDownloadProgress` option must be a function');
416
+ }
417
+ if (!supportsResponseStreams) {
418
+ throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');
419
+ }
420
+ return ky._stream(response.clone(), ky._options.onDownloadProgress);
421
+ }
422
+ return response;
423
+ };
424
+ const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());
425
+ const result = (isRetriableMethod ? ky._retry(fn) : fn());
426
+ for (const [type, mimeType] of Object.entries(responseTypes)) {
427
+ result[type] = async () => {
428
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
429
+ ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);
430
+ const awaitedResult = await result;
431
+ const response = awaitedResult.clone();
432
+ if (type === 'json') {
433
+ if (response.status === 204) {
434
+ return '';
435
+ }
436
+ const arrayBuffer = await response.clone().arrayBuffer();
437
+ const responseSize = arrayBuffer.byteLength;
438
+ if (responseSize === 0) {
439
+ return '';
440
+ }
441
+ if (options.parseJson) {
442
+ return options.parseJson(await response.text());
443
+ }
444
+ }
445
+ return response[type]();
446
+ };
447
+ }
448
+ return result;
449
+ }
337
450
  // eslint-disable-next-line complexity
338
451
  constructor(input, options = {}) {
339
- var _a, _b, _c;
340
- this._retryCount = 0;
452
+ Object.defineProperty(this, "request", {
453
+ enumerable: true,
454
+ configurable: true,
455
+ writable: true,
456
+ value: void 0
457
+ });
458
+ Object.defineProperty(this, "abortController", {
459
+ enumerable: true,
460
+ configurable: true,
461
+ writable: true,
462
+ value: void 0
463
+ });
464
+ Object.defineProperty(this, "_retryCount", {
465
+ enumerable: true,
466
+ configurable: true,
467
+ writable: true,
468
+ value: 0
469
+ });
470
+ Object.defineProperty(this, "_input", {
471
+ enumerable: true,
472
+ configurable: true,
473
+ writable: true,
474
+ value: void 0
475
+ });
476
+ Object.defineProperty(this, "_options", {
477
+ enumerable: true,
478
+ configurable: true,
479
+ writable: true,
480
+ value: void 0
481
+ });
341
482
  this._input = input;
342
483
  this._options = {
343
484
  // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
@@ -350,13 +491,13 @@ var ky$1 = {
350
491
  beforeError: [],
351
492
  afterResponse: [],
352
493
  }, options.hooks),
353
- method: normalizeRequestMethod((_a = options.method) !== null && _a !== void 0 ? _a : this._input.method),
494
+ method: normalizeRequestMethod(options.method ?? this._input.method),
354
495
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
355
496
  prefixUrl: String(options.prefixUrl || ''),
356
497
  retry: normalizeRetryOptions(options.retry),
357
498
  throwHttpErrors: options.throwHttpErrors !== false,
358
- timeout: typeof options.timeout === 'undefined' ? 10000 : options.timeout,
359
- fetch: (_b = options.fetch) !== null && _b !== void 0 ? _b : globalThis.fetch.bind(globalThis),
499
+ timeout: options.timeout ?? 10000,
500
+ fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
360
501
  };
361
502
  if (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {
362
503
  throw new TypeError('`input` must be a string, URL, or Request');
@@ -373,12 +514,17 @@ var ky$1 = {
373
514
  if (supportsAbortController) {
374
515
  this.abortController = new globalThis.AbortController();
375
516
  if (this._options.signal) {
517
+ const originalSignal = this._options.signal;
376
518
  this._options.signal.addEventListener('abort', () => {
377
- this.abortController.abort();
519
+ this.abortController.abort(originalSignal.reason);
378
520
  });
379
521
  }
380
522
  this._options.signal = this.abortController.signal;
381
523
  }
524
+ if (supportsRequestStreams) {
525
+ // @ts-expect-error - Types are outdated.
526
+ this._options.duplex = 'half';
527
+ }
382
528
  this.request = new globalThis.Request(this._input, this._options);
383
529
  if (this._options.searchParams) {
384
530
  // eslint-disable-next-line unicorn/prevent-abbreviations
@@ -393,74 +539,15 @@ var ky$1 = {
393
539
  || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {
394
540
  this.request.headers.delete('content-type');
395
541
  }
396
- this.request = new globalThis.Request(new globalThis.Request(url, this.request), this._options);
542
+ // The spread of `this.request` is required as otherwise it misses the `duplex` option for some reason and throws.
543
+ this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);
397
544
  }
398
545
  if (this._options.json !== undefined) {
399
546
  this._options.body = JSON.stringify(this._options.json);
400
- this.request.headers.set('content-type', (_c = this._options.headers.get('content-type')) !== null && _c !== void 0 ? _c : 'application/json');
547
+ this.request.headers.set('content-type', this._options.headers.get('content-type') ?? 'application/json');
401
548
  this.request = new globalThis.Request(this.request, { body: this._options.body });
402
549
  }
403
550
  }
404
- // eslint-disable-next-line @typescript-eslint/promise-function-async
405
- static create(input, options) {
406
- const ky = new Ky(input, options);
407
- const fn = async () => {
408
- if (ky._options.timeout > maxSafeTimeout) {
409
- throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
410
- }
411
- // Delay the fetch so that body method shortcuts can set the Accept header
412
- await Promise.resolve();
413
- let response = await ky._fetch();
414
- for (const hook of ky._options.hooks.afterResponse) {
415
- // eslint-disable-next-line no-await-in-loop
416
- const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));
417
- if (modifiedResponse instanceof globalThis.Response) {
418
- response = modifiedResponse;
419
- }
420
- }
421
- ky._decorateResponse(response);
422
- if (!response.ok && ky._options.throwHttpErrors) {
423
- let error = new HTTPError(response, ky.request, ky._options);
424
- for (const hook of ky._options.hooks.beforeError) {
425
- // eslint-disable-next-line no-await-in-loop
426
- error = await hook(error);
427
- }
428
- throw error;
429
- }
430
- // If `onDownloadProgress` is passed, it uses the stream API internally
431
- /* istanbul ignore next */
432
- if (ky._options.onDownloadProgress) {
433
- if (typeof ky._options.onDownloadProgress !== 'function') {
434
- throw new TypeError('The `onDownloadProgress` option must be a function');
435
- }
436
- if (!supportsStreams) {
437
- throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');
438
- }
439
- return ky._stream(response.clone(), ky._options.onDownloadProgress);
440
- }
441
- return response;
442
- };
443
- const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());
444
- const result = (isRetriableMethod ? ky._retry(fn) : fn());
445
- for (const [type, mimeType] of Object.entries(responseTypes)) {
446
- result[type] = async () => {
447
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
448
- ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);
449
- const awaitedResult = await result;
450
- const response = awaitedResult.clone();
451
- if (type === 'json') {
452
- if (response.status === 204) {
453
- return '';
454
- }
455
- if (options.parseJson) {
456
- return options.parseJson(await response.text());
457
- }
458
- }
459
- return response[type]();
460
- };
461
- }
462
- return result;
463
- }
464
551
  _calculateRetryDelay(error) {
465
552
  this._retryCount++;
466
553
  if (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {
@@ -477,7 +564,7 @@ var ky$1 = {
477
564
  else {
478
565
  after *= 1000;
479
566
  }
480
- if (typeof this._options.retry.maxRetryAfter !== 'undefined' && after > this._options.retry.maxRetryAfter) {
567
+ if (this._options.retry.maxRetryAfter !== undefined && after > this._options.retry.maxRetryAfter) {
481
568
  return 0;
482
569
  }
483
570
  return after;
@@ -487,7 +574,7 @@ var ky$1 = {
487
574
  }
488
575
  }
489
576
  const BACKOFF_FACTOR = 0.3;
490
- return BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000;
577
+ return Math.min(this._options.retry.backoffLimit, BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000);
491
578
  }
492
579
  return 0;
493
580
  }
@@ -500,12 +587,11 @@ var ky$1 = {
500
587
  async _retry(fn) {
501
588
  try {
502
589
  return await fn();
503
- // eslint-disable-next-line @typescript-eslint/no-implicit-any-catch
504
590
  }
505
591
  catch (error) {
506
592
  const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);
507
593
  if (ms !== 0 && this._retryCount > 0) {
508
- await delay(ms);
594
+ await delay(ms, { signal: this._options.signal });
509
595
  for (const hook of this._options.hooks.beforeRetry) {
510
596
  // eslint-disable-next-line no-await-in-loop
511
597
  const hookResult = await hook({
@@ -545,6 +631,16 @@ var ky$1 = {
545
631
  _stream(response, onDownloadProgress) {
546
632
  const totalBytes = Number(response.headers.get('content-length')) || 0;
547
633
  let transferredBytes = 0;
634
+ if (response.status === 204) {
635
+ if (onDownloadProgress) {
636
+ onDownloadProgress({ percent: 1, totalBytes, transferredBytes }, new Uint8Array());
637
+ }
638
+ return new globalThis.Response(null, {
639
+ status: response.status,
640
+ statusText: response.statusText,
641
+ headers: response.headers,
642
+ });
643
+ }
548
644
  return new globalThis.Response(new globalThis.ReadableStream({
549
645
  async start(controller) {
550
646
  const reader = response.body.getReader();
@@ -567,7 +663,11 @@ var ky$1 = {
567
663
  }
568
664
  await read();
569
665
  },
570
- }));
666
+ }), {
667
+ status: response.status,
668
+ statusText: response.statusText,
669
+ headers: response.headers,
670
+ });
571
671
  }
572
672
  }
573
673
 
@@ -588,12 +688,14 @@ var ky$1 = {
588
688
 
589
689
  exports.HTTPError = HTTPError;
590
690
  exports.TimeoutError = TimeoutError;
591
- exports["default"] = ky;
691
+ exports.default = ky;
592
692
 
593
693
  Object.defineProperty(exports, '__esModule', { value: true });
594
694
 
595
- }));
596
- } (ky$1, kyExports));
695
+ }));
696
+ } (ky$1, ky$1.exports));
697
+
698
+ var kyExports = ky$1.exports;
597
699
 
598
700
  const urlHttp = lightweight;
599
701
  const { flattie: flatten } = dist;
@@ -615,6 +717,7 @@ class MicrolinkError extends Error {
615
717
 
616
718
  const got = async (url, opts) => {
617
719
  try {
720
+ if (opts.retry > 0) opts.retry = opts.retry + 1;
618
721
  if (opts.timeout === undefined) opts.timeout = false;
619
722
  const response = await ky(url, opts);
620
723
  const body = await response.json();
@@ -645,8 +748,10 @@ var browser = factory({
645
748
  urlHttp,
646
749
  got,
647
750
  flatten,
648
- VERSION: '0.10.32'
751
+ VERSION: '0.10.34'
649
752
  });
650
753
 
651
- export { browser as default };
754
+ var browser$1 = /*@__PURE__*/getDefaultExportFromCjs(browser);
755
+
756
+ export { browser$1 as default };
652
757
  //# sourceMappingURL=mql.mjs.map